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

cntlr_map: don't publish multi cntlr ubus event unless supportedRole=cntlr

parent 5231cfa7
No related branches found
No related tags found
No related merge requests found
Pipeline #21871 failed
...@@ -194,7 +194,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rx_cmdu) ...@@ -194,7 +194,7 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rx_cmdu)
struct cmdu_buff *cmdu; struct cmdu_buff *cmdu;
uint8_t aladdr_origin[6] = {0}; uint8_t aladdr_origin[6] = {0};
struct tlv *tv[6][16] = {0}; struct tlv *tv[6][16] = {0};
int ret = 0; int ret = 0, i;
ret = cmdu_parse_tlvs(rx_cmdu, tv, a_policy, 6); ret = cmdu_parse_tlvs(rx_cmdu, tv, a_policy, 6);
...@@ -233,43 +233,40 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rx_cmdu) ...@@ -233,43 +233,40 @@ int handle_ap_autoconfig_search(void *cntlr, struct cmdu_buff *rx_cmdu)
return -1; return -1;
/* if supports agent, add to config */ /* if supports agent, add to config */
if (tv[3][0]->data[0] > 0) { for (i = 1; i <= tv[3][0]->data[0]; i++) {
int i;
char mac_str[18] = {0}; char mac_str[18] = {0};
int len = 0;
if (!hwaddr_ntoa(aladdr_origin, mac_str)) if (!hwaddr_ntoa(aladdr_origin, mac_str))
return -1; return -1;
for (i = 1; i <= tv[3][0]->data[0]; i++) { if (tv[3][0]->data[i] ==
if (tv[3][0]->data[i] == SUPPORTED_SERVICE_MULTIAP_AGENT) {
SUPPORTED_SERVICE_MULTIAP_AGENT) { ret = cntlr_config_add_agent(&c->cfg, mac_str);
ret = cntlr_config_add_agent(&c->cfg, mac_str); if (!ret)
if (!ret) cntlr_config_reload(&c->cfg);
cntlr_config_reload(&c->cfg); } else if (tv[3][0]->data[i] ==
} else if (tv[3][0]->data[i] == SUPPORTED_SERVICE_MULTIAP_CONTROLLER) {
SUPPORTED_SERVICE_MULTIAP_CONTROLLER) { if (!memcmp(aladdr_origin, c->almac, 6)) {
if (!memcmp(aladdr_origin, c->almac, 6)) { trace("%s: Discard ap-autoconfig search"\
trace("%s: Discard ap-autoconfig "\ " from self\n", __func__);
"search from self\n", return -1;
__func__);
return -1;
}
} }
break;
}
}
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)); if (c->state == CNTLR_INIT) {
cntlr_notify_event(c, "map.controller", data); 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);
}
}
break;
} }
/* TODO: don't answer if searched service does not include controller */ /* TODO: don't answer if searched service does not include controller */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment