diff --git a/src/cntlr.c b/src/cntlr.c index 8a2a5046004ccf537b669228b6d668cafca84535..078ec9310c2c7177a99de34cefc65c7dcd2128b0 100644 --- a/src/cntlr.c +++ b/src/cntlr.c @@ -1412,15 +1412,13 @@ static void cntlr_query_nodes(struct uloop_timeout *t) uint8_t cntlr_resync_config(struct controller *c) { uint8_t diff; - struct node *n; struct node_policy *np; diff = cntlr_config_reload(&c->cfg); -// list_for_each_entry(n, &c->nodelist, list) -// n->ap = c->cfg.apolicy; - list_for_each_entry(np, &c->cfg.nodelist, list) { + struct node *n; + n = find_node_by_mac(c, np->agent_id); if (n) n->np = np; @@ -1429,6 +1427,7 @@ uint8_t cntlr_resync_config(struct controller *c) return diff; } +#define RADIO_MAX 8 static void cntlr_signal_periodic_run(struct uloop_timeout *t) { struct controller *c = container_of(t, struct controller, signal_handler); @@ -1469,9 +1468,7 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t) } else if (diff & (CONFIG_DIFF_AGENT_POLICY | CONFIG_DIFF_AGENT_POLICY_CNT)) { struct node_policy *p; struct node *n; - struct cmdu_buff *cmdu; - int num_radio = 1; - int num_bk = 1; + /* TODO/CLEANUP: * as of now, no information is being stored about @@ -1483,16 +1480,27 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t) * ((later on radio id & bss id info for specific agent * will be stored using in Topology Response CMDU.)) */ - uint8_t radio_id[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - uint8_t bk_id[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; trace("agent policy config changed\n"); /* send the policy config cmdu to the marked agent */ list_for_each_entry(n, &c->nodelist, list) { + struct cmdu_buff *cmdu; + int num_bk = 1; + uint8_t bk_id[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct radio_policy *rp; + uint8_t radio_id[RADIO_MAX][6] = {0}; + int num_radio = 0; + if ((diff & CONFIG_DIFF_AGENT_POLICY) && !n->np->is_policy_diff) continue; + list_for_each_entry(rp, &n->np->radiolist, list) { + memcpy(&radio_id[num_radio++], + rp->macaddr, + 6); + } + cmdu = cntlr_gen_policy_config_req(c, n->alid, n->np, num_radio, radio_id, num_bk, bk_id); @@ -1507,8 +1515,6 @@ static void cntlr_signal_periodic_run(struct uloop_timeout *t) struct radio_policy *rp; p->is_policy_diff = false; - list_for_each_entry(rp, &p->radiolist, list) - rp->is_policy_diff = false; } } } @@ -2108,8 +2114,6 @@ int start_controller(void) np->is_policy_diff = false; alloc_node_init(c, np->agent_id); - list_for_each_entry(rp, &np->radiolist, list) - rp->is_policy_diff = false; } } cntlr_resync_config(c); diff --git a/src/cntlr_cmdu.c b/src/cntlr_cmdu.c index 1829b8ab27ebfcc45a1c6f53fe34dd94200396a4..cd161987be1f0f391f748b04cc6cca5d6d45ba7f 100644 --- a/src/cntlr_cmdu.c +++ b/src/cntlr_cmdu.c @@ -351,7 +351,6 @@ struct cmdu_buff *cntlr_gen_policy_config_req(struct controller *c, goto out; } // #endif - cmdu_put_eom(frm); return frm; diff --git a/src/config.c b/src/config.c index a79fe068e77d32aa610e0362d6f741b41d4c9716..4bc293cd1104dd332685ebac59c1b3c3a54adf9c 100644 --- a/src/config.c +++ b/src/config.c @@ -35,6 +35,9 @@ #include "cntlr.h" #include "config.h" +#define CONFIG_DEFAULT_RCPI_TH_5G 86 +#define CONFIG_DEFAULT_RCPI_TH_2G 70 + #define list_copy(a, b, type) \ ({ \ typeof(type *) ____ptr, ____tmp; \ @@ -61,17 +64,27 @@ z; \ }) -#define list_policy_memcmp(a, b, type, offset) \ + + +#define list_policy_memcmp(c, d, t, o) \ ({ \ int z = 0; \ - typeof(type *) ____ptr, ____p; \ - ____p = list_first_entry(a, type, list); \ - list_for_each_entry(____ptr, b, list) { \ - if (memcmp(____p, ____ptr, sizeof(type) - offset)) { \ + typeof(t *) ____d, ____c; \ + ____c = list_first_entry(c, t, list); \ + list_for_each_entry(____d, d, list) { \ + if (memcmp(____c, ____d, sizeof(t) - o)) { \ z = 1; \ - ____ptr->is_policy_diff = 1; \ + ____d->is_policy_diff = 1; \ + } else { \ + if (list_memcmp(&____d->radiolist, \ + &____c->radiolist, struct radio_policy, \ + (sizeof(struct radio_policy) - \ + offsetof(struct radio_policy, list)))) { \ + z = 1; \ + ____d->is_policy_diff = 1; \ + } \ } \ - ____p = list_entry(____p->list.next, type, list); \ + ____c = list_entry(____c->list.next, t, list); \ } \ z; \ }) @@ -817,6 +830,7 @@ static int cntlr_config_get_agent_node(struct controller_config *c, INIT_LIST_HEAD(&a->steer_exlist); INIT_LIST_HEAD(&a->btmsteer_exlist); + a->pvid = 1; } else return -1; @@ -935,12 +949,18 @@ static int cntlr_config_get_agent_radio(struct controller_config *c, hwaddr_aton(tb[RADIO_AGENT]->v.string, a->agent_id); hwaddr_aton(tb[RADIO_MAC]->v.string, a->macaddr); - if (atoi(tb[RADIO_BAND]->v.string) == 5) + if (atoi(tb[RADIO_BAND]->v.string) == 5) { a->band = BAND_5; - else if (atoi(tb[RADIO_BAND]->v.string) == 2) + a->rcpi_threshold = CONFIG_DEFAULT_RCPI_TH_5G; + } else if (atoi(tb[RADIO_BAND]->v.string) == 2) { a->band = BAND_2; - else + a->rcpi_threshold = CONFIG_DEFAULT_RCPI_TH_2G; + } else a->band = BAND_UNKNOWN; + + a->report_rcpi_threshold = a->rcpi_threshold + 10; + a->include_sta_stats = true; + a->include_sta_metric = true; list_add(&a->list, &c->radiolist); } else { warn("|%s:%d| invalid radio config! Must hold agent_id, macaddr and band", __func__, __LINE__); diff --git a/src/config.h b/src/config.h index c201a4feaf50d698936a6272df1a2231b8cbfec2..59e3c6577483dbe1cfca9c7a9450a8e2d46b3d55 100644 --- a/src/config.h +++ b/src/config.h @@ -132,10 +132,9 @@ struct radio_policy { uint8_t rcpi_threshold; /* 0 - 220 */ uint8_t report_rcpi_threshold; /* 0, or 1 - 220 */ uint8_t report_util_threshold; /* 0, or channel utilization value */ - uint8_t report_rcpi_hysteresis_margin; /* 0, or > 0 - hysteresis margin */ + uint8_t report_rcpi_hysteresis_margin;/* 0, or > 0 - hysteresis margin */ bool include_sta_stats; /* sta stats in AP metric response */ bool include_sta_metric; /* sta metric in AP metric response */ - bool is_policy_diff; struct list_head list; /* link to next policy */ };