3 * interface monitor by Pontus Fuchs <pontus.fuchs@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 #ifndef IFACE_MONITOR_H
12 #define IFACE_MONITOR_H
14 #include <wireshark.h>
18 #endif /* __cplusplus */
23 * Callback for interface changes.
25 * iface is a pointer to the name of the interface.
27 * up is 1 if the interface is up, 0 if it's down.
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".
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.
38 typedef void (*iface_mon_cb
)(const char *iface
, int added
, int up
);
41 * Start watching for interface changes.
44 iface_mon_start(iface_mon_cb cb
);
47 * Stop watching for interface changes.
53 * Get the socket on which interface changes are delivered, so that
54 * we can add it to the event loop.
56 * XXX - what if it's not a socket or other file descriptor?
59 iface_mon_get_sock(void);
62 * Call this if something is readable from the interface change socket.
63 * It will call the callback as appropriate.
66 iface_mon_event(void);
69 * Temporarily enable or disable watching for interface changes. This has
70 * no effect if interface monitoring has not been started.
72 * This is for Linux, where setting rfmon mode on an interface can create
73 * or destroy another (virtual) interface on the same wiphy, to avoid infinite
74 * loops. It is a no-op on other platforms.
77 iface_mon_enable(bool enable
);
79 #endif /* HAVE_LIBPCAP */
83 #endif /* __cplusplus */
85 #endif /* IFACE_MONITOR_H */