diff options
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-genl.c | 14 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-types-genl.c | 101 |
2 files changed, 11 insertions, 104 deletions
diff --git a/src/libsystemd/sd-netlink/netlink-genl.c b/src/libsystemd/sd-netlink/netlink-genl.c index 9330d66fe2..d8a628a683 100644 --- a/src/libsystemd/sd-netlink/netlink-genl.c +++ b/src/libsystemd/sd-netlink/netlink-genl.c @@ -29,8 +29,7 @@ int sd_genl_socket_open(sd_netlink **ret) { static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nlmsg_type, uint8_t cmd, sd_netlink_message **ret) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL; - const NLType *genl_cmd_type, *nl_type; - const NLTypeSystem *type_system; + const NLType *type; size_t size; int r; @@ -38,7 +37,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, &genl_cmd_type, family); + r = type_system_get_type(&genl_family_type_system, &type, family); if (r < 0) return r; @@ -52,17 +51,10 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family_t family, uint16_t nl return -ENOMEM; m->hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; - - type_system = type_get_type_system(genl_cmd_type); - - r = type_system_get_type(type_system, &nl_type, cmd); - if (r < 0) - return r; - m->hdr->nlmsg_len = size; m->hdr->nlmsg_type = nlmsg_type; - m->containers[0].type_system = type_get_type_system(nl_type); + m->containers[0].type_system = type_get_type_system(type); *(struct genlmsghdr *) NLMSG_DATA(m->hdr) = (struct genlmsghdr) { .cmd = cmd, diff --git a/src/libsystemd/sd-netlink/netlink-types-genl.c b/src/libsystemd/sd-netlink/netlink-types-genl.c index a88609c0be..7259d240fa 100644 --- a/src/libsystemd/sd-netlink/netlink-types-genl.c +++ b/src/libsystemd/sd-netlink/netlink-types-genl.c @@ -36,15 +36,6 @@ static const NLTypeSystem genl_ctrl_type_system = { .types = genl_ctrl_types, }; -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_cmd_type_system = { - .count = ELEMENTSOF(genl_ctrl_cmd_types), - .types = genl_ctrl_cmd_types, -}; - /***************** genl batadv type systems *****************/ static const NLType genl_batadv_types[] = { [BATADV_ATTR_VERSION] = { .type = NETLINK_TYPE_STRING }, @@ -114,15 +105,6 @@ static const NLTypeSystem genl_batadv_type_system = { .types = genl_batadv_types, }; -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_cmd_type_system = { - .count = ELEMENTSOF(genl_batadv_cmd_types), - .types = genl_batadv_cmd_types, -}; - /***************** genl fou type systems *****************/ static const NLType genl_fou_types[] = { [FOU_ATTR_PORT] = { .type = NETLINK_TYPE_U16 }, @@ -143,17 +125,6 @@ static const NLTypeSystem genl_fou_type_system = { .types = genl_fou_types, }; -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_cmd_type_system = { - .count = ELEMENTSOF(genl_fou_cmd_types), - .types = genl_fou_cmd_types, -}; - /***************** genl l2tp type systems *****************/ static const NLType genl_l2tp_types[] = { [L2TP_ATTR_PW_TYPE] = { .type = NETLINK_TYPE_U16 }, @@ -190,22 +161,6 @@ static const NLTypeSystem genl_l2tp_type_system = { .types = genl_l2tp_types, }; -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 }, - [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_cmd_type_system = { - .count = ELEMENTSOF(genl_l2tp_cmd_types), - .types = genl_l2tp_cmd_types, -}; - /***************** genl macsec type systems *****************/ static const NLType genl_macsec_rxsc_types[] = { [MACSEC_RXSC_ATTR_SCI] = { .type = NETLINK_TYPE_U64 }, @@ -240,17 +195,6 @@ static const NLTypeSystem genl_macsec_type_system = { .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 *****************/ static const NLType genl_nl80211_types[] = { [NL80211_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, @@ -264,26 +208,6 @@ static const NLTypeSystem genl_nl80211_type_system = { .types = genl_nl80211_types, }; -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 }, - [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_cmd_type_system = { - .count = ELEMENTSOF(genl_nl80211_cmd_types), - .types = genl_nl80211_cmd_types, -}; - /***************** genl wireguard type systems *****************/ static const NLType genl_wireguard_allowedip_types[] = { [WGALLOWEDIP_A_FAMILY] = { .type = NETLINK_TYPE_U16 }, @@ -325,24 +249,15 @@ static const NLTypeSystem genl_wireguard_type_system = { .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_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 }, + [SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_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_type_system }, + [SD_GENL_L2TP] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, + [SD_GENL_MACSEC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_type_system }, + [SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, + [SD_GENL_BATADV] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_type_system }, }; /* Mainly used when sending message */ @@ -355,7 +270,7 @@ static const NLType genl_types[] = { [SD_GENL_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system }, [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) }, + [SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system, .size = sizeof(struct genlmsghdr) }, }; /* Mainly used when message received */ |