2 * Utility definitions for packet capture
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
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>
39 * A snapshot length of 0 is useless - and libpcap/WinPcap don't guarantee
40 * that a snapshot length of 0 will work, and, on some platforms, it won't
41 * (with BPF, for example, the kernel is told the snapshot length via the
42 * return value of the BPF program, and a return value of 0 means "drop
43 * the packet"), so the minimum packet size is 1 byte.
45 #define MIN_PACKET_SIZE 1 /* minimum amount of packet data we can read */
48 * The list of interfaces returned by "get_interface_list()" is
49 * a list of these structures.
52 char *name; /* e.g. "eth0" */
53 char *description; /* from OS, e.g. "Local Area Connection" or NULL */
54 GSList *ip_addr; /* containing address values of if_addr_t */
55 gboolean loopback; /* TRUE if loopback, FALSE otherwise */
59 * An address in the "ip_addr" list.
62 address_type type; /* AT_IPv4 or AT_IPv6 */
64 guint32 ip4_addr; /* 4 byte IP V4 address, or */
65 guint8 ip6_addr[16];/* 16 byte IP V6 address */
69 GList *get_interface_list(int *err, char **err_str);
70 #ifdef HAVE_PCAP_REMOTE
71 GList *get_remote_interface_list(const char *hostname, const char *port,
72 int auth_type, const char *username,
73 const char *passwd, int *err, char **err_str);
76 /* Error values from "get_interface_list()/capture_interface_list()". */
77 #define CANT_GET_INTERFACE_LIST 1 /* error getting list */
78 #define NO_INTERFACES_FOUND 2 /* list is empty */
79 #define CANT_RUN_DUMPCAP 3 /* problem running dumpcap */
81 void free_interface_list(GList *if_list);
84 * The list of data link types returned by "get_pcap_linktype_list()" is
85 * a list of these structures.
88 int dlt; /* e.g. DLT_EN10MB (which is 1) */
89 char *name; /* e.g. "EN10MB" or "DLT 1" */
90 char *description; /* descriptive name from wiretap e.g. "Ethernet", NULL if unknown */
93 GList *get_pcap_linktype_list(const char *devname, char **err_str);
94 void free_pcap_linktype_list(GList *linktype_list);
96 /* get/set the link type of an interface */
97 /* (only used in capture_loop.c / capture-pcap-util.c) */
98 int get_pcap_linktype(pcap_t *pch, const char *devname);
99 const char *set_pcap_linktype(pcap_t *pch, char *devname, int dlt);
102 const char *linktype_val_to_name(int dlt);
103 int linktype_name_to_val(const char *linktype);
107 #endif /* __cplusplus */
109 #endif /* HAVE_LIBPCAP */
112 * Append to a GString an indication of the version of libpcap/WinPcap
113 * with which we were compiled, if we were, or an indication that we
114 * weren't compiled with libpcap/WinPcap, if we weren't.
116 extern void get_compiled_pcap_version(GString *str);
119 * Append to a GString an indication of the version of libpcap/WinPcap
120 * with which we're running, or an indication that we're not running
121 * with libpcap/WinPcap, if we were compiled with libpcap/WinPcap,
122 * or nothing, if we weren't compiled with libpcap/WinPcap.
124 extern void get_runtime_pcap_version(GString *str);
126 #endif /* __PCAP_UTIL_H__ */