mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
sd-netlink: rename several type systems for generic netlink
This commit is contained in:
parent
021273b782
commit
e6d58c2f71
@ -38,7 +38,7 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nl
|
||||
assert(nl->protocol == NETLINK_GENERIC);
|
||||
assert(ret);
|
||||
|
||||
r = type_system_get_type(&genl_family_type_system_root, &genl_cmd_type, family);
|
||||
r = type_system_get_type(&genl_family_type_system, &genl_cmd_type, family);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -15,34 +15,34 @@
|
||||
#include "netlink-types-internal.h"
|
||||
|
||||
/***************** genl ctrl type systems *****************/
|
||||
static const NLType genl_mcast_group_types[] = {
|
||||
static const NLType genl_ctrl_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 NLTypeSystem genl_ctrl_mcast_group_type_system = {
|
||||
.count = ELEMENTSOF(genl_ctrl_mcast_group_types),
|
||||
.types = genl_ctrl_mcast_group_types,
|
||||
};
|
||||
|
||||
static const NLType genl_get_family_types[] = {
|
||||
[CTRL_ATTR_FAMILY_NAME] = { .type = NETLINK_TYPE_STRING },
|
||||
static const NLType genl_ctrl_types[] = {
|
||||
[CTRL_ATTR_FAMILY_ID] = { .type = NETLINK_TYPE_U16 },
|
||||
[CTRL_ATTR_MCAST_GROUPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_mcast_group_type_system },
|
||||
[CTRL_ATTR_FAMILY_NAME] = { .type = NETLINK_TYPE_STRING },
|
||||
[CTRL_ATTR_MCAST_GROUPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_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 NLTypeSystem genl_ctrl_type_system = {
|
||||
.count = ELEMENTSOF(genl_ctrl_types),
|
||||
.types = genl_ctrl_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 NLType genl_ctrl_cmd_types[] = {
|
||||
[CTRL_CMD_GETFAMILY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_type_system, },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_ctrl_id_ctrl_type_system = {
|
||||
.count = ELEMENTSOF(genl_ctrl_id_ctrl_cmds),
|
||||
.types = genl_ctrl_id_ctrl_cmds,
|
||||
static const NLTypeSystem genl_ctrl_cmd_type_system = {
|
||||
.count = ELEMENTSOF(genl_ctrl_cmd_types),
|
||||
.types = genl_ctrl_cmd_types,
|
||||
};
|
||||
|
||||
/***************** genl batadv type systems *****************/
|
||||
@ -114,13 +114,13 @@ static const NLTypeSystem genl_batadv_type_system = {
|
||||
.types = genl_batadv_types,
|
||||
};
|
||||
|
||||
static const NLType genl_batadv_cmds[] = {
|
||||
static const NLType genl_batadv_cmd_types[] = {
|
||||
[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 NLTypeSystem genl_batadv_cmd_type_system = {
|
||||
.count = ELEMENTSOF(genl_batadv_cmd_types),
|
||||
.types = genl_batadv_cmd_types,
|
||||
};
|
||||
|
||||
/***************** genl fou type systems *****************/
|
||||
@ -143,15 +143,15 @@ static const NLTypeSystem genl_fou_type_system = {
|
||||
.types = genl_fou_types,
|
||||
};
|
||||
|
||||
static const NLType genl_fou_cmds[] = {
|
||||
static const NLType genl_fou_cmd_types[] = {
|
||||
[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,
|
||||
static const NLTypeSystem genl_fou_cmd_type_system = {
|
||||
.count = ELEMENTSOF(genl_fou_cmd_types),
|
||||
.types = genl_fou_cmd_types,
|
||||
};
|
||||
|
||||
/***************** genl l2tp type systems *****************/
|
||||
@ -190,7 +190,7 @@ static const NLTypeSystem genl_l2tp_type_system = {
|
||||
.types = genl_l2tp_types,
|
||||
};
|
||||
|
||||
static const NLType genl_l2tp[] = {
|
||||
static const NLType genl_l2tp_cmd_types[] = {
|
||||
[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 },
|
||||
@ -201,24 +201,14 @@ static const NLType genl_l2tp[] = {
|
||||
[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,
|
||||
static const NLTypeSystem genl_l2tp_cmd_type_system = {
|
||||
.count = ELEMENTSOF(genl_l2tp_cmd_types),
|
||||
.types = genl_l2tp_cmd_types,
|
||||
};
|
||||
|
||||
/***************** 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 },
|
||||
[MACSEC_RXSC_ATTR_SCI] = { .type = NETLINK_TYPE_U64 },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_macsec_rxsc_type_system = {
|
||||
@ -226,7 +216,7 @@ static const NLTypeSystem genl_macsec_rxsc_type_system = {
|
||||
.types = genl_macsec_rxsc_types,
|
||||
};
|
||||
|
||||
static const NLType genl_macsec_sa_config_types[] = {
|
||||
static const NLType genl_macsec_sa_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 },
|
||||
@ -234,41 +224,31 @@ static const NLType genl_macsec_sa_config_types[] = {
|
||||
[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 NLType genl_macsec_types[] = {
|
||||
[MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 },
|
||||
[MACSEC_ATTR_RXSC_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_rxsc_type_system },
|
||||
[MACSEC_ATTR_SA_CONFIG] = { .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,
|
||||
static const NLTypeSystem genl_macsec_type_system = {
|
||||
.count = ELEMENTSOF(genl_macsec_types),
|
||||
.types = genl_macsec_types,
|
||||
};
|
||||
|
||||
static const NLType genl_macsec_cmd_types[] = {
|
||||
[MACSEC_CMD_ADD_RXSC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_type_system },
|
||||
[MACSEC_CMD_ADD_TXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_type_system },
|
||||
[MACSEC_CMD_ADD_RXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_macsec_cmd_type_system = {
|
||||
.count = ELEMENTSOF(genl_macsec_cmd_types),
|
||||
.types = genl_macsec_cmd_types,
|
||||
};
|
||||
|
||||
/***************** genl nl80211 type systems *****************/
|
||||
@ -284,7 +264,7 @@ static const NLTypeSystem genl_nl80211_type_system = {
|
||||
.types = genl_nl80211_types,
|
||||
};
|
||||
|
||||
static const NLType genl_nl80211_cmds[] = {
|
||||
static const NLType genl_nl80211_cmd_types[] = {
|
||||
[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 },
|
||||
@ -299,9 +279,9 @@ static const NLType genl_nl80211_cmds[] = {
|
||||
[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,
|
||||
static const NLTypeSystem genl_nl80211_cmd_type_system = {
|
||||
.count = ELEMENTSOF(genl_nl80211_cmd_types),
|
||||
.types = genl_nl80211_cmd_types,
|
||||
};
|
||||
|
||||
/***************** genl wireguard type systems *****************/
|
||||
@ -330,7 +310,7 @@ static const NLTypeSystem genl_wireguard_peer_type_system = {
|
||||
.types = genl_wireguard_peer_types,
|
||||
};
|
||||
|
||||
static const NLType genl_wireguard_set_device_types[] = {
|
||||
static const NLType genl_wireguard_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 },
|
||||
@ -340,41 +320,42 @@ static const NLType genl_wireguard_set_device_types[] = {
|
||||
[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,
|
||||
.count = ELEMENTSOF(genl_wireguard_types),
|
||||
.types = genl_wireguard_types,
|
||||
};
|
||||
|
||||
static const NLType genl_wireguard_cmd_types[] = {
|
||||
[WG_CMD_SET_DEVICE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_type_system },
|
||||
};
|
||||
|
||||
static const NLTypeSystem genl_wireguard_cmd_type_system = {
|
||||
.count = ELEMENTSOF(genl_wireguard_cmd_types),
|
||||
.types = genl_wireguard_cmd_types,
|
||||
};
|
||||
|
||||
/***************** genl families *****************/
|
||||
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 },
|
||||
[SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_cmd_type_system },
|
||||
[SD_GENL_WIREGUARD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_cmd_type_system },
|
||||
[SD_GENL_FOU] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_cmd_type_system },
|
||||
[SD_GENL_L2TP] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_cmd_type_system },
|
||||
[SD_GENL_MACSEC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_cmd_type_system },
|
||||
[SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_cmd_type_system },
|
||||
[SD_GENL_BATADV] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_cmd_type_system },
|
||||
};
|
||||
|
||||
/* Mainly used when sending message */
|
||||
const NLTypeSystem genl_family_type_system_root = {
|
||||
const NLTypeSystem genl_family_type_system = {
|
||||
.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) },
|
||||
[SD_GENL_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) },
|
||||
[SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_type_system, .size = sizeof(struct genlmsghdr) },
|
||||
[SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_cmd_type_system, .size = sizeof(struct genlmsghdr) },
|
||||
};
|
||||
|
||||
/* Mainly used when message received */
|
||||
|
@ -35,7 +35,7 @@ typedef struct NLTypeSystemUnion NLTypeSystemUnion;
|
||||
typedef struct NLTypeSystem NLTypeSystem;
|
||||
typedef struct NLType NLType;
|
||||
|
||||
extern const NLTypeSystem genl_family_type_system_root;
|
||||
extern const NLTypeSystem genl_family_type_system;
|
||||
|
||||
int rtnl_get_type(uint16_t nlmsg_type, const NLType **ret);
|
||||
int nfnl_get_type(uint16_t nlmsg_type, const NLType **ret);
|
||||
|
Loading…
Reference in New Issue
Block a user