From bb61e971e5b9b24a096bd69ff6728416c8e7756a Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 15 Jul 2019 13:51:02 -0500 Subject: [PATCH] nl80211cmd: Introduce new utility --- Makefile.am | 1 + src/nl80211cmd.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++ src/nl80211cmd.h | 23 +++++++ 3 files changed, 189 insertions(+) create mode 100644 src/nl80211cmd.c create mode 100644 src/nl80211cmd.h diff --git a/Makefile.am b/Makefile.am index f2a54f22..968b7017 100644 --- a/Makefile.am +++ b/Makefile.am @@ -198,6 +198,7 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h src/iwd.h src/missing.h \ src/ap.c src/adhoc.c \ src/sae.h src/sae.c \ src/nl80211util.h src/nl80211util.c \ + src/nl80211cmd.h src/nl80211cmd.c \ src/owe.h src/owe.c \ src/blacklist.h src/blacklist.c \ src/manager.c \ diff --git a/src/nl80211cmd.c b/src/nl80211cmd.c new file mode 100644 index 00000000..c2944567 --- /dev/null +++ b/src/nl80211cmd.c @@ -0,0 +1,165 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "linux/nl80211.h" +#include "src/nl80211cmd.h" + +static const struct { + uint8_t cmd; + const char *str; +} cmd_table[] = { + { NL80211_CMD_GET_WIPHY, "Get Wiphy" }, + { NL80211_CMD_SET_WIPHY, "Set Wiphy" }, + { NL80211_CMD_NEW_WIPHY, "New Wiphy" }, + { NL80211_CMD_DEL_WIPHY, "Del Wiphy" }, + { NL80211_CMD_GET_INTERFACE, "Get Interface" }, + { NL80211_CMD_SET_INTERFACE, "Set Interface" }, + { NL80211_CMD_NEW_INTERFACE, "New Interface" }, + { NL80211_CMD_DEL_INTERFACE, "Del Interface" }, + { NL80211_CMD_GET_KEY, "Get Key" }, + { NL80211_CMD_SET_KEY, "Set Key" }, + { NL80211_CMD_NEW_KEY, "New Key" }, + { NL80211_CMD_DEL_KEY, "Del Key" }, + { NL80211_CMD_GET_BEACON, "Get Beacon" }, + { NL80211_CMD_SET_BEACON, "Set Beacon" }, + { NL80211_CMD_START_AP, "Start AP" }, + { NL80211_CMD_STOP_AP, "Stop AP" }, + { NL80211_CMD_GET_STATION, "Get Station" }, + { NL80211_CMD_SET_STATION, "Set Station" }, + { NL80211_CMD_NEW_STATION, "New Station" }, + { NL80211_CMD_DEL_STATION, "Del Station" }, + { NL80211_CMD_GET_MPATH, "Get Mesh Path" }, + { NL80211_CMD_SET_MPATH, "Set Mesh Path" }, + { NL80211_CMD_NEW_MPATH, "New Mesh Path" }, + { NL80211_CMD_DEL_MPATH, "Del Mesh Path" }, + { NL80211_CMD_SET_BSS, "Set BSS" }, + { NL80211_CMD_SET_REG, "Set Reg" }, + { NL80211_CMD_REQ_SET_REG, "Req Set Reg" }, + { NL80211_CMD_GET_MESH_CONFIG, "Get Mesh Config" }, + { NL80211_CMD_SET_MESH_CONFIG, "Set Mesh Config" }, + { NL80211_CMD_SET_MGMT_EXTRA_IE, "Mgmt Extra IE" }, + { NL80211_CMD_GET_REG, "Get Reg" }, + { NL80211_CMD_GET_SCAN, "Get Scan" }, + { NL80211_CMD_TRIGGER_SCAN, "Trigger Scan" }, + { NL80211_CMD_NEW_SCAN_RESULTS, "New Scan Results" }, + { NL80211_CMD_SCAN_ABORTED, "Scan Aborted" }, + { NL80211_CMD_REG_CHANGE, "Reg Change" }, + { NL80211_CMD_AUTHENTICATE, "Authenticate" }, + { NL80211_CMD_ASSOCIATE, "Associate" }, + { NL80211_CMD_DEAUTHENTICATE, "Deauthenticate" }, + { NL80211_CMD_DISASSOCIATE, "Disassociate" }, + { NL80211_CMD_MICHAEL_MIC_FAILURE, "Michael MIC Failure" }, + { NL80211_CMD_REG_BEACON_HINT, "Reg Beacon Hint" }, + { NL80211_CMD_JOIN_IBSS, "Join IBSS" }, + { NL80211_CMD_LEAVE_IBSS, "Leave IBSS" }, + { NL80211_CMD_TESTMODE, "Test Mode" }, + { NL80211_CMD_CONNECT, "Connect" }, + { NL80211_CMD_ROAM, "Roam" }, + { NL80211_CMD_DISCONNECT, "Disconnect" }, + { NL80211_CMD_SET_WIPHY_NETNS, "Set Wiphy Netns" }, + { NL80211_CMD_GET_SURVEY, "Get Survey" }, + { NL80211_CMD_NEW_SURVEY_RESULTS, "New Survey Results" }, + { NL80211_CMD_SET_PMKSA, "Set PMKSA" }, + { NL80211_CMD_DEL_PMKSA, "Del PMKSA" }, + { NL80211_CMD_FLUSH_PMKSA, "Flush PMKSA" }, + { NL80211_CMD_REMAIN_ON_CHANNEL, "Remain on Channel" }, + { NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL, "Cancel Remain on Channel"}, + { NL80211_CMD_SET_TX_BITRATE_MASK, "Set TX Bitrate Mask" }, + { NL80211_CMD_REGISTER_FRAME, "Register Frame" }, + { NL80211_CMD_FRAME, "Frame" }, + { NL80211_CMD_FRAME_TX_STATUS, "Frame TX Status" }, + { NL80211_CMD_SET_POWER_SAVE, "Set Power Save" }, + { NL80211_CMD_GET_POWER_SAVE, "Get Power Save" }, + { NL80211_CMD_SET_CQM, "Set CQM" }, + { NL80211_CMD_NOTIFY_CQM, "Notify CQM" }, + { NL80211_CMD_SET_CHANNEL, "Set Channel" }, + { NL80211_CMD_SET_WDS_PEER, "Set WDS Peer" }, + { NL80211_CMD_FRAME_WAIT_CANCEL, "Frame Wait Cancel" }, + { NL80211_CMD_JOIN_MESH, "Join Mesh" }, + { NL80211_CMD_LEAVE_MESH, "Leave Mesh" }, + { NL80211_CMD_UNPROT_DEAUTHENTICATE, "Unprot Deauthenticate" }, + { NL80211_CMD_UNPROT_DISASSOCIATE, "Unprot Disassociate" }, + { NL80211_CMD_NEW_PEER_CANDIDATE, "New Peer Candidate" }, + { NL80211_CMD_GET_WOWLAN, "Get WoWLAN" }, + { NL80211_CMD_SET_WOWLAN, "Set WoWLAN" }, + { NL80211_CMD_START_SCHED_SCAN, "Start Sched Scan" }, + { NL80211_CMD_STOP_SCHED_SCAN, "Stop Sched Scan" }, + { NL80211_CMD_SCHED_SCAN_RESULTS, "Sched Scan Results" }, + { NL80211_CMD_SCHED_SCAN_STOPPED, "Sched Scan Stopped" }, + { NL80211_CMD_SET_REKEY_OFFLOAD, "Set Rekey Offload" }, + { NL80211_CMD_PMKSA_CANDIDATE, "PMKSA Candidate" }, + { NL80211_CMD_TDLS_OPER, "TDLS Oper" }, + { NL80211_CMD_TDLS_MGMT, "TDLS Mgmt" }, + { NL80211_CMD_UNEXPECTED_FRAME, "Unexpected Frame" }, + { NL80211_CMD_PROBE_CLIENT, "Probe Client" }, + { NL80211_CMD_REGISTER_BEACONS, "Register Beacons" }, + { NL80211_CMD_UNEXPECTED_4ADDR_FRAME, "Unexpected 4addr Frame"}, + { NL80211_CMD_SET_NOACK_MAP, "Set NoAck Map" }, + { NL80211_CMD_CH_SWITCH_NOTIFY, "Channel Switch Notify" }, + { NL80211_CMD_START_P2P_DEVICE, "Start P2P Device" }, + { NL80211_CMD_STOP_P2P_DEVICE, "Stop P2P Device" }, + { NL80211_CMD_CONN_FAILED, "Conn Failed" }, + { NL80211_CMD_SET_MCAST_RATE, "Set Mcast Rate" }, + { NL80211_CMD_SET_MAC_ACL, "Set MAC ACL" }, + { NL80211_CMD_RADAR_DETECT, "Radar Detect" }, + { NL80211_CMD_GET_PROTOCOL_FEATURES, "Get Protocol Features" }, + { NL80211_CMD_UPDATE_FT_IES, "Update FT IEs" }, + { NL80211_CMD_FT_EVENT, "FT Event" }, + { NL80211_CMD_CRIT_PROTOCOL_START, "Crit Protocol Start" }, + { NL80211_CMD_CRIT_PROTOCOL_STOP, "Crit Protocol Stop" }, + { NL80211_CMD_GET_COALESCE, "Get Coalesce" }, + { NL80211_CMD_SET_COALESCE, "Set Coalesce" }, + { NL80211_CMD_CHANNEL_SWITCH, "Channel Switch" }, + { NL80211_CMD_VENDOR, "Vendor" }, + { NL80211_CMD_SET_QOS_MAP, "Set QoS Map" }, + { NL80211_CMD_ADD_TX_TS, "Add Traffic Stream" }, + { NL80211_CMD_DEL_TX_TS, "Delete Traffic Stream" }, + { NL80211_CMD_GET_MPP, "Get Mesh Proxy Path" }, + { NL80211_CMD_JOIN_OCB, "Join OCB Network" }, + { NL80211_CMD_LEAVE_OCB, "Leave OCB Network" }, + { NL80211_CMD_CH_SWITCH_STARTED_NOTIFY, "Channel Switch Notify" }, + { NL80211_CMD_TDLS_CHANNEL_SWITCH, "TDLS Channel Switch" }, + { NL80211_CMD_TDLS_CANCEL_CHANNEL_SWITCH, + "Cancel TLDS Channel Switch" }, + { NL80211_CMD_WIPHY_REG_CHANGE, "Wiphy Reg Change" }, + { } +}; + +const char *nl80211cmd_to_string(uint32_t cmd) +{ + unsigned int i; + + for (i = 0; cmd_table[i].str; i++) { + if (cmd_table[i].cmd != cmd) + continue; + + return cmd_table[i].str; + } + + return "Unknown"; +} diff --git a/src/nl80211cmd.h b/src/nl80211cmd.h new file mode 100644 index 00000000..5f6d661c --- /dev/null +++ b/src/nl80211cmd.h @@ -0,0 +1,23 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +const char *nl80211cmd_to_string(uint32_t cmd);