mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
sd-netlink: split netlink-types.[ch] into small files
Also renames several files.
This commit is contained in:
parent
b5beb9b0f5
commit
021273b782
@ -132,19 +132,23 @@ libsystemd_sources = files('''
|
||||
sd-device/sd-device.c
|
||||
sd-hwdb/hwdb-internal.h
|
||||
sd-hwdb/sd-hwdb.c
|
||||
sd-netlink/generic-netlink.c
|
||||
sd-netlink/generic-netlink.h
|
||||
sd-netlink/netlink-genl.c
|
||||
sd-netlink/netlink-genl.h
|
||||
sd-netlink/netlink-internal.h
|
||||
sd-netlink/netlink-message-nfnl.c
|
||||
sd-netlink/netlink-message-rtnl.c
|
||||
sd-netlink/netlink-message.c
|
||||
sd-netlink/netlink-slot.c
|
||||
sd-netlink/netlink-slot.h
|
||||
sd-netlink/netlink-socket.c
|
||||
sd-netlink/netlink-types-genl.c
|
||||
sd-netlink/netlink-types-internal.h
|
||||
sd-netlink/netlink-types-nfnl.c
|
||||
sd-netlink/netlink-types-rtnl.c
|
||||
sd-netlink/netlink-types.c
|
||||
sd-netlink/netlink-types.h
|
||||
sd-netlink/netlink-util.c
|
||||
sd-netlink/netlink-util.h
|
||||
sd-netlink/nfnl-message.c
|
||||
sd-netlink/rtnl-message.c
|
||||
sd-netlink/sd-netlink.c
|
||||
sd-network/network-util.c
|
||||
sd-network/network-util.h
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "sd-netlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "generic-netlink.h"
|
||||
#include "netlink-genl.h"
|
||||
#include "netlink-internal.h"
|
||||
|
||||
typedef struct {
|
405
src/libsystemd/sd-netlink/netlink-types-genl.c
Normal file
405
src/libsystemd/sd-netlink/netlink-types-genl.c
Normal file
@ -0,0 +1,405 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/batman_adv.h>
|
||||
#include <linux/fou.h>
|
||||
#include <linux/genetlink.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_macsec.h>
|
||||
#include <linux/l2tp.h>
|
||||
#include <linux/nl80211.h>
|
||||
#include <linux/wireguard.h>
|
||||
|
||||
#include "netlink-genl.h"
|
||||
#include "netlink-types-internal.h"
|
||||
|
||||
/***************** genl ctrl type systems *****************/
|
||||
static const NLType genl_mcast_group_types[] = {
|
||||
[CTRL_ATTR_MCAST_GRP_NAME] = { .type = NETLINK_TYPE_STRING },
|
||||
[CTRL_ATTR_MCAST_GRP_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_mcast_group_type_system = {
|
||||
.count = ELEMENTSOF(genl_mcast_group_types),
|
||||
.types = genl_mcast_group_types,
|
||||
};
|
||||
|
||||
static const NLType genl_get_family_types[] = {
|
||||
[CTRL_ATTR_FAMILY_NAME] = { .type = NETLINK_TYPE_STRING },
|
||||
[CTRL_ATTR_FAMILY_ID] = { .type = NETLINK_TYPE_U16 },
|
||||
[CTRL_ATTR_MCAST_GROUPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_mcast_group_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_get_family_type_system = {
|
||||
.count = ELEMENTSOF(genl_get_family_types),
|
||||
.types = genl_get_family_types,
|
||||
};
|
||||
|
||||
static const NLType genl_ctrl_id_ctrl_cmds[] = {
|
||||
[CTRL_CMD_GETFAMILY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_get_family_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_ctrl_id_ctrl_type_system = {
|
||||
.count = ELEMENTSOF(genl_ctrl_id_ctrl_cmds),
|
||||
.types = genl_ctrl_id_ctrl_cmds,
|
||||
};
|
||||
|
||||
/***************** genl batadv type systems *****************/
|
||||
static const NLType genl_batadv_types[] = {
|
||||
[BATADV_ATTR_VERSION] = { .type = NETLINK_TYPE_STRING },
|
||||
[BATADV_ATTR_ALGO_NAME] = { .type = NETLINK_TYPE_STRING },
|
||||
[BATADV_ATTR_MESH_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_MESH_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ },
|
||||
[BATADV_ATTR_MESH_ADDRESS] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_HARD_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_HARD_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ },
|
||||
[BATADV_ATTR_HARD_ADDRESS] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_ORIG_ADDRESS] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_TPMETER_RESULT] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_TPMETER_TEST_TIME] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_TPMETER_BYTES] = { .type = NETLINK_TYPE_U64 },
|
||||
[BATADV_ATTR_TPMETER_COOKIE] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_PAD] = { .type = NETLINK_TYPE_UNSPEC },
|
||||
[BATADV_ATTR_ACTIVE] = { .type = NETLINK_TYPE_FLAG },
|
||||
[BATADV_ATTR_TT_ADDRESS] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_TT_TTVN] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_TT_LAST_TTVN] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_TT_CRC32] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_TT_VID] = { .type = NETLINK_TYPE_U16 },
|
||||
[BATADV_ATTR_TT_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_FLAG_BEST] = { .type = NETLINK_TYPE_FLAG },
|
||||
[BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_NEIGH_ADDRESS] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_TQ] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_THROUGHPUT] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_BANDWIDTH_UP] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_BANDWIDTH_DOWN] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_ROUTER] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_BLA_OWN] = { .type = NETLINK_TYPE_FLAG },
|
||||
[BATADV_ATTR_BLA_ADDRESS] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_BLA_VID] = { .type = NETLINK_TYPE_U16 },
|
||||
[BATADV_ATTR_BLA_BACKBONE] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_BLA_CRC] = { .type = NETLINK_TYPE_U16 },
|
||||
[BATADV_ATTR_DAT_CACHE_IP4ADDRESS] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_DAT_CACHE_HWADDRESS] = { .size = ETH_ALEN },
|
||||
[BATADV_ATTR_DAT_CACHE_VID] = { .type = NETLINK_TYPE_U16 },
|
||||
[BATADV_ATTR_MCAST_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_MCAST_FLAGS_PRIV] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_VLANID] = { .type = NETLINK_TYPE_U16 },
|
||||
[BATADV_ATTR_AGGREGATED_OGMS_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_AP_ISOLATION_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_ISOLATION_MARK] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_ISOLATION_MASK] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_BONDING_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_FRAGMENTATION_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_GW_BANDWIDTH_DOWN] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_GW_BANDWIDTH_UP] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_GW_MODE] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_GW_SEL_CLASS] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_HOP_PENALTY] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_LOG_LEVEL] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_MULTICAST_FANOUT] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NETLINK_TYPE_U8 },
|
||||
[BATADV_ATTR_ORIG_INTERVAL] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_ELP_INTERVAL] = { .type = NETLINK_TYPE_U32 },
|
||||
[BATADV_ATTR_THROUGHPUT_OVERRIDE] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_batadv_type_system = {
|
||||
.count = ELEMENTSOF(genl_batadv_types),
|
||||
.types = genl_batadv_types,
|
||||
};
|
||||
|
||||
static const NLType genl_batadv_cmds[] = {
|
||||
[BATADV_CMD_SET_MESH] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_batadv_cmds_type_system = {
|
||||
.count = ELEMENTSOF(genl_batadv_cmds),
|
||||
.types = genl_batadv_cmds,
|
||||
};
|
||||
|
||||
/***************** genl fou type systems *****************/
|
||||
static const NLType genl_fou_types[] = {
|
||||
[FOU_ATTR_PORT] = { .type = NETLINK_TYPE_U16 },
|
||||
[FOU_ATTR_AF] = { .type = NETLINK_TYPE_U8 },
|
||||
[FOU_ATTR_IPPROTO] = { .type = NETLINK_TYPE_U8 },
|
||||
[FOU_ATTR_TYPE] = { .type = NETLINK_TYPE_U8 },
|
||||
[FOU_ATTR_REMCSUM_NOPARTIAL] = { .type = NETLINK_TYPE_FLAG },
|
||||
[FOU_ATTR_LOCAL_V4] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[FOU_ATTR_PEER_V4] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[FOU_ATTR_LOCAL_V6] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[FOU_ATTR_PEER_V6] = { .type = NETLINK_TYPE_IN_ADDR},
|
||||
[FOU_ATTR_PEER_PORT] = { .type = NETLINK_TYPE_U16},
|
||||
[FOU_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32},
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_fou_type_system = {
|
||||
.count = ELEMENTSOF(genl_fou_types),
|
||||
.types = genl_fou_types,
|
||||
};
|
||||
|
||||
static const NLType genl_fou_cmds[] = {
|
||||
[FOU_CMD_ADD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system },
|
||||
[FOU_CMD_DEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system },
|
||||
[FOU_CMD_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_fou_cmds_type_system = {
|
||||
.count = ELEMENTSOF(genl_fou_cmds),
|
||||
.types = genl_fou_cmds,
|
||||
};
|
||||
|
||||
/***************** genl l2tp type systems *****************/
|
||||
static const NLType genl_l2tp_types[] = {
|
||||
[L2TP_ATTR_PW_TYPE] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_OFFSET] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_DATA_SEQ] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_L2SPEC_TYPE] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_L2SPEC_LEN] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_PROTO_VERSION] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_IFNAME] = { .type = NETLINK_TYPE_STRING },
|
||||
[L2TP_ATTR_CONN_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_PEER_CONN_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_SESSION_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_PEER_SESSION_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_UDP_CSUM] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_VLAN_ID] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_RECV_SEQ] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_SEND_SEQ] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_LNS_MODE] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_USING_IPSEC] = { .type = NETLINK_TYPE_U8 },
|
||||
[L2TP_ATTR_FD] = { .type = NETLINK_TYPE_U32 },
|
||||
[L2TP_ATTR_IP_SADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_IP_DADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_UDP_SPORT] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_UDP_DPORT] = { .type = NETLINK_TYPE_U16 },
|
||||
[L2TP_ATTR_IP6_SADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_IP6_DADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[L2TP_ATTR_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_FLAG },
|
||||
[L2TP_ATTR_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_FLAG },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_l2tp_type_system = {
|
||||
.count = ELEMENTSOF(genl_l2tp_types),
|
||||
.types = genl_l2tp_types,
|
||||
};
|
||||
|
||||
static const NLType genl_l2tp[] = {
|
||||
[L2TP_CMD_TUNNEL_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_TUNNEL_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_TUNNEL_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_TUNNEL_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
[L2TP_CMD_SESSION_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_l2tp_tunnel_session_type_system = {
|
||||
.count = ELEMENTSOF(genl_l2tp),
|
||||
.types = genl_l2tp,
|
||||
};
|
||||
|
||||
/***************** genl macsec type systems *****************/
|
||||
static const NLType genl_rxsc_types[] = {
|
||||
[MACSEC_RXSC_ATTR_SCI] = { .type = NETLINK_TYPE_U64 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_rxsc_config_type_system = {
|
||||
.count = ELEMENTSOF(genl_rxsc_types),
|
||||
.types = genl_rxsc_types,
|
||||
};
|
||||
|
||||
static const NLType genl_macsec_rxsc_types[] = {
|
||||
[MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[MACSEC_ATTR_RXSC_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_rxsc_config_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_macsec_rxsc_type_system = {
|
||||
.count = ELEMENTSOF(genl_macsec_rxsc_types),
|
||||
.types = genl_macsec_rxsc_types,
|
||||
};
|
||||
|
||||
static const NLType genl_macsec_sa_config_types[] = {
|
||||
[MACSEC_SA_ATTR_AN] = { .type = NETLINK_TYPE_U8 },
|
||||
[MACSEC_SA_ATTR_ACTIVE] = { .type = NETLINK_TYPE_U8 },
|
||||
[MACSEC_SA_ATTR_PN] = { .type = NETLINK_TYPE_U32 },
|
||||
[MACSEC_SA_ATTR_KEYID] = { .size = MACSEC_KEYID_LEN },
|
||||
[MACSEC_SA_ATTR_KEY] = { .size = MACSEC_MAX_KEY_LEN },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_macsec_sa_config_type_system = {
|
||||
.count = ELEMENTSOF(genl_macsec_sa_config_types),
|
||||
.types = genl_macsec_sa_config_types,
|
||||
};
|
||||
|
||||
static const NLType genl_macsec_rxsa_types[] = {
|
||||
[MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[MACSEC_ATTR_SA_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_config_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_macsec_rxsa_type_system = {
|
||||
.count = ELEMENTSOF(genl_macsec_rxsa_types),
|
||||
.types = genl_macsec_rxsa_types,
|
||||
};
|
||||
|
||||
static const NLType genl_macsec_sa_types[] = {
|
||||
[MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[MACSEC_ATTR_RXSC_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_rxsc_config_type_system },
|
||||
[MACSEC_ATTR_SA_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_config_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_macsec_sa_type_system = {
|
||||
.count = ELEMENTSOF(genl_macsec_sa_types),
|
||||
.types = genl_macsec_sa_types,
|
||||
};
|
||||
|
||||
static const NLType genl_macsec[] = {
|
||||
[MACSEC_CMD_ADD_RXSC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_rxsc_type_system },
|
||||
[MACSEC_CMD_ADD_TXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_rxsa_type_system},
|
||||
[MACSEC_CMD_ADD_RXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_macsec_device_type_system = {
|
||||
.count = ELEMENTSOF(genl_macsec),
|
||||
.types = genl_macsec,
|
||||
};
|
||||
|
||||
/***************** genl nl80211 type systems *****************/
|
||||
static const NLType genl_nl80211_types[] = {
|
||||
[NL80211_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[NL80211_ATTR_MAC] = { .type = NETLINK_TYPE_ETHER_ADDR },
|
||||
[NL80211_ATTR_SSID] = { .type = NETLINK_TYPE_STRING },
|
||||
[NL80211_ATTR_IFTYPE] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_nl80211_type_system = {
|
||||
.count = ELEMENTSOF(genl_nl80211_types),
|
||||
.types = genl_nl80211_types,
|
||||
};
|
||||
|
||||
static const NLType genl_nl80211_cmds[] = {
|
||||
[NL80211_CMD_GET_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_SET_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_NEW_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_DEL_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_GET_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_SET_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_NEW_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_DEL_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_GET_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_SET_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_NEW_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
[NL80211_CMD_DEL_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_nl80211_cmds_type_system = {
|
||||
.count = ELEMENTSOF(genl_nl80211_cmds),
|
||||
.types = genl_nl80211_cmds,
|
||||
};
|
||||
|
||||
/***************** genl wireguard type systems *****************/
|
||||
static const NLType genl_wireguard_allowedip_types[] = {
|
||||
[WGALLOWEDIP_A_FAMILY] = { .type = NETLINK_TYPE_U16 },
|
||||
[WGALLOWEDIP_A_IPADDR] = { .type = NETLINK_TYPE_IN_ADDR },
|
||||
[WGALLOWEDIP_A_CIDR_MASK] = { .type = NETLINK_TYPE_U8 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_wireguard_allowedip_type_system = {
|
||||
.count = ELEMENTSOF(genl_wireguard_allowedip_types),
|
||||
.types = genl_wireguard_allowedip_types,
|
||||
};
|
||||
|
||||
static const NLType genl_wireguard_peer_types[] = {
|
||||
[WGPEER_A_PUBLIC_KEY] = { .size = WG_KEY_LEN },
|
||||
[WGPEER_A_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
[WGPEER_A_PRESHARED_KEY] = { .size = WG_KEY_LEN },
|
||||
[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NETLINK_TYPE_U16 },
|
||||
[WGPEER_A_ENDPOINT] = { .type = NETLINK_TYPE_SOCKADDR },
|
||||
[WGPEER_A_ALLOWEDIPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_allowedip_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_wireguard_peer_type_system = {
|
||||
.count = ELEMENTSOF(genl_wireguard_peer_types),
|
||||
.types = genl_wireguard_peer_types,
|
||||
};
|
||||
|
||||
static const NLType genl_wireguard_set_device_types[] = {
|
||||
[WGDEVICE_A_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[WGDEVICE_A_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ-1 },
|
||||
[WGDEVICE_A_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
[WGDEVICE_A_PRIVATE_KEY] = { .size = WG_KEY_LEN },
|
||||
[WGDEVICE_A_LISTEN_PORT] = { .type = NETLINK_TYPE_U16 },
|
||||
[WGDEVICE_A_FWMARK] = { .type = NETLINK_TYPE_U32 },
|
||||
[WGDEVICE_A_PEERS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_peer_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_wireguard_set_device_type_system = {
|
||||
.count = ELEMENTSOF(genl_wireguard_set_device_types),
|
||||
.types = genl_wireguard_set_device_types,
|
||||
};
|
||||
|
||||
static const NLType genl_wireguard_cmds[] = {
|
||||
[WG_CMD_SET_DEVICE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_set_device_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_wireguard_type_system = {
|
||||
.count = ELEMENTSOF(genl_wireguard_cmds),
|
||||
.types = genl_wireguard_cmds,
|
||||
};
|
||||
|
||||
static const NLType genl_families[] = {
|
||||
[SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_id_ctrl_type_system },
|
||||
[SD_GENL_WIREGUARD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_type_system },
|
||||
[SD_GENL_FOU] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_cmds_type_system },
|
||||
[SD_GENL_L2TP] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_tunnel_session_type_system },
|
||||
[SD_GENL_MACSEC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_device_type_system },
|
||||
[SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_cmds_type_system },
|
||||
[SD_GENL_BATADV] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_cmds_type_system },
|
||||
};
|
||||
|
||||
/* Mainly used when sending message */
|
||||
const NLTypeSystem genl_family_type_system_root = {
|
||||
.count = ELEMENTSOF(genl_families),
|
||||
.types = genl_families,
|
||||
};
|
||||
|
||||
static const NLType genl_types[] = {
|
||||
[SD_GENL_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) },
|
||||
[SD_GENL_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system },
|
||||
[SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_get_family_type_system, .size = sizeof(struct genlmsghdr) },
|
||||
[SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system, .size = sizeof(struct genlmsghdr) },
|
||||
};
|
||||
|
||||
/* Mainly used when message received */
|
||||
static const NLTypeSystem genl_type_system = {
|
||||
.count = ELEMENTSOF(genl_types),
|
||||
.types = genl_types,
|
||||
};
|
||||
|
||||
int genl_get_type(sd_netlink *genl, uint16_t nlmsg_type, const NLType **ret) {
|
||||
sd_genl_family_t family;
|
||||
const NLType *nl_type;
|
||||
int r;
|
||||
|
||||
r = nlmsg_type_to_genl_family(genl, nlmsg_type, &family);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (family >= genl_type_system.count)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
nl_type = &genl_type_system.types[family];
|
||||
|
||||
if (nl_type->type == NETLINK_TYPE_UNSPEC)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
*ret = nl_type;
|
||||
return 0;
|
||||
}
|
107
src/libsystemd/sd-netlink/netlink-types-internal.h
Normal file
107
src/libsystemd/sd-netlink/netlink-types-internal.h
Normal file
@ -0,0 +1,107 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "macro.h"
|
||||
#include "netlink-types.h"
|
||||
|
||||
struct NLType {
|
||||
uint16_t type;
|
||||
size_t size;
|
||||
const NLTypeSystem *type_system;
|
||||
const NLTypeSystemUnion *type_system_union;
|
||||
};
|
||||
|
||||
struct NLTypeSystem {
|
||||
uint16_t count;
|
||||
const NLType *types;
|
||||
};
|
||||
|
||||
struct NLTypeSystemUnion {
|
||||
int num;
|
||||
NLMatchType match_type;
|
||||
uint16_t match_attribute;
|
||||
int (*lookup)(const char *);
|
||||
const NLTypeSystem *type_systems;
|
||||
};
|
||||
|
||||
extern const NLTypeSystem empty_type_system;
|
||||
extern const NLTypeSystem error_type_system;
|
||||
|
||||
typedef enum NLUnionLinkInfoData {
|
||||
NL_UNION_LINK_INFO_DATA_BOND,
|
||||
NL_UNION_LINK_INFO_DATA_BRIDGE,
|
||||
NL_UNION_LINK_INFO_DATA_VLAN,
|
||||
NL_UNION_LINK_INFO_DATA_VETH,
|
||||
NL_UNION_LINK_INFO_DATA_DUMMY,
|
||||
NL_UNION_LINK_INFO_DATA_MACVLAN,
|
||||
NL_UNION_LINK_INFO_DATA_MACVTAP,
|
||||
NL_UNION_LINK_INFO_DATA_IPVLAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPVTAP,
|
||||
NL_UNION_LINK_INFO_DATA_VXLAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_ERSPAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_SIT_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_VTI_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_VRF,
|
||||
NL_UNION_LINK_INFO_DATA_VCAN,
|
||||
NL_UNION_LINK_INFO_DATA_GENEVE,
|
||||
NL_UNION_LINK_INFO_DATA_VXCAN,
|
||||
NL_UNION_LINK_INFO_DATA_WIREGUARD,
|
||||
NL_UNION_LINK_INFO_DATA_NETDEVSIM,
|
||||
NL_UNION_LINK_INFO_DATA_CAN,
|
||||
NL_UNION_LINK_INFO_DATA_MACSEC,
|
||||
NL_UNION_LINK_INFO_DATA_NLMON,
|
||||
NL_UNION_LINK_INFO_DATA_XFRM,
|
||||
NL_UNION_LINK_INFO_DATA_IFB,
|
||||
NL_UNION_LINK_INFO_DATA_BAREUDP,
|
||||
NL_UNION_LINK_INFO_DATA_BATADV,
|
||||
_NL_UNION_LINK_INFO_DATA_MAX,
|
||||
_NL_UNION_LINK_INFO_DATA_INVALID = -EINVAL,
|
||||
} NLUnionLinkInfoData;
|
||||
|
||||
const char *nl_union_link_info_data_to_string(NLUnionLinkInfoData p) _const_;
|
||||
NLUnionLinkInfoData nl_union_link_info_data_from_string(const char *p) _pure_;
|
||||
|
||||
typedef enum NLUnionTCAOptionData {
|
||||
NL_UNION_TCA_OPTION_DATA_CAKE,
|
||||
NL_UNION_TCA_OPTION_DATA_CODEL,
|
||||
NL_UNION_TCA_OPTION_DATA_DRR,
|
||||
NL_UNION_TCA_OPTION_DATA_ETS,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ_CODEL,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ_PIE,
|
||||
NL_UNION_TCA_OPTION_DATA_GRED,
|
||||
NL_UNION_TCA_OPTION_DATA_HHF,
|
||||
NL_UNION_TCA_OPTION_DATA_HTB,
|
||||
NL_UNION_TCA_OPTION_DATA_PIE,
|
||||
NL_UNION_TCA_OPTION_DATA_QFQ,
|
||||
NL_UNION_TCA_OPTION_DATA_SFB,
|
||||
NL_UNION_TCA_OPTION_DATA_TBF,
|
||||
_NL_UNION_TCA_OPTION_DATA_MAX,
|
||||
_NL_UNION_TCA_OPTION_DATA_INVALID = -EINVAL,
|
||||
} NLUnionTCAOptionData;
|
||||
|
||||
const char *nl_union_tca_option_data_to_string(NLUnionTCAOptionData p) _const_;
|
||||
NLUnionTCAOptionData nl_union_tca_option_data_from_string(const char *p) _pure_;
|
||||
|
||||
typedef enum NLUnionNFTExprData {
|
||||
NL_UNION_NFT_EXPR_DATA_BITWISE,
|
||||
NL_UNION_NFT_EXPR_DATA_CMP,
|
||||
NL_UNION_NFT_EXPR_DATA_FIB,
|
||||
NL_UNION_NFT_EXPR_DATA_LOOKUP,
|
||||
NL_UNION_NFT_EXPR_DATA_PAYLOAD,
|
||||
NL_UNION_NFT_EXPR_DATA_MASQ,
|
||||
NL_UNION_NFT_EXPR_DATA_META,
|
||||
NL_UNION_NFT_EXPR_DATA_NAT,
|
||||
_NL_UNION_NFT_EXPR_DATA_MAX,
|
||||
_NL_UNION_NFT_EXPR_DATA_INVALID = -EINVAL,
|
||||
} NLUnionNFTExprData;
|
||||
|
||||
const char *nl_union_nft_expr_data_to_string(NLUnionNFTExprData p) _const_;
|
||||
NLUnionNFTExprData nl_union_nft_expr_data_from_string(const char *p) _pure_;
|
251
src/libsystemd/sd-netlink/netlink-types-nfnl.c
Normal file
251
src/libsystemd/sd-netlink/netlink-types-nfnl.c
Normal file
@ -0,0 +1,251 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/netfilter/nf_tables.h>
|
||||
#include <linux/netfilter/nfnetlink.h>
|
||||
|
||||
#include "netlink-types-internal.h"
|
||||
#include "string-table.h"
|
||||
|
||||
static const NLType nfnl_nft_table_types[] = {
|
||||
[NFTA_TABLE_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_TABLE_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_table_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_table_types),
|
||||
.types = nfnl_nft_table_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_chain_hook_types[] = {
|
||||
[NFTA_HOOK_HOOKNUM] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_HOOK_PRIORITY] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_HOOK_DEV] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_chain_hook_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_chain_hook_types),
|
||||
.types = nfnl_nft_chain_hook_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_chain_types[] = {
|
||||
[NFTA_CHAIN_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_CHAIN_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_CHAIN_HOOK] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_chain_hook_type_system },
|
||||
[NFTA_CHAIN_TYPE] = { .type = NETLINK_TYPE_STRING, .size = 16 },
|
||||
[NFTA_CHAIN_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_chain_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_chain_types),
|
||||
.types = nfnl_nft_chain_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_meta_types[] = {
|
||||
[NFTA_META_DREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_META_KEY] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_META_SREG] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_payload_types[] = {
|
||||
[NFTA_PAYLOAD_DREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_PAYLOAD_BASE] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_PAYLOAD_OFFSET] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_PAYLOAD_LEN] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_nat_types[] = {
|
||||
[NFTA_NAT_TYPE] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_NAT_FAMILY] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_NAT_REG_ADDR_MIN] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_NAT_REG_ADDR_MAX] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_NAT_REG_PROTO_MIN] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_NAT_REG_PROTO_MAX] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_NAT_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_data_types[] = {
|
||||
[NFTA_DATA_VALUE] = { .type = NETLINK_TYPE_BINARY },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_data_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_data_types),
|
||||
.types = nfnl_nft_data_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_bitwise_types[] = {
|
||||
[NFTA_BITWISE_SREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_BITWISE_DREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_BITWISE_LEN] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_BITWISE_MASK] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system },
|
||||
[NFTA_BITWISE_XOR] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system },
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_cmp_types[] = {
|
||||
[NFTA_CMP_SREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_CMP_OP] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_CMP_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system },
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_fib_types[] = {
|
||||
[NFTA_FIB_DREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_FIB_RESULT] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_FIB_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_lookup_types[] = {
|
||||
[NFTA_LOOKUP_SET] = { .type = NETLINK_TYPE_STRING },
|
||||
[NFTA_LOOKUP_SREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_LOOKUP_DREG] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_LOOKUP_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_expr_masq_types[] = {
|
||||
[NFTA_MASQ_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_MASQ_REG_PROTO_MIN] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_MASQ_REG_PROTO_MAX] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_expr_data_type_systems[] = {
|
||||
[NL_UNION_NFT_EXPR_DATA_BITWISE] = { .count = ELEMENTSOF(nfnl_nft_expr_bitwise_types),
|
||||
.types = nfnl_nft_expr_bitwise_types },
|
||||
[NL_UNION_NFT_EXPR_DATA_CMP] = { .count = ELEMENTSOF(nfnl_nft_expr_cmp_types),
|
||||
.types = nfnl_nft_expr_cmp_types },
|
||||
[NL_UNION_NFT_EXPR_DATA_FIB] = { .count = ELEMENTSOF(nfnl_nft_expr_fib_types),
|
||||
.types = nfnl_nft_expr_fib_types },
|
||||
[NL_UNION_NFT_EXPR_DATA_LOOKUP] = { .count = ELEMENTSOF(nfnl_nft_expr_lookup_types),
|
||||
.types = nfnl_nft_expr_lookup_types },
|
||||
[NL_UNION_NFT_EXPR_DATA_MASQ] = { .count = ELEMENTSOF(nfnl_nft_expr_masq_types),
|
||||
.types = nfnl_nft_expr_masq_types },
|
||||
[NL_UNION_NFT_EXPR_DATA_META] = { .count = ELEMENTSOF(nfnl_nft_expr_meta_types),
|
||||
.types = nfnl_nft_expr_meta_types },
|
||||
[NL_UNION_NFT_EXPR_DATA_NAT] = { .count = ELEMENTSOF(nfnl_nft_expr_nat_types),
|
||||
.types = nfnl_nft_expr_nat_types },
|
||||
[NL_UNION_NFT_EXPR_DATA_PAYLOAD] = { .count = ELEMENTSOF(nfnl_nft_expr_payload_types),
|
||||
.types = nfnl_nft_expr_payload_types },
|
||||
};
|
||||
|
||||
static const char* const nl_union_nft_expr_data_table[] = {
|
||||
[NL_UNION_NFT_EXPR_DATA_BITWISE] = "bitwise",
|
||||
[NL_UNION_NFT_EXPR_DATA_CMP] = "cmp",
|
||||
[NL_UNION_NFT_EXPR_DATA_LOOKUP] = "lookup",
|
||||
[NL_UNION_NFT_EXPR_DATA_META] = "meta",
|
||||
[NL_UNION_NFT_EXPR_DATA_FIB] = "fib",
|
||||
[NL_UNION_NFT_EXPR_DATA_MASQ] = "masq",
|
||||
[NL_UNION_NFT_EXPR_DATA_NAT] = "nat",
|
||||
[NL_UNION_NFT_EXPR_DATA_PAYLOAD] = "payload",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(nl_union_nft_expr_data, NLUnionNFTExprData);
|
||||
|
||||
static const NLTypeSystemUnion nfnl_nft_data_expr_type_system_union = {
|
||||
.num = _NL_UNION_NFT_EXPR_DATA_MAX,
|
||||
.lookup = nl_union_nft_expr_data_from_string,
|
||||
.type_systems = nfnl_expr_data_type_systems,
|
||||
.match_type = NL_MATCH_SIBLING,
|
||||
.match_attribute = NFTA_EXPR_NAME,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_rule_expr_types[] = {
|
||||
[NFTA_EXPR_NAME] = { .type = NETLINK_TYPE_STRING, .size = 16 },
|
||||
[NFTA_EXPR_DATA] = { .type = NETLINK_TYPE_UNION,
|
||||
.type_system_union = &nfnl_nft_data_expr_type_system_union },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_rule_expr_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_rule_expr_types),
|
||||
.types = nfnl_nft_rule_expr_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_rule_types[] = {
|
||||
[NFTA_RULE_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_RULE_CHAIN] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_RULE_EXPRESSIONS] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_rule_expr_type_system }
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_rule_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_rule_types),
|
||||
.types = nfnl_nft_rule_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_set_types[] = {
|
||||
[NFTA_SET_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_SET_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_SET_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_SET_KEY_TYPE] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_SET_KEY_LEN] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_SET_DATA_TYPE] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_SET_DATA_LEN] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_SET_POLICY] = { .type = NETLINK_TYPE_U32 },
|
||||
[NFTA_SET_ID] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_set_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_set_types),
|
||||
.types = nfnl_nft_set_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_setelem_types[] = {
|
||||
[NFTA_SET_ELEM_KEY] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system },
|
||||
[NFTA_SET_ELEM_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system },
|
||||
[NFTA_SET_ELEM_FLAGS] = { .type = NETLINK_TYPE_U32 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_setelem_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_setelem_types),
|
||||
.types = nfnl_nft_setelem_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_setelem_list_types[] = {
|
||||
[NFTA_SET_ELEM_LIST_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_SET_ELEM_LIST_SET] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 },
|
||||
[NFTA_SET_ELEM_LIST_ELEMENTS] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_setelem_list_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_setelem_list_types),
|
||||
.types = nfnl_nft_setelem_list_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_nft_msg_types [] = {
|
||||
[NFT_MSG_DELTABLE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_table_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFT_MSG_NEWTABLE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_table_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFT_MSG_NEWCHAIN] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_chain_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFT_MSG_NEWRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_rule_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFT_MSG_NEWSET] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_set_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFT_MSG_NEWSETELEM] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_list_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFT_MSG_DELSETELEM] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_list_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_nft_msg_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_nft_msg_types),
|
||||
.types = nfnl_nft_msg_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_msg_batch_types [] = {
|
||||
[NFNL_BATCH_GENID] = { .type = NETLINK_TYPE_U32 }
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_msg_batch_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_msg_batch_types),
|
||||
.types = nfnl_msg_batch_types,
|
||||
};
|
||||
|
||||
static const NLType nfnl_types[] = {
|
||||
[NLMSG_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system, .size = 0 },
|
||||
[NLMSG_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) },
|
||||
[NFNL_MSG_BATCH_BEGIN] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_msg_batch_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFNL_MSG_BATCH_END] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_msg_batch_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
[NFNL_SUBSYS_NFTABLES] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_msg_type_system, .size = sizeof(struct nfgenmsg) },
|
||||
};
|
||||
|
||||
static const NLTypeSystem nfnl_type_system = {
|
||||
.count = ELEMENTSOF(nfnl_types),
|
||||
.types = nfnl_types,
|
||||
};
|
||||
|
||||
int nfnl_get_type(uint16_t nlmsg_type, const NLType **ret) {
|
||||
return type_system_get_type(&nfnl_type_system, ret, nlmsg_type);
|
||||
}
|
1056
src/libsystemd/sd-netlink/netlink-types-rtnl.c
Normal file
1056
src/libsystemd/sd-netlink/netlink-types-rtnl.c
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "macro.h"
|
||||
#include "sd-netlink.h"
|
||||
|
||||
enum {
|
||||
NETLINK_TYPE_UNSPEC,
|
||||
@ -37,6 +37,10 @@ typedef struct NLType NLType;
|
||||
|
||||
extern const NLTypeSystem genl_family_type_system_root;
|
||||
|
||||
int rtnl_get_type(uint16_t nlmsg_type, const NLType **ret);
|
||||
int nfnl_get_type(uint16_t nlmsg_type, const NLType **ret);
|
||||
int genl_get_type(sd_netlink *genl, uint16_t nlmsg_type, const NLType **ret);
|
||||
|
||||
uint16_t type_get_type(const NLType *type);
|
||||
size_t type_get_size(const NLType *type);
|
||||
const NLTypeSystem *type_get_type_system(const NLType *type);
|
||||
@ -51,82 +55,3 @@ NLMatchType type_system_union_get_match_type(const NLTypeSystemUnion *type_syste
|
||||
uint16_t type_system_union_get_match_attribute(const NLTypeSystemUnion *type_system_union);
|
||||
int type_system_union_get_type_system_by_string(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, const char *key);
|
||||
int type_system_union_get_type_system_by_protocol(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, uint16_t protocol);
|
||||
|
||||
typedef enum NLUnionLinkInfoData {
|
||||
NL_UNION_LINK_INFO_DATA_BOND,
|
||||
NL_UNION_LINK_INFO_DATA_BRIDGE,
|
||||
NL_UNION_LINK_INFO_DATA_VLAN,
|
||||
NL_UNION_LINK_INFO_DATA_VETH,
|
||||
NL_UNION_LINK_INFO_DATA_DUMMY,
|
||||
NL_UNION_LINK_INFO_DATA_MACVLAN,
|
||||
NL_UNION_LINK_INFO_DATA_MACVTAP,
|
||||
NL_UNION_LINK_INFO_DATA_IPVLAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPVTAP,
|
||||
NL_UNION_LINK_INFO_DATA_VXLAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_ERSPAN,
|
||||
NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_SIT_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_VTI_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL,
|
||||
NL_UNION_LINK_INFO_DATA_VRF,
|
||||
NL_UNION_LINK_INFO_DATA_VCAN,
|
||||
NL_UNION_LINK_INFO_DATA_GENEVE,
|
||||
NL_UNION_LINK_INFO_DATA_VXCAN,
|
||||
NL_UNION_LINK_INFO_DATA_WIREGUARD,
|
||||
NL_UNION_LINK_INFO_DATA_NETDEVSIM,
|
||||
NL_UNION_LINK_INFO_DATA_CAN,
|
||||
NL_UNION_LINK_INFO_DATA_MACSEC,
|
||||
NL_UNION_LINK_INFO_DATA_NLMON,
|
||||
NL_UNION_LINK_INFO_DATA_XFRM,
|
||||
NL_UNION_LINK_INFO_DATA_IFB,
|
||||
NL_UNION_LINK_INFO_DATA_BAREUDP,
|
||||
NL_UNION_LINK_INFO_DATA_BATADV,
|
||||
_NL_UNION_LINK_INFO_DATA_MAX,
|
||||
_NL_UNION_LINK_INFO_DATA_INVALID = -EINVAL,
|
||||
} NLUnionLinkInfoData;
|
||||
|
||||
const char *nl_union_link_info_data_to_string(NLUnionLinkInfoData p) _const_;
|
||||
NLUnionLinkInfoData nl_union_link_info_data_from_string(const char *p) _pure_;
|
||||
|
||||
typedef enum NLUnionTCAOptionData {
|
||||
NL_UNION_TCA_OPTION_DATA_CAKE,
|
||||
NL_UNION_TCA_OPTION_DATA_CODEL,
|
||||
NL_UNION_TCA_OPTION_DATA_DRR,
|
||||
NL_UNION_TCA_OPTION_DATA_ETS,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ_CODEL,
|
||||
NL_UNION_TCA_OPTION_DATA_FQ_PIE,
|
||||
NL_UNION_TCA_OPTION_DATA_GRED,
|
||||
NL_UNION_TCA_OPTION_DATA_HHF,
|
||||
NL_UNION_TCA_OPTION_DATA_HTB,
|
||||
NL_UNION_TCA_OPTION_DATA_PIE,
|
||||
NL_UNION_TCA_OPTION_DATA_QFQ,
|
||||
NL_UNION_TCA_OPTION_DATA_SFB,
|
||||
NL_UNION_TCA_OPTION_DATA_TBF,
|
||||
_NL_UNION_TCA_OPTION_DATA_MAX,
|
||||
_NL_UNION_TCA_OPTION_DATA_INVALID = -EINVAL,
|
||||
} NLUnionTCAOptionData;
|
||||
|
||||
const char *nl_union_tca_option_data_to_string(NLUnionTCAOptionData p) _const_;
|
||||
NLUnionTCAOptionData nl_union_tca_option_data_from_string(const char *p) _pure_;
|
||||
|
||||
typedef enum NLUnionNFTExprData {
|
||||
NL_UNION_NFT_EXPR_DATA_BITWISE,
|
||||
NL_UNION_NFT_EXPR_DATA_CMP,
|
||||
NL_UNION_NFT_EXPR_DATA_FIB,
|
||||
NL_UNION_NFT_EXPR_DATA_LOOKUP,
|
||||
NL_UNION_NFT_EXPR_DATA_PAYLOAD,
|
||||
NL_UNION_NFT_EXPR_DATA_MASQ,
|
||||
NL_UNION_NFT_EXPR_DATA_META,
|
||||
NL_UNION_NFT_EXPR_DATA_NAT,
|
||||
_NL_UNION_NFT_EXPR_DATA_MAX,
|
||||
_NL_UNION_NFT_EXPR_DATA_INVALID = -EINVAL,
|
||||
} NLUnionNFTExprData;
|
||||
|
||||
const char *nl_union_nft_expr_data_to_string(NLUnionNFTExprData p) _const_;
|
||||
NLUnionNFTExprData nl_union_nft_expr_data_from_string(const char *p) _pure_;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "lldp-internal.h"
|
||||
#include "macvlan.h"
|
||||
#include "ndisc-internal.h"
|
||||
#include "netlink-internal.h"
|
||||
#include "networkd-link.h"
|
||||
#include "networkd-network.h"
|
||||
#include "networkd-util.h"
|
||||
@ -35,7 +34,6 @@ int main(int argc, char **argv) {
|
||||
/* test_table(link_state, LINK_STATE); — not a reversible mapping */
|
||||
test_table(lldp_mode, LLDP_MODE);
|
||||
test_table(netdev_kind, NETDEV_KIND);
|
||||
test_table(nl_union_link_info_data, NL_UNION_LINK_INFO_DATA);
|
||||
test_table(radv_prefix_delegation, RADV_PREFIX_DELEGATION);
|
||||
test_table(lldp_event, SD_LLDP_EVENT);
|
||||
test_table(ndisc_event, SD_NDISC_EVENT);
|
||||
|
Loading…
Reference in New Issue
Block a user