From 97c1b48270dc9ad5a53c7b1142e4ad396ed18531 Mon Sep 17 00:00:00 2001 From: sverma <saurabh.verma@iopsys.eu> Date: Tue, 27 Dec 2022 22:36:28 +0530 Subject: [PATCH] add debug logs for failed connection CMDU --- src/cmdu_validate.c | 38 ++++++++++++++++++++++++++++++++++++++ src/cmdu_validate.h | 1 + src/cntlr.c | 1 + src/cntlr_map_debug.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/src/cmdu_validate.c b/src/cmdu_validate.c index 16cf9266..7d1f328f 100644 --- a/src/cmdu_validate.c +++ b/src/cmdu_validate.c @@ -1395,3 +1395,41 @@ bool validate_bss_configuration_result(struct cmdu_buff *cmdu, } #endif /* EASYMESH_VERSION > 2 */ + +bool validate_failed_connection_msg(struct cmdu_buff *cmdu, struct tlv *tv[][16]) +{ + int ret; + struct tlv_policy c_policy[] = { + [0] = { + .type = MAP_TLV_STA_MAC_ADDRESS, + .present = TLV_PRESENT_ONE, + .minlen = 6, + .maxlen = 6 + }, + [1] = { + .type = MAP_TLV_STATUS_CODE, + .present = TLV_PRESENT_ONE, + .minlen = 2, + .maxlen = 2 + }, + [2] = { + .type = MAP_TLV_REASON_CODE, + .present = TLV_PRESENT_MORE, + .minlen = 2, + .maxlen = 2 + } + }; + + ret = cmdu_parse_tlvs(cmdu, tv, c_policy, 3); + if (ret) { + dbg("%s: parse_tlv failed\n", __func__); + return false; + } + + if (!tv[0][0] || !tv[1][0]) { + dbg("%s: mandatory tlv missing\n", __func__); + return false; + } + + return true; +} diff --git a/src/cmdu_validate.h b/src/cmdu_validate.h index f0a2b087..412bc7e8 100644 --- a/src/cmdu_validate.h +++ b/src/cmdu_validate.h @@ -12,6 +12,7 @@ bool validate_topology_response(struct cmdu_buff *cmdu, struct tlv *tv_tsp[][16] bool validate_ap_autoconfig_wsc(struct cmdu_buff *cmdu, struct tlv *tv[][16]); bool validate_ap_autoconfig_search(struct cmdu_buff *cmdu, struct tlv *tv[][16]); bool validate_ap_autoconfig_response(struct cmdu_buff *cmdu, struct tlv *tv[][16]); +bool validate_failed_connection_msg(struct cmdu_buff *cmdu, struct tlv *tv[][16]); #if (EASYMESH_VERSION > 2) /** diff --git a/src/cntlr.c b/src/cntlr.c index 469f355c..e8712761 100644 --- a/src/cntlr.c +++ b/src/cntlr.c @@ -1717,6 +1717,7 @@ static int controller_subscribe_for_cmdus(struct controller *c) CMDU_AP_CAPABILITY_REPORT, CMDU_CLIENT_CAPABILITY_REPORT, CMDU_HIGHER_LAYER_DATA, + CMDU_FAILED_CONNECTION, #if (EASYMESH_VERSION > 2) CMDU_BSS_CONFIG_REQUEST, CMDU_BSS_CONFIG_RESULT, diff --git a/src/cntlr_map_debug.c b/src/cntlr_map_debug.c index 82c2ae97..a9e8b8c7 100644 --- a/src/cntlr_map_debug.c +++ b/src/cntlr_map_debug.c @@ -1425,7 +1425,35 @@ int debug_backhaul_sta_caps_report(void *cntlr, struct cmdu_buff *cmdu) int debug_failed_connection_msg(void *cntlr, struct cmdu_buff *cmdu) { + struct tlv *tv[3][16]; + + if (!validate_failed_connection_msg(cmdu, tv)) { + trace("%s: cmdu validation "\ + "[FAILED_CONNECTION] failed\n", __func__); + return -1; + } + trace("%s: --->\n", __func__); + trace("parsing failed connection message\n"); + + if (tv[0][0]) { + struct tlv_sta_mac *t = (struct tlv_sta_mac *)tv[0][0]->data; + + trace("\tmacaddr: " MACFMT "\n", MAC2STR(t->macaddr)); + } + + if (tv[1][0]) { + struct tlv_status_code *t = (struct tlv_status_code *)tv[1][0]->data; + + trace("\tstatus code: %d\n", BUF_GET_BE16(t->code)); + } + + if (tv[2][0]) { + struct tlv_reason_code *t = (struct tlv_reason_code *)tv[2][0]->data; + + trace("\treason code: %d\n", BUF_GET_BE16(t->code)); + } + return 0; } -- GitLab