mptcpd
Multipath TCP Daemon
network_monitor.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
10 #ifndef MPTCPD_NETWORK_MONITOR_H
11 #define MPTCPD_NETWORK_MONITOR_H
12 
13 #include <mptcpd/export.h>
14 
15 #include <stdbool.h>
16 #include <net/if.h> // For IF_NAMESIZE.
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 struct l_queue;
23 struct mptcpd_nm;
24 
31 {
41 
48  unsigned char family;
49 
55  unsigned short type;
56 
58  int index;
59 
65  unsigned int flags;
66 
68  char name[IF_NAMESIZE];
69 
74  struct l_queue *addrs;
76 };
77 
87 {
100  void (*new_interface)(struct mptcpd_interface const *i,
101  void *user_data);
102 
109  void (*update_interface)(struct mptcpd_interface const *i,
110  void *user_data);
111 
118  void (*delete_interface)(struct mptcpd_interface const *i,
119  void *user_data);
120 
128  void (*new_address)(struct mptcpd_interface const *i,
129  struct sockaddr const *sa,
130  void *user_data);
131 
139  void (*delete_address)(struct mptcpd_interface const *i,
140  struct sockaddr const *sa,
141  void *user_data);
142 };
143 
155 typedef void (*mptcpd_nm_callback)(
156  struct mptcpd_interface const *interface,
157  void *callback_data);
158 
168 MPTCPD_API void mptcpd_nm_foreach_interface(struct mptcpd_nm const *nm,
169  mptcpd_nm_callback callback,
170  void *data);
171 
189 MPTCPD_API bool mptcpd_nm_register_ops(struct mptcpd_nm *nm,
190  struct mptcpd_nm_ops const *ops,
191  void *user_data);
192 
211 MPTCPD_API bool mptcpd_nm_monitor_loopback(struct mptcpd_nm *nm,
212  bool enable);
213 
214 #ifdef __cplusplus
215 }
216 #endif
217 
218 #endif // MPTCPD_NETWORK_MONITOR_H
219 
220 
221 /*
222  Local Variables:
223  c-file-style: "linux"
224  End:
225 */
mptcpd shared library symbol export/import macros.
MPTCPD_API void mptcpd_nm_foreach_interface(struct mptcpd_nm const *nm, mptcpd_nm_callback callback, void *data)
Iterate over all monitored network interfaces.
Definition: network_monitor.c:1525
void(* mptcpd_nm_callback)(struct mptcpd_interface const *interface, void *callback_data)
Network monitor iteration function type.
Definition: network_monitor.h:155
MPTCPD_API bool mptcpd_nm_monitor_loopback(struct mptcpd_nm *nm, bool enable)
Enable monitoring of the loopback network interface.
Definition: network_monitor.c:1572
MPTCPD_API bool mptcpd_nm_register_ops(struct mptcpd_nm *nm, struct mptcpd_nm_ops const *ops, void *user_data)
Subscribe to mptcpd network monitor events.
Definition: network_monitor.c:1542
Network interface-specific information.
Definition: network_monitor.h:31
unsigned char family
Address family, e.g AF_UNSPEC.
Definition: network_monitor.h:48
int index
Network interface (link) index.
Definition: network_monitor.h:58
struct l_queue * addrs
Definition: network_monitor.h:74
unsigned short type
Network device type, e.g. ARPHRD_ETHER.
Definition: network_monitor.h:55
unsigned int flags
Network interface flags, e.g. IFF_UP.
Definition: network_monitor.h:65
char name[IF_NAMESIZE]
Network interface name.
Definition: network_monitor.h:68
Network monitor event tracking operations.
Definition: network_monitor.h:87
void(* update_interface)(struct mptcpd_interface const *i, void *user_data)
Network interface flags were updated.
Definition: network_monitor.h:109
void(* delete_interface)(struct mptcpd_interface const *i, void *user_data)
A network interface was removed.
Definition: network_monitor.h:118
void(* new_interface)(struct mptcpd_interface const *i, void *user_data)
A new network interface is available.
Definition: network_monitor.h:100
void(* new_address)(struct mptcpd_interface const *i, struct sockaddr const *sa, void *user_data)
A new network address is available.
Definition: network_monitor.h:128
void(* delete_address)(struct mptcpd_interface const *i, struct sockaddr const *sa, void *user_data)
A network address was removed.
Definition: network_monitor.h:139
Data needed to run the network monitor.
Definition: network_monitor.c:72