monitor: Pretty-print commands supported by phy

This commit is contained in:
Denis Kenzior 2015-05-06 15:23:57 -05:00
parent 619448cacc
commit c3abaf8181
1 changed files with 147 additions and 124 deletions

View File

@ -1631,6 +1631,151 @@ static const struct attr_entry rekey_table[] = {
{ }
};
#define NLA_OK(nla,len) ((len) >= (int) sizeof(struct nlattr) && \
(nla)->nla_len >= sizeof(struct nlattr) && \
(nla)->nla_len <= (len))
#define NLA_NEXT(nla,attrlen) ((attrlen) -= NLA_ALIGN((nla)->nla_len), \
(struct nlattr*)(((char*)(nla)) + \
NLA_ALIGN((nla)->nla_len)))
#define NLA_LENGTH(len) (NLA_ALIGN(sizeof(struct nlattr)) + (len))
#define NLA_DATA(nla) ((void*)(((char*)(nla)) + NLA_LENGTH(0)))
#define NLA_PAYLOAD(nla) ((int)((nla)->nla_len - NLA_LENGTH(0)))
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" },
{ }
};
static void print_supported_commands(unsigned int level, const char *label,
const void *data, uint16_t size)
{
const struct nlattr *nla;
print_attr(level, "%s:", label);
for (nla = data; NLA_OK(nla, size); nla = NLA_NEXT(nla, size)) {
const char *cmd_str = "Reserved";
uint32_t cmd = *((uint32_t *) NLA_DATA(nla));
unsigned int i;
for (i = 0; cmd_table[i].str; i++) {
if (cmd_table[i].cmd == cmd) {
cmd_str = cmd_table[i].str;
break;
}
}
print_attr(level + 1, "%s [%d]", cmd_str, cmd);
}
}
static const struct attr_entry attr_table[] = {
{ NL80211_ATTR_WIPHY,
"Wiphy", ATTR_U32 },
@ -1736,8 +1881,8 @@ static const struct attr_entry attr_table[] = {
{ NL80211_ATTR_REG_TYPE,
"Regulatory Type" },
{ NL80211_ATTR_SUPPORTED_COMMANDS,
"Supported Commands", ATTR_ARRAY,
{ .array_type = ATTR_U32 } },
"Supported Commands", ATTR_CUSTOM,
{ .function = print_supported_commands } },
{ NL80211_ATTR_FRAME,
"Frame", ATTR_CUSTOM, { .function = print_frame } },
{ NL80211_ATTR_SSID,
@ -2065,17 +2210,6 @@ static const struct attr_entry attr_table[] = {
{ }
};
#define NLA_OK(nla,len) ((len) >= (int) sizeof(struct nlattr) && \
(nla)->nla_len >= sizeof(struct nlattr) && \
(nla)->nla_len <= (len))
#define NLA_NEXT(nla,attrlen) ((attrlen) -= NLA_ALIGN((nla)->nla_len), \
(struct nlattr*)(((char*)(nla)) + \
NLA_ALIGN((nla)->nla_len)))
#define NLA_LENGTH(len) (NLA_ALIGN(sizeof(struct nlattr)) + (len))
#define NLA_DATA(nla) ((void*)(((char*)(nla)) + NLA_LENGTH(0)))
#define NLA_PAYLOAD(nla) ((int)((nla)->nla_len - NLA_LENGTH(0)))
static void print_value(int indent, const char *label, enum attr_type type,
const void *buf, uint32_t len)
{
@ -2262,117 +2396,6 @@ static void print_attributes(int indent, const struct attr_entry *table,
}
}
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" },
{ }
};
static void netlink_str(char *str, size_t size,
uint16_t type, uint16_t flags, uint32_t len)
{