mptcpd
Multipath TCP Daemon
Macros | Functions
commands.h File Reference

mptcpd generic netlink command utilities. More...

#include <stdbool.h>
#include <stddef.h>
#include <assert.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/netlink.h>
Include dependency graph for commands.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MPTCPD_NLA_ALIGN(v)   (NLA_HDRLEN + NLA_ALIGN(sizeof(v)))
 Return netlink aligned size of a variable or type. More...
 
#define MPTCPD_NLA_ALIGN_OPT(v)   ((v) == 0 ? 0 : (MPTCPD_NLA_ALIGN(v)))
 Return netlink aligned size of an optional variable. More...
 
#define MPTCPD_NLA_ALIGN_ADDR(v)    (NLA_HDRLEN + NLA_ALIGN(mptcpd_get_addr_size(v)))
 Return netlink aligned size of an IP address. More...
 

Functions

bool mptcpd_is_inet_family (struct sockaddr const *addr)
 Check for internet address family. More...
 
size_t mptcpd_get_addr_size (struct sockaddr const *addr)
 Get the underlying internet address size. More...
 
uint16_t mptcpd_get_addr_family (struct sockaddr const *addr)
 Get network address family. More...
 
uint16_t mptcpd_get_port_number (struct sockaddr const *addr)
 Get IP port number. More...
 
struct mptcpd_pm_cmd_ops const * mptcpd_get_upstream_cmd_ops (void)
 Get upstream kernel MPTCP generic netlink command operations.
 
struct mptcpd_pm_cmd_ops const * mptcpd_get_mptcp_org_cmd_ops (void)
 Get multipath-tcp.org kernel MPTCP generic netlink command operations.
 
bool mptcpd_check_genl_error (struct l_genl_msg *msg, char const *fname)
 Check for genl operation failure. More...
 
void mptcpd_family_send_callback (struct l_genl_msg *msg, void *user_data)
 Generic error reporting callback. More...
 

Detailed Description

mptcpd generic netlink command utilities.

Copyright (c) 2017-2021, Intel Corporation

Macro Definition Documentation

◆ MPTCPD_NLA_ALIGN

#define MPTCPD_NLA_ALIGN (   v)    (NLA_HDRLEN + NLA_ALIGN(sizeof(v)))

Return netlink aligned size of a variable or type.

Parameters
[in]vVariable or type to be aligned.

◆ MPTCPD_NLA_ALIGN_ADDR

#define MPTCPD_NLA_ALIGN_ADDR (   v)     (NLA_HDRLEN + NLA_ALIGN(mptcpd_get_addr_size(v)))

Return netlink aligned size of an IP address.

Parameters
[in]vPointer to struct sockaddr containing an IP address (i.e., struct in_addr or struct in6_addr ) to be aligned.
Returns
The netlink aligned size of the IP address contained in the sockaddr pointed to by v.

◆ MPTCPD_NLA_ALIGN_OPT

#define MPTCPD_NLA_ALIGN_OPT (   v)    ((v) == 0 ? 0 : (MPTCPD_NLA_ALIGN(v)))

Return netlink aligned size of an optional variable.

Parameters
[in]vVariable to be aligned.
Returns
The netlink aligned size of the variable v or 0 if v is zero or implicitly convertible to zero (e.g. NULL).

Function Documentation

◆ mptcpd_check_genl_error()

bool mptcpd_check_genl_error ( struct l_genl_msg *  msg,
char const *  fname 
)

Check for genl operation failure.

Check for generic netlink operation failure, and log associated error message.

Parameters
[in]msgGeneric netlink message information.
[in]fnameName function from which the error check was initiated.
Returns
true if no error was found, and false otherwise.

◆ mptcpd_family_send_callback()

void mptcpd_family_send_callback ( struct l_genl_msg *  msg,
void *  user_data 
)

Generic error reporting callback.

Parameters
[in]msgGeneric netlink message information.
[in]user_dataFunction name.

◆ mptcpd_get_addr_family()

uint16_t mptcpd_get_addr_family ( struct sockaddr const *  addr)
inline

Get network address family.

Parameters
[in]addrNetwork address information.

Get network address family suitably typed for use in MPTCP generic netlink API calls, or zero if no address was provided.

Returns
Network address family, or zero if no address family was provided.

◆ mptcpd_get_addr_size()

size_t mptcpd_get_addr_size ( struct sockaddr const *  addr)
inline

Get the underlying internet address size.

Parameters
[in]addrNetwork address information.
Returns
Size of the underlying internet address (e.g., struct in_addr6).

◆ mptcpd_get_port_number()

uint16_t mptcpd_get_port_number ( struct sockaddr const *  addr)

Get IP port number.

Parameters
[in]addrNetwork address information.

Get IP port suitably typed for use in MPTCP generic netlink API calls, or zero if no address was provided.

Returns
IP port number, or zero if no IP address was provided.

◆ mptcpd_is_inet_family()

bool mptcpd_is_inet_family ( struct sockaddr const *  addr)
inline

Check for internet address family.

Parameters
[in]addrNetwork address information.
Returns
true if the addr is an internet address, and false otherwise.