2 * Utility definitions for packet capture
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #ifndef __PCAP_UTIL_H__
26 #define __PCAP_UTIL_H__
32 #endif /* __cplusplus */
34 #include <epan/address.h>
38 /* declaration of pcap_t here, to reduce pcap dependencies */
39 /*typedef struct pcap pcap_t;*/
43 * XXX - this is also the traditional default snapshot size in
44 * tcpdump - but, if IPv6 is enabled, it defaults to 96, to get an
45 * IPv6 header + TCP + 22 extra bytes.
47 * Some libpcap versions for particular capture devices might happen
48 * to impose a minimum, but it's not always 68.
50 #define MIN_PACKET_SIZE 68 /* minimum amount of packet data we can read */
52 /* XXX - this must be optimized, removing the dependency!!! */
53 #define CAPTURE_PCAP_ERRBUF_SIZE PCAP_ERRBUF_SIZE
56 * The list of interfaces returned by "get_interface_list()" is
57 * a list of these structures.
60 char *name; /* e.g. "eth0" */
61 char *description; /* from OS, e.g. "Local Area Connection" or NULL */
62 GSList *ip_addr; /* containing address values of if_addr_t */
63 gboolean loopback; /* TRUE if loopback, FALSE otherwise */
67 * An address in the "ip_addr" list.
70 address_type type; /* AT_IPv4 or AT_IPv6 */
72 guint32 ip4_addr; /* 4 byte IP V4 address, or */
73 guint8 ip6_addr[16];/* 16 byte IP V6 address */
77 GList *get_interface_list(int *err, char *err_str);
79 /* Error values from "get_interface_list()". */
80 #define CANT_GET_INTERFACE_LIST 0 /* error getting list */
81 #define NO_INTERFACES_FOUND 1 /* list is empty */
83 void free_interface_list(GList *if_list);
86 * Get an error message string for a CANT_GET_INTERFACE_LIST error from
87 * "get_interface_list()".
89 gchar *cant_get_if_list_error_message(const char *err_str);
92 * The list of data link types returned by "get_pcap_linktype_list()" is
93 * a list of these structures.
96 int dlt; /* e.g. DLT_EN10MB (which is 1) */
97 char *name; /* e.g. "EN10MB" or "DLT 1" */
98 char *description; /* descriptive name from wiretap e.g. "Ethernet", NULL if unknown */
101 GList *get_pcap_linktype_list(const char *devname, char *err_buf);
102 void free_pcap_linktype_list(GList *linktype_list);
104 /* get/set the link type of an interface */
105 /* (only used in capture_loop.c / capture-pcap-util.c) */
106 int get_pcap_linktype(pcap_t *pch, const char *devname);
107 const char *set_pcap_linktype(pcap_t *pch, char *devname, int dlt);
110 #ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
111 const char *linktype_val_to_name(int dlt);
113 #ifdef HAVE_PCAP_DATALINK_NAME_TO_VAL
114 int linktype_name_to_val(const char *linktype);
119 #endif /* __cplusplus */
121 #endif /* HAVE_LIBPCAP */
124 * Append to a GString an indication of the version of libpcap/WinPcap
125 * with which we were compiled, if we were, or an indication that we
126 * weren't compiled with libpcap/WinPcap, if we weren't.
128 extern void get_compiled_pcap_version(GString *str);
131 * Append to a GString an indication of the version of libpcap/WinPcap
132 * with which we're running, or an indication that we're not running
133 * with libpcap/WinPcap, if we were compiled with libpcap/WinPcap,
134 * or nothing, if we weren't compiled with libpcap/WinPcap.
136 extern void get_runtime_pcap_version(GString *str);
138 #endif /* __PCAP_UTIL_H__ */