From a1d736e25c747a0a99aea741bc41f16d5840f4b5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 23 Jul 2019 15:59:48 +0900 Subject: sd-netlink: add nl80211 type systems --- src/libsystemd/sd-netlink/generic-netlink.c | 1 + src/libsystemd/sd-netlink/netlink-types.c | 34 +++++++++++++++++++++++++++++ src/systemd/sd-netlink.h | 1 + 3 files changed, 36 insertions(+) diff --git a/src/libsystemd/sd-netlink/generic-netlink.c b/src/libsystemd/sd-netlink/generic-netlink.c index 58dda0323d..ad35b143f8 100644 --- a/src/libsystemd/sd-netlink/generic-netlink.c +++ b/src/libsystemd/sd-netlink/generic-netlink.c @@ -19,6 +19,7 @@ static const genl_family genl_families[] = { [SD_GENL_FOU] = { .name = "fou", .version = 1 }, [SD_GENL_L2TP] = { .name = "l2tp", .version = 1 }, [SD_GENL_MACSEC] = { .name = "macsec", .version = 1 }, + [SD_GENL_NL80211] = { .name = "nl80211", .version = 1 }, }; int sd_genl_socket_open(sd_netlink **ret) { diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index c9e20d6ed7..5c57ccf503 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -988,12 +989,44 @@ static const NLTypeSystem genl_macsec_device_type_system = { .types = genl_macsec, }; +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 }, +}; + +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, +}; + 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 }, }; /* Mainly used when sending message */ @@ -1006,6 +1039,7 @@ static const NLType genl_types[] = { [SD_GENL_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_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 */ diff --git a/src/systemd/sd-netlink.h b/src/systemd/sd-netlink.h index 43a15a98c0..53ac45775e 100644 --- a/src/systemd/sd-netlink.h +++ b/src/systemd/sd-netlink.h @@ -42,6 +42,7 @@ typedef enum sd_gen_family { SD_GENL_FOU, SD_GENL_L2TP, SD_GENL_MACSEC, + SD_GENL_NL80211, } sd_genl_family; /* callback */ -- cgit v1.2.1