11e80a9205c5a39fa23579a5792e141068e9a13f
[gd/wireshark/.git] / caputils / iface_monitor.h
1 /* iface_monitor.h
2  * interface monitor by Pontus Fuchs <pontus.fuchs@gmail.com>
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later*/
9 #ifndef IFACE_MONITOR_H
10 #define IFACE_MONITOR_H
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif /* __cplusplus */
15
16 #ifdef HAVE_LIBPCAP
17
18 /*
19  * Callback for interface changes.
20  *
21  * iface is a pointer to the name of the interface.
22  *
23  * up is 1 if the interface is up, 0 if it's down.
24  *
25  * XXX - we really want "gone", not "down", where "gone" may include
26  * "down" if the OS requires an interface to be up in order to start
27  * a capture on it (as is the case in Linux and in macOS prior to
28  * Lion), but should also include *gone*, as in "there is no longer
29  * an interface with this name, so it's neither down nor up".
30  *
31  * We also may want other events, such as address changes, so what
32  * we might want is "add", "remove", and "modify" as the events.
33  */
34 typedef void (*iface_mon_cb)(const char *iface, int up);
35
36 /*
37  * Start watching for interface changes.
38  */
39 int
40 iface_mon_start(iface_mon_cb cb);
41
42 /*
43  * Stop watching for interface changes.
44  */
45 void
46 iface_mon_stop(void);
47
48 /*
49  * Get the socket on which interface changes are delivered, so that
50  * we can add it to the event loop.
51  *
52  * XXX - what if it's not a socket or other file descriptor?
53  */
54 int
55 iface_mon_get_sock(void);
56
57 /*
58  * Call this if something is readable from the interface change socket.
59  * It will call the callback as appropriate.
60  */
61 void
62 iface_mon_event(void);
63
64 #endif /* HAVE_LIBPCAP */
65
66 #ifdef __cplusplus
67 }
68 #endif /* __cplusplus */
69
70 #endif /* IFACE_MONITOR_H */