Various:
[obnox/wireshark/wip.git] / capture_ifinfo.h
1 /* capture_ifinfo.h
2  * Definitions for routines to get information about capture interfaces
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 #ifndef __CAPTURE_IFINFO_H__
26 #define __CAPTURE_IFINFO_H__
27
28 #ifdef HAVE_LIBPCAP
29
30 /*
31  * The list of interfaces returned by "get_interface_list()" is
32  * a list of these structures.
33  */
34 typedef struct {
35         char    *name;          /* e.g. "eth0" */
36         char    *description;   /* from OS, e.g. "Local Area Connection" or NULL */
37         GSList  *addrs;         /* containing address values of if_addr_t */
38         gboolean loopback;      /* TRUE if loopback, FALSE otherwise */
39 } if_info_t;
40
41 /*
42  * An address in the "addrs" list.
43  */
44 typedef enum {
45         IF_AT_IPv4,
46         IF_AT_IPv6
47 } if_address_type;
48
49 typedef struct {
50         if_address_type ifat_type;
51         union {
52                 guint32 ip4_addr;   /*  4 byte IP V4 address, or */
53                 guint8 ip6_addr[16];/* 16 byte IP V6 address */
54         } addr;
55 } if_addr_t;
56
57 /**
58  * Fetch the interface list from a child process.
59  */
60 extern GList *capture_interface_list(int *err, char **err_str);
61
62 /* Error values from "get_interface_list()/capture_interface_list()". */
63 #define CANT_GET_INTERFACE_LIST 1       /* error getting list */
64 #define NO_INTERFACES_FOUND     2       /* list is empty */
65 #define CANT_RUN_DUMPCAP        3       /* problem running dumpcap */
66
67 void free_interface_list(GList *if_list);
68
69 /*
70  * The list of data link types returned by "get_pcap_linktype_list()" and
71  * "capture_pcap_linktype_list()" is a list of these structures.
72  */
73 typedef struct {
74         int     dlt;            /* e.g. DLT_EN10MB (which is 1) */
75         char    *name;          /* e.g. "EN10MB" or "DLT 1" */
76         char    *description;   /* descriptive name from wiretap e.g. "Ethernet", NULL if unknown */
77 } data_link_info_t;
78
79 /**
80  * Fetch the linktype list for the specified interface from a child process.
81  */
82 extern GList *capture_pcap_linktype_list(const char *devname, char **err_str);
83
84 void free_pcap_linktype_list(GList *linktype_list);
85
86 #endif /* HAVE_LIBPCAP */
87
88 #endif /* __CAPTURE_IFINFO_H__ */