Wireshark  4.3.0
The Wireshark network protocol analyzer
iface_monitor.h
Go to the documentation of this file.
1 
11 #ifndef IFACE_MONITOR_H
12 #define IFACE_MONITOR_H
13 
14 #include <wireshark.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19 
20 #ifdef HAVE_LIBPCAP
21 
22 /*
23  * Callback for interface changes.
24  *
25  * iface is a pointer to the name of the interface.
26  *
27  * up is 1 if the interface is up, 0 if it's down.
28  *
29  * XXX - we really want "gone", not "down", where "gone" may include
30  * "down" if the OS requires an interface to be up in order to start
31  * a capture on it (as is the case in Linux and in macOS prior to
32  * Lion), but should also include *gone*, as in "there is no longer
33  * an interface with this name, so it's neither down nor up".
34  *
35  * We also may want other events, such as address changes, so what
36  * we might want is "add", "remove", and "modify" as the events.
37  */
38 typedef void (*iface_mon_cb)(const char *iface, int added, int up);
39 
40 /*
41  * Start watching for interface changes.
42  */
43 int
44 iface_mon_start(iface_mon_cb cb);
45 
46 /*
47  * Stop watching for interface changes.
48  */
49 void
50 iface_mon_stop(void);
51 
52 /*
53  * Get the socket on which interface changes are delivered, so that
54  * we can add it to the event loop.
55  *
56  * XXX - what if it's not a socket or other file descriptor?
57  */
58 int
59 iface_mon_get_sock(void);
60 
61 /*
62  * Call this if something is readable from the interface change socket.
63  * It will call the callback as appropriate.
64  */
65 void
66 iface_mon_event(void);
67 
68 #endif /* HAVE_LIBPCAP */
69 
70 #ifdef __cplusplus
71 }
72 #endif /* __cplusplus */
73 
74 #endif /* IFACE_MONITOR_H */