Glib docs recommend using the slice API if you know you won't need to realloc.
[metze/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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __CAPTURE_IFINFO_H__
26 #define __CAPTURE_IFINFO_H__
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31
32 /*
33  * The list of interfaces returned by "get_interface_list()" is
34  * a list of these structures.
35  */
36 typedef struct {
37         char    *name;          /* e.g. "eth0" */
38         char    *friendly_name; /* from OS, e.g. "Local Area Connection", or
39                                    NULL if not available */
40         char    *vendor_description;
41                                 /* vendor description from pcap_findalldevs(),
42                                    e.g. "Realtek PCIe GBE Family Controller",
43                                    or NULL if not available */
44         GSList  *addrs;         /* containing address values of if_addr_t */
45         gboolean loopback;      /* TRUE if loopback, FALSE otherwise */
46 } if_info_t;
47
48 /*
49  * An address in the "addrs" list.
50  */
51 typedef enum {
52         IF_AT_IPv4,
53         IF_AT_IPv6
54 } if_address_type;
55
56 typedef struct {
57         if_address_type ifat_type;
58         union {
59                 guint32 ip4_addr;   /*  4 byte IP V4 address, or */
60                 guint8 ip6_addr[16];/* 16 byte IP V6 address */
61         } addr;
62 } if_addr_t;
63
64 /**
65  * Fetch the interface list from a child process.
66  */
67 extern GList *capture_interface_list(int *err, char **err_str);
68
69 /* Error values from "get_interface_list()/capture_interface_list()". */
70 #define CANT_GET_INTERFACE_LIST 1       /* error getting list */
71 #define NO_INTERFACES_FOUND     2       /* list is empty */
72 #define DONT_HAVE_PCAP          3       /* couldn't load WinPcap */
73
74 void free_interface_list(GList *if_list);
75
76 /*
77  * "get_if_capabilities()" and "capture_if_capabilities()" return a pointer
78  * to an allocated instance of this structure.  "free_if_capabilities()"
79  * frees the returned instance.
80  */
81 typedef struct {
82         gboolean        can_set_rfmon;  /* TRUE if can be put into monitor mode */
83         GList           *data_link_types;       /* GList of data_link_info_t's */
84 } if_capabilities_t;
85
86 /*
87  * Information about data link types.
88  */
89 typedef struct {
90         int     dlt;            /* e.g. DLT_EN10MB (which is 1) */
91         char    *name;          /* e.g. "EN10MB" or "DLT 1" */
92         char    *description;   /* descriptive name from wiretap e.g. "Ethernet", NULL if unknown */
93 } data_link_info_t;
94
95 /**
96  * Fetch the linktype list for the specified interface from a child process.
97  */
98 extern if_capabilities_t *
99 capture_get_if_capabilities(const char *devname, gboolean monitor_mode,
100                             char **err_str);
101
102 void free_if_capabilities(if_capabilities_t *caps);
103
104 void add_interface_to_remote_list(if_info_t *if_info);
105
106 /**
107  * Get the type of an interface, given its name and description.
108  */
109 extern guint
110 get_interface_type(gchar *name, gchar *description);
111
112 #ifdef __cplusplus
113 }
114 #endif /* __cplusplus */
115
116 #endif /* __CAPTURE_IFINFO_H__ */