Skip to content
Snippets Groups Projects
Commit c12dcdd2 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

map-controller: controller discovery porting

parent d543e72a
No related branches found
No related tags found
No related merge requests found
Pipeline #20342 failed
...@@ -178,7 +178,7 @@ out: ...@@ -178,7 +178,7 @@ out:
return ret; return ret;
} }
int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu) int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rx_cmdu)
{ {
trace("%s: --->\n", __func__); trace("%s: --->\n", __func__);
struct controller *c = (struct controller *) cntlr; struct controller *c = (struct controller *) cntlr;
...@@ -196,7 +196,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu) ...@@ -196,7 +196,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu)
struct tlv *tv[6][16] = {0}; struct tlv *tv[6][16] = {0};
int ret = 0; int ret = 0;
ret = cmdu_parse_tlvs(rec_cmdu, tv, a_policy, 6); ret = cmdu_parse_tlvs(rx_cmdu, tv, a_policy, 6);
if (!tv[0][0] || !tv[1][0] || !tv[2][0] || !tv[3][0] || !tv[4][0] if (!tv[0][0] || !tv[1][0] || !tv[2][0] || !tv[3][0] || !tv[4][0]
|| !tv[5][0]) || !tv[5][0])
...@@ -260,7 +260,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu) ...@@ -260,7 +260,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu)
} else { } else {
char data[128] = {0}; char data[128] = {0};
snprintf(data, sizeof(data), "{\"type\":\"error\", \"reason\":\"multiple controllers\", \"almac\":\""MACFMT"\"}", MAC2STR(rec_cmdu->origin)); snprintf(data, sizeof(data), "{\"type\":\"error\", \"reason\":\"multiple controllers\", \"almac\":\""MACFMT"\"}", MAC2STR(rx_cmdu->origin));
cntlr_notify_event(c, "map.controller", data); cntlr_notify_event(c, "map.controller", data);
} }
...@@ -270,7 +270,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu) ...@@ -270,7 +270,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu)
__func__, freq->band); __func__, freq->band);
cmdu = cntlr_gen_ap_autoconfig_response(cntlr, aladdr_origin, cmdu = cntlr_gen_ap_autoconfig_response(cntlr, aladdr_origin,
freq->band, freq->band,
cmdu_get_mid(rec_cmdu)); cmdu_get_mid(rx_cmdu));
if (!cmdu) if (!cmdu)
return -1; return -1;
...@@ -281,9 +281,61 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu) ...@@ -281,9 +281,61 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rec_cmdu)
} }
/* disable and quit on controller response */ /* disable and quit on controller response */
int handle_ap_autoconfig_response(void *cntlr, struct cmdu_buff *cmdu) int handle_ap_autoconfig_response(void *cntlr, struct cmdu_buff *rx_cmdu)
{ {
trace("%s: --->\n", __func__); trace("%s: --->\n", __func__);
struct controller *c = (struct controller *) cntlr;
bool has_cntlr = false;
struct tlv_policy a_policy[] = {
[0] = { .type = TLV_TYPE_SUPPORTED_ROLE, .present = TLV_PRESENT_ONE },
[1] = { .type = MAP_TLV_SUPPORTED_SERVICE, .present = TLV_PRESENT_ONE },
[2] = { .type = MAP_TLV_MULTIAP_PROFILE, .present = TLV_PRESENT_ONE },
[3] = { .type = TLV_TYPE_SUPPORTED_FREQ_BAND, .present = TLV_PRESENT_ONE }
};
struct tlv *tv[4][16] = {0};
int i;
cmdu_parse_tlvs(rx_cmdu, tv, a_policy, 4);
if (!tv[0][0] || !tv[1][0] || !tv[2][0] || !tv[3][0])
return -1;
/* find if supported services containts controller */
if (tv[1][0]->data[0] > 0) {
int i;
for (i = 0; i < tv[1][0]->data[0]; i++) {
if (tv[1][0]->data[(i+1)] ==
SUPPORTED_SERVICE_MULTIAP_CONTROLLER) {
has_cntlr = true;
break;
}
}
}
/* if does not support controller - return */
if (!has_cntlr) {
dbg("autoconfig response does not support controller!\n");
return -1;
}
/* discard self response */
if (!memcmp(rx_cmdu->origin, c->almac, 6))
return 0;
trace("Received AP-Autoconfig Response which was not from self\n");
if (c->state == CNTLR_INIT) {
trace("Disable and exit\n");
set_value_by_string("mapcontroller", "controller", "enabled", "0",
UCI_TYPE_STRING);
exit(0);
} else {
char data[128] = {0};
snprintf(data, sizeof(data), "{\"type\":\"error\", \"reason\":\"multiple controllers\", \"almac\":\""MACFMT"\"}", MAC2STR(rx_cmdu->origin));
cntlr_notify_event(c, "map.controller", data);
}
return 0; return 0;
// struct controller *c = (struct controller *) cntlr; // struct controller *c = (struct controller *) cntlr;
// struct tlv_supp_service *tlv; // struct tlv_supp_service *tlv;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment