Loading...
Searching...
No Matches
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 <stdbool.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);
};
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);
MPTCPD_API bool mptcpd_nm_monitor_loopback(struct mptcpd_nm *nm,
bool enable);
#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:1528
mptcpd_nm_callback
void(* mptcpd_nm_callback)(struct mptcpd_interface const *interface, void *callback_data)
Network monitor iteration function type.
Definition network_monitor.h:155
mptcpd_nm_monitor_loopback
MPTCPD_API bool mptcpd_nm_monitor_loopback(struct mptcpd_nm *nm, bool enable)
Enable monitoring of the loopback network interface.
Definition network_monitor.c:1575
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:1545
mptcpd_interface
Network interface-specific information.
Definition network_monitor.h:31
mptcpd_interface::family
unsigned char family
Address family, e.g AF_UNSPEC.
Definition network_monitor.h:48
mptcpd_interface::index
int index
Network interface (link) index.
Definition network_monitor.h:58
mptcpd_interface::addrs
struct l_queue * addrs
Definition network_monitor.h:74
mptcpd_interface::type
unsigned short type
Network device type, e.g. ARPHRD_ETHER.
Definition network_monitor.h:55
mptcpd_interface::flags
unsigned int flags
Network interface flags, e.g. IFF_UP.
Definition network_monitor.h:65
mptcpd_interface::name
char name[IF_NAMESIZE]
Network interface name.
Definition network_monitor.h:68
mptcpd_nm_ops
Network monitor event tracking operations.
Definition network_monitor.h:87
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:109
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:118
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:100
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:128
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:139
mptcpd_nm
Data needed to run the network monitor.
Definition network_monitor.c:72