mptcpd
Multipath TCP Daemon
Loading...
Searching...
No Matches
commands.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
10#ifndef MPTCPD_COMMANDS_H
11#define MPTCPD_COMMANDS_H
12
13#ifdef HAVE_CONFIG_H
14# include <mptcpd/private/config.h>
15#endif
16
17#include <stdbool.h>
18#include <stddef.h> // For NULL.
19#include <assert.h>
20#include <sys/socket.h>
21#include <netinet/in.h>
22#include <linux/netlink.h> // For NLA_* macros.
23
29#define MPTCPD_NLA_ALIGN(v) (NLA_HDRLEN + NLA_ALIGN(sizeof(v)))
30
40#define MPTCPD_NLA_ALIGN_OPT(v) ((v) == 0 ? 0 : (MPTCPD_NLA_ALIGN(v)))
41
52#define MPTCPD_NLA_ALIGN_ADDR(v) \
53 (NLA_HDRLEN + NLA_ALIGN(mptcpd_get_addr_size(v)))
54
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60struct l_genl_msg;
61
70static inline bool mptcpd_is_inet_family(struct sockaddr const *addr)
71{
72 return addr->sa_family == AF_INET || addr->sa_family == AF_INET6;
73}
74
83static inline size_t mptcpd_get_addr_size(struct sockaddr const *addr)
84{
85 assert(mptcpd_is_inet_family(addr));
86
87 return addr->sa_family == AF_INET
88 ? sizeof(struct in_addr)
89 : sizeof(struct in6_addr);
90}
91
103static inline uint16_t mptcpd_get_addr_family(struct sockaddr const *addr)
104{
105 sa_family_t const family = (addr == NULL ? 0 : addr->sa_family);
106
107 return family;
108}
109
121uint16_t mptcpd_get_port_number(struct sockaddr const *addr);
122
128
134
147bool mptcpd_check_genl_error(struct l_genl_msg *msg, char const *fname);
148
155void mptcpd_family_send_callback(struct l_genl_msg *msg, void *user_data);
156
157#ifdef __cplusplus
158}
159#endif
160
161
162#endif /* MPTCPD_COMMANDS_H */
163
164
165/*
166 Local Variables:
167 c-file-style: "linux"
168 End:
169*/
uint16_t mptcpd_get_port_number(struct sockaddr const *addr)
Get TCP port number (host byte order).
Definition commands.c:24
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.
Definition commands.c:47
void mptcpd_family_send_callback(struct l_genl_msg *msg, void *user_data)
Generic error reporting callback.
Definition commands.c:74
MPTCP path management generic netlink command functions.
Definition path_manager.h:136