diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-06-29 16:06:04 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-08-29 17:18:11 +0900 |
commit | 0dac2688a43be587d8bb698fbd9ffe080a4de4c3 (patch) | |
tree | b3dc2129a690e55b3254449188b501e2c54e1e68 | |
parent | b019c545e982de08c024b91db4e8839cafa2381b (diff) | |
download | systemd-0dac2688a43be587d8bb698fbd9ffe080a4de4c3.tar.gz |
sd-netlink: move type systems
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-types.c | 715 |
1 files changed, 365 insertions, 350 deletions
diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index f7ea451b3b..80492af0dd 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -80,7 +80,7 @@ struct NLTypeSystemUnion { const NLTypeSystem *type_systems; }; -static const NLTypeSystem rtnl_link_type_system; +/***************** basic type systems *****************/ static const NLType empty_types[1] = { /* fake array to avoid .types==NULL, which denotes invalid type-systems */ @@ -91,6 +91,20 @@ static const NLTypeSystem empty_type_system = { .types = empty_types, }; +static const NLType error_types[] = { + [NLMSGERR_ATTR_MSG] = { .type = NETLINK_TYPE_STRING }, + [NLMSGERR_ATTR_OFFS] = { .type = NETLINK_TYPE_U32 }, +}; + +static const NLTypeSystem error_type_system = { + .count = ELEMENTSOF(error_types), + .types = error_types, +}; + +/***************** rtnl type systems *****************/ + +static const NLTypeSystem rtnl_link_type_system; + static const NLType rtnl_link_info_data_batadv_types[] = { [IFLA_BATADV_ALGO_NAME] = { .type = NETLINK_TYPE_STRING, .size = 20 }, }; @@ -1045,16 +1059,6 @@ static const NLTypeSystem rtnl_mdb_type_system = { .types = mdb_types, }; -static const NLType error_types[] = { - [NLMSGERR_ATTR_MSG] = { .type = NETLINK_TYPE_STRING }, - [NLMSGERR_ATTR_OFFS] = { .type = NETLINK_TYPE_U32 }, -}; - -static const NLTypeSystem error_type_system = { - .count = ELEMENTSOF(error_types), - .types = error_types, -}; - static const NLType rtnl_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) }, @@ -1099,55 +1103,248 @@ const NLTypeSystem rtnl_type_system_root = { .types = rtnl_types, }; -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 }, +/***************** nfnl type systems *****************/ + +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 genl_wireguard_allowedip_type_system = { - .count = ELEMENTSOF(genl_wireguard_allowedip_types), - .types = genl_wireguard_allowedip_types, +static const NLTypeSystem nfnl_nft_table_type_system = { + .count = ELEMENTSOF(nfnl_nft_table_types), + .types = nfnl_nft_table_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 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 genl_wireguard_peer_type_system = { - .count = ELEMENTSOF(genl_wireguard_peer_types), - .types = genl_wireguard_peer_types, +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 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 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 genl_wireguard_set_device_type_system = { - .count = ELEMENTSOF(genl_wireguard_set_device_types), - .types = genl_wireguard_set_device_types, +static const NLTypeSystem nfnl_nft_chain_type_system = { + .count = ELEMENTSOF(nfnl_nft_chain_types), + .types = nfnl_nft_chain_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 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 NLTypeSystem genl_wireguard_type_system = { - .count = ELEMENTSOF(genl_wireguard_cmds), - .types = genl_wireguard_cmds, +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) }, +}; + +const NLTypeSystem nfnl_type_system_root = { + .count = ELEMENTSOF(nfnl_types), + .types = nfnl_types, }; +/***************** genl type systems *****************/ + +/***************** 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 }, @@ -1178,6 +1375,85 @@ static const NLTypeSystem genl_ctrl_id_ctrl_type_system = { .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 }, @@ -1208,6 +1484,7 @@ static const NLTypeSystem genl_fou_cmds_type_system = { .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 }, @@ -1259,6 +1536,7 @@ static const NLTypeSystem genl_l2tp_tunnel_session_type_system = { .types = genl_l2tp, }; +/***************** genl macsec type systems *****************/ static const NLType genl_rxsc_types[] = { [MACSEC_RXSC_ATTR_SCI] = { .type = NETLINK_TYPE_U64 }, }; @@ -1323,6 +1601,7 @@ static const NLTypeSystem genl_macsec_device_type_system = { .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 }, @@ -1355,328 +1634,64 @@ static const NLTypeSystem genl_nl80211_cmds_type_system = { .types = genl_nl80211_cmds, }; -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, -}; - -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 }, -}; - -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, +/***************** 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 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 genl_wireguard_allowedip_type_system = { + .count = ELEMENTSOF(genl_wireguard_allowedip_types), + .types = genl_wireguard_allowedip_types, }; -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 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 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 genl_wireguard_peer_type_system = { + .count = ELEMENTSOF(genl_wireguard_peer_types), + .types = genl_wireguard_peer_types, }; -static const NLTypeSystem nfnl_nft_msg_type_system = { - .count = ELEMENTSOF(nfnl_nft_msg_types), - .types = nfnl_nft_msg_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 NLType nfnl_msg_batch_types [] = { - [NFNL_BATCH_GENID] = { .type = NETLINK_TYPE_U32 } +static const NLTypeSystem genl_wireguard_set_device_type_system = { + .count = ELEMENTSOF(genl_wireguard_set_device_types), + .types = genl_wireguard_set_device_types, }; -static const NLTypeSystem nfnl_msg_batch_type_system = { - .count = ELEMENTSOF(nfnl_msg_batch_types), - .types = nfnl_msg_batch_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 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 genl_wireguard_type_system = { + .count = ELEMENTSOF(genl_wireguard_cmds), + .types = genl_wireguard_cmds, }; -const NLTypeSystem nfnl_type_system_root = { - .count = ELEMENTSOF(nfnl_types), - .types = nfnl_types, +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 */ |