network_monitor.h
Go to the documentation of this file.
// SPDX-License-Identifier: BSD-3-Clause
#ifndef MPTCPD_NETWORK_MONITOR_H
#define MPTCPD_NETWORK_MONITOR_H
#include <mptcpd/export.h>
#include <net/if.h> // For IF_NAMESIZE.
#ifdef __cplusplus
extern "C" {
#endif
struct l_queue;
struct mptcpd_nm;
struct mptcpd_interface
{
unsigned char family;
unsigned short type;
int index;
unsigned int flags;
char name[IF_NAMESIZE];
struct l_queue *addrs;
};
struct mptcpd_nm_ops
{
void (*new_interface)(struct mptcpd_interface const *i,
void *user_data);
void (*update_interface)(struct mptcpd_interface const *i,
void *user_data);
void (*delete_interface)(struct mptcpd_interface const *i,
void *user_data);
void (*new_address)(struct mptcpd_interface const *i,
struct sockaddr const *sa,
void *user_data);
void (*delete_address)(struct mptcpd_interface const *i,
struct sockaddr const *sa,
void *user_data);
};
MPTCPD_API struct mptcpd_nm *mptcpd_nm_create(uint32_t flags);
MPTCPD_API void mptcpd_nm_destroy(struct mptcpd_nm *nm);
typedef void (*mptcpd_nm_callback)(
struct mptcpd_interface const *interface,
void *callback_data);
MPTCPD_API void mptcpd_nm_foreach_interface(struct mptcpd_nm const *nm,
mptcpd_nm_callback callback,
void *data);
MPTCPD_API bool mptcpd_nm_register_ops(struct mptcpd_nm *nm,
struct mptcpd_nm_ops const *ops,
void *user_data);
#ifdef __cplusplus
}
#endif
#endif // MPTCPD_NETWORK_MONITOR_H
/*
Local Variables:
c-file-style: "linux"
End:
*/
export.h
mptcpd shared library symbol export/import macros.
mptcpd_nm_foreach_interface
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:1508
mptcpd_nm_callback
void(* mptcpd_nm_callback)(struct mptcpd_interface const *interface, void *callback_data)
Network monitor iteration function type.
Definition: network_monitor.h:178
mptcpd_nm_create
MPTCPD_API struct mptcpd_nm * mptcpd_nm_create(uint32_t flags)
Create a network monitor.
Definition: network_monitor.c:1393
mptcpd_nm_destroy
MPTCPD_API void mptcpd_nm_destroy(struct mptcpd_nm *nm)
Destroy a network monitor.
Definition: network_monitor.c:1481
mptcpd_nm_register_ops
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:1525
mptcpd_interface
Network interface-specific information.
Definition: network_monitor.h:30
mptcpd_interface::family
unsigned char family
Address family, e.g AF_UNSPEC.
Definition: network_monitor.h:47
mptcpd_interface::index
int index
Network interface (link) index.
Definition: network_monitor.h:57
mptcpd_interface::addrs
struct l_queue * addrs
Definition: network_monitor.h:73
mptcpd_interface::type
unsigned short type
Network device type, e.g. ARPHRD_ETHER.
Definition: network_monitor.h:54
mptcpd_interface::flags
unsigned int flags
Network interface flags, e.g. IFF_UP.
Definition: network_monitor.h:64
mptcpd_interface::name
char name[IF_NAMESIZE]
Network interface name.
Definition: network_monitor.h:67
mptcpd_nm_ops
Network monitor event tracking operations.
Definition: network_monitor.h:86
mptcpd_nm_ops::update_interface
void(* update_interface)(struct mptcpd_interface const *i, void *user_data)
Network interface flags were updated.
Definition: network_monitor.h:108
mptcpd_nm_ops::delete_interface
void(* delete_interface)(struct mptcpd_interface const *i, void *user_data)
A network interface was removed.
Definition: network_monitor.h:117
mptcpd_nm_ops::new_interface
void(* new_interface)(struct mptcpd_interface const *i, void *user_data)
A new network interface is available.
Definition: network_monitor.h:99
mptcpd_nm_ops::new_address
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:127
mptcpd_nm_ops::delete_address
void(* delete_address)(struct mptcpd_interface const *i, struct sockaddr const *sa, void *user_data)
A network address was removed.
Definition: network_monitor.h:138
mptcpd_nm
Data needed to run the network monitor.
Definition: network_monitor.c:60