diff --git a/src/cmdu.c b/src/cmdu.c index 01f6eb4b96df1fbd3b23dc22dced1f378e9218f8..c3241cf7b55a0cae0c71074ec8da79e20df6758e 100644 --- a/src/cmdu.c +++ b/src/cmdu.c @@ -24,6 +24,64 @@ #include "cmdu.h" +const char *cmdu_type2str(uint16_t type) +{ + +#define T2STR(t) case CMDU_TYPE_ ## t: return #t; + + switch (type) { + T2STR(TOPOLOGY_DISCOVERY) + T2STR(TOPOLOGY_NOTIFICATION) + T2STR(TOPOLOGY_QUERY) + T2STR(TOPOLOGY_RESPONSE) + T2STR(VENDOR_SPECIFIC) + T2STR(LINK_METRIC_QUERY) + T2STR(LINK_METRIC_RESPONSE) + T2STR(AP_AUTOCONFIGURATION_SEARCH) + T2STR(AP_AUTOCONFIGURATION_RESPONSE) + T2STR(AP_AUTOCONFIGURATION_WSC) + T2STR(AP_AUTOCONFIGURATION_RENEW) + T2STR(PUSH_BUTTON_EVENT_NOTIFICATION) + T2STR(PUSH_BUTTON_JOIN_NOTIFICATION) + T2STR(HIGHER_LAYER_QUERY) + T2STR(HIGHER_LAYER_RESPONSE) + T2STR(INTERFACE_POWER_CHANGE_REQUEST) + T2STR(INTERFACE_POWER_CHANGE_RESPONSE) + T2STR(GENERIC_PHY_QUERY) + T2STR(GENERIC_PHY_RESPONSE) + } + + return "UNKNOWN"; + +#undef T2STR +} + +const char *tlv_type2str(uint8_t type) +{ + +#define T2STR(t) case TLV_TYPE_ ## t: return #t; + + switch (type) { + T2STR(END_OF_MESSAGE) + T2STR(AL_MAC_ADDRESS_TYPE) + T2STR(DEVICE_INFORMATION_TYPE) + T2STR(DEVICE_BRIDGING_CAPABILITIES) + T2STR(NON_1905_NEIGHBOR_DEVICE_LIST) + T2STR(NEIGHBOR_DEVICE_LIST) + T2STR(TRANSMITTER_LINK_METRIC) + T2STR(RECEIVER_LINK_METRIC) + T2STR(SEARCHED_ROLE) + T2STR(AUTOCONFIG_FREQ_BAND) + T2STR(SUPPORTED_ROLE) + T2STR(SUPPORTED_FREQ_BAND) + T2STR(WSC) + } + + return "UNKNOWN"; + +#undef T2STR +} + struct tlv *tlv_alloc(uint16_t datalen) { struct tlv *n = calloc(1, sizeof(*n) + datalen); diff --git a/src/cmdu.h b/src/cmdu.h index 00bb6347545f8bf5d27b9b85cc8d282f034381ec..450d01f58742330f431120425a9d614e02f7e7f6 100644 --- a/src/cmdu.h +++ b/src/cmdu.h @@ -144,6 +144,8 @@ uint16_t tlv_length(struct tlv *t); /** Get total length of a TLV including the header */ uint16_t tlv_total_length(struct tlv *t); +/** Helper function to stringify TLV type */ +const char *tlv_type2str(uint8_t type); /* Allocates cmdu_buff to hold 'size' length cmdu payload */ struct cmdu_buff *cmdu_alloc(int size); // XXX: internal use diff --git a/src/extensions/map/map_module.h b/src/extensions/map/map_module.h index cebc63b23f1d404c3c740d99c905d936a07cda10..dae09d2ea6e782715f8ef1befc22f11baf041324 100644 --- a/src/extensions/map/map_module.h +++ b/src/extensions/map/map_module.h @@ -13,5 +13,7 @@ struct map_module { int map_prepare_cmdu_mask(uint8_t mask[], ...); +const char *map_cmdu_type2str(uint16_t type); +const char *map_tlv_type2str(uint8_t type); #endif /* MAP_MODULE_H */ diff --git a/src/extensions/map/maputil.c b/src/extensions/map/maputil.c index b9dc47c527898e39d6d96e71b75a30ac2fd64eb8..a85e750148b54f5ede4056560c928719e6d9e22a 100644 --- a/src/extensions/map/maputil.c +++ b/src/extensions/map/maputil.c @@ -3,10 +3,10 @@ #include <stdint.h> #include <stdarg.h> +#include "1905_tlvs.h" #include "map2.h" #include "map_module.h" - #define cmdu_mask_setbit(m, f) \ do { \ if (f >= 0x8000) \ @@ -15,6 +15,11 @@ do { \ (m[(f) / 8] |= (1 << ((f) % 8))); \ } while(0) + +extern const char *tlv_type2str(uint8_t type); //FIXME +extern const char *cmdu_type2str(uint16_t type); + + int map_prepare_cmdu_mask(uint8_t mask[], ...) { va_list args; @@ -32,3 +37,137 @@ int map_prepare_cmdu_mask(uint8_t mask[], ...) va_end(args); return 0; } + +const char *map_cmdu_type2str(uint16_t type) +{ + if (type >= CMDU_TYPE_1905_START && type <= CMDU_TYPE_1905_END) + return cmdu_type2str(type); + +#define T2STR(t) case CMDU_ ## t: return #t; + + switch (type) { + T2STR(1905_ACK) + T2STR(AP_CAPABILITY_QUERY) + T2STR(AP_CAPABILITY_REPORT) + T2STR(POLICY_CONFIG_REQ) + T2STR(CHANNEL_PREFERENCE_QUERY) + T2STR(CHANNEL_PREFERENCE_REPORT) + T2STR(CHANNEL_SELECTION_REQ) + T2STR(CHANNEL_SELECTION_RESPONSE) + T2STR(OPERATING_CHANNEL_REPORT) + T2STR(CLIENT_CAPABILITY_QUERY) + T2STR(CLIENT_CAPABILITY_REPORT) + T2STR(AP_METRICS_QUERY) + T2STR(AP_METRICS_RESPONSE) + T2STR(ASSOC_STA_LINK_METRICS_QUERY) + T2STR(ASSOC_STA_LINK_METRICS_RESPONSE) + T2STR(UNASSOC_STA_LINK_METRIC_QUERY) + T2STR(UNASSOC_STA_LINK_METRIC_RESPONSE) + T2STR(BEACON_METRICS_QUERY) + T2STR(BEACON_METRICS_RESPONSE) + T2STR(COMBINED_INFRA_METRICS) + T2STR(CLIENT_STEERING_REQUEST) + T2STR(CLIENT_STEERING_BTM_REPORT) + T2STR(CLIENT_ASSOC_CONTROL_REQUEST) + T2STR(STEERING_COMPLETED) + T2STR(HIGHER_LAYER_DATA) + T2STR(BACKHAUL_STEER_REQUEST) + T2STR(BACKHAUL_STEER_RESPONSE) + T2STR(CHANNEL_SCAN_REQUEST) + T2STR(CHANNEL_SCAN_REPORT) + T2STR(CAC_REQUEST) + T2STR(CAC_TERMINATION) + T2STR(CLIENT_DISASSOCIATION_STATS) + T2STR(ERROR_RESPONSE) + T2STR(ASSOCIATION_STATUS_NOTIFICATION) + T2STR(TUNNELED) + T2STR(BACKHAUL_STA_CAPABILITY_QUERY) + T2STR(BACKHAUL_STA_CAPABILITY_REPORT) + T2STR(FAILED_CONNECTION) + } + + return "UNKNOWN"; + +#undef T2STR +} + +const char *map_tlv_type2str(uint8_t type) +{ + if (type >= TLV_TYPE_END_OF_MESSAGE && type <= TLV_TYPE_WSC) + return tlv_type2str(type); + +#define T2STR(t) case MAP_TLV_ ## t: return #t; + + switch (type) { + T2STR(SUPPORTED_SERVICE) + T2STR(SEARCHED_SERVICE) + T2STR(AP_RADIO_IDENTIFIER) + T2STR(AP_OPERATIONAL_BSS) + T2STR(ASSOCIATED_CLIENTS) + T2STR(AP_CAPABILITY) + T2STR(AP_RADIO_BASIC_CAPABILITIES) + T2STR(AP_HT_CAPABILITIES) + T2STR(AP_VHT_CAPABILITIES) + T2STR(AP_HE_CAPABILITIES) + T2STR(STEERING_POLICY) + T2STR(METRIC_REPORTING_POLICY) + T2STR(CHANNEL_PREFERENCE) + T2STR(RADIO_OPERATION_RESTRICTION) + T2STR(TRANSMIT_POWER_LIMIT) + T2STR(CHANNEL_SELECTION_RESPONSE) + T2STR(OPERATING_CHANNEL_REPORT) + T2STR(CLIENT_INFO) + T2STR(CLIENT_CAPABILITY_REPORT) + T2STR(CLIENT_ASSOCIATION_EVENT) + T2STR(AP_METRIC_QUERY) + T2STR(AP_METRICS) + T2STR(STA_MAC_ADDRESS) + T2STR(ASSOCIATED_STA_LINK_METRICS) + T2STR(UNASSOCIATED_STA_LINK_METRICS_QUERY) + T2STR(UNASSOCIATED_STA_LINK_METRICS_RESPONSE) + T2STR(BEACON_METRICS_QUERY) + T2STR(BEACON_METRICS_RESPONSE) + T2STR(STEERING_REQUEST) + T2STR(STEERING_BTM_REPORT) + T2STR(CLIENT_ASSOCIATION_CONTROL_REQUEST) + T2STR(BACKHAUL_STEERING_REQUEST) + T2STR(BACKHAUL_STEERING_RESPONSE) + T2STR(HIGHER_LAYER_DATA) + T2STR(ASSOCIATED_STA_TRAFFIC_STATS) + T2STR(ERROR_CODE) + T2STR(CHANNEL_SCAN_REPORTING_POLICY) + T2STR(CHANNEL_SCAN_CAPABILITY) + T2STR(CHANNEL_SCAN_REQ) + T2STR(CHANNEL_SCAN_RES) + T2STR(TIMESTAMP) + T2STR(CAC_REQ) + T2STR(CAC_TERMINATION) + T2STR(CAC_COMPLETION_REPORT) + T2STR(CAC_STATUS_REPORT) + T2STR(CAC_CAPABILITY) + T2STR(MULTIAP_PROFILE) + T2STR(PROFILE2_AP_CAPABILITY) + T2STR(DEFAULT_8021Q_SETTINGS) + T2STR(TRAFFIC_SEPARATION_POLICY) + T2STR(PROFILE2_ERR_CODE) + T2STR(AP_RADIO_ADV_CAPABILITY) + T2STR(ASSOCIATION_STATUS_NOTIF) + T2STR(SOURCE_INFO) + T2STR(TUNNELED_MSG_TYPE) + T2STR(TUNNELED) + T2STR(PROFILE2_STEERING_REQ) + T2STR(UNSUCCESS_ASSOCIATION_POLICY) + T2STR(METRIC_COLLECTION_INTERVAL) + T2STR(RADIO_METRICS) + T2STR(AP_EXTENDED_METRICS) + T2STR(ASSOCIATED_STA_EXT_LINK_METRICS) + T2STR(STATUS_CODE) + T2STR(REASON_CODE) + T2STR(BACKHAUL_STA_RADIO_CAPABILITY) + T2STR(BACKHAUL_BSS_CONFIG) + } + + return "UNKNOWN"; + +#undef T2STR +} \ No newline at end of file diff --git a/src/i1905.c b/src/i1905.c index 65dd643c7c5ab357dd0808e6e83ac56726323676..d970657796dabdfe7c227ce7eff519ac82f6c521 100644 --- a/src/i1905.c +++ b/src/i1905.c @@ -58,37 +58,6 @@ uint8_t MCAST_1905[] = "\x01\x80\xC2\x00\x00\x13"; uint8_t MCAST_LLDP[] = "\x01\x80\xC2\x00\x00\x0E"; -const char *cmdu_type2str(uint16_t type) -{ - -#define T2STR(t) case CMDU_TYPE_ ## t: return #t; - - switch (type) { - T2STR(TOPOLOGY_DISCOVERY) - T2STR(TOPOLOGY_NOTIFICATION) - T2STR(TOPOLOGY_QUERY) - T2STR(TOPOLOGY_RESPONSE) - T2STR(VENDOR_SPECIFIC) - T2STR(LINK_METRIC_QUERY) - T2STR(LINK_METRIC_RESPONSE) - T2STR(AP_AUTOCONFIGURATION_SEARCH) - T2STR(AP_AUTOCONFIGURATION_RESPONSE) - T2STR(AP_AUTOCONFIGURATION_WSC) - T2STR(AP_AUTOCONFIGURATION_RENEW) - T2STR(PUSH_BUTTON_EVENT_NOTIFICATION) - T2STR(PUSH_BUTTON_JOIN_NOTIFICATION) - T2STR(HIGHER_LAYER_QUERY) - T2STR(HIGHER_LAYER_RESPONSE) - T2STR(INTERFACE_POWER_CHANGE_REQUEST) - T2STR(INTERFACE_POWER_CHANGE_RESPONSE) - T2STR(GENERIC_PHY_QUERY) - T2STR(GENERIC_PHY_RESPONSE) - } - - return "UNKNOWN"; - -#undef T2STR -} static int signal_pending;