diff --git a/src/Makefile b/src/Makefile
index dc001c4fc8868681db04b8db9443cc126a69e633..ff679580e50aefd39f53d11b42c52d259b2fd8a5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -28,8 +28,7 @@ AGENT_OBJS = \
LIBS = -lubus -lubox -ljson-c -lblobmsg_json -luci -lwifi-6 -leasy -pthread
LIBS += -I/usr/include/libnl3 -lnl-3 -lnl-route-3
LIBS += -rdynamic -ldl
-LIBS += -lmaputils
-LIBS += -lwsc
+LIBS += -li1905 -lmaputil
plugin_subdirs ?= $(wildcard plugins/*)
plugin_sofile = $(wildcard $(d)/*.so)
diff --git a/src/core/agent.c b/src/core/agent.c
index 8091f0713db9a456572d9485413a8ac3c325b281..9b42537bb375ac2679a6289dce37a8e861eb033d 100644
--- a/src/core/agent.c
+++ b/src/core/agent.c
@@ -32,18 +32,19 @@
#include <pthread.h>
-#include <map1905/map2.h>
-#include <map1905/maputils.h>
+#include <timer_impl.h>
+#include <cmdu.h>
+#include <1905_tlvs.h>
#include <easy/easy.h>
#include <wifi.h>
-#include <wsc.h>
+#include <i1905_wsc.h>
#include <uci.h>
-
+#include <map_module22.h>
#include "utils/utils.h"
-#include "map_module.h"
+//#include "map_module.h"
#include "utils.h"
#include "debug.h"
#include "liblist.h"
@@ -1272,7 +1273,7 @@ static int wifi_send_sta_report(struct agent *a, const char *vif,
uint8_t *macaddr, uint32_t status, uint8_t *bssid)
{
uint8_t src_bssid[6] = { 0 };
- char ifname[IFNAMESIZE] = {0};
+ char ifname[16] = {0};
uint8_t origin[6] = { 0 };
uint8_t ret = 0;
struct netif_fh *ifptr;
@@ -1434,11 +1435,11 @@ static int wifi_del_sta(struct agent *a, const char *vif,
return -2;
}
-int wifi_topology_notification (struct agent *agent, uint8_t *mac, char *ifname, uint8_t assoc_event)
+int wifi_topology_notification(struct agent *agent, uint8_t *mac, char *ifname, uint8_t assoc_event)
{
trace("%s: --->\n", __func__);
struct agent *a = (struct agent *) agent;
- struct cmdu_cstruct *cmdu;
+ struct cmdu_buff *cmdu;
struct netif_fh *fh;
fh = get_netif_by_name(a, ifname);
if (!fh)
@@ -1451,18 +1452,18 @@ int wifi_topology_notification (struct agent *agent, uint8_t *mac, char *ifname,
// Send cmdu
agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
+ cmdu_free(cmdu);
if (!assoc_event) {
cmdu = agent_gen_client_disassoc(a, mac, fh->bssid);
if (!cmdu)
goto error;
agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
+ cmdu_free(cmdu);
}
return 0;
error:
- map_free_cmdu(cmdu);
+ cmdu_free(cmdu);
return -1;
}
@@ -2147,13 +2148,13 @@ static void agent_schedule_cntlr_start(struct agent *a, int secs)
static void agent_trigger_vendor_specific(struct uloop_timeout *t)
{
struct agent *a = container_of(t, struct agent, loop_detection_dispatcher);
- struct cmdu_cstruct *cmdu;
+ struct cmdu_buff *cmdu;
uint8_t origin[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x13};
cmdu = agent_gen_vendor_specific_cmdu(a, origin, a->depth);
if (cmdu) {
a->loop_detection.tx_mid = agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
+ cmdu_free(cmdu);
}
}
@@ -2198,7 +2199,7 @@ static void wifi_bsta_event_handler(void *agent, struct blob_attr *msg)
struct netif_bk *bk;
struct tlv_backhaul_steer_resp *p;
uint8_t bssid[6] = {0};
- struct cmdu_cstruct *cmdu;
+ struct cmdu_buff *cmdu;
bool add, del;
blobmsg_parse(ev_attr, 3, tb, blob_data(msg), blob_len(msg));
@@ -2272,50 +2273,50 @@ static void wifi_bsta_event_handler(void *agent, struct blob_attr *msg)
wifi_mod_bridge(a, ifname, "remove");
}
- cmdu = bk->bsta_steer.cmdu;
- if (!cmdu)
- goto fail_cmdu;
-
- p = (struct tlv_backhaul_steer_resp *) extract_tlv_by_type(cmdu,
- MAP_TLV_BACKHAUL_STEERING_RESPONSE);
- if (!p)
- goto fail_cmdu;
-
- /**
- * if event bssid and tlv target bssid differ, that means steering
- * failed, add an error TLV prior to sending response
- */
- //TODO: move to if(add)?
- if (memcmp(bssid, p->bssid, 6)) {
- struct tlv_error_code *p1;
- uint8_t **tlvs;
-
- p->res_code = 0x01;
- p1 = (struct tlv_error_code *) calloc(1,
- sizeof(struct tlv_error_code));
- if (!p1)
- goto fail_cmdu;
-
- p1->tlv_type = MAP_TLV_ERROR_CODE;
- p1->reason_code = 0x05;
-
- cmdu->num_tlvs++;
-
- tlvs = (uint8_t **)realloc(cmdu->tlvs,
- cmdu->num_tlvs * sizeof(uint8_t *));
- if (!tlvs) {
- free(p1);
- goto fail_cmdu;
- }
- cmdu->tlvs = tlvs;
- cmdu->tlvs[cmdu->num_tlvs - 1] = (uint8_t *) p1;
- }
-
- uloop_timeout_cancel(&bk->connect_timer);
- agent_send_cmdu(a, cmdu);
-fail_cmdu:
- map_free_cmdu(cmdu);
- bk->bsta_steer.cmdu = NULL;
+// cmdu = bk->bsta_steer.cmdu;
+// if (!cmdu)
+// goto fail_cmdu;
+//
+// p = (struct tlv_backhaul_steer_resp *) extract_tlv_by_type(cmdu,
+// MAP_TLV_BACKHAUL_STEERING_RESPONSE);
+// if (!p)
+// goto fail_cmdu;
+//
+// /**
+// * if event bssid and tlv target bssid differ, that means steering
+// * failed, add an error TLV prior to sending response
+// */
+// //TODO: move to if(add)?
+// if (memcmp(bssid, p->bssid, 6)) {
+// struct tlv_error_code *p1;
+// uint8_t **tlvs;
+//
+// p->res_code = 0x01;
+// p1 = (struct tlv_error_code *) calloc(1,
+// sizeof(struct tlv_error_code));
+// if (!p1)
+// goto fail_cmdu;
+//
+// p1->tlv_type = MAP_TLV_ERROR_CODE;
+// p1->reason_code = 0x05;
+//
+// cmdu->num_tlvs++;
+//
+// tlvs = (uint8_t **)realloc(cmdu->tlvs,
+// cmdu->num_tlvs * sizeof(uint8_t *));
+// if (!tlvs) {
+// free(p1);
+// goto fail_cmdu;
+// }
+// cmdu->tlvs = tlvs;
+// cmdu->tlvs[cmdu->num_tlvs - 1] = (uint8_t *) p1;
+// }
+//
+// uloop_timeout_cancel(&bk->connect_timer);
+// agent_send_cmdu(a, cmdu);
+//fail_cmdu:
+// map_free_cmdu(cmdu);
+// bk->bsta_steer.cmdu = NULL;
}
static void wifi_wps_creds_event_handler(void *c, struct blob_attr *msg)
@@ -2416,43 +2417,44 @@ static void ubus_wifi_event_handler(struct ubus_context *ctx,
static void ieee1905_cmdu_event_handler(void *c, struct blob_attr *msg)
{
struct agent *a = (struct agent *)c;
- //uint8_t tlvlist[MAX_TLV_BUF] = { 0 };
char *tlvstr = NULL;
uint8_t *tlv = NULL;
char in_ifname[16] = {0};
- //struct blob_attr *attr;
char src[18] = { 0 };
uint8_t srcmac[6];
- //int pos = 0;
int len = 0;
uint16_t type;
uint16_t mid = 0;
struct blob_attr *tb[5];
- static const struct blobmsg_policy cmdu_attrs[5] = {
- [0] = { .name = "type", .type = BLOBMSG_TYPE_INT32 },
- [1] = { .name = "mid", .type = BLOBMSG_TYPE_INT32 },
- [2] = { .name = "ingress", .type = BLOBMSG_TYPE_STRING },
+ char *data_str;
+ int data_strlen;
+ uint8_t *data;
+ int data_len;
+
+
+ static const struct blobmsg_policy unish_cmdu_attrs[5] = {
+ [0] = { .name = "type", .type = BLOBMSG_TYPE_INT16 },
+ [1] = { .name = "mid", .type = BLOBMSG_TYPE_INT16 },
+ [2] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING },
[3] = { .name = "source", .type = BLOBMSG_TYPE_STRING },
- // TODO, what if tlvs is an array?
- [4] = { .name = "tlvs", .type = BLOBMSG_TYPE_STRING },
+ [4] = { .name = "cmdu", .type = BLOBMSG_TYPE_STRING },
};
+ blobmsg_parse(unish_cmdu_attrs, 5, tb, blob_data(msg), blob_len(msg));
trace("%s: --->\n", __func__);
- blobmsg_parse(cmdu_attrs, 5, tb, blob_data(msg), blob_len(msg));
-
if (!tb[0] || !tb[1])
return;
if (tb[0]) {
- type = (uint16_t)blobmsg_get_u32(tb[0]);
+ type = (uint16_t)blobmsg_get_u16(tb[0]);
if (type < 0 || !is_cmdu_for_us(a, type))
return;
}
if (tb[1])
- mid = (uint16_t)blobmsg_get_u32(tb[1]);
+ mid = (uint16_t)blobmsg_get_u16(tb[1]);
if (tb[2])
strncpy(in_ifname, blobmsg_data(tb[2]), 15);
@@ -2463,12 +2465,12 @@ static void ieee1905_cmdu_event_handler(void *c, struct blob_attr *msg)
}
if (tb[4]) {
- len = blobmsg_data_len(tb[4]);
+ len = blobmsg_data_len(tb[4]) - 16;
tlvstr = calloc(len + 1, sizeof(char));
if (!tlvstr)
return;
- strncpy(tlvstr, blobmsg_data(tb[4]), len);
+ strncpy(tlvstr, blobmsg_data(tb[4]) + 16, len);
len = (len - 1) / 2;
tlv = calloc(len, sizeof(uint8_t));
if (!tlv) {
@@ -2479,68 +2481,13 @@ static void ieee1905_cmdu_event_handler(void *c, struct blob_attr *msg)
strtob(tlvstr, len, tlv);
free(tlvstr);
- }
-#if 0
- if (tb[4]) {
- int rem;
- int len;
-
- blobmsg_for_each_attr(attr, tb[4], rem) {
- char tlvstr[513] = { 0 }; /* FIXME: size */
- uint8_t tlv[256] = { 0 };
-
- if (blobmsg_type(attr) != BLOBMSG_TYPE_STRING)
- continue;
-
- len = blobmsg_data_len(attr);
- memcpy(tlvstr, blobmsg_data(attr), len);
-
- len = (len - 1) / 2;
- if (pos + len > MAX_TLV_BUF)
- break;
-
- strtob(tlvstr, len, tlv);
- memcpy(&tlvlist[pos], tlv, len);
- pos += len;
- }
}
-#endif
agent_handle_map_event(a, type, mid, in_ifname, srcmac, tlv, len);
free(tlv);
}
-static void ubus_1905_event_handler(struct ubus_context *ctx,
- struct ubus_event_handler *ev,
- const char *type,
- struct blob_attr *msg)
-{
- int i;
- char *str;
- struct agent *a = container_of(ev, struct agent, ieee1905_evh);
- struct wifi_ev_handler {
- const char *ev_type;
- void (*handler)(void *ctx, struct blob_attr *ev_data);
- } evs[] = { {"ieee1905.cmdu", ieee1905_cmdu_event_handler} };
-
- str = blobmsg_format_json(msg, true);
- if (!str)
- return;
-
- info("[ &agent = %p ] Received [event = %s] [val = %s]\n",
- a, type, str);
-
- for (i = 0; i < ARRAY_SIZE(evs); i++) {
- if (!strcmp(type, evs[i].ev_type)) {
- evs[i].handler(a, msg);
- break;
- }
- }
-
- free(str);
-}
-
static int delete_neighbor_entry(struct netif_fh *vif, unsigned char *macaddr,
bool cntlr_cmd)
{
@@ -2889,7 +2836,6 @@ static int run_agent(struct agent *a)
struct netif_fh *fh;
int i = 0;
- fprintf(stderr, "%s: %d\n", __func__, __LINE__);
return 0; // TODO: remove
if (a->cfg.runfreq == AGENT_RUN_OFF)
return 0;
@@ -3892,7 +3838,7 @@ static void agent_steering_opp_timeout(struct uloop_timeout *t)
trace("agent: %s: --->\n", __func__);
struct agent *a = container_of(t, struct agent, sta_steer_req_timer);
uint8_t src_bssid[6] = { 0 };
- char ifname[IFNAMESIZE] = { 0 };
+ char ifname[16] = { 0 };
uint8_t origin[6] = { 0 };
strncpy(ifname, a->cfg.al_bridge, sizeof(ifname));
@@ -4001,6 +3947,8 @@ static void agent_dispatch_autoconfig(struct uloop_timeout *t)
int i;
trace("|%s:%d| Triggering AP-Autoconfig Search\n", __func__, __LINE__);
+ //trace("NOT SENDING AUTOCONFIG SEARCH!\n");
+ //return;
agent_ensure_controller_running(a);
@@ -4031,7 +3979,7 @@ static void agent_dispatch_autoconfig(struct uloop_timeout *t)
}
for (i = 0; i < a->num_radios; i++) {
- struct cmdu_cstruct *cmdu;
+ struct cmdu_buff *cmdu;
struct wifi_radio_element *radio = &a->radios[i];
int mid;
@@ -4042,6 +3990,7 @@ static void agent_dispatch_autoconfig(struct uloop_timeout *t)
continue;
}
#endif
+#if 0
cmdu = agent_gen_ap_autoconfig_search(a, radio, NULL, 0x02);
if (!cmdu)
continue;
@@ -4053,6 +4002,15 @@ static void agent_dispatch_autoconfig(struct uloop_timeout *t)
if (mid >= 0)
radio->mid = mid;
map_free_cmdu(cmdu);
+#endif
+ cmdu = agent_gen_ap_autoconfig_search(a, radio, NULL, 0x02);
+ if (!cmdu)
+ continue;
+
+ radio->mid = agent_send_cmdu(a, cmdu);
+
+ cmdu_free(cmdu);
+
}
a->acs_interval = a->cntlr_select.probe_int;
@@ -4153,6 +4111,138 @@ void clear_fhlist(struct agent *a)
}
}
+
+#define map_plugin "i1905.map"
+
+
+static void mapclient_sub_remove_cb(struct ubus_context *ctx,
+ struct ubus_subscriber *sub,
+ uint32_t obj)
+{
+ trace("Object 0x%x no longer present\n", obj);
+}
+
+static int mapclient_sub_cb(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *type,
+ struct blob_attr *msg)
+{
+ struct ubus_subscriber *s = container_of(obj, struct ubus_subscriber, obj);
+ struct agent *priv = container_of(s, struct agent, sub);
+ char *str;
+
+ str = blobmsg_format_json(msg, true);
+ trace("Received notification '%s': %s\n", type, str);
+
+ ieee1905_cmdu_event_handler(priv, msg);
+
+ free(str);
+
+ return 0;
+}
+
+static int mapclient_subscribe(struct agent *a, uint32_t oid)
+{
+ int ret;
+
+ /* register mapclient as a subscriber with ubus */
+ a->sub.cb = mapclient_sub_cb;
+ a->sub.remove_cb = mapclient_sub_remove_cb;
+
+ ret = ubus_register_subscriber(a->ubus_ctx, &a->sub);
+ if (ret)
+ trace("Failed to register sub: %s\n", ubus_strerror(ret));
+
+
+ /* now subscribe to events from map plugin over passed oid */
+ ret = ubus_subscribe(a->ubus_ctx, &a->sub, oid);
+ if (ret)
+ trace("Failed to subscribe: %s\n", ubus_strerror(ret));
+
+ return 0;
+}
+
+typedef uint32_t mapmodule_object_t;
+
+struct map_module_unish {
+ mapmodule_object_t id;
+ uint32_t cmdu_mask;
+ char process_cmdu_funcname[64];
+};
+
+
+static void register_cb(struct ubus_request *req, int type, struct blob_attr *msg)
+{
+ struct agent *priv = (struct agent *)req->priv;
+ const struct blobmsg_policy pol[1] = {
+ [0] = { .name = "oid", .type = BLOBMSG_TYPE_INT32 },
+ };
+ struct blob_attr *tb[1];
+
+
+ blobmsg_parse(pol, 1, tb, blob_data(msg), blob_len(msg));
+
+ if (tb[0]) {
+ uint32_t oid = blobmsg_get_u32(tb[0]);
+
+ trace("Response ID: %u\n", oid);
+ mapclient_subscribe(priv, oid);
+ }
+}
+
+#ifndef BITx
+#define BITx(n) (1U << (n))
+#endif
+
+static void mapclient_subscribe_for_cmdus(struct agent *a)
+{
+ char data[2 * sizeof(struct map_module) + 1] = {0};
+ int ret;
+ uint32_t map_id;
+ struct blob_buf bb = {};
+ struct map_module m = {
+ .id = 0x11111111,
+ .process_cmdu_funcname = "mapclient_process_cmdu",
+ };
+
+ map_prepare_cmdu_mask(m.cmdu_mask,
+ CMDU_TYPE_TOPOLOGY_DISCOVERY,
+ CMDU_TYPE_TOPOLOGY_NOTIFICATION,
+ CMDU_TYPE_TOPOLOGY_QUERY,
+ CMDU_TYPE_TOPOLOGY_RESPONSE,
+ CMDU_TYPE_VENDOR_SPECIFIC,
+ CMDU_TYPE_AP_AUTOCONFIGURATION_SEARCH,
+ CMDU_TYPE_AP_AUTOCONFIGURATION_RESPONSE,
+ CMDU_TYPE_AP_AUTOCONFIGURATION_WSC);
+
+ trace("<----------------------------------- %s\n", __func__);
+
+ //trace("cmdu-mask = 0x%x\n", i1905cmdus_mask);
+ ret = ubus_lookup_id(a->ubus_ctx, map_plugin, &map_id);
+ if (ret) {
+ trace("plugin '%s' lookup failed. %s\n",
+ map_plugin, ubus_strerror(ret));
+ return;
+ }
+
+ a->map_oid = map_id;
+
+ /* register as client to the map module */
+ blob_buf_init(&bb, 0);
+ blobmsg_add_string(&bb, "module", "mapagent");
+ btostr((unsigned char *)&m, sizeof(struct map_module), data);
+ blobmsg_add_string(&bb, "data", data);
+ ret = ubus_invoke(a->ubus_ctx, a->map_oid, "register", bb.head, register_cb,
+ a, 1000);
+ if (ret) {
+ trace("Failed to 'register' with %s (err = %s)\n",
+ map_plugin, ubus_strerror(ret));
+ }
+
+ blob_buf_free(&bb);
+
+ return;
+}
+
int start_agent(void)
{
struct agent *w;
@@ -4195,7 +4285,7 @@ int start_agent(void)
}
w->ubus_ctx = ctx;
w->wifi_evh.cb = ubus_wifi_event_handler;
- w->ieee1905_evh.cb = ubus_1905_event_handler;
+ //w->ieee1905_evh.cb = ubus_1905_event_handler;
ubus_add_uloop(ctx);
@@ -4264,7 +4354,6 @@ int start_agent(void)
ubus_register_event_handler(ctx, &w->wifi_evh, "ethport");
ubus_register_event_handler(ctx, &w->wifi_evh, "wifi.*");
ubus_register_event_handler(ctx, &w->wifi_evh, "wps_credentials");
- ubus_register_event_handler(ctx, &w->ieee1905_evh, "ieee1905.*");
w->autocfg_dispatcher.cb = agent_dispatch_autoconfig;
w->loop_detection_dispatcher.cb = agent_trigger_vendor_specific;
@@ -4289,11 +4378,13 @@ int start_agent(void)
uloop_timeout_set(&w->autocfg_dispatcher, 0 * 1000);
+ mapclient_subscribe_for_cmdus(w);
+
uloop_run();
/* out_and_exit: */
worker_exit(&w->cmd_dispatcher);
- ubus_unregister_event_handler(ctx, &w->ieee1905_evh);
+ //ubus_unregister_event_handler(ctx, &w->ieee1905_evh);
ubus_unregister_event_handler(ctx, &w->wifi_evh);
warn("Error!! exit ...\n");
agent_remove_object(w);
@@ -4362,7 +4453,7 @@ void stop_agent(struct agent *w)
stop_test_logging();
worker_exit(&w->cmd_dispatcher);
ubus_unregister_event_handler(w->ubus_ctx, &w->wifi_evh);
- ubus_unregister_event_handler(w->ubus_ctx, &w->ieee1905_evh);
+ //ubus_unregister_event_handler(w->ubus_ctx, &w->ieee1905_evh);
plugins_unload(&w->pluginlist);
agent_remove_object(w);
ubus_free(w->ubus_ctx);
diff --git a/src/core/agent.h b/src/core/agent.h
index 640689ac949c9a0a2a8b37e22104165a48c167b1..2260111381ee90e60edca95e4757f60ab759a6f5 100644
--- a/src/core/agent.h
+++ b/src/core/agent.h
@@ -348,6 +348,12 @@ struct wifi_unassoc_sta_element {
uint8_t rssi;
};
+struct wsc_key {
+ uint8_t *key;
+ uint32_t key_len;
+ uint8_t mac[6];
+};
+
struct wsc_data {
uint8_t *m1_frame;
uint16_t m1_size;
@@ -490,6 +496,8 @@ struct agent {
int ignore_scan_finished_event;
struct uloop_timeout available_scan_timer; /* 5 minutes available for scan */
time_t last_scan_time; /* minimum scan interval */
+ uint32_t map_oid;
+ struct ubus_subscriber sub;
};
struct netif_bk *find_bkhaul_by_bssid(struct agent *a, uint8_t *bssid);
diff --git a/src/core/agent_cmdu_generator.c b/src/core/agent_cmdu_generator.c
index cc1e4455a9277f1533c5d1e39b94ff31bd596566..af13848bdfcb9f1fee544bc427eac12f213c4077 100644
--- a/src/core/agent_cmdu_generator.c
+++ b/src/core/agent_cmdu_generator.c
@@ -26,9 +26,12 @@
#include <libubox/utils.h>
#include <libubus.h>
-#include <map1905/map2.h>
-#include <map1905/maputils.h>
-#include <wsc.h>
+#include <timer_impl.h>
+#include <cmdu.h>
+#include <1905_tlvs.h>
+#include <map22.h>
+#include <i1905_wsc.h>
+#include <map_module22.h>
#include <uci.h>
@@ -42,921 +45,987 @@
#include "msgqueue.h"
#include "worker.h"
#include "agent.h"
-//#include "platform_interfaces.h"
+
#include "agent_tlv_generator.h"
#include "agent_cmdu_generator.h"
-struct cmdu_cstruct *agent_gen_ap_autoconfig_search(struct agent *a,
+struct cmdu_buff *agent_gen_ap_autoconfig_search(struct agent *a,
struct wifi_radio_element *radio, char *intf_name,
uint8_t profile)
{
- struct cmdu_cstruct *cmdu;
- struct tlv_supp_service *p = NULL;
- struct tlv_searched_service *p1;
- struct tlv_map_profile *p2;
- struct tlv_al_mac *p3;
- struct tlv_autoconf_freq_band *p4;
- struct tlv_searched_role *p5;
- int i, tlv_index = 0;
+ struct cmdu_buff *frm = NULL;
+ struct tlv *t;
+ int ret = 0;
uint8_t band = 0;
+ uint16_t mid = 0;
- cmdu = (struct cmdu_cstruct *)calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu) {
- fprintf(stderr, "failed to malloc cmdu\n");
+ frm = cmdu_alloc_simple(CMDU_TYPE_AP_AUTOCONFIGURATION_SEARCH, &mid);
+ if (!frm) {
+ dbg("%s: -ENOMEM\n", __func__);
return NULL;
}
- memcpy(cmdu->origin, "\x01\x80\xc2\x00\x00\x13", 6);
- if (intf_name)
- strncpy(cmdu->intf_name, intf_name,
- sizeof(cmdu->intf_name) - 1);
- else
- strncpy(cmdu->intf_name, a->cfg.al_bridge, sizeof(cmdu->intf_name) - 1);
-
- cmdu->message_type = CMDU_TYPE_AP_AUTOCONFIGURATION_SEARCH;
-
- p = calloc(1, sizeof(struct tlv_supp_service));
- if (!p)
- goto fail_cmdu;
-
- cmdu->num_tlvs++;
- p->tlv_type = MAP_TLV_SUPPORTED_SERVICE;
- p->supported_services_list = 1;
- p->supported_services = calloc(p->supported_services_list,
- sizeof(*p->supported_services));
- if (!p->supported_services)
- goto fail_p;
-
- for (i = 0; i < p->supported_services_list; i++)
- p->supported_services[i].service =
- SUPPORTED_SERVICE_MULTIAP_AGENT;
-
- p1 = calloc(1, sizeof(struct tlv_searched_service));
- if (!p1)
- goto fail_p;
-
- cmdu->num_tlvs++;
- p1->tlv_type = MAP_TLV_SEARCHED_SERVICE;
- p1->searched_services_list = 1;
- p1->service = calloc(p1->searched_services_list, sizeof(*p1->service));
- if (!p1->service)
- goto fail_p1;
-
- for (i = 0; i < p1->searched_services_list; i++)
- p1->service[i] = SEARCHED_SERVICE_MULTIAP_CONTROLLER;
-
- p2 = calloc(1, sizeof(struct tlv_map_profile));
- if (!p2)
- goto fail_p1;
+ CMDU_SET_RELAY_MCAST(frm->cdata);
- cmdu->num_tlvs++;
- p2->tlv_type = MAP_TLV_MULTIAP_PROFILE;
- p2->profile = profile;
+ ret = agent_gen_al_mac(a, frm, a->almac);
+ if (ret) {
+ cmdu_free(frm);
+ return NULL;
+ }
- p3 = agent_gen_al_mac(a, a->almac);
- if (!p3)
- goto fail_p2;
- cmdu->num_tlvs++;
+ ret = agent_gen_searched_role(a, frm, IEEE80211_ROLE_REGISTRAR);
+ if (ret) {
+ cmdu_free(frm);
+ return NULL;
+ }
band = wifi_band_to_ieee1905band(radio->band);
trace("radio band = %d, band = %d\n", radio->band, band);
- p4 = agent_gen_autoconf_freq_band(a, band);
- if (!p4)
- goto fail_p3;
- cmdu->num_tlvs++;
-
- p5 = agent_gen_searched_role(a, 0x00); /* registrar */
- if (!p5)
- goto fail_p4;
- cmdu->num_tlvs++;
-
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs,
- sizeof(uint8_t *));
- if (!cmdu->tlvs)
- goto fail_p5;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p4;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p5;
-
- return cmdu;
-fail_p5:
- map_free_tlv_cstruct((uint8_t *) p5);
-fail_p4:
- map_free_tlv_cstruct((uint8_t *) p4);
-fail_p3:
- map_free_tlv_cstruct((uint8_t *) p3);
-fail_p2:
- map_free_tlv_cstruct((uint8_t *) p2);
-fail_p1:
- map_free_tlv_cstruct((uint8_t *) p1);
-fail_p:
- map_free_tlv_cstruct((uint8_t *) p);
-fail_cmdu:
- free(cmdu);
- return NULL;
-}
-
-struct cmdu_cstruct *agent_gen_ap_metrics_response(struct agent *a,
- struct cmdu_cstruct *rec_cmdu)
-{
- int i, j;
- int tlv_index = 0;
- uint8_t *tmp;
- struct cmdu_cstruct *cmdu;
-
- cmdu = calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu) {
- dbg("Out of memory.!\n");
+ ret = agent_gen_autoconf_freq_band(a, frm, band);
+ if (ret) {
+ cmdu_free(frm);
return NULL;
}
- cmdu->message_type = CMDU_AP_METRICS_RESPONSE;
- memcpy(cmdu->origin, rec_cmdu->origin, 6);
- strncpy(cmdu->intf_name, rec_cmdu->intf_name, IFNAMESIZE - 1);
- cmdu->message_id = rec_cmdu->message_id;
-
- /* Calculate number of TLVs required for the response
- * based on the received CMDU
- */
- for (i = 0; i < rec_cmdu->num_tlvs; i++) {
- tmp = (uint8_t *)rec_cmdu->tlvs[i];
-
- switch (*tmp) {
- case MAP_TLV_AP_RADIO_IDENTIFIER:
- {
- int radio_index;
- struct tlv_ap_radio_identifier *p =
- (struct tlv_ap_radio_identifier *)tmp;
-
- radio_index = get_radio_index(a, p->radio_id);
- if (radio_index != -1) {
-// #ifdef PROFILE2
- /* Radio Metrics TLV */
- cmdu->num_tlvs++;
-// #endif
- }
- break;
- }
-
- case MAP_TLV_AP_METRIC_QUERY:
- {
- struct tlv_ap_metric_query *p =
- (struct tlv_ap_metric_query *)tmp;
-
- for (j = 0; j < p->bssid_nr; j++) {
- int num_sta = 0;
- struct sta *s;
- uint8_t bssid[6] = { 0 };
- struct netif_fh *fh;
-
- memcpy(bssid, p->ap_metric_query_bssid[j].bssid, 6);
- fh = wifi_get_netif_by_bssid(a, bssid);
- if (!fh)
- continue;
-
- /* AP Metrics TLV */
- cmdu->num_tlvs++;
-// #ifdef PROFILE2
- /* AP Extended Metrics TLV */
- cmdu->num_tlvs++;
-// #endif
-
- list_for_each_entry(s, &fh->stalist, list)
- num_sta++;
-
- if (fh->cfg->include_sta_stats) {
- /* Associated STA Traffic Stats TLV */
- cmdu->num_tlvs += num_sta;
- }
-
- if (fh->cfg->include_sta_metric) {
- /* Associated STA Link Metrics TLV */
- cmdu->num_tlvs += num_sta;
-
-// #ifdef PROFILE2
- /* Associated STA Extended Link Metrics TLV */
- cmdu->num_tlvs += num_sta;
-// #endif
- }
-
- }
- break;
- }
-
- default:
- dbg("Unsupported tlv in cmdu:%s\n",
- map_stringify_cmdu_type(rec_cmdu->message_type));
- break;
- }
+ ret = agent_gen_supported_service(a, frm, SUPPORTED_SERVICE_MULTIAP_AGENT);
+ if (ret) {
+ cmdu_free(frm);
+ return NULL;
}
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- if (!cmdu->tlvs) {
- cmdu->num_tlvs = 0;
- goto error;
+ ret = agent_gen_searched_service(a, frm, SEARCHED_SERVICE_MULTIAP_CONTROLLER);
+ if (ret) {
+ cmdu_free(frm);
+ return NULL;
}
- /* Process response based on received CMDU */
- for (i = 0; i < rec_cmdu->num_tlvs; i++) {
- tmp = (uint8_t *)rec_cmdu->tlvs[i];
-
- switch (*tmp) {
- case MAP_TLV_AP_RADIO_IDENTIFIER:
- {
- int radio_index;
- struct tlv_radio_metrics *p1;
- struct tlv_ap_radio_identifier *p =
- (struct tlv_ap_radio_identifier *)tmp;
-
- radio_index = get_radio_index(a, p->radio_id);
- if (radio_index != -1) {
-// #ifdef PROFILE2
- /* Radio Metrics TLV */
- p1 = agent_gen_radio_metrics(a,
- radio_index);
- if (!p1)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
-// #endif
- }
- break;
- }
-
- case MAP_TLV_AP_METRIC_QUERY:
- {
- struct wifi_radio_element *radio;
- struct wifi_bss_element *bss;
- struct tlv_ap_metrics *p2;
- struct tlv_ap_ext_metrics *p3;
- struct tlv_ap_metric_query *p =
- (struct tlv_ap_metric_query *)tmp;
-
- for (j = 0; j < p->bssid_nr; j++) {
- int radio_index;
- int bss_index;
- struct sta *s;
- struct netif_fh *fh;
-
- bss_index = get_radio_and_bss_index(a,
- p->ap_metric_query_bssid[j].bssid,
- &radio_index);
-
- if (bss_index == -1)
- continue;
-
- radio = a->radios + radio_index;
- bss = radio->bsslist + bss_index;
- /* AP Metrics TLV */
- p2 = agent_gen_ap_metrics(a,
- radio_index, bss_index);
- if (!p2)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-// #ifdef PROFILE2
- /* AP Extended Metrics TLV */
- p3 = agent_gen_ap_ext_metrics(a,
- radio_index, bss_index);
- if (!p3)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
-// #endif
-
- fh = wifi_get_netif_by_bssid(a, bss->bssid);
- if (fh == NULL)
- continue;
-
- list_for_each_entry(s, &fh->stalist, list) {
- if (fh->cfg->include_sta_stats) {
- /* Associated STA Traffic Stats TLV */
- struct tlv_assoc_sta_traffic_stats *p4;
-
- p4 = agent_gen_assoc_sta_traffic_stats(a, s);
- if (!p4)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p4;
- }
-
- if (fh->cfg->include_sta_metric) {
- struct tlv_assoc_sta_link_metrics *p5;
- struct tlv_assoc_sta_ext_link_metric *p6;
-
- p5 = agent_gen_assoc_sta_link_metrics(a, s, bss->bssid);
- if (!p5)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p5;
-
-// #ifdef PROFILE2
- p6 = agent_gen_assoc_sta_ext_link_metric(a, s, bss->bssid);
- if (!p6)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p6;
-// #endif
- }
-
- }
- }
- break;
- }
- }
+ ret = agent_gen_map_profile(a, frm, MULTIAP_PROFILE_2);
+ if (ret) {
+ cmdu_free(frm);
+ return NULL;
}
- /* if tlv_index is zero,
- * means no valid data is found
- * free the allocated memory for tlvs
- */
- if (tlv_index == 0)
- goto error;
-
- return cmdu;
+ cmdu_put_eom(frm);
-error:
- map_free_cmdu(cmdu);
+ dbg("%s:%d: radio = %s\n", __func__, __LINE__, radio->name);
+ return frm;
+out:
+ cmdu_free(frm);
return NULL;
}
-struct cmdu_cstruct *agent_gen_assoc_sta_metric_response_per_intf(
- struct agent *a, char *ifname)
+struct cmdu_buff *agent_gen_ap_autoconfig_wsc(struct agent *a, struct cmdu_buff *rec_cmdu,
+ struct wifi_radio_element *radio, uint16_t mid)
{
- int i;
- int tlv_index = 0;
- struct cmdu_cstruct *cmdu;
- struct wifi_radio_element *radio;
- struct wifi_bss_element *bss;
+ trace("agent: %s: --->\n", __func__);
+ struct cmdu_buff *frm = NULL;
+ struct tlv *t;
+ int ret = 0;
+ uint8_t band = 0;
- cmdu = calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu)
+ frm = cmdu_alloc_simple(CMDU_TYPE_AP_AUTOCONFIGURATION_WSC, &mid);
+ if (!frm) {
+ dbg("%s: -ENOMEM\n", __func__);
return NULL;
-
- cmdu->message_type = CMDU_ASSOC_STA_LINK_METRICS_RESPONSE;
- memcpy(cmdu->origin, a->cntlr_almac, 6);
- strncpy(cmdu->intf_name, a->cfg.al_bridge, IFNAMESIZE - 1);
-
- radio = wifi_ifname_to_radio_element(a, ifname);
- if (!radio)
- goto error;
-
- /* Calculate number of TLVs required for the response
- */
- for (i = 0; i < radio->num_bss; i++) {
- struct netif_fh *fh;
- int num_sta = 0;
- struct sta *s;
-
- bss = radio->bsslist + i;
- fh = wifi_get_netif_by_bssid(a, bss->bssid);
- if (!fh)
- continue;
-
- list_for_each_entry(s, &fh->stalist, list)
- num_sta++;
-
- /* Associated STA Link Metrics TLV */
- cmdu->num_tlvs += num_sta;
-// #ifdef PROFILE2
- /* Associated STA Extended Link Metrics TLV */
- cmdu->num_tlvs += num_sta;
-// #endif
- }
-
- if (cmdu->num_tlvs > 0)
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- else {
- /* no sta is for this radio interface
- * free the cmdu */
- goto error;
- }
-
- if (!cmdu->tlvs) {
- cmdu->num_tlvs = 0;
- goto error;
}
- for (i = 0; i < radio->num_bss; i++) {
- struct sta *s;
- struct netif_fh *fh;
-
- bss = radio->bsslist + i;
- fh = wifi_get_netif_by_bssid(a, bss->bssid);
- if (!fh)
- continue;
+ memcpy(frm->origin, rec_cmdu->origin, 6);
- list_for_each_entry(s, &fh->stalist, list) {
- struct tlv_assoc_sta_link_metrics *p1;
- struct tlv_assoc_sta_ext_link_metric *p2;
+ ret = agent_gen_ap_radio_basic_cap(a, frm, radio);
+ if (ret)
+ goto out;
- p1 = agent_gen_assoc_sta_link_metrics(a, s, bss->bssid);
- if (!p1)
- goto error;
+ ret = agent_gen_profile2_ap_cap(a, frm);
+ if (ret)
+ goto out;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+ ret = agent_gen_ap_radio_adv_cap(a, frm, radio);
+ if (ret)
+ goto out;
-// #ifdef PROFILE2
- p2 = agent_gen_assoc_sta_ext_link_metric(a, s, bss->bssid);
- if (!p2)
- goto error;
+ ret = agent_gen_wsc(a, frm, radio);
+ if (ret)
+ goto out;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-// #endif
- }
-
- }
-
- return cmdu;
-
-error:
- map_free_cmdu(cmdu);
+ trace("build ap autoconfig wsc!\n");
+ cmdu_put_eom(frm);
+ return frm;
+out:
+ cmdu_free(frm);
return NULL;
+// struct agent *a = (struct agent *) agent;
+// struct cmdu_buff *cmdu;
+// struct tlv_ap_radio_basic_cap *p;
+// struct tlv_profile2_ap_cap *p1;
+// struct tlv_ap_radio_adv_cap *p2;
+// struct tlv_wsc *p3;
+// int tlv_index = 0;
+//
+// /* don't trigger autoconfig for bSTA radios */
+// //if (radio->onboarded)
+// // return -1;
+//
+// cmdu = (struct cmdu_buff *)calloc(1, sizeof(struct cmdu_buff));
+// if (!cmdu) {
+// fprintf(stderr, "failed to malloc cmdu\n");
+// return -1;
+// }
+//
+// memcpy(cmdu->origin, rec_cmdu->origin, 6);
+// cmdu->message_type = CMDU_TYPE_AP_AUTOCONFIGURATION_WSC;
+// strncpy(cmdu->intf_name, rec_cmdu->intf_name,
+// sizeof(cmdu->intf_name) - 1);
+//
+// p = agent_gen_ap_radio_basic_cap(a, cmdu, radio);
+// if (!p)
+// goto fail_cmdu;
+// cmdu->num_tlvs++;
+//
+// p1 = agent_gen_profile2_ap_cap(a);
+// if (!p1)
+// goto fail_p;
+// cmdu->num_tlvs++;
+//
+// p2 = agent_gen_ap_radio_adv_cap(a, cmdu, radio);
+// if (!p2)
+// goto fail_p1;
+// cmdu->num_tlvs++;
+//
+// p3 = agent_gen_wsc(a, cmdu, radio);
+// if (!p3)
+// goto fail_p2;
+// cmdu->num_tlvs++;
+//
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs)
+// goto fail_p3;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p;
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
+// // TODO: ff:ff:ff:ff:ff:ff = send to all agents
+//
+// agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+// return 0;
+//fail_p3:
+// map_free_tlv_cstruct((uint8_t *) p3);
+//fail_p2:
+// map_free_tlv_cstruct((uint8_t *) p2);
+//fail_p1:
+// map_free_tlv_cstruct((uint8_t *) p1);
+//fail_p:
+// map_free_tlv_cstruct((uint8_t *) p);
+//fail_cmdu:
+// free(cmdu);
+// return -1;
}
-struct cmdu_cstruct *agent_gen_assoc_sta_metric_response(
- struct agent *a, struct cmdu_cstruct *rec_cmdu)
+struct cmdu_buff *agent_gen_ap_metrics_response(struct agent *a,
+ struct cmdu_buff *rec_cmdu)
{
- struct cmdu_cstruct *cmdu;
- struct tlv_sta_mac *query;
- struct netif_fh *fh;
- struct sta *s;
- struct tlv_assoc_sta_link_metrics *p1;
- struct tlv_assoc_sta_ext_link_metric *p2;
- struct tlv_error_code *p3;
- uint8_t *tmp;
- uint8_t reason_code;
- int tlv_index = 0;
- bool is_sta_found = false;
-
- if (!rec_cmdu)
- return NULL;
-
- cmdu = calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu) {
- fprintf(stderr, "failed to malloc cmdu\n");
- return NULL;
- }
-
- cmdu->message_type = CMDU_ASSOC_STA_LINK_METRICS_RESPONSE;
- memcpy(cmdu->origin, rec_cmdu->origin, 6);
- strncpy(cmdu->intf_name, rec_cmdu->intf_name, IFNAMESIZE - 1);
- cmdu->message_id = rec_cmdu->message_id;
-
- if (!rec_cmdu->num_tlvs || (rec_cmdu->num_tlvs > 1))
- goto error;
-
- tmp = (uint8_t *)rec_cmdu->tlvs[0];
- if (*tmp != MAP_TLV_STA_MAC_ADDRESS)
- goto error;
-
- query = (struct tlv_sta_mac *)tmp;
- list_for_each_entry(fh, &a->fhlist, list) {
- list_for_each_entry(s, &fh->stalist, list) {
- if (hwaddr_equal(query->addr, s->macaddr)) {
- is_sta_found = true;
- break;
- }
- }
- if (is_sta_found)
- break;
- }
-
- /* Associated STA Link Metrics TLV */
- cmdu->num_tlvs = 1;
- if (is_sta_found) {
-// #ifdef PROFILE2
- /* Associated STA Extended Link Metrics TLV */
- cmdu->num_tlvs++;
-// #endif
- } else
- cmdu->num_tlvs++; /* Error Code TLV*/
-
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- if (!cmdu->tlvs) {
- cmdu->num_tlvs = 0;
- goto error;
- }
-
- if (is_sta_found) {
- /* Associated STA Link Metrics TLV */
- p1 = agent_gen_assoc_sta_link_metrics(a, s, fh->bssid);
- if (!p1)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
-
-// #ifdef PROFILE2
- /* Associated STA Extended Link Metrics TLV */
- p2 = agent_gen_assoc_sta_ext_link_metric(a, s, fh->bssid);
- if (!p2)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-// #endif
-
- } else {
- /* Associated STA Link Metrics TLV */
- p1 = calloc(1, sizeof(*p1));
- if (!p1)
- goto error;
-
- p1->tlv_type = MAP_TLV_ASSOCIATED_STA_LINK_METRICS;
- memcpy(p1->addr, query->addr, 6);
- /* Reported BSS for STA */
- p1->bssid_nr = 0;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
-
- /* Error Code TLV */
- reason_code = 0x02; /* STA not associated with any BSS */
- p3 = agent_gen_tlv_error_code(a, NULL, query->addr, reason_code);
- if (!p3)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
- }
-
- return cmdu;
+ return NULL;
+// int i, j;
+// int tlv_index = 0;
+// uint8_t *tmp;
+// struct cmdu_cstruct *cmdu;
+//
+// cmdu = calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu) {
+// dbg("Out of memory.!\n");
+// return NULL;
+// }
+//
+// cmdu->message_type = CMDU_AP_METRICS_RESPONSE;
+// memcpy(cmdu->origin, rec_cmdu->origin, 6);
+// strncpy(cmdu->intf_name, rec_cmdu->intf_name, IFNAMESIZE - 1);
+// cmdu->message_id = rec_cmdu->message_id;
+//
+// /* Calculate number of TLVs required for the response
+// * based on the received CMDU
+// */
+// for (i = 0; i < rec_cmdu->num_tlvs; i++) {
+// tmp = (uint8_t *)rec_cmdu->tlvs[i];
+//
+// switch (*tmp) {
+// case MAP_TLV_AP_RADIO_IDENTIFIER:
+// {
+// int radio_index;
+// struct tlv_ap_radio_identifier *p =
+// (struct tlv_ap_radio_identifier *)tmp;
+//
+// radio_index = get_radio_index(a, p->radio_id);
+// if (radio_index != -1) {
+//// #ifdef PROFILE2
+// /* Radio Metrics TLV */
+// cmdu->num_tlvs++;
+//// #endif
+// }
+// break;
+// }
+//
+// case MAP_TLV_AP_METRIC_QUERY:
+// {
+// struct tlv_ap_metric_query *p =
+// (struct tlv_ap_metric_query *)tmp;
+//
+// for (j = 0; j < p->bssid_nr; j++) {
+// int num_sta = 0;
+// struct sta *s;
+// uint8_t bssid[6] = { 0 };
+// struct netif_fh *fh;
+//
+// memcpy(bssid, p->ap_metric_query_bssid[j].bssid, 6);
+// fh = wifi_get_netif_by_bssid(a, bssid);
+// if (!fh)
+// continue;
+//
+// /* AP Metrics TLV */
+// cmdu->num_tlvs++;
+//// #ifdef PROFILE2
+// /* AP Extended Metrics TLV */
+// cmdu->num_tlvs++;
+//// #endif
+//
+// list_for_each_entry(s, &fh->stalist, list)
+// num_sta++;
+//
+// if (fh->cfg->include_sta_stats) {
+// /* Associated STA Traffic Stats TLV */
+// cmdu->num_tlvs += num_sta;
+// }
+//
+// if (fh->cfg->include_sta_metric) {
+// /* Associated STA Link Metrics TLV */
+// cmdu->num_tlvs += num_sta;
+//
+//// #ifdef PROFILE2
+// /* Associated STA Extended Link Metrics TLV */
+// cmdu->num_tlvs += num_sta;
+//// #endif
+// }
+//
+// }
+// break;
+// }
+//
+// default:
+// dbg("Unsupported tlv in cmdu:%s\n",
+// map_stringify_cmdu_type(rec_cmdu->message_type));
+// break;
+// }
+// }
+//
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs) {
+// cmdu->num_tlvs = 0;
+// goto error;
+// }
+//
+// /* Process response based on received CMDU */
+// for (i = 0; i < rec_cmdu->num_tlvs; i++) {
+// tmp = (uint8_t *)rec_cmdu->tlvs[i];
+//
+// switch (*tmp) {
+// case MAP_TLV_AP_RADIO_IDENTIFIER:
+// {
+// int radio_index;
+// struct tlv_radio_metrics *p1;
+// struct tlv_ap_radio_identifier *p =
+// (struct tlv_ap_radio_identifier *)tmp;
+//
+// radio_index = get_radio_index(a, p->radio_id);
+// if (radio_index != -1) {
+//// #ifdef PROFILE2
+// /* Radio Metrics TLV */
+// p1 = agent_gen_radio_metrics(a,
+// radio_index);
+// if (!p1)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+//// #endif
+// }
+// break;
+// }
+//
+// case MAP_TLV_AP_METRIC_QUERY:
+// {
+// struct wifi_radio_element *radio;
+// struct wifi_bss_element *bss;
+// struct tlv_ap_metrics *p2;
+// struct tlv_ap_ext_metrics *p3;
+// struct tlv_ap_metric_query *p =
+// (struct tlv_ap_metric_query *)tmp;
+//
+// for (j = 0; j < p->bssid_nr; j++) {
+// int radio_index;
+// int bss_index;
+// struct sta *s;
+// struct netif_fh *fh;
+//
+// bss_index = get_radio_and_bss_index(a,
+// p->ap_metric_query_bssid[j].bssid,
+// &radio_index);
+//
+// if (bss_index == -1)
+// continue;
+//
+// radio = a->radios + radio_index;
+// bss = radio->bsslist + bss_index;
+// /* AP Metrics TLV */
+// p2 = agent_gen_ap_metrics(a,
+// radio_index, bss_index);
+// if (!p2)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//// #ifdef PROFILE2
+// /* AP Extended Metrics TLV */
+// p3 = agent_gen_ap_ext_metrics(a,
+// radio_index, bss_index);
+// if (!p3)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
+//// #endif
+//
+// fh = wifi_get_netif_by_bssid(a, bss->bssid);
+// if (fh == NULL)
+// continue;
+//
+// list_for_each_entry(s, &fh->stalist, list) {
+// if (fh->cfg->include_sta_stats) {
+// /* Associated STA Traffic Stats TLV */
+// struct tlv_assoc_sta_traffic_stats *p4;
+//
+// p4 = agent_gen_assoc_sta_traffic_stats(a, s);
+// if (!p4)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p4;
+// }
+//
+// if (fh->cfg->include_sta_metric) {
+// struct tlv_assoc_sta_link_metrics *p5;
+// struct tlv_assoc_sta_ext_link_metric *p6;
+//
+// p5 = agent_gen_assoc_sta_link_metrics(a, s, bss->bssid);
+// if (!p5)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p5;
+//
+//// #ifdef PROFILE2
+// p6 = agent_gen_assoc_sta_ext_link_metric(a, s, bss->bssid);
+// if (!p6)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p6;
+//// #endif
+// }
+//
+// }
+// }
+// break;
+// }
+// }
+// }
+//
+// /* if tlv_index is zero,
+// * means no valid data is found
+// * free the allocated memory for tlvs
+// */
+// if (tlv_index == 0)
+// goto error;
+//
+// return cmdu;
+//
+//error:
+// map_free_cmdu(cmdu);
+// return NULL;
+}
-error:
- map_free_cmdu(cmdu);
+struct cmdu_buff *agent_gen_assoc_sta_metric_response_per_intf(
+ struct agent *a, char *ifname)
+{
+ return NULL;
+// int i;
+// int tlv_index = 0;
+// struct cmdu_cstruct *cmdu;
+// struct wifi_radio_element *radio;
+// struct wifi_bss_element *bss;
+//
+// cmdu = calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu)
+// return NULL;
+//
+// cmdu->message_type = CMDU_ASSOC_STA_LINK_METRICS_RESPONSE;
+// memcpy(cmdu->origin, a->cntlr_almac, 6);
+// /* TODO/FIXME: interface name
+// * hardcoded: br-lan
+// */
+// strncpy(cmdu->intf_name, "br-lan", IFNAMESIZE - 1);
+//
+// radio = wifi_ifname_to_radio_element(a, ifname);
+// if (!radio)
+// goto error;
+//
+// /* Calculate number of TLVs required for the response
+// */
+// for (i = 0; i < radio->num_bss; i++) {
+// struct netif_fh *fh;
+// int num_sta = 0;
+// struct sta *s;
+//
+// bss = radio->bsslist + i;
+// fh = wifi_get_netif_by_bssid(a, bss->bssid);
+// if (!fh)
+// continue;
+//
+// list_for_each_entry(s, &fh->stalist, list)
+// num_sta++;
+//
+// /* Associated STA Link Metrics TLV */
+// cmdu->num_tlvs += num_sta;
+//// #ifdef PROFILE2
+// /* Associated STA Extended Link Metrics TLV */
+// cmdu->num_tlvs += num_sta;
+//// #endif
+// }
+//
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs) {
+// cmdu->num_tlvs = 0;
+// goto error;
+// }
+//
+// for (i = 0; i < radio->num_bss; i++) {
+// struct sta *s;
+// struct netif_fh *fh;
+//
+// bss = radio->bsslist + i;
+// fh = wifi_get_netif_by_bssid(a, bss->bssid);
+// if (!fh)
+// continue;
+//
+// list_for_each_entry(s, &fh->stalist, list) {
+// struct tlv_assoc_sta_link_metrics *p1;
+// struct tlv_assoc_sta_ext_link_metric *p2;
+//
+// p1 = agent_gen_assoc_sta_link_metrics(a, s, bss->bssid);
+// if (!p1)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+//
+//// #ifdef PROFILE2
+// p2 = agent_gen_assoc_sta_ext_link_metric(a, s, bss->bssid);
+// if (!p2)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//// #endif
+// }
+//
+// }
+//
+// return cmdu;
+//
+//error:
+// map_free_cmdu(cmdu);
+//
+// return NULL;
+}
+struct cmdu_buff *agent_gen_assoc_sta_metric_response(
+ struct agent *a, struct cmdu_buff *rec_cmdu)
+{
return NULL;
+// struct cmdu_cstruct *cmdu;
+// struct tlv_sta_mac *query;
+// struct netif_fh *fh;
+// struct sta *s;
+// struct tlv_assoc_sta_link_metrics *p1;
+// struct tlv_assoc_sta_ext_link_metric *p2;
+// struct tlv_error_code *p3;
+// uint8_t *tmp;
+// uint8_t reason_code;
+// int tlv_index = 0;
+// bool is_sta_found = false;
+//
+// if (!rec_cmdu)
+// return NULL;
+//
+// cmdu = calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu) {
+// fprintf(stderr, "failed to malloc cmdu\n");
+// return NULL;
+// }
+//
+// cmdu->message_type = CMDU_ASSOC_STA_LINK_METRICS_RESPONSE;
+// memcpy(cmdu->origin, rec_cmdu->origin, 6);
+// strncpy(cmdu->intf_name, rec_cmdu->intf_name, IFNAMESIZE - 1);
+// cmdu->message_id = rec_cmdu->message_id;
+//
+// if (!rec_cmdu->num_tlvs || (rec_cmdu->num_tlvs > 1))
+// goto error;
+//
+// tmp = (uint8_t *)rec_cmdu->tlvs[0];
+// if (*tmp != MAP_TLV_STA_MAC_ADDRESS)
+// goto error;
+//
+// query = (struct tlv_sta_mac *)tmp;
+// list_for_each_entry(fh, &a->fhlist, list) {
+// list_for_each_entry(s, &fh->stalist, list) {
+// if (hwaddr_equal(query->addr, s->macaddr)) {
+// is_sta_found = true;
+// break;
+// }
+// }
+// if (is_sta_found)
+// break;
+// }
+//
+// /* Associated STA Link Metrics TLV */
+// cmdu->num_tlvs = 1;
+// if (is_sta_found) {
+//// #ifdef PROFILE2
+// /* Associated STA Extended Link Metrics TLV */
+// cmdu->num_tlvs++;
+//// #endif
+// } else
+// cmdu->num_tlvs++; /* Error Code TLV*/
+//
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs) {
+// cmdu->num_tlvs = 0;
+// goto error;
+// }
+//
+// if (is_sta_found) {
+// /* Associated STA Link Metrics TLV */
+// p1 = agent_gen_assoc_sta_link_metrics(a, s, fh->bssid);
+// if (!p1)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+//
+//// #ifdef PROFILE2
+// /* Associated STA Extended Link Metrics TLV */
+// p2 = agent_gen_assoc_sta_ext_link_metric(a, s, fh->bssid);
+// if (!p2)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//// #endif
+//
+// } else {
+// /* Associated STA Link Metrics TLV */
+// p1 = calloc(1, sizeof(*p1));
+// if (!p1)
+// goto error;
+//
+// p1->tlv_type = MAP_TLV_ASSOCIATED_STA_LINK_METRICS;
+// memcpy(p1->addr, query->addr, 6);
+// /* Reported BSS for STA */
+// p1->bssid_nr = 0;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+//
+// /* Error Code TLV */
+// reason_code = 0x02; /* STA not associated with any BSS */
+// p3 = agent_gen_tlv_error_code(a, NULL, query->addr, reason_code);
+// if (!p3)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
+// }
+//
+// return cmdu;
+//
+//error:
+// map_free_cmdu(cmdu);
+//
+// return NULL;
}
-struct cmdu_cstruct *agent_gen_tunneled_msg(struct agent *a, uint8_t protocol,
+struct cmdu_buff *agent_gen_tunneled_msg(struct agent *a, uint8_t protocol,
uint8_t *sta, int frame_len, uint8_t *frame_body)
{
- struct cmdu_cstruct *cmdu;
- struct tlv_source_info *p1;
- struct tlv_tunnel_msg_type *p2;
- struct tlv_tunneled *p3;
- int tlv_index = 0;
-
- /* TODO: check profile type
- * return NULL,in case of PROFILE-1
- * #ifdef PROFILE1
- * return NULL;
- * #endif
- */
-
- if (!sta && !frame_body)
- return NULL;
-
- cmdu = calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu)
- return NULL;
-
- cmdu->message_type = CMDU_TUNNELED;
- memcpy(cmdu->origin, a->cntlr_almac, 6);
- strncpy(cmdu->intf_name, a->cfg.al_bridge, IFNAMESIZE - 1);
-
- cmdu->num_tlvs = 3;
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs,
- sizeof(uint8_t *));
- if (!cmdu->tlvs) {
- cmdu->num_tlvs = 0;
- goto error;
- }
-
- /* Source Info TLV */
- p1 = agent_gen_source_info(a, sta);
- if (!p1)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
-
- /* Tunneled message type TLV */
- p2 = agent_gen_tunnel_msg_type(a, protocol);
- if (!p2)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-
- /* Tunneled TLV */
- p3 = agent_gen_tunneled(a, frame_len, frame_body);
- if (!p3)
- goto error;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
-
- return cmdu;
-
-error:
- map_free_cmdu(cmdu);
-
return NULL;
+// struct cmdu_cstruct *cmdu;
+// struct tlv_source_info *p1;
+// struct tlv_tunnel_msg_type *p2;
+// struct tlv_tunneled *p3;
+// int tlv_index = 0;
+//
+// /* TODO: check profile type
+// * return NULL,in case of PROFILE-1
+// * #ifdef PROFILE1
+// * return NULL;
+// * #endif
+// */
+//
+// if (!sta && !frame_body)
+// return NULL;
+//
+// cmdu = calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu)
+// return NULL;
+//
+// cmdu->message_type = CMDU_TUNNELED;
+// memcpy(cmdu->origin, a->cntlr_almac, 6);
+// /* TODO/FIXME: interface name
+// * hardcoded: br-lan
+// */
+// strncpy(cmdu->intf_name, "br-lan", IFNAMESIZE - 1);
+//
+// cmdu->num_tlvs = 3;
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs,
+// sizeof(uint8_t *));
+// if (!cmdu->tlvs) {
+// cmdu->num_tlvs = 0;
+// goto error;
+// }
+//
+// /* Source Info TLV */
+// p1 = agent_gen_source_info(a, sta);
+// if (!p1)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+//
+// /* Tunneled message type TLV */
+// p2 = agent_gen_tunnel_msg_type(a, protocol);
+// if (!p2)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//
+// /* Tunneled TLV */
+// p3 = agent_gen_tunneled(a, frame_len, frame_body);
+// if (!p3)
+// goto error;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
+//
+// return cmdu;
+//
+//error:
+// map_free_cmdu(cmdu);
+//
+// return NULL;
}
-struct cmdu_cstruct *agent_gen_vendor_specific_cmdu(struct agent *a,
+struct cmdu_buff *agent_gen_vendor_specific_cmdu(struct agent *a,
uint8_t *origin, uint8_t depth)
{
- struct tlv_vendor_specific *p;
- struct cmdu_cstruct *cmdu;
- int tlv_index = 0;
-
- cmdu = calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu)
- return NULL;
-
- cmdu->message_type = CMDU_TYPE_VENDOR_SPECIFIC;
- memcpy(cmdu->origin, origin, 6);
- strncpy(cmdu->intf_name, a->cfg.al_bridge, IFNAMESIZE - 1);
-
- p = agent_gen_vendor_specific_tlv(a, depth);
- if (!p)
- goto error;
-
- cmdu->num_tlvs++;
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs,
- sizeof(uint8_t *));
- cmdu->tlvs[tlv_index++] = (uint8_t *)p;
- return cmdu;
-error:
- map_free_cmdu(cmdu);
return NULL;
+// struct tlv_vendor_specific *p;
+// struct cmdu_cstruct *cmdu;
+// int tlv_index = 0;
+//
+// cmdu = calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu)
+// return NULL;
+//
+// cmdu->message_type = CMDU_TYPE_VENDOR_SPECIFIC;
+// memcpy(cmdu->origin, origin, 6);
+// strncpy(cmdu->intf_name, a->cfg.al_bridge, IFNAMESIZE - 1);
+//
+// p = agent_gen_vendor_specific_tlv(a, depth);
+// if (!p)
+// goto error;
+//
+// cmdu->num_tlvs++;
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs,
+// sizeof(uint8_t *));
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p;
+// return cmdu;
+//error:
+// map_free_cmdu(cmdu);
+// return NULL;
}
-struct cmdu_cstruct *agent_gen_ch_scan_response(struct agent *a,
- struct cmdu_cstruct *cmdu)
+struct cmdu_buff *agent_gen_ch_scan_response(struct agent *a,
+ struct cmdu_buff *cmdu)
{
trace("%s --->\n", __func__);
- struct wifi_radio_element *radio = a->radios;
- uint16_t tlv_index = 0;
- uint32_t i, j, k, m;
- int radio_index, opclass_index, channel_index;
- struct cmdu_cstruct *cmdu_data = NULL; /* The response cmdu */
- struct tlv_timestamp *p; /* Timestamp TLV */
- struct tlv_ch_scan_res *p1; /* Channel Scan Response TLV */
- uint8_t query_channel; /* The current channel from the request TLV */
- uint8_t *tmp = NULL; /* The received TLV */
-
- tmp = cmdu->tlvs[0];
- if (*tmp != MAP_TLV_CHANNEL_SCAN_REQ) {
- dbg("Wrong received TLV type!\n");
- return NULL;
- }
- struct tlv_ch_scan_req *query = (struct tlv_ch_scan_req *)tmp;
-
- /* Allocate the cmdu */
- cmdu_data = (struct cmdu_cstruct *)calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu_data) {
- dbg("Out of memory!\n");
- return NULL;
- }
-
- /* Define the cmdu */
- cmdu_data->message_type = CMDU_CHANNEL_SCAN_REPORT;
- cmdu_data->message_id = cmdu->message_id;
- strcpy(cmdu_data->intf_name, cmdu->intf_name);
- memcpy(cmdu_data->origin, cmdu->origin, 6);
- cmdu_data->num_tlvs = 1; // timestamp tlv
- for (m = 0; m < query->nbr_radios; m++) {
- if (query->radio_data[m].nbr_op_class == 0 || query->radio_data[m].op_class_data->nbr_ch == 0) { // all_ch_scan
- radio_index = wifi_get_radio_index_by_mac(a, query->radio_data[m].radio_id);
- for (i = 0; i < radio[radio_index].scanlist->num_opclass_scanned; i++) {
- if (radio[radio_index].scanlist->opclass_scanlist[i].bandwidth == 20) {
- for (j = 0; j < radio[radio_index].scanlist->opclass_scanlist[i].num_channels_scanned; j++)
- cmdu_data->num_tlvs++;
- }
- }
- } else // specified channels
- cmdu_data->num_tlvs += query->radio_data[m].op_class_data->nbr_ch; // ch scan res tlvs
- }
- trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
-
- // Allocate the TLVs
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
- if (!cmdu_data->tlvs) {
- goto error;
- }
- // Define the TLVs
- /* Timestamp */
- p = agent_gen_timestamp_tlv(a);
- if (!p)
- goto error;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
- trace("|%s:%d| Added %s\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
-
- /* Channel scan result */
- for (m = 0; m < query->nbr_radios; m++) {
- // dbg("\tMID: %d Radio_id in %d iteration:
- // " MACFMT "\n", cmdu->message_id, m, MAC2STR(query->radio_data[m].radio_id));
- radio_index = wifi_get_radio_index_by_mac(a, query->radio_data[m].radio_id);
- /* Success scan */
- if (a->status_code == CH_SCAN_STATUS_SUCCESS) {
- /* All channels scan */
- if (query->radio_data[m].nbr_op_class == 0 || query->radio_data[m].op_class_data->nbr_ch == 0) {
- for (i = 0; i < radio[radio_index].scanlist->num_opclass_scanned; i++) {
- if (radio[radio_index].scanlist->opclass_scanlist[i].bandwidth == 20) {
- for (j = 0; j < radio[radio_index].scanlist->opclass_scanlist[i].num_channels_scanned; j++) {
- opclass_index = i;
- channel_index = j;
- p1 = agent_gen_ch_scan_respons_tlv(a, radio_index, opclass_index, channel_index);
- if (!p1)
- goto error;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
- trace("|%s:%d| Added %s for channel %d\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]),
- radio[radio_index].scanlist->opclass_scanlist[i].channel_scanlist[j].channel);
- }
- }
- }
- /* Specified channels */
- } else {
- for (k = 0; k < query->radio_data[m].op_class_data->nbr_ch; k++) {
- query_channel = query->radio_data[m].op_class_data->ch[k];
- for (i = 0; i < radio[radio_index].scanlist->num_opclass_scanned; i++) {
- for (j = 0; j < radio[radio_index].scanlist->opclass_scanlist[i].num_channels_scanned; j++) {
- if (radio[radio_index].scanlist->opclass_scanlist[i].channel_scanlist[j].channel == query_channel) {
- opclass_index = i;
- channel_index = j;
- p1 = agent_gen_ch_scan_respons_tlv(a, radio_index, opclass_index, channel_index);
- if (!p1)
- goto error;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
- trace("|%s:%d| Added %s for channel %d\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]),
- radio[radio_index].scanlist->opclass_scanlist[i].channel_scanlist[j].channel);
- goto found;
- }
- }
- }
-found:
- continue;
- }
- }
- /* Non-success scan */
- } else {
- for (k = 0; k < query->radio_data[m].op_class_data->nbr_ch; k++) {
- query_channel = query->radio_data[m].op_class_data->ch[k];
- p1 = agent_gen_non_success_ch_scan_respons_tlv(a, radio_index, 0, query_channel);
- if (!p1)
- goto error;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
- trace("|%s:%d| Added %s for channel %d\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]),
- query_channel);
- }
- }
- }
- return cmdu_data;
-error:
- dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
- map_free_cmdu(cmdu_data);
return NULL;
+// struct wifi_radio_element *radio = a->radios;
+// uint16_t tlv_index = 0;
+// uint32_t i, j, k, m;
+// int radio_index, opclass_index, channel_index;
+// struct cmdu_cstruct *cmdu_data = NULL; /* The response cmdu */
+// struct tlv_timestamp *p; /* Timestamp TLV */
+// struct tlv_ch_scan_res *p1; /* Channel Scan Response TLV */
+// uint8_t query_channel; /* The current channel from the request TLV */
+// uint8_t *tmp = NULL; /* The received TLV */
+//
+// tmp = cmdu->tlvs[0];
+// if (*tmp != MAP_TLV_CHANNEL_SCAN_REQ) {
+// dbg("Wrong received TLV type!\n");
+// return NULL;
+// }
+// struct tlv_ch_scan_req *query = (struct tlv_ch_scan_req *)tmp;
+//
+// /* Allocate the cmdu */
+// cmdu_data = (struct cmdu_cstruct *)calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu_data) {
+// dbg("Out of memory!\n");
+// return NULL;
+// }
+//
+// /* Define the cmdu */
+// cmdu_data->message_type = CMDU_CHANNEL_SCAN_REPORT;
+// cmdu_data->message_id = cmdu->message_id;
+// strcpy(cmdu_data->intf_name, cmdu->intf_name);
+// memcpy(cmdu_data->origin, cmdu->origin, 6);
+// cmdu_data->num_tlvs = 1; // timestamp tlv
+// for (m = 0; m < query->nbr_radios; m++) {
+// if (query->radio_data[m].nbr_op_class == 0 || query->radio_data[m].op_class_data->nbr_ch == 0) { // all_ch_scan
+// radio_index = wifi_get_radio_index_by_mac(a, query->radio_data[m].radio_id);
+// for (i = 0; i < radio[radio_index].scanlist->num_opclass_scanned; i++) {
+// if (radio[radio_index].scanlist->opclass_scanlist[i].bandwidth == 20) {
+// for (j = 0; j < radio[radio_index].scanlist->opclass_scanlist[i].num_channels_scanned; j++)
+// cmdu_data->num_tlvs++;
+// }
+// }
+// } else // specified channels
+// cmdu_data->num_tlvs += query->radio_data[m].op_class_data->nbr_ch; // ch scan res tlvs
+// }
+// trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
+//
+// // Allocate the TLVs
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu_data->tlvs) {
+// goto error;
+// }
+// // Define the TLVs
+// /* Timestamp */
+// p = agent_gen_timestamp_tlv(a);
+// if (!p)
+// goto error;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+// trace("|%s:%d| Added %s\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
+//
+// /* Channel scan result */
+// for (m = 0; m < query->nbr_radios; m++) {
+// // dbg("\tMID: %d Radio_id in %d iteration:
+// // " MACFMT "\n", cmdu->message_id, m, MAC2STR(query->radio_data[m].radio_id));
+// radio_index = wifi_get_radio_index_by_mac(a, query->radio_data[m].radio_id);
+// /* Success scan */
+// if (a->status_code == CH_SCAN_STATUS_SUCCESS) {
+// /* All channels scan */
+// if (query->radio_data[m].nbr_op_class == 0 || query->radio_data[m].op_class_data->nbr_ch == 0) {
+// for (i = 0; i < radio[radio_index].scanlist->num_opclass_scanned; i++) {
+// if (radio[radio_index].scanlist->opclass_scanlist[i].bandwidth == 20) {
+// for (j = 0; j < radio[radio_index].scanlist->opclass_scanlist[i].num_channels_scanned; j++) {
+// opclass_index = i;
+// channel_index = j;
+// p1 = agent_gen_ch_scan_respons_tlv(a, radio_index, opclass_index, channel_index);
+// if (!p1)
+// goto error;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
+// trace("|%s:%d| Added %s for channel %d\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]),
+// radio[radio_index].scanlist->opclass_scanlist[i].channel_scanlist[j].channel);
+// }
+// }
+// }
+// /* Specified channels */
+// } else {
+// for (k = 0; k < query->radio_data[m].op_class_data->nbr_ch; k++) {
+// query_channel = query->radio_data[m].op_class_data->ch[k];
+// for (i = 0; i < radio[radio_index].scanlist->num_opclass_scanned; i++) {
+// for (j = 0; j < radio[radio_index].scanlist->opclass_scanlist[i].num_channels_scanned; j++) {
+// if (radio[radio_index].scanlist->opclass_scanlist[i].channel_scanlist[j].channel == query_channel) {
+// opclass_index = i;
+// channel_index = j;
+// p1 = agent_gen_ch_scan_respons_tlv(a, radio_index, opclass_index, channel_index);
+// if (!p1)
+// goto error;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
+// trace("|%s:%d| Added %s for channel %d\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]),
+// radio[radio_index].scanlist->opclass_scanlist[i].channel_scanlist[j].channel);
+// goto found;
+// }
+// }
+// }
+//found:
+// continue;
+// }
+// }
+// /* Non-success scan */
+// } else {
+// for (k = 0; k < query->radio_data[m].op_class_data->nbr_ch; k++) {
+// query_channel = query->radio_data[m].op_class_data->ch[k];
+// p1 = agent_gen_non_success_ch_scan_respons_tlv(a, radio_index, 0, query_channel);
+// if (!p1)
+// goto error;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
+// trace("|%s:%d| Added %s for channel %d\n", __func__, __LINE__, map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]),
+// query_channel);
+// }
+// }
+// }
+// return cmdu_data;
+//error:
+// dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
+// map_free_cmdu(cmdu_data);
+// return NULL;
}
-
-
-
-struct cmdu_cstruct *agent_gen_bk_caps_response(struct agent *a,
- struct cmdu_cstruct *cmdu)
+struct cmdu_buff *agent_gen_bk_caps_response(struct agent *a,
+ struct cmdu_buff *cmdu)
{
- struct cmdu_cstruct *cmdu_data;
- struct tlv_backhaul_sta_radio_cap *p;
- uint16_t tlv_index = 0;
- uint32_t i;
-
- // Allocate the cmdu
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
- if (!cmdu_data) {
- dbg("Out of memory!\n");
- return NULL;
- }
- // Define the cmdu
- cmdu_data->message_type = CMDU_BACKHAUL_STA_CAPABILITY_REPORT;
- cmdu_data->message_id = cmdu->message_id;
- strcpy(cmdu_data->intf_name, cmdu->intf_name);
- memcpy(cmdu_data->origin, cmdu->origin, 6);
- cmdu_data->num_tlvs = a->num_radios;
- trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
-
- // Allocate the TLVs
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
- if (!cmdu_data->tlvs)
- goto error;
-
- // Define the TLVs
- for (i = 0; i < a->num_radios; i++) {
- /* Backhaul STA radio capabilities TLV */
- p = agent_gen_bk_sta_radio_cap_tlv(a, i);
- if (!p)
- goto error;
-
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
- trace("|%s:%d| Added %s\n", __func__, __LINE__,
- map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
- }
- return cmdu_data;
-error:
- map_free_cmdu(cmdu_data);
return NULL;
+// struct cmdu_cstruct *cmdu_data;
+// struct tlv_backhaul_sta_radio_cap *p;
+// uint16_t tlv_index = 0;
+// uint32_t i;
+//
+// // Allocate the cmdu
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+// if (!cmdu_data) {
+// dbg("Out of memory!\n");
+// return NULL;
+// }
+// // Define the cmdu
+// cmdu_data->message_type = CMDU_BACKHAUL_STA_CAPABILITY_REPORT;
+// cmdu_data->message_id = cmdu->message_id;
+// strcpy(cmdu_data->intf_name, cmdu->intf_name);
+// memcpy(cmdu_data->origin, cmdu->origin, 6);
+// cmdu_data->num_tlvs = a->num_radios;
+// trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
+//
+// // Allocate the TLVs
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu_data->tlvs)
+// goto error;
+//
+// // Define the TLVs
+// for (i = 0; i < a->num_radios; i++) {
+// /* Backhaul STA radio capabilities TLV */
+// p = agent_gen_bk_sta_radio_cap_tlv(a, i);
+// if (!p)
+// goto error;
+//
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+// trace("|%s:%d| Added %s\n", __func__, __LINE__,
+// map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
+// }
+// return cmdu_data;
+//error:
+// map_free_cmdu(cmdu_data);
+// return NULL;
}
-struct cmdu_cstruct *agent_gen_topology_notification (struct agent *agent,
+struct cmdu_buff *agent_gen_topology_notification (struct agent *agent,
uint8_t *mac, uint8_t *bssid, uint8_t assoc_event)
{
- struct cmdu_cstruct *cmdu_data;
- struct agent *a = (struct agent *) agent;
- struct tlv_client_assoc_event *p;
- uint8_t mcast[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x13};
-
-
- // Allocate the cmdu
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
- if (!cmdu_data) {
- dbg("Out of memory!\n");
- return NULL;
- }
- // Define the cmdu
- cmdu_data->message_type = CMDU_TYPE_TOPOLOGY_NOTIFICATION;
- strcpy(cmdu_data->intf_name, agent->cfg.al_bridge);
- memcpy(cmdu_data->origin, mcast, 6);
- cmdu_data->num_tlvs = 1;
- trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
-
- // Allocate the TLVs
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
- if (!cmdu_data->tlvs)
- goto error;
-
- // Define the TLVs
- /* Client Association Event TLV */
- p = agent_gen_client_assoc_event_tlv(a, mac, bssid, assoc_event);
- if (!p)
- goto error;
- cmdu_data->tlvs[0] = (uint8_t *)p;
- trace("|%s:%d| Added %s\n", __func__, __LINE__,
- map_stringify_tlv_type(*cmdu_data->tlvs[0]));
- return cmdu_data;
-
-error:
- map_free_cmdu(cmdu_data);
return NULL;
+// struct cmdu_cstruct *cmdu_data;
+// struct agent *a = (struct agent *) agent;
+// struct tlv_client_assoc_event *p;
+// uint8_t mcast[6] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x13};
+//
+//
+// // Allocate the cmdu
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+// if (!cmdu_data) {
+// dbg("Out of memory!\n");
+// return NULL;
+// }
+// // Define the cmdu
+// cmdu_data->message_type = CMDU_TYPE_TOPOLOGY_NOTIFICATION;
+// strcpy(cmdu_data->intf_name, agent->cfg.al_bridge);
+// memcpy(cmdu_data->origin, mcast, 6);
+// cmdu_data->num_tlvs = 1;
+// trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
+//
+// // Allocate the TLVs
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu_data->tlvs)
+// goto error;
+//
+// // Define the TLVs
+// /* Client Association Event TLV */
+// p = agent_gen_client_assoc_event_tlv(a, mac, bssid, assoc_event);
+// if (!p)
+// goto error;
+// cmdu_data->tlvs[0] = (uint8_t *)p;
+// trace("|%s:%d| Added %s\n", __func__, __LINE__,
+// map_stringify_tlv_type(*cmdu_data->tlvs[0]));
+// return cmdu_data;
+//
+//error:
+// map_free_cmdu(cmdu_data);
+// return NULL;
}
-struct cmdu_cstruct *agent_gen_client_disassoc(struct agent *a,
+struct cmdu_buff *agent_gen_client_disassoc(struct agent *a,
uint8_t *mac, uint8_t *bssid)
{
- struct cmdu_cstruct *cmdu_data;
- struct tlv_sta_mac *p;
- struct tlv_reason_code *p1;
- struct tlv_assoc_sta_traffic_stats *p2;
- uint16_t tlv_index = 0;
-
- // Allocate the cmdu
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
- if (!cmdu_data) {
- dbg("Out of memory!\n");
- return NULL;
- }
- // Define the cmdu
- cmdu_data->message_type = CMDU_CLIENT_DISASSOCIATION_STATS;
- strcpy(cmdu_data->intf_name, a->cfg.al_bridge);
- memcpy(cmdu_data->origin, a->cntlr_almac, 6);
- cmdu_data->num_tlvs = 3;
- trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
-
- // Allocate the TLVs
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
- if (!cmdu_data->tlvs)
- goto error;
-
- // Define the TLVs
- /* STA MAC Address TLV */
- p = agent_gen_sta_mac_tlv(a, mac);
- if (!p)
- goto error;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
- trace("|%s:%d| Added %s\n", __func__, __LINE__,
- map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
- /* Reason Code TLV */
- p1 = agent_gen_reason_code_tlv(a);
- if (!p1)
- goto error;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
- trace("|%s:%d| Added %s\n", __func__, __LINE__,
- map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
- /* Associated STA Traffic Stats TLV */
- p2 = agent_gen_assoc_sta_traffic_stats_tlv(a, mac);
- if (!p2)
- goto error;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p2;
- trace("|%s:%d| Added %s\n", __func__, __LINE__,
- map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
- return cmdu_data;
-
-error:
- map_free_cmdu(cmdu_data);
return NULL;
+// struct cmdu_cstruct *cmdu_data;
+// struct tlv_sta_mac *p;
+// struct tlv_reason_code *p1;
+// struct tlv_assoc_sta_traffic_stats *p2;
+// uint16_t tlv_index = 0;
+//
+// // Allocate the cmdu
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+// if (!cmdu_data) {
+// dbg("Out of memory!\n");
+// return NULL;
+// }
+// // Define the cmdu
+// cmdu_data->message_type = CMDU_CLIENT_DISASSOCIATION_STATS;
+// strcpy(cmdu_data->intf_name, a->cfg.al_bridge);
+// memcpy(cmdu_data->origin, a->cntlr_almac, 6);
+// cmdu_data->num_tlvs = 3;
+// trace("Number of tlvs: %d\n", cmdu_data->num_tlvs);
+//
+// // Allocate the TLVs
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu_data->tlvs)
+// goto error;
+//
+// // Define the TLVs
+// /* STA MAC Address TLV */
+// p = agent_gen_sta_mac_tlv(a, mac);
+// if (!p)
+// goto error;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+// trace("|%s:%d| Added %s\n", __func__, __LINE__,
+// map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
+// /* Reason Code TLV */
+// p1 = agent_gen_reason_code_tlv(a);
+// if (!p1)
+// goto error;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
+// trace("|%s:%d| Added %s\n", __func__, __LINE__,
+// map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
+// /* Associated STA Traffic Stats TLV */
+// p2 = agent_gen_assoc_sta_traffic_stats_tlv(a, mac);
+// if (!p2)
+// goto error;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p2;
+// trace("|%s:%d| Added %s\n", __func__, __LINE__,
+// map_stringify_tlv_type(*cmdu_data->tlvs[tlv_index-1]));
+// return cmdu_data;
+//
+//error:
+// map_free_cmdu(cmdu_data);
+// return NULL;
}
/* TODO: This function should not be needed once extension is hooked into new
diff --git a/src/core/agent_cmdu_generator.h b/src/core/agent_cmdu_generator.h
index ef819f8c0a9047e32ea722bdc1d8def0c49b41a5..8e614ab6277e95bbf80ee68d2b5c3f01040779a5 100644
--- a/src/core/agent_cmdu_generator.h
+++ b/src/core/agent_cmdu_generator.h
@@ -10,23 +10,24 @@
#ifndef AGENT_CMDU_GEN_H
#define AGENT_CMDU_GEN_H
-struct cmdu_cstruct *agent_gen_ap_autoconfig_search(struct agent *a,
+struct cmdu_buff *agent_gen_ap_autoconfig_search(struct agent *a,
struct wifi_radio_element *radio, char *intf_name,
uint8_t profile);
-struct cmdu_cstruct *agent_gen_ap_metrics_response(struct agent *a,
- struct cmdu_cstruct *rec_cmdu);
-struct cmdu_cstruct *agent_gen_assoc_sta_metric_response_per_intf(
+struct cmdu_buff *agent_gen_ap_metrics_response(struct agent *a,
+ struct cmdu_buff *rec_cmdu);
+struct cmdu_buff *agent_gen_assoc_sta_metric_response_per_intf(
struct agent *a, char *ifname);
-struct cmdu_cstruct *agent_gen_assoc_sta_metric_response(
- struct agent *a, struct cmdu_cstruct *rec_cmdu);
-struct cmdu_cstruct *agent_gen_tunneled_msg(struct agent *a, uint8_t protocol,
+struct cmdu_buff *agent_gen_assoc_sta_metric_response(
+ struct agent *a, struct cmdu_buff *rec_cmdu);
+struct cmdu_buff *agent_gen_tunneled_msg(struct agent *a, uint8_t protocol,
uint8_t *sta, int frame_len, uint8_t *frame_body);
-struct cmdu_cstruct *agent_gen_vendor_specific_cmdu(struct agent *a, uint8_t *origin, uint8_t depth);
-struct cmdu_cstruct *agent_gen_ch_scan_response(struct agent *a,
- struct cmdu_cstruct *cmdu);
-struct cmdu_cstruct *agent_gen_bk_caps_response(struct agent *a,
- struct cmdu_cstruct *cmdu);
-struct cmdu_cstruct *agent_gen_topology_notification (struct agent *agent,
+struct cmdu_buff *agent_gen_vendor_specific_cmdu(struct agent *a, uint8_t *origin, uint8_t depth);
+struct cmdu_buff *agent_gen_ch_scan_response(struct agent *a,
+ struct cmdu_buff *cmdu);
+struct cmdu_buff *agent_gen_bk_caps_response(struct agent *a,
+ struct cmdu_buff *cmdu);
+struct cmdu_buff *agent_gen_topology_notification (struct agent *agent,
uint8_t *mac, uint8_t *bssid, uint8_t assoc_event);
-
+struct cmdu_buff *agent_gen_ap_autoconfig_wsc(struct agent *a, struct cmdu_buff *rec_cmdu,
+ struct wifi_radio_element *radio, uint16_t mid);
#endif
diff --git a/src/core/agent_map.c b/src/core/agent_map.c
index 17c5e3d8ed538b151b9c6f8c0d64f4523537e52c..c7cc8680972aa9c41ae46dd1595f2819bac4c00e 100644
--- a/src/core/agent_map.c
+++ b/src/core/agent_map.c
@@ -37,7 +37,15 @@
#include <uci.h>
-#include "map_module.h"
+#include <i1905_wsc.h>
+#include <timer_impl.h>
+#include <cmdu.h>
+#include <1905_tlvs.h>
+#include <map22.h>
+#include <easy/easy.h>
+#include <map_module22.h>
+
+//#include "map_module.h"
#include "utils.h"
#include "debug.h"
#include "liblist.h"
@@ -47,15 +55,10 @@
#include "msgqueue.h"
#include "worker.h"
#include "agent.h"
-//#include "platform_interfaces.h"
-#include <map1905/map2.h>
-#include <map1905/maputils.h>
-#include <wsc.h>
-
-#include "agent_tlv_generator.h"
#include "agent_cmdu_generator.h"
+
#define UBUS_TIMEOUT 1000
/* TODO/FIXME: hardcoded 5 sec */
@@ -74,37 +77,16 @@ struct sta_error_response {
uint8_t response;
};
-#define for_each_tlv(e, _buf, _len) \
-for ((e) = (struct tlv *)(_buf); \
- (e)->len && (_buf) + (_len) - (uint8_t *)(e) - 3 - (e)->len >= 0; \
- (e) = (struct tlv *)(_buf + 3 + (e)->len))
-
-struct tlv {
- uint8_t type;
- uint16_t len;
- uint8_t value[];
-} __attribute__ ((packed));
-
+typedef int (*map_cmdu_handler_t)(void *agent, struct cmdu_buff *cmdu);
+typedef int (*map_cmdu_sendfunc_t)(void *agent, struct cmdu_buff *cmdu);
-typedef int (*map_cmdu_handler_t)(void *agent, struct cmdu_cstruct *cmdu);
-typedef int (*map_cmdu_sendfunc_t)(void *agent, struct cmdu_cstruct *cmdu);
-
-uint16_t agent_send_cmdu(struct agent *a, struct cmdu_cstruct *cmdu);
-int agent_transition_sta(struct agent *a, struct tlv_steer_Req *p, struct netif_fh *fh,
+uint16_t agent_send_cmdu(struct agent *a, struct cmdu_buff *cmdu);
+int agent_transition_sta(struct agent *a, uint8_t *p, struct netif_fh *fh,
int l, int m);
-uint8_t *extract_tlv_by_type(struct cmdu_cstruct *cmdu, uint8_t tlv_type)
+uint8_t *extract_tlv_by_type(struct cmdu_buff *cmdu, uint8_t tlv_type)
{
- uint8_t *tlv;
- int i;
-
- for (i = 0; i < cmdu->num_tlvs; i++) {
- tlv = cmdu->tlvs[i];
- if (*tlv == tlv_type)
- return tlv;
- }
-
- return NULL;
+ return 0;
}
@@ -123,208 +105,208 @@ static struct netif_fh *get_netif_by_bssid(struct agent *a, uint8_t *bssid)
return NULL;
}
-int build_ap_autoconfig_wsc(void *agent, struct cmdu_cstruct *rec_cmdu,
+int build_ap_autoconfig_wsc(void *agent, struct cmdu_buff *rx_cmdu,
struct wifi_radio_element *radio, int idx)
{
- struct agent *a = (struct agent *) agent;
- struct cmdu_cstruct *cmdu;
- struct tlv_ap_radio_basic_cap *p;
- struct tlv_profile2_ap_cap *p1;
- struct tlv_ap_radio_adv_cap *p2;
- struct tlv_wsc *p3;
- int tlv_index = 0;
- uint16_t wsc_mid;
-
- /* don't trigger autoconfig for bSTA radios */
- //if (radio->onboarded)
- // return -1;
-
- cmdu = (struct cmdu_cstruct *)calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu) {
- fprintf(stderr, "failed to malloc cmdu\n");
- return -1;
- }
-
- memcpy(cmdu->origin, rec_cmdu->origin, 6);
- cmdu->message_type = CMDU_TYPE_AP_AUTOCONFIGURATION_WSC;
- strncpy(cmdu->intf_name, rec_cmdu->intf_name,
- sizeof(cmdu->intf_name) - 1);
-
- p = agent_gen_ap_radio_basic_cap(a, cmdu, radio);
- if (!p)
- goto fail_cmdu;
- cmdu->num_tlvs++;
-
- p1 = agent_gen_profile2_ap_cap(a);
- if (!p1)
- goto fail_p;
- cmdu->num_tlvs++;
-
- p2 = agent_gen_ap_radio_adv_cap(a, cmdu, radio);
- if (!p2)
- goto fail_p1;
- cmdu->num_tlvs++;
-
- p3 = agent_gen_wsc(a, cmdu, radio);
- if (!p3)
- goto fail_p2;
- cmdu->num_tlvs++;
-
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- if (!cmdu->tlvs)
- goto fail_p3;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
- // TODO: ff:ff:ff:ff:ff:ff = send to all agents
-
- agent_send_cmdu(a, cmdu);
- wsc_mid = agent_send_cmdu(a, cmdu);
- if (wsc_mid >= 0)
- radio->wsc_mid = wsc_mid;
- map_free_cmdu(cmdu);
- return 0;
-fail_p3:
- map_free_tlv_cstruct((uint8_t *) p3);
-fail_p2:
- map_free_tlv_cstruct((uint8_t *) p2);
-fail_p1:
- map_free_tlv_cstruct((uint8_t *) p1);
-fail_p:
- map_free_tlv_cstruct((uint8_t *) p);
-fail_cmdu:
- free(cmdu);
- return -1;
-}
-
-int send_topology_notification(void *agent, struct cmdu_cstruct *cmdu)
+ trace("agent: %s: --->\n", __func__);
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// struct cmdu_buff *cmdu;
+// struct tlv_ap_radio_basic_cap *p;
+// struct tlv_profile2_ap_cap *p1;
+// struct tlv_ap_radio_adv_cap *p2;
+// struct tlv_wsc *p3;
+// int tlv_index = 0;
+//
+// /* don't trigger autoconfig for bSTA radios */
+// //if (radio->onboarded)
+// // return -1;
+//
+// cmdu = (struct cmdu_buff *)calloc(1, sizeof(struct cmdu_buff));
+// if (!cmdu) {
+// fprintf(stderr, "failed to malloc cmdu\n");
+// return -1;
+// }
+//
+// memcpy(cmdu->origin, rx_cmdu->origin, 6);
+// cmdu->message_type = CMDU_TYPE_AP_AUTOCONFIGURATION_WSC;
+// strncpy(cmdu->intf_name, rx_cmdu->intf_name,
+// sizeof(cmdu->intf_name) - 1);
+//
+// p = agent_gen_ap_radio_basic_cap(a, cmdu, radio);
+// if (!p)
+// goto fail_cmdu;
+// cmdu->num_tlvs++;
+//
+// p1 = agent_gen_profile2_ap_cap(a);
+// if (!p1)
+// goto fail_p;
+// cmdu->num_tlvs++;
+//
+// p2 = agent_gen_ap_radio_adv_cap(a, cmdu, radio);
+// if (!p2)
+// goto fail_p1;
+// cmdu->num_tlvs++;
+//
+// p3 = agent_gen_wsc(a, cmdu, radio);
+// if (!p3)
+// goto fail_p2;
+// cmdu->num_tlvs++;
+//
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs)
+// goto fail_p3;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p;
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
+// // TODO: ff:ff:ff:ff:ff:ff = send to all agents
+//
+// agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+// return 0;
+//fail_p3:
+// map_free_tlv_cstruct((uint8_t *) p3);
+//fail_p2:
+// map_free_tlv_cstruct((uint8_t *) p2);
+//fail_p1:
+// map_free_tlv_cstruct((uint8_t *) p1);
+//fail_p:
+// map_free_tlv_cstruct((uint8_t *) p);
+//fail_cmdu:
+// free(cmdu);
+// return -1;
+}
+
+int send_topology_notification(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_topology_query(void *agent, struct cmdu_cstruct *cmdu)
+int send_topology_query(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_topology_response(void *agent, struct cmdu_cstruct *cmdu)
+int send_topology_response(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_ap_autoconfig_search(void *agent, struct cmdu_cstruct *cmdu)
+int send_ap_autoconfig_search(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_ap_autoconfig_response(void *agent, struct cmdu_cstruct *cmdu)
+int send_ap_autoconfig_response(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_ap_autoconfig_wsc(void *agent, struct cmdu_cstruct *cmdu)
+int send_ap_autoconfig_wsc(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_1905_ack(void *agent, struct cmdu_cstruct *cmdu)
+int send_1905_ack(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_ap_caps_report(void *agent, struct cmdu_cstruct *cmdu)
+int send_ap_caps_report(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_channel_pref_report(void *agent, struct cmdu_cstruct *cmdu)
+int send_channel_pref_report(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_oper_channel_report(void *agent, struct cmdu_cstruct *rec_cmdu)
+int send_oper_channel_report(void *agent, struct cmdu_buff *rx_cmdu)
{
trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- uint16_t tlv_index = 0;
- uint32_t j;
- struct cmdu_cstruct *cmdu_data;
- int ret = 0;
-
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
-
- if (!cmdu_data) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu_data->message_type = CMDU_OPERATING_CHANNEL_REPORT;
- memcpy(cmdu_data->origin, rec_cmdu->origin, 6);
- cmdu_data->message_id = 10;
- strcpy(cmdu_data->intf_name, rec_cmdu->intf_name);
-
- cmdu_data->num_tlvs = 1 * a->num_radios; /* (Operating Channel report) */
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
- sizeof(uint8_t *));
- if (!cmdu_data->tlvs) {
- map_free_cmdu(cmdu_data);
- return -1;
- }
-
- /* Operating Channel Report TLV 17.2.17 */
- for (j = 0; j < a->num_radios; j++) {
- struct tlv_oper_ch_report *p =
- p = agent_gen_operate_channel_report(a, rec_cmdu, j);
- if (!p)
- continue;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
- }
-
- ret = agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
-
- return ret;
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// uint16_t tlv_index = 0;
+// uint32_t j;
+// struct cmdu_cstruct *cmdu_data;
+// int ret = 0;
+//
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+//
+// if (!cmdu_data) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu_data->message_type = CMDU_OPERATING_CHANNEL_REPORT;
+// memcpy(cmdu_data->origin, rx_cmdu->origin, 6);
+// cmdu_data->message_id = 10;
+// strcpy(cmdu_data->intf_name, rx_cmdu->intf_name);
+//
+// cmdu_data->num_tlvs = 1 * a->num_radios; /* (Operating Channel report) */
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
+// sizeof(uint8_t *));
+// if (!cmdu_data->tlvs) {
+// map_free_cmdu(cmdu_data);
+// return -1;
+// }
+//
+// /* Operating Channel Report TLV 17.2.17 */
+// for (j = 0; j < a->num_radios; j++) {
+// struct tlv_oper_ch_report *p =
+// p = agent_gen_operate_channel_report(a, rx_cmdu, j);
+// if (!p)
+// continue;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+// }
+//
+// ret = agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+//
+// return ret;
}
int send_sta_steer_complete(void *agent, uint8_t *origin, const char *intf_name)
{
trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- struct cmdu_cstruct *cmdu_data;
- int ret = 0;
-
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
- if (!cmdu_data) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu_data->message_type = CMDU_STEERING_COMPLETED;
- memcpy(cmdu_data->origin, origin, 6);
- //cmdu_data->message_id = 19;
- strcpy(cmdu_data->intf_name, intf_name);
-
- cmdu_data->num_tlvs = 0; /* (No TLVs) */
- if (a->is_sta_steer_start) {
- /**
- * Here we are sending the steering completed message
- * so we need to reset all the values of the
- * steering opportunity
- */
- a->is_sta_steer_start = 0;
- a->sta_steerlist_count = 0;
- memset(a->sta_steer_list, 0, sizeof(a->sta_steer_list));
- /* stop the timer if it is running */
- uloop_timeout_cancel(&a->sta_steer_req_timer);
- }
-
- agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- return ret;
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// struct cmdu_cstruct *cmdu_data;
+// int ret = 0;
+//
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+// if (!cmdu_data) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu_data->message_type = CMDU_STEERING_COMPLETED;
+// memcpy(cmdu_data->origin, origin, 6);
+// //cmdu_data->message_id = 19;
+// strcpy(cmdu_data->intf_name, intf_name);
+//
+// cmdu_data->num_tlvs = 0; /* (No TLVs) */
+// if (a->is_sta_steer_start) {
+// /**
+// * Here we are sending the steering completed message
+// * so we need to reset all the values of the
+// * steering opportunity
+// */
+// a->is_sta_steer_start = 0;
+// a->sta_steerlist_count = 0;
+// memset(a->sta_steer_list, 0, sizeof(a->sta_steer_list));
+// /* stop the timer if it is running */
+// uloop_timeout_cancel(&a->sta_steer_req_timer);
+// }
+//
+// agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// return ret;
}
int send_steer_btm_report(void *agent, uint8_t *origin, const char *intf_name,
@@ -333,144 +315,145 @@ int send_steer_btm_report(void *agent, uint8_t *origin, const char *intf_name,
{
trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- uint16_t tlv_index = 0;
- struct cmdu_cstruct *cmdu_data;
- int ret = 0, all_complete = 1;
-
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
-
- if (!cmdu_data) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu_data->message_type = CMDU_CLIENT_STEERING_BTM_REPORT;
- memcpy(cmdu_data->origin, origin, 6);
- //cmdu_data->message_id = 15;
- strcpy(cmdu_data->intf_name, intf_name);
-
- cmdu_data->num_tlvs = 1; /* (Steering BTM report) */
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
- sizeof(uint8_t *));
-
- if (!cmdu_data->tlvs) {
- map_free_cmdu(cmdu_data);
- return -1;
- }
-
- /* Clent Steering BTM Report TLV 17.2.30 */
- struct tlv_steer_btm_report *p =
- p = agent_gen_steer_btm_report(a, target_bssid,
- src_bssid, sta, status_code);
- if (!p) {
- map_free_cmdu(cmdu_data);
- return -1;
- }
-
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
-
- ret = agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
-
- trace("is_steer is %d steer count %d\n",
- a->is_sta_steer_start, a->sta_steerlist_count);
-
- /**
- * Check that the report is sent for a steering opportunity.
- * Here we store the status in the sta list and check
- * if the steering completed message can be sent
- */
- if (a->is_sta_steer_start) {
- int i;
-
- /* iterate list of clients attempted to be steered */
- for (i = 0; i < a->sta_steerlist_count; i++) {
-
- /* mark all steered clients as completed */
- ret = memcmp(sta, a->sta_steer_list[i].sta_mac, 6);
- if (ret == 0)
- a->sta_steer_list[i].complete = 1;
- }
-
- /**
- * Now we need to check if the steering completed
- * message can be sent
- */
- for (i = 0; i < a->sta_steerlist_count; i++) {
- if (a->sta_steer_list[i].complete != 1) {
- all_complete = 0;
- break;
- }
- }
-
- if (all_complete) {
- /* Here we need to send the steering completed CMDU */
- send_sta_steer_complete(agent, origin, intf_name);
- }
- }
-
- return ret;
-}
-
-int send_sta_caps_report(void *agent, struct cmdu_cstruct *cmdu)
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// uint16_t tlv_index = 0;
+// struct cmdu_cstruct *cmdu_data;
+// int ret = 0, all_complete = 1;
+//
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+//
+// if (!cmdu_data) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu_data->message_type = CMDU_CLIENT_STEERING_BTM_REPORT;
+// memcpy(cmdu_data->origin, origin, 6);
+// //cmdu_data->message_id = 15;
+// strcpy(cmdu_data->intf_name, intf_name);
+//
+// cmdu_data->num_tlvs = 1; /* (Steering BTM report) */
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
+// sizeof(uint8_t *));
+//
+// if (!cmdu_data->tlvs) {
+// map_free_cmdu(cmdu_data);
+// return -1;
+// }
+//
+// /* Clent Steering BTM Report TLV 17.2.30 */
+// struct tlv_steer_btm_report *p =
+// p = agent_gen_steer_btm_report(a, target_bssid,
+// src_bssid, sta, status_code);
+// if (!p) {
+// map_free_cmdu(cmdu_data);
+// return -1;
+// }
+//
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+//
+// ret = agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+//
+// trace("is_steer is %d steer count %d\n",
+// a->is_sta_steer_start, a->sta_steerlist_count);
+//
+// /**
+// * Check that the report is sent for a steering opportunity.
+// * Here we store the status in the sta list and check
+// * if the steering completed message can be sent
+// */
+// if (a->is_sta_steer_start) {
+// int i;
+//
+// /* iterate list of clients attempted to be steered */
+// for (i = 0; i < a->sta_steerlist_count; i++) {
+//
+// /* mark all steered clients as completed */
+// ret = memcmp(sta, a->sta_steer_list[i].sta_mac, 6);
+// if (ret == 0)
+// a->sta_steer_list[i].complete = 1;
+// }
+//
+// /**
+// * Now we need to check if the steering completed
+// * message can be sent
+// */
+// for (i = 0; i < a->sta_steerlist_count; i++) {
+// if (a->sta_steer_list[i].complete != 1) {
+// all_complete = 0;
+// break;
+// }
+// }
+//
+// if (all_complete) {
+// /* Here we need to send the steering completed CMDU */
+// send_sta_steer_complete(agent, origin, intf_name);
+// }
+// }
+//
+// return ret;
+}
+
+int send_sta_caps_report(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_ap_metrics_response(void *agent, struct cmdu_cstruct *cmdu)
+int send_ap_metrics_response(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_sta_link_metrics_response(void *agent, struct cmdu_cstruct *cmdu)
+int send_sta_link_metrics_response(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
int send_unassoc_sta_link_metrics_response(void *agent,
- struct cmdu_cstruct *cmdu)
+ struct cmdu_buff *cmdu)
{
return 0;
}
-int send_beacon_metrics_response(void *agent, struct cmdu_cstruct *cmdu)
+int send_beacon_metrics_response(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_backhaul_sta_steer_response(void *agent, struct cmdu_cstruct *cmdu)
+int send_backhaul_sta_steer_response(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_channel_scan_report(void *agent, struct cmdu_cstruct *cmdu)
+int send_channel_scan_report(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_sta_disassoc_stats(void *agent, struct cmdu_cstruct *cmdu)
+int send_sta_disassoc_stats(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_assoc_status_notification(void *agent, struct cmdu_cstruct *cmdu)
+int send_assoc_status_notification(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_tunneled_message(void *agent, struct cmdu_cstruct *cmdu)
+int send_tunneled_message(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_backhaul_sta_caps_report(void *agent, struct cmdu_cstruct *cmdu)
+int send_backhaul_sta_caps_report(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
-int send_failed_connection_msg(void *agent, struct cmdu_cstruct *cmdu)
+int send_failed_connection_msg(void *agent, struct cmdu_buff *cmdu)
{
return 0;
}
@@ -507,7 +490,7 @@ static const map_cmdu_sendfunc_t agent_maptxftable[] = {
};
-int handle_topology_discovery(void *agent, struct cmdu_cstruct *cmdu)
+int handle_topology_discovery(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
struct agent *a = (struct agent *) agent;
@@ -524,13 +507,13 @@ int handle_topology_discovery(void *agent, struct cmdu_cstruct *cmdu)
return 0;
}
-int handle_topology_notification(void *agent, struct cmdu_cstruct *cmdu)
+int handle_topology_notification(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
-int handle_topology_query(void *agent, struct cmdu_cstruct *cmdu)
+int handle_topology_query(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
struct cmdu_cstruct *response;
@@ -549,14 +532,14 @@ int handle_topology_query(void *agent, struct cmdu_cstruct *cmdu)
return 0;
}
-int handle_topology_response(void *agent, struct cmdu_cstruct *cmdu)
+int handle_topology_response(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
-int handle_vendor_specific(void *agent, struct cmdu_cstruct *rec_cmdu)
+int handle_vendor_specific(void *agent, struct cmdu_buff *rx_cmdu)
{
trace("%s: --->\n", __func__);
#if 0
@@ -627,7 +610,7 @@ int handle_vendor_specific(void *agent, struct cmdu_cstruct *rec_cmdu)
#define CTRL_MAC_OLD 0
#define CTRL_MAC_NEW 1
-static int agent_update_controller_data(struct agent *a, struct cmdu_cstruct *cmdu)
+static int agent_update_controller_data(struct agent *a, struct cmdu_buff *cmdu)
{
int ret = CTRL_MAC_OLD;
char mac_str[18] = {0};
@@ -700,7 +683,7 @@ static void agent_trigger_immediate_acs(struct agent *a)
}
}
-int handle_ap_autoconfig_search(void *agent, struct cmdu_cstruct *cmdu)
+int handle_ap_autoconfig_search(void *agent, struct cmdu_buff *cmdu)
{
struct agent *a = (struct agent *) agent;
struct tlv_supp_service *supp_serv;
@@ -782,50 +765,75 @@ static void agent_reschedule_heartbeat_acs(struct agent *a)
(a->acs_interval - elapsed) * 1000);
}
-int handle_ap_autoconfig_response(void *agent, struct cmdu_cstruct *cmdu)
+int handle_ap_autoconfig_response(void *agent, struct cmdu_buff *rx_cmdu)
{
trace("agent: %s: --->\n", __func__);
struct agent *a = (struct agent *) agent;
+ 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 wifi_radio_element *radio = NULL;
- struct tlv_supp_service *supp_serv;
- struct tlv_supported_freq_band *supp_freq;
+ struct tlv *tv[4][16] = {0};
+ char mac_str[18] = {0};
bool cntlr = false;
uint8_t band;
- int i;
+ int i, ret;
+
+ ret = cmdu_parse_tlvs(rx_cmdu, tv, a_policy, 4);
- trace("%s %d mid = %d\n", __func__, __LINE__, cmdu->message_id);
+ if (!tv[0][0] || !tv[1][0] || !tv[2][0] || !tv[3][0])
+ return -1;
/* If MID is not the one we sent, discard response */
for (i = 0; i < a->num_radios; i++) {
trace("radio %s has mid %d\n", a->radios[i].name, a->radios[i].mid);
- if (a->radios[i].mid != cmdu->message_id)
+ if (a->radios[i].mid != cmdu_get_mid(rx_cmdu))
continue;
radio = &a->radios[i];
break;
}
- if (!radio)
+ if (!radio) {
+ dbg("autoconfig response mid did not match!\n");
return -1;
+ }
- supp_serv = (struct tlv_supp_service *) extract_tlv_by_type(cmdu,
- MAP_TLV_SUPPORTED_SERVICE);
- if (!supp_serv)
- return -1;
+ if (tv[1][0]->data[0] > 0) {
+ int i;
- for (i = 0; i < supp_serv->supported_services_list; i++) {
- if (supp_serv->supported_services[i].service == SUPPORTED_SERVICE_MULTIAP_CONTROLLER) {
- cntlr = true;
- break;
+ for (i = 0; i < tv[1][0]->data[0]; i++) {
+ if (tv[1][0]->data[(i+1)] == SUPPORTED_SERVICE_MULTIAP_CONTROLLER) {
+ cntlr = true;
+ break;
+ }
}
}
-
if (!cntlr) {
- trace("agent: Autoconfig response was not from controller\n");
+ dbg("autoconfig response does not support controller!\n");
return -1;
}
/* ACS answered - increase ACS interval if needed */
agent_reschedule_heartbeat_acs(a);
+ dbg("cntlr_almac " MACFMT " origin " MACFMT "\n",
+ MAC2STR(a->cntlr_almac), MAC2STR(rx_cmdu->origin));
+
+ if (hwaddr_is_zero(rx_cmdu->origin))
+ memcpy(rx_cmdu->origin, a->almac, 6);
+
+ /* if it is a new controller, update cntlr_almac and uci */
+ if (memcmp(a->cntlr_almac, rx_cmdu->origin, 6)) {
+ dbg("%s %d\n", __func__, __LINE__);
+ memcpy(a->cntlr_almac, rx_cmdu->origin, 6);
+ if (!hwaddr_ntoa(a->cntlr_almac, mac_str))
+ return -1;
+ dbg("%s %d\n", __func__, __LINE__);
+ /* set self as root node, used for loop detection */
+ if (!memcmp(a->cntlr_almac, a->almac, 6))
+ a->depth = 0;
if (agent_update_controller_data(a, cmdu) == CTRL_MAC_NEW) {
dbg("|%s:%d| new controller found! Activate ACS configuration"\
@@ -839,23 +847,29 @@ int handle_ap_autoconfig_response(void *agent, struct cmdu_cstruct *cmdu)
}
if (radio->state == ACS_ACTIVE) {
+ struct cmdu_buff *resp;
+ struct tlv_supported_band *data;
+
if (a->cntlr_select.local == true &&
memcmp(cmdu->origin, a->almac, 6))
/* local cntlr enforced: don't WSC with non-local one */
return -1;
- supp_freq = (struct tlv_supported_freq_band *) extract_tlv_by_type(cmdu,
- TLV_TYPE_SUPPORTED_FREQ_BAND);
- if (!supp_freq)
- return -1;
+ data = (struct tlv_supported_band *) tv[1][0]->data;
band = wifi_band_to_ieee1905band(radio->band);
- if (band != supp_freq->freq_band)
+ if (band != data->band)
return -1;
dbg("|%s:%d| generate wsc for radio %s\n", __func__, __LINE__,
radio->name);
- build_ap_autoconfig_wsc(a, cmdu, radio, i);
+
+ resp = agent_gen_ap_autoconfig_wsc(a, rx_cmdu, radio, cmdu_get_mid(rx_cmdu));
+ if (!resp)
+ return -1;
+
+ agent_send_cmdu(a, resp);
+ cmdu_free(resp);
} else if (radio->state == ACS_HEARTBEAT) {
/* heartbeat from controller - no activity */
dbg("|%s:%d| Received ACS response from controller during"\
@@ -863,6 +877,88 @@ int handle_ap_autoconfig_response(void *agent, struct cmdu_cstruct *cmdu)
}
return 0;
+// struct agent *a = (struct agent *) agent;
+// struct wifi_radio_element *radio = NULL;
+// struct tlv_supp_service *supp_serv;
+// struct tlv_supported_freq_band *supp_freq;
+// char mac_str[18] = {0};
+// bool cntlr = false;
+// uint8_t band;
+// int i;
+//
+// trace("%s %d mid = %d\n", __func__, __LINE__, cmdu->message_id);
+//
+// /* If MID is not the one we sent, discard response */
+// for (i = 0; i < a->num_radios; i++) {
+// trace("radio %s has mid %d\n", a->radios[i].name, a->radios[i].mid);
+// if (a->radios[i].mid != cmdu->message_id)
+// continue;
+//
+// radio = &a->radios[i];
+// break;
+// }
+// if (!radio)
+// return -1;
+//
+// supp_serv = (struct tlv_supp_service *) extract_tlv_by_type(cmdu,
+// MAP_TLV_SUPPORTED_SERVICE);
+// if (!supp_serv)
+// return -1;
+//
+// for (i = 0; i < supp_serv->supported_services_list; i++) {
+// if (supp_serv->supported_services[i].service == SUPPORTED_SERVICE_MULTIAP_CONTROLLER) {
+// cntlr = true;
+// break;
+// }
+// }
+//
+// if (!cntlr) {
+// trace("agent: Autoconfig response was not from controller\n");
+// return -1;
+// }
+//
+// dbg("cntlr_almac " MACFMT " origin " MACFMT "\n",
+// MAC2STR(a->cntlr_almac), MAC2STR(cmdu->origin));
+//
+// /* if it is a new controller, update cntlr_almac and uci */
+// if (memcmp(a->cntlr_almac, cmdu->origin, 6)) {
+// memcpy(a->cntlr_almac, cmdu->origin, 6);
+// if (!hwaddr_ntoa(a->cntlr_almac, mac_str))
+// return -1;
+//
+// /* set self as root node, used for loop detection */
+// if (!memcmp(a->cntlr_almac, a->almac, 6))
+// a->depth = 0;
+//
+// set_value_by_string("mapagent", "agent", "controller_mac", mac_str,
+// UCI_TYPE_STRING);
+// dbg("|%s:%d| new controller found! Activate ACS configuration"\
+// " for all radios\n", __func__, __LINE__);
+// for (i = 0; i < a->num_radios; i++)
+// a->radios[i].state = ACS_ACTIVE;
+// }
+//
+// /* return if it was just heartbeat and no activity */
+// if (radio->state == ACS_HEARTBEAT) {
+// /** TODO: active own controller if no controller has been
+// * observed for certain time period
+// */
+// } else if (radio->state == ACS_ACTIVE) {
+// supp_freq = (struct tlv_supported_freq_band *) extract_tlv_by_type(cmdu,
+// TLV_TYPE_SUPPORTED_FREQ_BAND);
+// if (!supp_freq)
+// return -1;
+//
+// band = wifi_band_to_ieee1905band(radio->band);
+// if (band != supp_freq->freq_band)
+// return -1;
+//
+// dbg("|%s:%d| generate wsc for radio %s\n", __func__, __LINE__,
+// radio->name);
+// build_ap_autoconfig_wsc(a, cmdu, radio, i);
+// }
+//
+// return 0;
}
static struct wifi_radio_element *wifi_get_radio_by_mac(struct agent *a,
@@ -1056,23 +1152,29 @@ char *wifi_gen_first_ifname(struct agent *a, char *device, char *ifname)
return NULL;
}
-int handle_ap_autoconfig_wsc(void *agent, struct cmdu_cstruct *cmdu)
+int handle_ap_autoconfig_wsc(void *agent, struct cmdu_buff *rx_cmdu)
{
struct agent *a = (struct agent *) agent;
+ struct tlv_policy a_policy[] = {
+ [0] = { .type = MAP_TLV_DEFAULT_8021Q_SETTINGS, .present = TLV_PRESENT_ONE },
+ [1] = { .type = MAP_TLV_TRAFFIC_SEPARATION_POLICY, .present = TLV_PRESENT_ONE },
+ [2] = { .type = MAP_TLV_AP_RADIO_IDENTIFIER, .present = TLV_PRESENT_ONE },
+ [3] = { .type = TLV_TYPE_WSC, .present = TLV_PRESENT_NUM }
+ };
uint8_t bssid[6];
- int i;
- uint8_t *tlv = NULL;
+ struct tlv *tlv = NULL;
struct wifi_radio_element *radio;
- struct tlv_ap_radio_identifier *id_tlv;
+ struct tlv *tv[4][16] = {0};
+ bool agent_found;
+ int ret = 0, num = 0, i;
+ trace("%s: --->\n", __func__);
- trace("%s %d mid = %d\n", __func__, __LINE__, cmdu->message_id);
+ ret = cmdu_parse_tlvs(rx_cmdu, tv, a_policy, 4);
- id_tlv = (struct tlv_ap_radio_identifier *) extract_tlv_by_type(cmdu,
- MAP_TLV_AP_RADIO_IDENTIFIER);
- if (!id_tlv)
+ if (!tv[0][0] || !tv[1][0] || !tv[2][0] || !tv[3][0])
return -1;
- memcpy(bssid, id_tlv->radio_id, 6);
+ memcpy(bssid, tv[2][0]->data, 6);
radio = wifi_get_radio_by_mac(a, bssid);
if (!radio)
@@ -1086,80 +1188,54 @@ int handle_ap_autoconfig_wsc(void *agent, struct cmdu_cstruct *cmdu)
wifi_teardown_map_ifaces_by_radio(a, radio->name);
- /* iterate every TLV_TYPE_WSC, may be multiple */
- for (i = 0; i < cmdu->num_tlvs; i++) {
- tlv = cmdu->tlvs[i];
- switch (*tlv) {
- case TLV_TYPE_WSC: {
- struct mdata out;
- struct tlv_wsc *m2;
- char ifname[IFNAMSIZ] = {0};
- int rv;
-
- m2 = (struct tlv_wsc *) tlv;
-
- if (!wifi_gen_first_ifname(a, radio->name, ifname)) {
- err("Failed to find valid interface name, "\
- "probably maximum number of "\
- "interfaces have been reached\n",
- MACFMT "!\n", MAC2STR(bssid));
- return -1;
- }
+ while (tv[3][num]) {
+ struct wps_credential out = {0};
+ char ifname[IFNAMSIZ] = {0};
+ int rv;
- rv = wscProcessM2((void *) radio->autconfig.key,
- radio->autconfig.m1_frame,
- radio->autconfig.m1_size,
- m2->wsc_frame,
- m2->wsc_frame_size, &out, ifname);
- if (!rv) {
- err("Failed to process M2 target for interface "\
- MACFMT "!\n", MAC2STR(bssid));
-
- wifi_teardown_map_ifaces_by_radio(a,
- radio->name);
- /* Return rather than freeing because it may
- * belong to an updated frame
- */
- return -1;
- }
+ if (!wifi_gen_first_ifname(a, radio->name, ifname)) {
+ err("Failed to find valid interface name, probably "\
+ "maximum number of interfaces have "\
+ "been reached\n", MACFMT "!\n",
+ MAC2STR(bssid));
+ return -1;
+ }
- if (BIT(4, out.output.mapie)) {
- err("MAP Extension had teardown bit set, "\
- "tearing down all MAP interfaces"\
- " for bssid" MACFMT "\n",
- MAC2STR(bssid));
- wifi_teardown_map_ifaces_by_radio(a,
- radio->name);
- uci_set_wireless_interface_option("mapagent",
- "wifi-radio", "device",
- radio->name, "configured", "0");
- goto teardown;
- }
+ ret = wsc_process_m2(radio->autconfig.m1_frame, radio->autconfig.m1_size,
+ radio->autconfig.key, tv[3][num]->data, tlv_length(tv[3][num]),
+ &out);
+ if (ret) {
+ err("Failed to process M2 target for interface "\
+ MACFMT "!\n", MAC2STR(bssid));
- rv = uci_apply_m2(&a->cfg, ifname, radio->name,
- out.output.ssid, out.output.auth_types,
- out.output.encryption_types,
- out.output.network_key,
- out.output.mapie, radio->band,
- out.output.bridge, out.output.proto,
- out.output.vid, out.output.br_ip,
- out.output.bk_ssid, out.output.bk_key,
- radio->onboarded);
- if (rv) {
- err("Failure to process M2, tearing down all "\
- " MAP interfaces"\
- " for bssid" MACFMT "\n",
- MAC2STR(bssid));
- wifi_teardown_map_ifaces_by_radio(a,
- radio->name);
- goto teardown;
- }
+ wifi_teardown_map_ifaces_by_radio(a, radio->name);
+ /* Return rather than freeing because it may belong to
+ * an updated frame
+ */
+ return -1;
+ }
- break;
+ if (BIT(4, out.mapie)) {
+ err("MAP Extension had teardown bit set, tearing down "\
+ "all MAP interfaces for bssid " MACFMT \
+ "\n", MAC2STR(bssid));
+ wifi_teardown_map_ifaces_by_radio(a, radio->name);
+ uci_set_wireless_interface_option("mapagent",
+ "wifi-radio", "device",
+ radio->name, "configured", "0");
+ goto teardown;
}
- default:
- break;
+
+ ret = uci_apply_m2(&a->cfg, ifname, radio->name, &out,
+ radio->onboarded);
+ if (ret) {
+ err("Failure to process M2, tearing down all MAP "\
+ " interfaces for bssid " MACFMT "\n",
+ MAC2STR(bssid));
+ wifi_teardown_map_ifaces_by_radio(a, radio->name);
+ goto teardown;
}
+ num++;
}
uci_set_wireless_interface_option("mapagent", "wifi-radio", "device",
@@ -1182,7 +1258,7 @@ teardown:
return 0;
}
-int handle_ap_autoconfig_renew(void *agent, struct cmdu_cstruct *cmdu)
+int handle_ap_autoconfig_renew(void *agent, struct cmdu_buff *cmdu)
{
trace("agent: %s: --->\n", __func__);
struct agent *a = (struct agent *) agent;
@@ -1194,11 +1270,11 @@ int handle_ap_autoconfig_renew(void *agent, struct cmdu_cstruct *cmdu)
/* local cntlr enforced: accept renew from self only */
return -1;
- for (i = 0; i < a->num_radios; i++) {
- radio = a->radios + i;
- build_ap_autoconfig_wsc(a, cmdu, radio, i);
- }
-
+// for (i = 0; i < a->num_radios; i++) {
+// radio = a->radios + i;
+// build_ap_autoconfig_wsc(a, cmdu, radio, i);
+// }
+//
return 0;
}
int get_radio_index(struct agent *a, uint8_t *mac)
@@ -1245,298 +1321,288 @@ int get_radio_and_bss_index(struct agent *a, uint8_t *bssid,
/* ifname: interface name, prepare the query for that specific interface;
* ifname: NULL, include all the interface.
*/
-static struct cmdu_cstruct *prepare_ap_metrics_query(
+static struct cmdu_buff *prepare_ap_metrics_query(
void *agent, char *ifname)
{
- trace("%s --->\n", __func__);
- int total_bss = 0;
- int i, j, k;
- int tlv_index = 0;
- struct agent *a = (struct agent *)agent;
- struct wifi_radio_element *radio;
- struct wifi_bss_element *bss;
- struct tlv_ap_metric_query *p1;
- struct cmdu_cstruct *cmdu;
-
- cmdu = calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu)
- return NULL;
-
- cmdu->message_type = CMDU_AP_METRICS_QUERY;
- memcpy(cmdu->origin, a->cntlr_almac, 6);
- strncpy(cmdu->intf_name, "br-lan", IFNAMESIZE - 1);
-
- if (ifname == NULL) {
- /* AP Metrics Query TLV */
- cmdu->num_tlvs++;
-// #ifdef PROFILE2
- /* AP Radio Identifier TLV */
- cmdu->num_tlvs += a->num_radios;
-// #endif
-
- for (i = 0; i < a->num_radios; i++)
- total_bss += a->radios[i].num_bss;
-
- } else if (ifname && (ifname[0] != '\0')) {
- /* AP Metrics Query TLV */
- cmdu->num_tlvs++;
-// #ifdef PROFILE2
- /* AP Radio Identifier TLV */
- cmdu->num_tlvs++;
-// #endif
-
- radio = wifi_ifname_to_radio_element(a, ifname);
- if (!radio) {
- cmdu->num_tlvs = 0;
- goto error;
- }
-
- total_bss = radio->num_bss;
- }
-
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- if (!cmdu->tlvs) {
- cmdu->num_tlvs = 0;
- goto error;
- }
-
-
- p1 = calloc(1, sizeof(*p1));
- if (!p1)
- goto error;
-
- p1->tlv_type = MAP_TLV_AP_METRIC_QUERY;
- p1->bssid_nr = total_bss;
- p1->ap_metric_query_bssid = calloc(p1->bssid_nr,
- sizeof(*p1->ap_metric_query_bssid));
- if (!p1->ap_metric_query_bssid) {
- free(p1);
- goto error;
- }
-
- if (ifname == NULL) {
- struct tlv_ap_radio_identifier *p2;
-
- k = 0;
- for (i = 0; i < a->num_radios; i++) {
- radio = a->radios + i;
-// #ifdef PROFILE2
- p2 = agent_gen_ap_radio_identifier(a, radio->macaddr);
- if (p2)
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-// #endif
-
- for (j = 0; j < radio->num_bss; j++) {
- bss = radio->bsslist + j;
- memcpy(p1->ap_metric_query_bssid[k].bssid,
- bss->bssid, 6);
- k++;
- }
- }
-
- } else if (ifname && (ifname[0] != '\0')) {
- struct tlv_ap_radio_identifier *p2;
-
- k = 0;
- radio = wifi_ifname_to_radio_element(a, ifname);
- if (!radio) {
- map_free_tlv_cstruct((uint8_t *)p1);
- goto error;
- }
-
-// #ifdef PROFILE2
- p2 = agent_gen_ap_radio_identifier(a, radio->macaddr);
- if (p2)
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-// #endif
-
- for (i = 0; i < radio->num_bss; i++) {
- bss = radio->bsslist + i;
- memcpy(p1->ap_metric_query_bssid[k].bssid,
- bss->bssid, 6);
- k++;
- }
-
- }
-
- cmdu->tlvs[tlv_index] = (uint8_t *)p1;
-
- return cmdu;
-error:
- map_free_cmdu(cmdu);
- return NULL;
+ return 0;
+// int total_bss = 0;
+// int i, j, k;
+// int tlv_index = 0;
+// struct agent *a = (struct agent *)agent;
+// struct wifi_radio_element *radio;
+// struct wifi_bss_element *bss;
+// struct tlv_ap_metric_query *p1;
+// struct cmdu_cstruct *cmdu;
+//
+// cmdu = calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu)
+// return NULL;
+//
+// cmdu->message_type = CMDU_AP_METRICS_QUERY;
+// memcpy(cmdu->origin, a->cntlr_almac, 6);
+// strncpy(cmdu->intf_name, "br-lan", IFNAMESIZE - 1);
+//
+// if (ifname == NULL) {
+// /* AP Metrics Query TLV */
+// cmdu->num_tlvs++;
+//// #ifdef PROFILE2
+// /* AP Radio Identifier TLV */
+// cmdu->num_tlvs += a->num_radios;
+//// #endif
+//
+// for (i = 0; i < a->num_radios; i++)
+// total_bss += a->radios[i].num_bss;
+//
+// } else if (ifname && (ifname[0] != '\0')) {
+// /* AP Metrics Query TLV */
+// cmdu->num_tlvs++;
+//// #ifdef PROFILE2
+// /* AP Radio Identifier TLV */
+// cmdu->num_tlvs++;
+//// #endif
+//
+// radio = wifi_ifname_to_radio_element(a, ifname);
+// if (!radio) {
+// cmdu->num_tlvs = 0;
+// goto error;
+// }
+//
+// total_bss = radio->num_bss;
+// }
+//
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs) {
+// cmdu->num_tlvs = 0;
+// goto error;
+// }
+//
+//
+// p1 = calloc(1, sizeof(*p1));
+// if (!p1)
+// goto error;
+//
+// p1->tlv_type = MAP_TLV_AP_METRIC_QUERY;
+// p1->bssid_nr = total_bss;
+// p1->ap_metric_query_bssid = calloc(p1->bssid_nr,
+// sizeof(*p1->ap_metric_query_bssid));
+// if (!p1->ap_metric_query_bssid) {
+// free(p1);
+// goto error;
+// }
+//
+// if (ifname == NULL) {
+// struct tlv_ap_radio_identifier *p2;
+//
+// k = 0;
+// for (i = 0; i < a->num_radios; i++) {
+// radio = a->radios + i;
+//// #ifdef PROFILE2
+// p2 = agent_gen_ap_radio_identifier(a, radio->macaddr);
+// if (p2)
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//// #endif
+//
+// for (j = 0; j < radio->num_bss; j++) {
+// bss = radio->bsslist + j;
+// memcpy(p1->ap_metric_query_bssid[k].bssid,
+// bss->bssid, 6);
+// k++;
+// }
+// }
+//
+// } else if (ifname && (ifname[0] != '\0')) {
+// struct tlv_ap_radio_identifier *p2;
+//
+// k = 0;
+// radio = wifi_ifname_to_radio_element(a, ifname);
+// if (!radio) {
+// map_free_tlv_cstruct((uint8_t *)p1);
+// goto error;
+// }
+//
+//// #ifdef PROFILE2
+// p2 = agent_gen_ap_radio_identifier(a, radio->macaddr);
+// if (p2)
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//// #endif
+//
+// for (i = 0; i < radio->num_bss; i++) {
+// bss = radio->bsslist + i;
+// memcpy(p1->ap_metric_query_bssid[k].bssid,
+// bss->bssid, 6);
+// k++;
+// }
+//
+// }
+//
+// cmdu->tlvs[tlv_index] = (uint8_t *)p1;
+//
+// return cmdu;
+//error:
+// map_free_cmdu(cmdu);
+// return NULL;
}
static int prepare_ap_metrics_response(void *agent,
- struct cmdu_cstruct *rec_cmdu)
+ struct cmdu_buff *rx_cmdu)
{
trace("%s: --->\n", __func__);
- struct cmdu_cstruct *cmdu;
- struct agent *a = (struct agent *)agent;
-
- cmdu = agent_gen_ap_metrics_response(a, rec_cmdu);
- if (!cmdu)
- return -1;
-
- agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
-
return 0;
+// struct cmdu_cstruct *cmdu;
+// struct agent *a = (struct agent *)agent;
+//
+// cmdu = agent_gen_ap_metrics_response(a, rx_cmdu);
+// if (!cmdu)
+// return -1;
+//
+// agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+//
+// return 0;
}
static int prepare_assoc_sta_metric_response(void *agent, char *ifname)
{
trace("%s: --->\n", __func__);
- struct cmdu_cstruct *cmdu;
- struct agent *a = (struct agent *)agent;
-
- cmdu = agent_gen_assoc_sta_metric_response_per_intf(a, ifname);
- if (!cmdu)
- return -1;
-
- agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
-
return 0;
-
+// struct cmdu_cstruct *cmdu;
+// struct agent *a = (struct agent *)agent;
+//
+// cmdu = agent_gen_assoc_sta_metric_response_per_intf(a, ifname);
+// if (!cmdu)
+// return -1;
+//
+// agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+//
+// return 0;
}
-int handle_1905_ack(void *agent, struct cmdu_cstruct *cmdu)
+int handle_1905_ack(void *agent, struct cmdu_buff *cmdu)
{
trace("agent: %s: --->\n", __func__);
return 0;
}
-int handle_ap_caps_query(void *agent, struct cmdu_cstruct *rec_cmdu)
-{
- trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- uint16_t tlv_index = 0;
- uint32_t i;
- struct cmdu_cstruct *cmdu;
- struct tlv_ap_cap *p2;
- struct tlv_ch_scan_cap *p5;
- struct tlv_cac_cap *p6;
- struct tlv_profile2_ap_cap *p7;
- struct tlv_metric_collection_interval *p8;
- int ret;
-
- cmdu = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
- if (!cmdu) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu->message_type = CMDU_AP_CAPABILITY_REPORT;
- memcpy(cmdu->origin, rec_cmdu->origin, 6);
- cmdu->message_id = rec_cmdu->message_id;
- strcpy(cmdu->intf_name, rec_cmdu->intf_name);
-
- cmdu->num_tlvs = 3 * a->num_radios + 1; /* (Radio basic, HT, VHT capability per radio) */
-
-//#ifdef PROFILE2
- cmdu->num_tlvs += 1 + 1 + 1 + 1; /* Channel scan, CAC, profile-2 AP capabilities and metric collection interval TLV */
-//#endif PROFILE2
-
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- if (!cmdu->tlvs) {
- map_free_cmdu(cmdu);
- return -1;
- }
-
- /* AP basic Radio Capability TLV*/
- for (i = 0; i < a->num_radios; i++) {
- struct tlv_ap_radio_basic_cap *p;
-
- p = agent_gen_ap_radio_basic_cap(a, cmdu, &a->radios[i]);
- if (!p)
- continue;
- //cmdu->num_tlvs++;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p;
- }
-
- /* AP capability TLV */
- p2 = agent_gen_ap_caps(a, cmdu);
- if (!p2)
- goto fail;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-
- /* HT Capability */
- for (i = 0; i < a->num_radios; i++) {
- struct tlv_ap_ht_cap *p3;
-
- p3 = agent_gen_ap_ht_caps(a, cmdu, i);
- if (!p3)
- continue;
- //cmdu->num_tlvs++;
-
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
- }
-
- /* VHT Capability */
- for (i = 0; i < a->num_radios; i++) {
- struct tlv_ap_vht_cap *p4;
-
- p4 = agent_gen_ap_vht_caps(a, cmdu, i);
- if (!p4)
- continue;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p4;
- }
-
-//#ifdef PROFILE2
- /* Channel Scan Capability */
- p5 = agent_gen_ch_scan_cap(a);
- if (!p5)
- goto fail;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p5;
-
- /* CAC Capability */
- p6 = agent_gen_cac_cap(a);
- if (!p6)
- goto fail;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p6;
-
- /* Profile Capability */
- p7 = agent_gen_profile2_ap_cap(a);
- if (!p7)
- goto fail;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p7;
-
- /* Metric Collection Interval */
- p8 = agent_gen_metric_collection_interval(a);
- if (!p8)
- goto fail;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p8;
-//#endif PROFILE2
-
- ret = agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
-
- return ret;
-fail:
- map_free_cmdu(cmdu);
- return -1;
-}
-
-uint8_t rssi_to_rcpi(int rssi)
+int handle_ap_caps_query(void *agent, struct cmdu_buff *rx_cmdu)
{
- if (!rssi)
- return 255;
- else if (rssi < -110)
- return 0;
- else if (rssi > 0)
- return 220;
- else
- return (rssi + 110) * 2;
+ return 0;
+// trace("agent: %s: --->\n", __func__);
+// struct agent *a = (struct agent *) agent;
+// uint16_t tlv_index = 0;
+// uint32_t i;
+// struct cmdu_cstruct *cmdu;
+// struct tlv_ap_cap *p2;
+// struct tlv_ch_scan_cap *p5;
+// struct tlv_cac_cap *p6;
+// struct tlv_profile2_ap_cap *p7;
+// struct tlv_metric_collection_interval *p8;
+// int ret;
+//
+// cmdu = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+// if (!cmdu) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu->message_type = CMDU_AP_CAPABILITY_REPORT;
+// memcpy(cmdu->origin, rx_cmdu->origin, 6);
+// cmdu->message_id = rx_cmdu->message_id;
+// strcpy(cmdu->intf_name, rx_cmdu->intf_name);
+//
+// cmdu->num_tlvs = 3 * a->num_radios + 1; /* (Radio basic, HT, VHT capability per radio) */
+//
+////#ifdef PROFILE2
+// cmdu->num_tlvs += 1 + 1 + 1 + 1; /* Channel scan, CAC, profile-2 AP capabilities and metric collection interval TLV */
+////#endif PROFILE2
+//
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs) {
+// map_free_cmdu(cmdu);
+// return -1;
+// }
+//
+// /* AP basic Radio Capability TLV*/
+// for (i = 0; i < a->num_radios; i++) {
+// struct tlv_ap_radio_basic_cap *p;
+//
+// p = agent_gen_ap_radio_basic_cap(a, cmdu, &a->radios[i]);
+// if (!p)
+// continue;
+// //cmdu->num_tlvs++;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p;
+// }
+//
+// /* AP capability TLV */
+// p2 = agent_gen_ap_caps(a, cmdu);
+// if (!p2)
+// goto fail;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//
+// /* HT Capability */
+// for (i = 0; i < a->num_radios; i++) {
+// struct tlv_ap_ht_cap *p3;
+//
+// p3 = agent_gen_ap_ht_caps(a, cmdu, i);
+// if (!p3)
+// continue;
+// //cmdu->num_tlvs++;
+//
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p3;
+// }
+//
+// /* VHT Capability */
+// for (i = 0; i < a->num_radios; i++) {
+// struct tlv_ap_vht_cap *p4;
+//
+// p4 = agent_gen_ap_vht_caps(a, cmdu, i);
+// if (!p4)
+// continue;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p4;
+// }
+//
+////#ifdef PROFILE2
+// /* Channel Scan Capability */
+// p5 = agent_gen_ch_scan_cap(a);
+// if (!p5)
+// goto fail;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p5;
+//
+// /* CAC Capability */
+// p6 = agent_gen_cac_cap(a);
+// if (!p6)
+// goto fail;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p6;
+//
+// /* Profile Capability */
+// p7 = agent_gen_profile2_ap_cap(a);
+// if (!p7)
+// goto fail;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p7;
+//
+// /* Metric Collection Interval */
+// p8 = agent_gen_metric_collection_interval(a);
+// if (!p8)
+// goto fail;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p8;
+////#endif PROFILE2
+//
+// ret = agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+//
+// return ret;
+//fail:
+// map_free_cmdu(cmdu);
+// return -1;
}
static uint8_t calculate_radio_util(struct agent *a, char *ifname)
@@ -1552,420 +1618,428 @@ static uint8_t calculate_radio_util(struct agent *a, char *ifname)
static uint8_t calculate_radio_rcpi(struct agent *a, char *ifname)
{
- int j, k;
- struct wifi_radio_element *radio;
- struct wifi_bss_element *bss;
- struct wifi_sta_element *sta;
- int8_t rssi = 0;
- uint8_t rcpi = 0;
-
- radio = wifi_ifname_to_radio_element(a, ifname);
- if (!radio)
- return 0;
-
- for (j = 0; j < radio->num_bss; j++) {
- bss = radio->bsslist + j;
- for (k = 0; k < bss->num_stations; k++) {
- sta = bss->stalist + k;
- rssi += sta->rssi;
- }
- }
-
- rcpi = rssi_to_rcpi(rssi);
-
- return rcpi;
+ return 0;
+// int j, k;
+// struct wifi_radio_element *radio;
+// struct wifi_bss_element *bss;
+// struct wifi_sta_element *sta;
+// int8_t rssi = 0;
+// uint8_t rcpi = 0;
+//
+// radio = wifi_ifname_to_radio_element(a, ifname);
+// if (!radio)
+// return 0;
+//
+// for (j = 0; j < radio->num_bss; j++) {
+// bss = radio->bsslist + j;
+// for (k = 0; k < bss->num_stations; k++) {
+// sta = bss->stalist + k;
+// rssi += sta->rssi;
+// }
+// }
+//
+// rcpi = rssi_to_rcpi(rssi);
+//
+// return rcpi;
}
static void agent_metric_report_timer_cb(struct uloop_timeout *t)
{
- struct agent_config *cfg =
- container_of(t, struct agent_config, metric_report_timer);
- struct agent *a = container_of(cfg, struct agent, cfg);
- struct cmdu_cstruct *cmdu;
- char *ifname = NULL;
-
- cmdu = prepare_ap_metrics_query((void *)a, ifname);
- if (!cmdu)
- goto refresh_interval;
-
- prepare_ap_metrics_response(a, cmdu);
- map_free_cmdu(cmdu);
-
-refresh_interval:
- uloop_timeout_set(&cfg->metric_report_timer,
- cfg->pcfg->report_interval * 1000);
+ return;
+// struct agent_config *cfg =
+// container_of(t, struct agent_config, metric_report_timer);
+// struct agent *a = container_of(cfg, struct agent, cfg);
+// struct cmdu_cstruct *cmdu;
+// char *ifname = NULL;
+//
+// cmdu = prepare_ap_metrics_query((void *)a, ifname);
+// if (!cmdu)
+// goto refresh_interval;
+//
+// prepare_ap_metrics_response(a, cmdu);
+// map_free_cmdu(cmdu);
+//
+//refresh_interval:
+// uloop_timeout_set(&cfg->metric_report_timer,
+// cfg->pcfg->report_interval * 1000);
}
static void agent_util_threshold_timer_cb(struct uloop_timeout *t)
{
- struct netif_fh *p = container_of(t, struct netif_fh,
- util_threshold_timer);
- struct agent *a = p->agent;
- struct cmdu_cstruct *cmdu;
- uint8_t curr_util = 0;
- uint8_t prev_util;
-
- curr_util = calculate_radio_util(a, p->name);
- prev_util = p->prev_util;
- if (((prev_util > p->cfg->util_threshold) &&
- (curr_util > p->cfg->util_threshold)) ||
- ((prev_util < p->cfg->util_threshold) &&
- (curr_util < p->cfg->util_threshold)))
- goto refresh_interval;
-
- cmdu = prepare_ap_metrics_query((void *)a, p->name);
- if (!cmdu)
- goto refresh_interval;
-
- prepare_ap_metrics_response(a, cmdu);
- map_free_cmdu(cmdu);
-
-refresh_interval:
- p->prev_util = curr_util;
- uloop_timeout_set(&p->util_threshold_timer, UTIL_THRESHOLD_TIMER);
+ return;
+// struct netif_fh *p = container_of(t, struct netif_fh,
+// util_threshold_timer);
+// struct agent *a = p->agent;
+// struct cmdu_cstruct *cmdu;
+// uint8_t curr_util = 0;
+// uint8_t prev_util;
+//
+// curr_util = calculate_radio_util(a, p->name);
+// prev_util = p->prev_util;
+// if (((prev_util > p->cfg->util_threshold) &&
+// (curr_util > p->cfg->util_threshold)) ||
+// ((prev_util < p->cfg->util_threshold) &&
+// (curr_util < p->cfg->util_threshold)))
+// goto refresh_interval;
+//
+// cmdu = prepare_ap_metrics_query((void *)a, p->name);
+// if (!cmdu)
+// goto refresh_interval;
+//
+// prepare_ap_metrics_response(a, cmdu);
+// map_free_cmdu(cmdu);
+//
+//refresh_interval:
+// p->prev_util = curr_util;
+// uloop_timeout_set(&p->util_threshold_timer, UTIL_THRESHOLD_TIMER);
}
static void agent_rcpi_thresold_timer_cb(struct uloop_timeout *t)
{
- struct netif_fh *p = container_of(t, struct netif_fh,
- rcpi_threshold_timer);
- struct agent *a = p->agent;
- uint8_t curr_rcpi = 0;
- uint8_t prev_rcpi;
-
- curr_rcpi = calculate_radio_rcpi(a, p->name);
- prev_rcpi = p->prev_rcpi;
- if (((prev_rcpi > p->cfg->rcpi_threshold) &&
- (curr_rcpi > p->cfg->rcpi_threshold)) ||
- ((prev_rcpi < p->cfg->rcpi_threshold) &&
- (curr_rcpi < p->cfg->rcpi_threshold)))
- goto refresh_interval;
-
- prepare_assoc_sta_metric_response(a, p->name);
-
-refresh_interval:
- p->prev_rcpi = curr_rcpi;
- uloop_timeout_set(&p->rcpi_threshold_timer, RCPI_THRESHOLD_TIMER);
+ return;
+// struct netif_fh *p = container_of(t, struct netif_fh,
+// rcpi_threshold_timer);
+// struct agent *a = p->agent;
+// uint8_t curr_rcpi = 0;
+// uint8_t prev_rcpi;
+//
+// curr_rcpi = calculate_radio_rcpi(a, p->name);
+// prev_rcpi = p->prev_rcpi;
+// if (((prev_rcpi > p->cfg->rcpi_threshold) &&
+// (curr_rcpi > p->cfg->rcpi_threshold)) ||
+// ((prev_rcpi < p->cfg->rcpi_threshold) &&
+// (curr_rcpi < p->cfg->rcpi_threshold)))
+// goto refresh_interval;
+//
+// prepare_assoc_sta_metric_response(a, p->name);
+//
+//refresh_interval:
+// p->prev_rcpi = curr_rcpi;
+// uloop_timeout_set(&p->rcpi_threshold_timer, RCPI_THRESHOLD_TIMER);
}
static int agent_process_policy_config(struct agent *a)
{
trace("%s: --->\n", __func__);
- int i;
- struct agent_config *cfg = &a->cfg;
- struct policy_cfg *c = cfg->pcfg;
-
- /* timer cleanup */
- if (cfg->metric_report_timer.cb) {
- uloop_timeout_cancel(&cfg->metric_report_timer);
- cfg->metric_report_timer.cb = NULL;
- }
-
-
- if (c && (c->report_interval > 0)) {
- cfg->metric_report_timer.cb = agent_metric_report_timer_cb;
- uloop_timeout_set(&cfg->metric_report_timer,
- c->report_interval * 1000);
- }
-
- for (i = 0; i < a->num_radios; i++) {
- struct netif_fh *p;
-
- p = wifi_radio_to_ap(a, a->radios[i].name);
- if (!p)
- continue;
-
- /* timers cleanup fh specific */
- if (p->util_threshold_timer.cb) {
- uloop_timeout_cancel(&p->util_threshold_timer);
- p->util_threshold_timer.cb = NULL;
- }
-
- if (p->rcpi_threshold_timer.cb) {
- uloop_timeout_cancel(&p->rcpi_threshold_timer);
- p->rcpi_threshold_timer.cb = NULL;
- }
-
- if (p->cfg->util_threshold > 0) {
- p->util_threshold_timer.cb =
- agent_util_threshold_timer_cb;
- uloop_timeout_set(&p->util_threshold_timer,
- UTIL_THRESHOLD_TIMER);
- }
-
- if (p->cfg->rcpi_threshold > 0) {
- p->rcpi_threshold_timer.cb =
- agent_rcpi_thresold_timer_cb;
- uloop_timeout_set(&p->rcpi_threshold_timer,
- RCPI_THRESHOLD_TIMER);
- }
- }
-
- /* TODO:
- * 17.2.37: report independent channel scan,
- * will be useful while extending channel scan response
- *
- * 17.2.66: Backhaul configuration
- * 17.2.49, 17.2.50: Will be used in traffic seperation
- *
- * 17.2.58: report unsuccesful association,
- * Sta events should be checked & reported accordingly
- */
-
- return 0;
-}
-
-int handle_map_policy_config(void *agent, struct cmdu_cstruct *cmdu)
-{
- trace("%s: --->\n", __func__);
- int i;
- uint8_t *tlv;
- struct agent *a = (struct agent *)agent;
- struct uci_context *ctx;
- struct uci_package *pkg;
-
- /* send the 1905 ack message to controller */
- // handle_1905_ack(a, cmdu);
-
- ctx = uci_alloc_context();
- if (!ctx)
- return -1;
-
- if (uci_load(ctx, "mapagent", &pkg)) {
- uci_free_context(ctx);
- return -1;
- }
-
- for (i = 0; i < cmdu->num_tlvs; i++) {
- tlv = (uint8_t *)cmdu->tlvs[i];
- fprintf(stderr, "TLV: %s\n", map_stringify_tlv_type(*tlv));
-
- switch (*tlv) {
- case MAP_TLV_STEERING_POLICY:
- {
- struct tlv_steering_policy *p =
- (struct tlv_steering_policy *)tlv;
-
- agent_fill_steering_policy(a, p, ctx, pkg);
-
- break;
- }
-
- case MAP_TLV_METRIC_REPORTING_POLICY:
- {
- struct tlv_metric_report_policy *p =
- (struct tlv_metric_report_policy *)tlv;
-
- agent_fill_metric_report_policy(a, p, ctx, pkg);
-
- break;
- }
-
- case MAP_TLV_DEFAULT_8021Q_SETTINGS:
- {
- struct tlv_default_8021q_settings *p =
- (struct tlv_default_8021q_settings *)tlv;
-
- agent_fill_8021q_setting(a, p, ctx, pkg);
- break;
- }
-
- case MAP_TLV_TRAFFIC_SEPARATION_POLICY:
- {
- struct tlv_traffic_sep_policy *p =
- (struct tlv_traffic_sep_policy *)tlv;
-
- agent_fill_traffic_sep_policy(a, p, ctx, pkg);
- break;
- }
-
- case MAP_TLV_CHANNEL_SCAN_REPORTING_POLICY:
- {
- struct tlv_ch_scan_rep_policy *p =
- (struct tlv_ch_scan_rep_policy *)tlv;
-
- agent_fill_ch_scan_rep_policy(a, p, ctx, pkg);
- break;
- }
-
- case MAP_TLV_UNSUCCESS_ASSOCIATION_POLICY:
- {
- struct tlv_unsuccess_assoc_policy *p =
- (struct tlv_unsuccess_assoc_policy *)tlv;
-
- agent_fill_unsuccess_assoc_policy(a, p, ctx, pkg);
- break;
- }
-
- case MAP_TLV_BACKHAUL_BSS_CONFIG:
- {
- uint8_t generic_id[6] = {0xff, 0x0ff, 0xff, 0xff, 0xff, 0xff};
- struct tlv_backhaul_bss_config *p =
- (struct tlv_backhaul_bss_config *)tlv;
-
- if (!memcmp(p->bssid, generic_id, 6)) {
- agent_fill_backhaul_bss_config_all(a, p, ctx, pkg);
- } else
- agent_fill_backhaul_bss_config(a, p, ctx, pkg);
-
- break;
- }
- }
- }
-
- /* update agent config file */
- uci_commit(ctx, &pkg, false);
- uci_unload(ctx, pkg);
- uci_free_context(ctx);
-
- /* Reload agent config */
- agent_config_reload(&a->cfg);
-
- agent_process_policy_config(a);
-
- return 0;
-}
-
-int handle_channel_pref_query(void *agent, struct cmdu_cstruct *rec_cmdu)
-{
- trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- uint16_t tlv_index = 0;
- uint32_t j;
- struct cmdu_cstruct *cmdu_data;
- int ret = 0;
-
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
- if (!cmdu_data) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu_data->message_type = CMDU_CHANNEL_PREFERENCE_REPORT;
- memcpy(cmdu_data->origin, rec_cmdu->origin, 6);
- cmdu_data->message_id = rec_cmdu->message_id;
- strcpy(cmdu_data->intf_name, rec_cmdu->intf_name);
-
- cmdu_data->num_tlvs = 2 * a->num_radios + 1 + 1; /* (Preference TLV + Restriction TLV)+(CAC status + CAC_report) */
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
- sizeof(uint8_t *));
- if (!cmdu_data->tlvs) {
- map_free_cmdu(cmdu_data);
- return -1;
- }
-
- /* Channel Preference TLV 17.2.13 */
- for (j = 0; j < a->num_radios; j++) {
- struct tlv_channel_pref *p =
- (struct tlv_channel_pref *)calloc(1,
- sizeof(struct tlv_channel_pref));
- if (p) {
- p->tlv_type = MAP_TLV_CHANNEL_PREFERENCE;
- agent_gen_radio_channel_preference(a, p, j);
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
- }
- }
-
- /* Radio Operation Restriction TLV 17.2.14*/
- for (j = 0; j < a->num_radios; j++) {
- struct tlv_radio_oper_restrict *p1 =
- (struct tlv_radio_oper_restrict *)calloc(1,
- sizeof(struct tlv_radio_oper_restrict));
- if (p1) {
- p1->tlv_type = MAP_TLV_RADIO_OPERATION_RESTRICTION;
- agent_gen_radio_restrict_channel(a, p1, j);
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
- }
- }
-
-
-//#ifdef profile2
- /*TODO CAC Completion Report TLV (section 17.2.44). [Profile-2]*/
- struct tlv_cac_comp_report *p2 =
- (struct tlv_cac_comp_report *)calloc(1,
- sizeof(struct tlv_cac_comp_report));
- if (p2) {
- p2->tlv_type = MAP_TLV_CAC_COMPLETION_REPORT;
- agent_gen_cac_comp_report(a, p2);
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p2;
- }
-
- /*TODO CAC Status Report TLV (section 17.2.45). [Profile-2]*/
- struct tlv_cac_status_report *p3 =
- (struct tlv_cac_status_report *)calloc(1,
- sizeof(struct tlv_cac_status_report));
- if (p3) {
- p3->tlv_type = MAP_TLV_CAC_STATUS_REPORT;
- p3->nbr_available_ch = 0; //TODO dummy value
- p3->ch_data = NULL; //TODO dummy value
- p3->nbr_pairs_duration = 0; //TODO dummy value
- p3->duration_pair_data = NULL; //TODO dummy value
- p3->nbr_pairs_coundown = 0; //TODO dummy value
- p3->count_pair_data = NULL; //TODO dummy value
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p3;
- }
-//#endif
- ret = agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
-
- return ret;
-}
-
-int send_channel_sel_response(void *agent, struct cmdu_cstruct *rec_cmdu,
- struct channel_response *channel_resp,
- uint32_t channel_response_nr)
-{
- trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- uint16_t tlv_index = 0;
- uint32_t j, ret = 0;
- struct cmdu_cstruct *cmdu_data;
-
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
-
- if (!cmdu_data) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu_data->message_type = CMDU_CHANNEL_SELECTION_RESPONSE;
- memcpy(cmdu_data->origin, rec_cmdu->origin, 6);
- cmdu_data->message_id = rec_cmdu->message_id;
- strcpy(cmdu_data->intf_name, rec_cmdu->intf_name);
-
- cmdu_data->num_tlvs = 1 * channel_response_nr; /* (channel selection response) */
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
- sizeof(uint8_t *));
-
- if (!cmdu_data->tlvs) {
- map_free_cmdu(cmdu_data);
- return -1;
- }
-
- /* Operating Channel Response TLV 17.2.16 */
- for (j = 0; j < channel_response_nr; j++) {
- struct tlv_ch_selection_resp *p = NULL;
- /* Here we need to check that the radio
- *response is for the radio for which we get request
- */
- p = agent_gen_operate_channel_response(a, rec_cmdu,
- channel_resp[j].radio_id, channel_resp[j].response);
- if (!p)
- continue;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
- }
- ret = agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
-
- /* TODO send a report message for each radio. This will be
- * sent not here but on receiving of the event when the
- * actually radio channel poreference have been changed
- */
- send_oper_channel_report(agent, rec_cmdu);
- return ret;
-}
+ return 0;
+// int i;
+// struct agent_config *cfg = &a->cfg;
+// struct policy_cfg *c = cfg->pcfg;
+//
+// /* timer cleanup */
+// if (cfg->metric_report_timer.cb) {
+// uloop_timeout_cancel(&cfg->metric_report_timer);
+// cfg->metric_report_timer.cb = NULL;
+// }
+//
+//
+// if (c && (c->report_interval > 0)) {
+// cfg->metric_report_timer.cb = agent_metric_report_timer_cb;
+// uloop_timeout_set(&cfg->metric_report_timer,
+// c->report_interval * 1000);
+// }
+//
+// for (i = 0; i < a->num_radios; i++) {
+// struct netif_fh *p;
+//
+// p = wifi_radio_to_ap(a, a->radios[i].name);
+// if (!p)
+// continue;
+//
+// /* timers cleanup fh specific */
+// if (p->util_threshold_timer.cb) {
+// uloop_timeout_cancel(&p->util_threshold_timer);
+// p->util_threshold_timer.cb = NULL;
+// }
+//
+// if (p->rcpi_threshold_timer.cb) {
+// uloop_timeout_cancel(&p->rcpi_threshold_timer);
+// p->rcpi_threshold_timer.cb = NULL;
+// }
+//
+// if (p->cfg->util_threshold > 0) {
+// p->util_threshold_timer.cb =
+// agent_util_threshold_timer_cb;
+// uloop_timeout_set(&p->util_threshold_timer,
+// UTIL_THRESHOLD_TIMER);
+// }
+//
+// if (p->cfg->rcpi_threshold > 0) {
+// p->rcpi_threshold_timer.cb =
+// agent_rcpi_thresold_timer_cb;
+// uloop_timeout_set(&p->rcpi_threshold_timer,
+// RCPI_THRESHOLD_TIMER);
+// }
+// }
+//
+// /* TODO:
+// * 17.2.37: report independent channel scan,
+// * will be useful while extending channel scan response
+// *
+// * 17.2.66: Backhaul configuration
+// * 17.2.49, 17.2.50: Will be used in traffic seperation
+// *
+// * 17.2.58: report unsuccesful association,
+// * Sta events should be checked & reported accordingly
+// */
+//
+// return 0;
+}
+
+int handle_map_policy_config(void *agent, struct cmdu_buff *cmdu)
+{
+ trace("%s: --->\n", __func__);
+ return 0;
+// int i;
+// uint8_t *tlv;
+// struct agent *a = (struct agent *)agent;
+// struct uci_context *ctx;
+// struct uci_package *pkg;
+//
+// /* send the 1905 ack message to controller */
+// // handle_1905_ack(a, cmdu);
+//
+// ctx = uci_alloc_context();
+// if (!ctx)
+// return -1;
+//
+// if (uci_load(ctx, "mapagent", &pkg)) {
+// uci_free_context(ctx);
+// return -1;
+// }
+//
+// for (i = 0; i < cmdu->num_tlvs; i++) {
+// tlv = (uint8_t *)cmdu->tlvs[i];
+// fprintf(stderr, "TLV: %s\n", map_stringify_tlv_type(*tlv));
+//
+// switch (*tlv) {
+// case MAP_TLV_STEERING_POLICY:
+// {
+// struct tlv_steering_policy *p =
+// (struct tlv_steering_policy *)tlv;
+//
+// agent_fill_steering_policy(a, p, ctx, pkg);
+//
+// break;
+// }
+//
+// case MAP_TLV_METRIC_REPORTING_POLICY:
+// {
+// struct tlv_metric_report_policy *p =
+// (struct tlv_metric_report_policy *)tlv;
+//
+// agent_fill_metric_report_policy(a, p, ctx, pkg);
+//
+// break;
+// }
+//
+// case MAP_TLV_DEFAULT_8021Q_SETTINGS:
+// {
+// struct tlv_default_8021q_settings *p =
+// (struct tlv_default_8021q_settings *)tlv;
+//
+// agent_fill_8021q_setting(a, p, ctx, pkg);
+// break;
+// }
+//
+// case MAP_TLV_TRAFFIC_SEPARATION_POLICY:
+// {
+// struct tlv_traffic_sep_policy *p =
+// (struct tlv_traffic_sep_policy *)tlv;
+//
+// agent_fill_traffic_sep_policy(a, p, ctx, pkg);
+// break;
+// }
+//
+// case MAP_TLV_CHANNEL_SCAN_REPORTING_POLICY:
+// {
+// struct tlv_ch_scan_rep_policy *p =
+// (struct tlv_ch_scan_rep_policy *)tlv;
+//
+// agent_fill_ch_scan_rep_policy(a, p, ctx, pkg);
+// break;
+// }
+//
+// case MAP_TLV_UNSUCCESS_ASSOCIATION_POLICY:
+// {
+// struct tlv_unsuccess_assoc_policy *p =
+// (struct tlv_unsuccess_assoc_policy *)tlv;
+//
+// agent_fill_unsuccess_assoc_policy(a, p, ctx, pkg);
+// break;
+// }
+//
+// case MAP_TLV_BACKHAUL_BSS_CONFIG:
+// {
+// uint8_t generic_id[6] = {0xff, 0x0ff, 0xff, 0xff, 0xff, 0xff};
+// struct tlv_backhaul_bss_config *p =
+// (struct tlv_backhaul_bss_config *)tlv;
+//
+// if (!memcmp(p->bssid, generic_id, 6)) {
+// agent_fill_backhaul_bss_config_all(a, p, ctx, pkg);
+// } else
+// agent_fill_backhaul_bss_config(a, p, ctx, pkg);
+//
+// break;
+// }
+// }
+// }
+//
+// /* update agent config file */
+// uci_commit(ctx, &pkg, false);
+// uci_unload(ctx, pkg);
+// uci_free_context(ctx);
+//
+// /* Reload agent config */
+// agent_config_reload(&a->cfg);
+//
+// agent_process_policy_config(a);
+//
+// return 0;
+}
+
+int handle_channel_pref_query(void *agent, struct cmdu_buff *rx_cmdu)
+{
+ trace("%s: --->\n", __func__);
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// uint16_t tlv_index = 0;
+// uint32_t j;
+// struct cmdu_cstruct *cmdu_data;
+// int ret = 0;
+//
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+// if (!cmdu_data) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu_data->message_type = CMDU_CHANNEL_PREFERENCE_REPORT;
+// memcpy(cmdu_data->origin, rx_cmdu->origin, 6);
+// cmdu_data->message_id = rx_cmdu->message_id;
+// strcpy(cmdu_data->intf_name, rx_cmdu->intf_name);
+//
+// cmdu_data->num_tlvs = 2 * a->num_radios + 1 + 1; /* (Preference TLV + Restriction TLV)+(CAC status + CAC_report) */
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
+// sizeof(uint8_t *));
+// if (!cmdu_data->tlvs) {
+// map_free_cmdu(cmdu_data);
+// return -1;
+// }
+//
+// /* Channel Preference TLV 17.2.13 */
+// for (j = 0; j < a->num_radios; j++) {
+// struct tlv_channel_pref *p =
+// (struct tlv_channel_pref *)calloc(1,
+// sizeof(struct tlv_channel_pref));
+// if (p) {
+// p->tlv_type = MAP_TLV_CHANNEL_PREFERENCE;
+// agent_gen_radio_channel_preference(a, p, j);
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+// }
+// }
+//
+// /* Radio Operation Restriction TLV 17.2.14*/
+// for (j = 0; j < a->num_radios; j++) {
+// struct tlv_radio_oper_restrict *p1 =
+// (struct tlv_radio_oper_restrict *)calloc(1,
+// sizeof(struct tlv_radio_oper_restrict));
+// if (p1) {
+// p1->tlv_type = MAP_TLV_RADIO_OPERATION_RESTRICTION;
+// agent_gen_radio_restrict_channel(a, p1, j);
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p1;
+// }
+// }
+//
+//
+////#ifdef profile2
+// /*TODO CAC Completion Report TLV (section 17.2.44). [Profile-2]*/
+// struct tlv_cac_comp_report *p2 =
+// (struct tlv_cac_comp_report *)calloc(1,
+// sizeof(struct tlv_cac_comp_report));
+// if (p2) {
+// p2->tlv_type = MAP_TLV_CAC_COMPLETION_REPORT;
+// agent_gen_cac_comp_report(a, p2);
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p2;
+// }
+//
+// /*TODO CAC Status Report TLV (section 17.2.45). [Profile-2]*/
+// struct tlv_cac_status_report *p3 =
+// (struct tlv_cac_status_report *)calloc(1,
+// sizeof(struct tlv_cac_status_report));
+// if (p3) {
+// p3->tlv_type = MAP_TLV_CAC_STATUS_REPORT;
+// p3->nbr_available_ch = 0; //TODO dummy value
+// p3->ch_data = NULL; //TODO dummy value
+// p3->nbr_pairs_duration = 0; //TODO dummy value
+// p3->duration_pair_data = NULL; //TODO dummy value
+// p3->nbr_pairs_coundown = 0; //TODO dummy value
+// p3->count_pair_data = NULL; //TODO dummy value
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p3;
+// }
+////#endif
+// ret = agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+//
+// return ret;
+}
+
+int send_channel_sel_response(void *agent, struct cmdu_buff *rx_cmdu,
+ struct channel_response *channel_resp,
+ uint32_t channel_response_nr)
+{
+ trace("agent: %s: --->\n", __func__);
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// uint16_t tlv_index = 0;
+// uint32_t j, ret = 0;
+// struct cmdu_cstruct *cmdu_data;
+//
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+//
+// if (!cmdu_data) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu_data->message_type = CMDU_CHANNEL_SELECTION_RESPONSE;
+// memcpy(cmdu_data->origin, rx_cmdu->origin, 6);
+// cmdu_data->message_id = rx_cmdu->message_id;
+// strcpy(cmdu_data->intf_name, rx_cmdu->intf_name);
+//
+// cmdu_data->num_tlvs = 1 * channel_response_nr; /* (channel selection response) */
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
+// sizeof(uint8_t *));
+//
+// if (!cmdu_data->tlvs) {
+// map_free_cmdu(cmdu_data);
+// return -1;
+// }
+//
+// /* Operating Channel Response TLV 17.2.16 */
+// for (j = 0; j < channel_response_nr; j++) {
+// struct tlv_ch_selection_resp *p = NULL;
+// /* Here we need to check that the radio
+// *response is for the radio for which we get request
+// */
+// p = agent_gen_operate_channel_response(a, rx_cmdu,
+// channel_resp[j].radio_id, channel_resp[j].response);
+// if (!p)
+// continue;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+// }
+// ret = agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+//
+// /* TODO send a report message for each radio. This will be
+// * sent not here but on receiving of the event when the
+// * actually radio channel poreference have been changed
+// */
+// send_oper_channel_report(agent, rx_cmdu);
+// return ret;
+}
int agent_fill_radio_max_preference(void *agent,
struct channel_response *channel_resp,
@@ -1993,333 +2067,337 @@ int agent_fill_radio_max_preference(void *agent,
return 0;
}
-int agent_process_channel_pref_tlv(void *agent, struct tlv_channel_pref *p,
+int agent_process_channel_pref_tlv(void *agent, uint8_t *p,
struct channel_response *channel_resp,
uint32_t *channel_resp_nr)
{
trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- int ret = 0;
- uint32_t match = 0, found = 0;
- int j, l;
- struct wifi_radio_element *radio;
-
- trace("\tradio_id: " MACFMT "\n", MAC2STR(p->radio_id));
- for (l = 0; l < a->num_radios; l++) {
- radio = a->radios + l;
- match = memcmp(radio->macaddr, p->radio_id, 6);
- if (match == 0) {
- found = 1;
- memcpy(channel_resp[*channel_resp_nr].radio_id,
- radio->macaddr, 6);
- channel_resp[*channel_resp_nr].response = 0x00;
- break;
- }
- }
- if (found == 0) {
- memcpy(channel_resp[*channel_resp_nr].radio_id,
- p->radio_id, 6);
- /* Here response code is a Reserved code
- * to decline the request
- */
- channel_resp[*channel_resp_nr].response = 0x04;
- *channel_resp_nr = *channel_resp_nr + 1;
- return ret;
- }
- trace("ch_preference_op_class_nr: %d\n", p->ch_preference_op_class_nr);
-
- for (j = 0; j < p->ch_preference_op_class_nr; j++) {
- /* Here we need to search the operating class in the radio */
- for (l = 0; l < radio->num_supp_opclass; l++) {
- if (radio->supp_opclass[l].id == p->op_class[j].op_class) {
- int k;
-
- /* Here we reset all the channels preferences
- * in the operating class as 15 highest
- * preference
- */
- trace("op_class : %d channel_nr %d\n",
- p->op_class[j].op_class,
- p->op_class[j].channel_nr);
-
- for (k = 0; k <
- radio->supp_opclass[l].num_supported_channels;
- k++)
- radio->supp_opclass[l].
- supp_chanlist[k].pref = 0xff;
-
- for (k = 0; k < p->op_class[j].channel_nr; k++) {
- int m;
-
- for (m = 0; m <
- radio->supp_opclass[l].
- num_supported_channels ; m++) {
- trace("channel %d\n",
- p->op_class[j].channel_list[k]);
- if (p->op_class[j].channel_list[k] ==
- radio->supp_opclass[l].
- supp_chanlist[m].channel) {
- radio->supp_opclass[l].
- supp_chanlist[m].pref =
- p->op_class[j].preference;
-
- trace("channel pref is %d\n",
- p->op_class[j].preference);
- }
- }
- }
- break;
- }
- }
- }
- *channel_resp_nr = *channel_resp_nr + 1;
- return ret;
-}
-
-int handle_channel_sel_request(void *agent, struct cmdu_cstruct *cmdu)
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// int ret = 0;
+// uint32_t match = 0, found = 0;
+// int j, l;
+// struct wifi_radio_element *radio;
+//
+// trace("\tradio_id: " MACFMT "\n", MAC2STR(p->radio_id));
+// for (l = 0; l < a->num_radios; l++) {
+// radio = a->radios + l;
+// match = memcmp(radio->macaddr, p->radio_id, 6);
+// if (match == 0) {
+// found = 1;
+// memcpy(channel_resp[*channel_resp_nr].radio_id,
+// radio->macaddr, 6);
+// channel_resp[*channel_resp_nr].response = 0x00;
+// break;
+// }
+// }
+// if (found == 0) {
+// memcpy(channel_resp[*channel_resp_nr].radio_id,
+// p->radio_id, 6);
+// /* Here response code is a Reserved code
+// * to decline the request
+// */
+// channel_resp[*channel_resp_nr].response = 0x04;
+// *channel_resp_nr = *channel_resp_nr + 1;
+// return ret;
+// }
+// trace("ch_preference_op_class_nr: %d\n", p->ch_preference_op_class_nr);
+//
+// for (j = 0; j < p->ch_preference_op_class_nr; j++) {
+// /* Here we need to search the operating class in the radio */
+// for (l = 0; l < radio->num_supp_opclass; l++) {
+// if (radio->supp_opclass[l].id == p->op_class[j].op_class) {
+// int k;
+//
+// /* Here we reset all the channels preferences
+// * in the operating class as 15 highest
+// * preference
+// */
+// trace("op_class : %d channel_nr %d\n",
+// p->op_class[j].op_class,
+// p->op_class[j].channel_nr);
+//
+// for (k = 0; k <
+// radio->supp_opclass[l].num_supported_channels;
+// k++)
+// radio->supp_opclass[l].
+// supp_chanlist[k].pref = 0xff;
+//
+// for (k = 0; k < p->op_class[j].channel_nr; k++) {
+// int m;
+//
+// for (m = 0; m <
+// radio->supp_opclass[l].
+// num_supported_channels ; m++) {
+// trace("channel %d\n",
+// p->op_class[j].channel_list[k]);
+// if (p->op_class[j].channel_list[k] ==
+// radio->supp_opclass[l].
+// supp_chanlist[m].channel) {
+// radio->supp_opclass[l].
+// supp_chanlist[m].pref =
+// p->op_class[j].preference;
+//
+// trace("channel pref is %d\n",
+// p->op_class[j].preference);
+// }
+// }
+// }
+// break;
+// }
+// }
+// }
+// *channel_resp_nr = *channel_resp_nr + 1;
+// return ret;
+}
+
+int handle_channel_sel_request(void *agent, struct cmdu_buff *cmdu)
{
trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- int ret = 0;
- struct channel_response channel_resp[MAX_RADIO];
- uint32_t channel_resp_nr = 0, match = 0;
- int i;
- uint8_t *tlv = NULL;
- struct wifi_radio_element *radio;
- uint32_t pref_tlv_present = 0;
-
- /* Here we first need to update the channel preference values
- * from the channel selection request
- * then send the CMDU for channel selection response
- */
- if (cmdu->num_tlvs != 0) {
- for (i = 0; i < cmdu->num_tlvs; i++) {
- tlv = (uint8_t *) cmdu->tlvs[i];
- switch (*tlv) {
- case MAP_TLV_CHANNEL_PREFERENCE:
- {
- struct tlv_channel_pref *p =
- (struct tlv_channel_pref *)tlv;
- pref_tlv_present = 1;
-
- ret = agent_process_channel_pref_tlv
- (agent, p, channel_resp,
- &channel_resp_nr);
- }
- case MAP_TLV_TRANSMIT_POWER_LIMIT:
- {
- struct tlv_tx_power_limit *p =
- (struct tlv_tx_power_limit *)tlv;
- int l;
-
- trace("tlv radio_id: " MACFMT "\n",
- MAC2STR(p->radio_id));
- for (l = 0; l < a->num_radios; l++) {
- radio = a->radios + l;
- match = memcmp(radio->macaddr, p->radio_id, 6);
- if (match == 0) {
- /* Here we set the
- * transmit_power_limit
- * of the radio
- */
- radio->transmit_power_limit =
- p->tx_power_limit;
- trace("transmit power %d\n",
- p->tx_power_limit);
- break;
- }
- }
- }
- default:
- break;
- }
- }
- }
-
- if (cmdu->num_tlvs == 0 || pref_tlv_present == 0) {
- /* Here the condition is that the
- * channel selection request have no tlvs or only transmit power tlv
- * so we need to set all the prefernce in all radios to max 15
- */
- agent_fill_radio_max_preference(agent,
- channel_resp, &channel_resp_nr);
- }
-
- ret = send_channel_sel_response(agent, cmdu,
- channel_resp, channel_resp_nr);
-
- return ret;
-}
-
-int handle_sta_caps_query(void *agent, struct cmdu_cstruct *rec_cmdu)
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// int ret = 0;
+// struct channel_response channel_resp[MAX_RADIO];
+// uint32_t channel_resp_nr = 0, match = 0;
+// int i;
+// uint8_t *tlv = NULL;
+// struct wifi_radio_element *radio;
+// uint32_t pref_tlv_present = 0;
+//
+// /* Here we first need to update the channel preference values
+// * from the channel selection request
+// * then send the CMDU for channel selection response
+// */
+// if (cmdu->num_tlvs != 0) {
+// for (i = 0; i < cmdu->num_tlvs; i++) {
+// tlv = (uint8_t *) cmdu->tlvs[i];
+// switch (*tlv) {
+// case MAP_TLV_CHANNEL_PREFERENCE:
+// {
+// struct tlv_channel_pref *p =
+// (struct tlv_channel_pref *)tlv;
+// pref_tlv_present = 1;
+//
+// ret = agent_process_channel_pref_tlv
+// (agent, p, channel_resp,
+// &channel_resp_nr);
+// }
+// case MAP_TLV_TRANSMIT_POWER_LIMIT:
+// {
+// struct tlv_tx_power_limit *p =
+// (struct tlv_tx_power_limit *)tlv;
+// int l;
+//
+// trace("tlv radio_id: " MACFMT "\n",
+// MAC2STR(p->radio_id));
+// for (l = 0; l < a->num_radios; l++) {
+// radio = a->radios + l;
+// match = memcmp(radio->macaddr, p->radio_id, 6);
+// if (match == 0) {
+// /* Here we set the
+// * transmit_power_limit
+// * of the radio
+// */
+// radio->transmit_power_limit =
+// p->tx_power_limit;
+// trace("transmit power %d\n",
+// p->tx_power_limit);
+// break;
+// }
+// }
+// }
+// default:
+// break;
+// }
+// }
+// }
+//
+// if (cmdu->num_tlvs == 0 || pref_tlv_present == 0) {
+// /* Here the condition is that the
+// * channel selection request have no tlvs or only transmit power tlv
+// * so we need to set all the prefernce in all radios to max 15
+// */
+// agent_fill_radio_max_preference(agent,
+// channel_resp, &channel_resp_nr);
+// }
+//
+// ret = send_channel_sel_response(agent, cmdu,
+// channel_resp, channel_resp_nr);
+//
+// return ret;
+}
+
+int handle_sta_caps_query(void *agent, struct cmdu_buff *rx_cmdu)
{
- struct agent *a = (struct agent *) agent;
- struct cmdu_cstruct *cmdu;
- struct tlv_client_info *p = NULL, *query;
- struct tlv_client_cap_report *p1 = NULL;
- struct tlv_error_code *p2 = NULL;
- struct netif_fh *fh;
- uint16_t tlv_index = 0, len;
- // frame ctrl + duration/id + addr1 + addr2 + addr3 + sequence control
- uint16_t offset = 2 + 2 + 6 + 6 + 6 + 2;
- int rv = -1;
- struct sta *s;
- bool found = false;
- uint8_t *body;
-
- if (rec_cmdu->num_tlvs == 0)
- return -1;
-
- query = (struct tlv_client_info *) rec_cmdu->tlvs[0];
- if (query->tlv_type != MAP_TLV_CLIENT_INFO)
- return -1;
-
- cmdu = (struct cmdu_cstruct *)calloc(1, sizeof(struct cmdu_cstruct));
- if (!cmdu) {
- dbg("Out of memory!\n");
- return -1;
- }
-
- cmdu->message_type = CMDU_CLIENT_CAPABILITY_REPORT;
- cmdu->message_id = rec_cmdu->message_id;
- cmdu->num_tlvs = 3;
-
- memcpy(cmdu->origin, rec_cmdu->origin, 6);
- strcpy(cmdu->intf_name, rec_cmdu->intf_name);
- p = (struct tlv_client_info *)calloc(1, sizeof(struct tlv_client_info));
- if (!p)
- goto fail_cmdu;
-
- p->tlv_type = MAP_TLV_CLIENT_INFO;
- memcpy(p->bssid, query->bssid, 6);
- memcpy(p->client_addr, query->client_addr, 6);
- p1 = (struct tlv_client_cap_report *) calloc(1,
- sizeof(struct tlv_client_cap_report));
- if (!p1)
- goto fail_cmdu;
-
- p1->result_code = 0x01;
- p1->tlv_type = MAP_TLV_CLIENT_CAPABILITY_REPORT;
-
- p2 = (struct tlv_error_code *) calloc(1, sizeof(struct tlv_error_code));
- if (!p2)
- goto fail_cmdu;
-
- p2->reason_code = 0x03;
- p2->tlv_type = MAP_TLV_ERROR_CODE;
- memcpy(p2->addr, query->client_addr, 6);
-
- fh = get_netif_by_bssid(a, query->bssid);
- if (!fh) {
- dbg("BSS not found!\n");
- goto send_cmdu;
- }
-
- list_for_each_entry(s, &fh->stalist, list)
- if (!memcmp(s->macaddr, query->client_addr, 6)) {
- found = true;
- break;
- }
- if (!found || !s) {
- p2->reason_code = 0x02;
- dbg("Missing client!\n");
- goto send_cmdu;
- }
-
- if (!s->assoc_frame) {
- dbg("Missing assoc frame!\n");
- goto send_cmdu;
- }
-
- /* if bit is set, HT Control section is included and
- * should be skipped
- */
- if (!(s->assoc_frame->frame[0] & 0x80))
- offset += 4;
-
- body = s->assoc_frame->frame + offset;
- /* subtract 4 from remaining len to not include FCS section */
- len = s->assoc_frame->len - offset - 4;
-
- cmdu->num_tlvs--;
- p1->result_code = 0x00;
- p1->frame_body = calloc(len, sizeof(uint8_t));
- if (!p1->frame_body)
- goto fail_cmdu;
-
- /* first byte annotates length of frame */
- *(p1->frame_body) = (1 + len);
-
- memcpy(p1->frame_body + 1, body, len);
- p2->reason_code = 0x00;
-
-send_cmdu:
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- if (!cmdu->tlvs)
- goto fail_cmdu;
-
- cmdu->tlvs[tlv_index++] = (uint8_t *)p;
- cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
- if (p2->reason_code)
- cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
-
- rv = agent_send_cmdu(a, cmdu);
-
-fail_cmdu:
- map_free_cmdu(cmdu);
- return rv;
-}
-
-int handle_ap_metrics_query(void *agent, struct cmdu_cstruct *cmdu)
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// struct cmdu_cstruct *cmdu;
+// struct tlv_client_info *p = NULL, *query;
+// struct tlv_client_cap_report *p1 = NULL;
+// struct tlv_error_code *p2 = NULL;
+// struct netif_fh *fh;
+// uint16_t tlv_index = 0, len;
+// // frame ctrl + duration/id + addr1 + addr2 + addr3 + sequence control
+// uint16_t offset = 2 + 2 + 6 + 6 + 6 + 2;
+// int rv = -1;
+// struct sta *s;
+// bool found = false;
+// uint8_t *body;
+//
+// if (rx_cmdu->num_tlvs == 0)
+// return -1;
+//
+// query = (struct tlv_client_info *) rx_cmdu->tlvs[0];
+// if (query->tlv_type != MAP_TLV_CLIENT_INFO)
+// return -1;
+//
+// cmdu = (struct cmdu_cstruct *)calloc(1, sizeof(struct cmdu_cstruct));
+// if (!cmdu) {
+// dbg("Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu->message_type = CMDU_CLIENT_CAPABILITY_REPORT;
+// cmdu->message_id = rx_cmdu->message_id;
+// cmdu->num_tlvs = 3;
+//
+// memcpy(cmdu->origin, rx_cmdu->origin, 6);
+// strcpy(cmdu->intf_name, rx_cmdu->intf_name);
+// p = (struct tlv_client_info *)calloc(1, sizeof(struct tlv_client_info));
+// if (!p)
+// goto fail_cmdu;
+//
+// p->tlv_type = MAP_TLV_CLIENT_INFO;
+// memcpy(p->bssid, query->bssid, 6);
+// memcpy(p->client_addr, query->client_addr, 6);
+// p1 = (struct tlv_client_cap_report *) calloc(1,
+// sizeof(struct tlv_client_cap_report));
+// if (!p1)
+// goto fail_cmdu;
+//
+// p1->result_code = 0x01;
+// p1->tlv_type = MAP_TLV_CLIENT_CAPABILITY_REPORT;
+//
+// p2 = (struct tlv_error_code *) calloc(1, sizeof(struct tlv_error_code));
+// if (!p2)
+// goto fail_cmdu;
+//
+// p2->reason_code = 0x03;
+// p2->tlv_type = MAP_TLV_ERROR_CODE;
+// memcpy(p2->addr, query->client_addr, 6);
+//
+// fh = get_netif_by_bssid(a, query->bssid);
+// if (!fh) {
+// dbg("BSS not found!\n");
+// goto send_cmdu;
+// }
+//
+// list_for_each_entry(s, &fh->stalist, list)
+// if (!memcmp(s->macaddr, query->client_addr, 6)) {
+// found = true;
+// break;
+// }
+// if (!found || !s) {
+// p2->reason_code = 0x02;
+// dbg("Missing client!\n");
+// goto send_cmdu;
+// }
+//
+// if (!s->assoc_frame) {
+// dbg("Missing assoc frame!\n");
+// goto send_cmdu;
+// }
+//
+// /* if bit is set, HT Control section is included and
+// * should be skipped
+// */
+// if (!(s->assoc_frame->frame[0] & 0x80))
+// offset += 4;
+//
+// body = s->assoc_frame->frame + offset;
+// /* subtract 4 from remaining len to not include FCS section */
+// len = s->assoc_frame->len - offset - 4;
+//
+// cmdu->num_tlvs--;
+// p1->result_code = 0x00;
+// p1->frame_body = calloc(len, sizeof(uint8_t));
+// if (!p1->frame_body)
+// goto fail_cmdu;
+//
+// /* first byte annotates length of frame */
+// *(p1->frame_body) = (1 + len);
+//
+// memcpy(p1->frame_body + 1, body, len);
+// p2->reason_code = 0x00;
+//
+//send_cmdu:
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs)
+// goto fail_cmdu;
+//
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p;
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p1;
+// if (p2->reason_code)
+// cmdu->tlvs[tlv_index++] = (uint8_t *)p2;
+//
+// rv = agent_send_cmdu(a, cmdu);
+//
+//fail_cmdu:
+// map_free_cmdu(cmdu);
+// return rv;
+}
+
+int handle_ap_metrics_query(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
- prepare_ap_metrics_response(agent, cmdu);
+// prepare_ap_metrics_response(agent, cmdu);
return 0;
}
-int handle_sta_link_metrics_query(void *agent, struct cmdu_cstruct *rec_cmdu)
+int handle_sta_link_metrics_query(void *agent, struct cmdu_buff *rx_cmdu)
{
trace("%s: --->\n", __func__);
- struct cmdu_cstruct *cmdu;
- struct agent *a = (struct agent *)agent;
-
- cmdu = agent_gen_assoc_sta_metric_response(a, rec_cmdu);
- if (!cmdu)
- return -1;
-
- agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
-
return 0;
+// struct cmdu_cstruct *cmdu;
+// struct agent *a = (struct agent *)agent;
+//
+// cmdu = agent_gen_assoc_sta_metric_response(a, rx_cmdu);
+// if (!cmdu)
+// return -1;
+//
+// agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+//
+// return 0;
}
int handle_unassoc_sta_link_metrics_query(void *agent,
- struct cmdu_cstruct *cmdu)
+ struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
int handle_unassoc_sta_link_metrics_response(void *agent,
- struct cmdu_cstruct *cmdu)
+ struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
-int handle_beacon_metrics_query(void *agent, struct cmdu_cstruct *cmdu)
+int handle_beacon_metrics_query(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
-int handle_beacon_metrics_response(void *agent, struct cmdu_cstruct *cmdu)
+int handle_beacon_metrics_response(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
-int handle_combined_infra_metrics(void *agent, struct cmdu_cstruct *cmdu)
+int handle_combined_infra_metrics(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
@@ -2337,43 +2415,44 @@ bool agent_rcpi_steer(void)
return false;
}
-int validate_sta_bssid_assoc(struct netif_fh *fh, struct tlv_steer_Req *p,
+int validate_sta_bssid_assoc(struct netif_fh *fh, uint8_t *p,
struct sta_error_response *sta_resp, uint32_t *cnt,
struct agent *a)
{
- int l = 0;
- struct sta *s;
- uint32_t count = 0;
- uint32_t res = 0, found = 0;
-
- for (l = 0; l < p->sta_list_cnt; l++) {
- list_for_each_entry(s, &fh->stalist, list) {
- trace("stalist :" MACFMT "\n",
- MAC2STR(s->macaddr));
- res = memcmp(s->macaddr, p->steering_req_macs[l].addr, 6);
- if (res == 0) {
- found = 1;
- /**
- * Here as the sta is present check that in this case
- * for steering opportunity put that in the array
- */
- if (p->request_mode == 0x00) {
- memcpy(a->sta_steer_list[a->sta_steerlist_count].sta_mac,
- p->steering_req_macs[l].addr, 6);
- a->sta_steerlist_count = a->sta_steerlist_count + 1;
- }
- break;
- }
- }
- if (found == 0 || !s) {
- dbg("Missing STA client!\n");
- memcpy(sta_resp[count].sta_mac, p->steering_req_macs[l].addr, 6);
- sta_resp[count].response = 0x02;
- count++;
- }
- }
- *cnt += count;
return 0;
+// int l = 0;
+// struct sta *s;
+// uint32_t count = 0;
+// uint32_t res = 0, found = 0;
+//
+// for (l = 0; l < p->sta_list_cnt; l++) {
+// list_for_each_entry(s, &fh->stalist, list) {
+// trace("stalist :" MACFMT "\n",
+// MAC2STR(s->macaddr));
+// res = memcmp(s->macaddr, p->steering_req_macs[l].addr, 6);
+// if (res == 0) {
+// found = 1;
+// /**
+// * Here as the sta is present check that in this case
+// * for steering opportunity put that in the array
+// */
+// if (p->request_mode == 0x00) {
+// memcpy(a->sta_steer_list[a->sta_steerlist_count].sta_mac,
+// p->steering_req_macs[l].addr, 6);
+// a->sta_steerlist_count = a->sta_steerlist_count + 1;
+// }
+// break;
+// }
+// }
+// if (found == 0 || !s) {
+// dbg("Missing STA client!\n");
+// memcpy(sta_resp[count].sta_mac, p->steering_req_macs[l].addr, 6);
+// sta_resp[count].response = 0x02;
+// count++;
+// }
+// }
+// *cnt += count;
+// return 0;
}
int agent_send_request_transition(void *agent, uint8_t *client_sta,
@@ -2441,54 +2520,55 @@ int agent_search_bssid_for_sta(struct agent *a, uint8_t *sta, uint8_t *bssid,
}
int send_1905_acknowledge(void *agent,
- struct cmdu_cstruct *rec_cmdu,
+ struct cmdu_buff *rx_cmdu,
struct sta_error_response *sta_resp, uint32_t sta_count)
{
- struct agent *a = (struct agent *) agent;
- uint16_t tlv_index = 0;
- uint32_t j;
- struct cmdu_cstruct *cmdu_data;
- int ret = 0;
-
- trace("agent: %s: --->\n", __func__);
- cmdu_data = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
-
- if (!cmdu_data) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu_data->message_type = CMDU_1905_ACK;
- memcpy(cmdu_data->origin, rec_cmdu->origin, 6);
- //cmdu_data->message_id = 11;
- strcpy(cmdu_data->intf_name, rec_cmdu->intf_name);
-
- cmdu_data->num_tlvs = sta_count; /* (TLV for error) */
- cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
- sizeof(uint8_t *));
-
- if (!cmdu_data->tlvs) {
- map_free_cmdu(cmdu_data);
- return -1;
- }
-
- /* Error Code TLV 17.2.36 */
- for (j = 0; j < sta_count; j++) {
- struct tlv_error_code *p = NULL;
- /**
- * Here we need to check that the sta error
- * response
- */
- p = agent_gen_tlv_error_code(a, rec_cmdu,
- sta_resp[j].sta_mac, sta_resp[j].response);
- if (!p)
- continue;
- cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
- }
- ret = agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- return ret;
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// uint16_t tlv_index = 0;
+// uint32_t j;
+// struct cmdu_cstruct *cmdu_data;
+// int ret = 0;
+//
+// trace("agent: %s: --->\n", __func__);
+// cmdu_data = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+//
+// if (!cmdu_data) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu_data->message_type = CMDU_1905_ACK;
+// memcpy(cmdu_data->origin, rx_cmdu->origin, 6);
+// //cmdu_data->message_id = 11;
+// strcpy(cmdu_data->intf_name, rx_cmdu->intf_name);
+//
+// cmdu_data->num_tlvs = sta_count; /* (TLV for error) */
+// cmdu_data->tlvs = (uint8_t **)calloc(cmdu_data->num_tlvs,
+// sizeof(uint8_t *));
+//
+// if (!cmdu_data->tlvs) {
+// map_free_cmdu(cmdu_data);
+// return -1;
+// }
+//
+// /* Error Code TLV 17.2.36 */
+// for (j = 0; j < sta_count; j++) {
+// struct tlv_error_code *p = NULL;
+// /**
+// * Here we need to check that the sta error
+// * response
+// */
+// p = agent_gen_tlv_error_code(a, rx_cmdu,
+// sta_resp[j].sta_mac, sta_resp[j].response);
+// if (!p)
+// continue;
+// cmdu_data->tlvs[tlv_index++] = (uint8_t *)p;
+// }
+// ret = agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// return ret;
}
int agent_send_restrict_sta(void *agent, uint32_t count_sta,
@@ -2583,913 +2663,924 @@ int agent_check_start_validity_tmr(uint16_t validity_period,
list_add_tail(&ss->list, &fh->restrict_stalist);
}
}
- return 0;
-}
-
-int agent_check_stop_validity_tmr(uint32_t sta_count, uint8_t stalist[][6],
- struct netif_fh *fh)
-{
- uint32_t i = 0;
- struct restrict_sta_entry *s = NULL, *tmp = NULL;
-
- trace("agent: %s: --->\n", __func__);
- if (stalist == NULL)
- return -1;
-
- for (i = 0; i < sta_count; i++) {
- // check if the sta is already running a timer
- // delete the timer
- list_for_each_entry_safe(s, tmp, &fh->restrict_stalist, list) {
- if (s != NULL) {
- if (!memcmp(s->sta, stalist[i], 6)) {
- uloop_timeout_cancel(&s->restrict_timer);
- list_del(&s->list);
- free(s);
- }
- }
- }
- }
- return 0;
-}
-
-int agent_process_assoc_cntl_tlv(void *agent,
- struct tlv_client_assoc_control_req *p,
- struct cmdu_cstruct *cmdu)
-{
- trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- int ret = 0, result = 0;
- uint32_t match = 0, found = 0;
- int i, j, k, l, m;
- struct netif_fh *fh;
- struct sta *s;
- struct sta_error_response sta_resp[MAX_STA];
- uint32_t count = 0;
- uint32_t res = 0, present = 0;
- uint8_t sta_list[30][6];
-
- for (m = 0; m < p->sta_list_cnt; m++)
- memcpy(sta_list[m], p->client_assoc_ctrl_req_stas[m].addr, 6);
-
- fh = get_netif_by_bssid(a, p->bssid);
- if (!fh) {
- trace("[%s:%d] Error BSSID not present", __func__, __LINE__);
- return -1;
- }
-
- /*Here we first validate that the STA has been sent for
- * blocking */
- if (p->assoc_control == 0x00) {
-
- /*Check if the validity timer value is not zero*/
- if (p->validity_period == 0) {
- trace("[%s:%d] Error validity period is invalid\n", __func__, __LINE__);
- return -1;
- }
-
- /* Here we validate if the sta is associated with the bssid
- * then we need to send an error TLV as the STA should not
- * be associated with the bssid for which the blocking mode is
- * set */
-
- for (l = 0; l < p->sta_list_cnt; l++) {
- list_for_each_entry(s, &fh->stalist, list) {
- trace("stalist :" MACFMT "\n",
- MAC2STR(s->macaddr));
- res = memcmp(s->macaddr, p->client_assoc_ctrl_req_stas[l].addr, 6);
- if (res == 0) {
- found = 1;
- break;
- }
- }
- if (found == 1) {
- dbg("STA client already associated with the bssid!\n");
- memcpy(sta_resp[count].sta_mac, p->client_assoc_ctrl_req_stas[l].addr, 6);
- sta_resp[count].response = 0x01;
- count++;
- }
- }
- /*Here we need the logic to block the STA*/
- ret = agent_send_restrict_sta(agent, p->sta_list_cnt,
- sta_list, fh, p->assoc_control);
- if (ret != 0) {
- trace("[%s:%d] Error in agent_send_restrict_sta\n", __func__, __LINE__);
- return -1;
- }
- /* Here we need to start the timer for which the sta is blocked as
- * per the validity period also need to check if the sta is all
- * in the blocking list */
- ret = agent_check_start_validity_tmr(p->validity_period, p->sta_list_cnt, sta_list, fh);
- if (ret != 0) {
- trace("[%s:%d] Error in start validity tmr\n", __func__, __LINE__);
- return -1;
- }
- } else if (p->assoc_control == 0x01) {
-
- /*Here we will ignore the validity timer value in the request
- * as the validity timer value is ignored in the unblock case */
- /*Here we need to check if the validity timer is already running
- * in that case we need to stop the validity timer */
- ret = agent_check_stop_validity_tmr(p->sta_list_cnt, sta_list, fh);
- if (ret != 0) {
- trace("[%s:%d] Error in stop validity tmr\n", __func__, __LINE__);
- return -1;
- }
- /*Here we need the logic to unblock the STA */
- ret = agent_send_restrict_sta(agent, p->sta_list_cnt,
- sta_list, fh, p->assoc_control);
- if (ret != 0) {
- trace("[%s:%d] Error in agent_send_restrict_sta\n", __func__, __LINE__);
- return -1;
- }
- } else {
- trace("[%s:%d] Reserved mode is called", __func__, __LINE__);
- }
-
-send_ack:
- send_1905_acknowledge(agent, cmdu, sta_resp, count);
- return ret;
-}
-
-int agent_process_steer_request_tlv(void *agent, struct tlv_steer_Req *p,
- struct cmdu_cstruct *cmdu)
-{
- trace("agent: %s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- int ret = 0, result = 0;
- int l, m;
- struct netif_fh *fh;
- struct sta *s;
- struct sta_error_response sta_resp[MAX_STA];
- uint32_t count = 0;
- char wildcard_str[18] = { 0x0 };
- uint8_t wildcard[6];
- uint8_t wildcard_bssid[6];
- uint32_t res = 0, present = 0;
-
- snprintf(wildcard_str, 18, "FF:FF:FF:FF:FF:FF");
- hwaddr_aton(wildcard_str, wildcard);
-
- trace("request_mode: %d\n",
- p->request_mode);
-
- if (p->request_mode == 0x00) {
- /* Here we start the steer opportunity timer */
- if (a->is_sta_steer_start == 1) {
- trace("Error steering opportunity timer already running\n");
- return 1;
- }
-
- /**
- * Here we need to check the three conditions that needs to be
- * satisfied according to section 11.2
- */
- if (p->steer_opp_window == 0) {
- trace("Error steering opportunity timer value is zero\n");
- return 1;
- }
-
- /**
- * TODO check that the sta mac address is not included
- * in the Local Steering Disallowed STA List in the Steering
- * Policy TLV
- */
- a->is_sta_steer_start = 1;
- a->sta_steerlist_count = 0;
- uloop_timeout_set(&a->sta_steer_req_timer, p->steer_opp_window * 1000);
-
- } else if (p->request_mode != 0x01) {
- trace("Invalid request mode");
- return 1;
- }
-
- /* TODO check the rcpi based steering rule section 11.3*/
- agent_rcpi_steer();
-
- /**
- * The src bssid is with which the STA is associated so
- * Here we need to check that the STA is associated with the
- * src_bssid according to section 11.1 of the steer mandate
- * Here we trace the values
- */
- trace("btm_disassoc_imminent: %d\n",
- p->btm_disassoc_imminent);
- trace("btm_abridged: %d\n",
- p->btm_abridged);
- trace("reserved: %d\n",
- p->reserved);
- trace("steer_opp_window: %d\n",
- p->steer_opp_window);
- trace("btm_disassoc_timer: %d\n",
- p->btm_disassoc_timer);
- trace("sta_list_cnt: %d\n",
- p->sta_list_cnt);
- trace("target_bssid_list_cnt: %d\n",
- p->target_bssid_list_cnt);
- trace("src_bssid: " MACFMT "\n",
- MAC2STR(p->bssid));
-
- /* Here we validate if the sta is associated with the src bssid */
- fh = get_netif_by_bssid(a, p->bssid);
- if (!fh) {
- trace("[%s:%d] Error BSSID not present", __func__, __LINE__);
- for (l = 0; l < p->sta_list_cnt; l++) {
- memcpy(sta_resp[count].sta_mac, p->steering_req_macs[l].addr, 6);
- sta_resp[count].response = 0x02;
- count++;
- goto send_ack;
- }
- }
-
- ret = validate_sta_bssid_assoc(fh, p, sta_resp, &count, a);
- if (ret == -1)
- goto send_ack;
-
- /* Number of STAs and BSSIDs are equal, map STA to BSSID */
- if (p->sta_list_cnt > 0 && p->sta_list_cnt == p->target_bssid_list_cnt) {
- for (l = 0; l < p->sta_list_cnt; l++) {
- trace("sta_addr: " MACFMT "\n",
- MAC2STR(p->steering_req_macs[l].addr));
- trace("target bssid: " MACFMT "\n",
- MAC2STR(p->steering_req_target_bssids[l].bssid));
- trace("op_class: %d\n",
- p->steering_req_target_bssids[l].op_class);
- trace("channel: %d\n",
- p->steering_req_target_bssids[l].channel);
- /**
- * Here we need to check that the STA is associated with the
- * src bssid or not
- */
- present = 0;
- trace("count of error code sta %d\n", count);
- for (m = 0; m < count; m++) {
- trace("steer mac: " MACFMT "\n",
- MAC2STR(p->steering_req_macs[l].addr));
- trace("sta error mac: " MACFMT "\n",
- MAC2STR(sta_resp[m].sta_mac));
- res = memcmp(p->steering_req_macs[l].addr,
- sta_resp[m].sta_mac, 6);
- if (res == 0) {
- present = 1;
- break;
- }
- }
- if (present != 1) {
- /*Here we call for transition of sta*/
- ret = agent_transition_sta(a, p, fh, l, l);
- }
- }
- }
- /* Multiple STAs and single BSSID, send all STAs to same BSSID */
- else if (p->sta_list_cnt > 0 && p->target_bssid_list_cnt == 1) {
- trace("target bssid: " MACFMT "\n",
- MAC2STR(p->steering_req_target_bssids[0].bssid));
- trace("op_class: %d\n",
- p->steering_req_target_bssids[0].op_class);
- trace("channel: %d\n",
- p->steering_req_target_bssids[0].channel);
-
- for (l = 0; l < p->sta_list_cnt; l++) {
- /* Here we need to call the ubus method */
- trace("sta_addr: " MACFMT "\n",
- MAC2STR(p->steering_req_macs[l].addr));
- /**
- * Here we need to check that the STA is associated with
- * the src bssid or not
- */
- present = 0;
- for (m = 0; m < count; m++) {
- res = memcmp(p->steering_req_macs[l].addr,
- sta_resp[m].sta_mac, 6);
- if (res == 0) {
- present = 1;
- break;
- }
- }
- if (present != 1) {
- /*Here we call for transition of sta*/
- ret = agent_transition_sta(a, p, fh, l, 0);
- }
- }
- }
- /**
- * No STA provided, Steering request applies to all associated STAs
- * in the BSS, per policy setting.
- */
- else if (p->sta_list_cnt == 0 && p->target_bssid_list_cnt == 1) {
- result = memcmp(p->steering_req_target_bssids[0].bssid, wildcard, 6);
- if (result == 0) {
- trace("[%s:%d] bssid id wildcard", __func__, __LINE__);
- ret = agent_search_bssid_for_sta(a,
- p->steering_req_macs[l].addr, wildcard_bssid, p->bssid);
- if (ret != 0) {
- list_for_each_entry(s, &fh->stalist, list) {
- ret = agent_send_request_transition(
- agent, s->macaddr,
- fh, wildcard_bssid, 0);
- }
- }
- } else {
- list_for_each_entry(s, &fh->stalist, list) {
- ret = agent_send_request_transition(
- agent, s->macaddr,
- fh, p->steering_req_target_bssids[0].bssid, 0);
- }
- }
- }
- /* No BSSID specified for the STAs */
- else if (p->sta_list_cnt > 0 && p->target_bssid_list_cnt == 0) {
- if (p->request_mode != 0x00) {
- trace("[%s:%d]Error steer mandate target BSSID not present\n",
- __func__, __LINE__);
- return 1;
- }
- trace("[%s:%d] target BSSID not present\n", __func__, __LINE__);
- for (l = 0; l < p->sta_list_cnt; l++) {
- trace("sta_addr: " MACFMT "\n",
- MAC2STR(p->steering_req_macs[l].addr));
- /**
- * Here we need to check that the STA is associated with the
- * src bssid or not
- */
- present = 0;
- for (m = 0; m < count; m++) {
- res = memcmp(p->steering_req_macs[l].addr, sta_resp[m].sta_mac, 6);
- if (res == 0) {
- present = 1;
- break;
- }
- }
- if (present != 1) {
- /**
- * Here we need to get the bssids that are best
- * for the STAs in case of steering opportunity
- */
- ret = agent_search_bssid_for_sta(a,
- p->steering_req_macs[l].addr,
- wildcard_bssid, p->bssid);
- if (ret != 0)
- ret = agent_send_request_transition(
- agent, p->steering_req_macs[l].addr,
- fh, wildcard_bssid, 0);
- }
- }
- }
- /* No BSSID or STAs */
- else if (p->sta_list_cnt == 0 && p->target_bssid_list_cnt == 0) {
- trace("[%s:%d] Error No STA and target BSSID present\n", __func__, __LINE__);
- return 1;
- } else {
- trace("[%s:%d] Error condition\n", __func__, __LINE__);
- return 1;
- }
-
-send_ack:
- send_1905_acknowledge(agent, cmdu, sta_resp, count);
- return ret;
-}
-
-int handle_sta_steer_request(void *agent, struct cmdu_cstruct *cmdu)
-{
- trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- int ret = 0;
- int i;
- uint8_t *tlv = NULL;
-
- /* Here we first parse the steer request */
- if (cmdu->num_tlvs != 0) {
- for (i = 0; i < cmdu->num_tlvs; i++) {
- tlv = (uint8_t *) cmdu->tlvs[i];
- switch (*tlv) {
- case MAP_TLV_STEERING_REQUEST:
- {
- struct tlv_steer_Req *p =
- (struct tlv_steer_Req *)tlv;
-
- ret = agent_process_steer_request_tlv(agent,
- p, cmdu);
- break;
- }
-//#ifdef profile2
- case MAP_TLV_PROFILE2_STEERING_REQ:
- {
- //TODO here we need to call the request transmission for the
- //STAs are Agile Multiband capable
- struct tlv_profile2_steer_req *p =
- (struct tlv_profile2_steer_req *)tlv;
-
- break;
- }
-//#endif
- default:
- break;
- }
- }
- }
- return ret;
+ return 0;
}
-int agent_transition_sta(struct agent *a, struct tlv_steer_Req *p, struct netif_fh *fh,
- int l, int m)
+int agent_check_stop_validity_tmr(uint32_t sta_count, uint8_t stalist[][6],
+ struct netif_fh *fh)
{
- uint8_t wildcard[6];
- uint8_t wildcard_bssid[6];
- int result = 0;
- char wildcard_str[18] = { 0x0 };
- int ret = 0;
+ uint32_t i = 0;
+ struct restrict_sta_entry *s = NULL, *tmp = NULL;
trace("agent: %s: --->\n", __func__);
- snprintf(wildcard_str, 18, "FF:FF:FF:FF:FF:FF");
- hwaddr_aton(wildcard_str, wildcard);
-
- result = memcmp(p->steering_req_target_bssids[l].bssid, wildcard, 6);
- if (result == 0) {
- /**
- * code to search bssid as the bssid is a
- * wildcard
- */
- trace("[%s:%d] bssid id wildcard\n",
- __func__, __LINE__);
- ret = agent_search_bssid_for_sta(a,
- p->steering_req_macs[l].addr,
- wildcard_bssid, p->bssid);
- if (ret == 0)
- ret = agent_send_request_transition(a,
- p->steering_req_macs[l].addr,
- fh, wildcard_bssid, 0);
- } else {
- ret = agent_send_request_transition(a,
- p->steering_req_macs[l].addr,
- fh, p->steering_req_target_bssids[m].bssid, 0);
- }
- return 0;
-}
+ if (stalist == NULL)
+ return -1;
-int handle_sta_assoc_control_request(void *agent, struct cmdu_cstruct *cmdu)
-{
- trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- int ret = 0;
- int i;
- uint8_t *tlv = NULL;
-
- /* Here we first parse the steer request */
- if (cmdu->num_tlvs != 0) {
- for (i = 0; i < cmdu->num_tlvs; i++) {
- tlv = (uint8_t *) cmdu->tlvs[i];
- switch (*tlv) {
- case MAP_TLV_CLIENT_ASSOCIATION_CONTROL_REQUEST:
- {
- struct tlv_client_assoc_control_req *p =
- (struct tlv_client_assoc_control_req *)tlv;
-
- ret = agent_process_assoc_cntl_tlv(agent,
- p, cmdu);
+ for (i = 0; i < sta_count; i++) {
+ // check if the sta is already running a timer
+ // delete the timer
+ list_for_each_entry_safe(s, tmp, &fh->restrict_stalist, list) {
+ if (s != NULL) {
+ if (!memcmp(s->sta, stalist[i], 6)) {
+ uloop_timeout_cancel(&s->restrict_timer);
+ list_del(&s->list);
+ free(s);
}
- default:
- break;
}
}
}
- return ret;
+ return 0;
}
-int handle_hld_message(void *agent, struct cmdu_cstruct *cmdu)
+int agent_process_assoc_cntl_tlv(void *agent,
+ struct tlv_client_assoc_control_req *p,
+ struct cmdu_buff *cmdu)
+{
+ return 0;
+ trace("agent: %s: --->\n", __func__);
+// struct agent *a = (struct agent *) agent;
+// int ret = 0, result = 0;
+// uint32_t match = 0, found = 0;
+// int i, j, k, l, m;
+// struct netif_fh *fh;
+// struct sta *s;
+// struct sta_error_response sta_resp[MAX_STA];
+// uint32_t count = 0;
+// uint32_t res = 0, present = 0;
+// uint8_t sta_list[30][6];
+//
+// for (m = 0; m < p->sta_list_cnt; m++)
+// memcpy(sta_list[m], p->client_assoc_ctrl_req_stas[m].addr, 6);
+//
+// fh = get_netif_by_bssid(a, p->bssid);
+// if (!fh) {
+// trace("[%s:%d] Error BSSID not present", __func__, __LINE__);
+// return -1;
+// }
+//
+// /*Here we first validate that the STA has been sent for
+// * blocking */
+// if (p->assoc_control == 0x00) {
+//
+// /*Check if the validity timer value is not zero*/
+// if (p->validity_period == 0) {
+// trace("[%s:%d] Error validity period is invalid\n", __func__, __LINE__);
+// return -1;
+// }
+//
+// /* Here we validate if the sta is associated with the bssid
+// * then we need to send an error TLV as the STA should not
+// * be associated with the bssid for which the blocking mode is
+// * set */
+//
+// for (l = 0; l < p->sta_list_cnt; l++) {
+// list_for_each_entry(s, &fh->stalist, list) {
+// trace("stalist :" MACFMT "\n",
+// MAC2STR(s->macaddr));
+// res = memcmp(s->macaddr, p->client_assoc_ctrl_req_stas[l].addr, 6);
+// if (res == 0) {
+// found = 1;
+// break;
+// }
+// }
+// if (found == 1) {
+// dbg("STA client already associated with the bssid!\n");
+// memcpy(sta_resp[count].sta_mac, p->client_assoc_ctrl_req_stas[l].addr, 6);
+// sta_resp[count].response = 0x01;
+// count++;
+// }
+// }
+// /*Here we need the logic to block the STA*/
+// ret = agent_send_restrict_sta(agent, p->sta_list_cnt,
+// sta_list, fh, p->assoc_control);
+// if (ret != 0) {
+// trace("[%s:%d] Error in agent_send_restrict_sta\n", __func__, __LINE__);
+// return -1;
+// }
+// /* Here we need to start the timer for which the sta is blocked as
+// * per the validity period also need to check if the sta is all
+// * in the blocking list */
+// ret = agent_check_start_validity_tmr(p->validity_period, p->sta_list_cnt, sta_list, fh);
+// if (ret != 0) {
+// trace("[%s:%d] Error in start validity tmr\n", __func__, __LINE__);
+// return -1;
+// }
+// } else if (p->assoc_control == 0x01) {
+//
+// /*Here we will ignore the validity timer value in the request
+// * as the validity timer value is ignored in the unblock case */
+// /*Here we need to check if the validity timer is already running
+// * in that case we need to stop the validity timer */
+// ret = agent_check_stop_validity_tmr(p->sta_list_cnt, sta_list, fh);
+// if (ret != 0) {
+// trace("[%s:%d] Error in stop validity tmr\n", __func__, __LINE__);
+// return -1;
+// }
+// /*Here we need the logic to unblock the STA */
+// ret = agent_send_restrict_sta(agent, p->sta_list_cnt,
+// sta_list, fh, p->assoc_control);
+// if (ret != 0) {
+// trace("[%s:%d] Error in agent_send_restrict_sta\n", __func__, __LINE__);
+// return -1;
+// }
+// } else {
+// trace("[%s:%d] Reserved mode is called", __func__, __LINE__);
+// }
+//
+//send_ack:
+// send_1905_acknowledge(agent, cmdu, sta_resp, count);
+// return ret;
+}
+
+int agent_process_steer_request_tlv(void *agent, uint8_t *p,
+ struct cmdu_buff *cmdu)
+{
+ trace("agent: %s: --->\n", __func__);
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// int ret = 0, result = 0;
+// int l, m;
+// struct netif_fh *fh;
+// struct sta *s;
+// struct sta_error_response sta_resp[MAX_STA];
+// uint32_t count = 0;
+// char wildcard_str[18] = { 0x0 };
+// uint8_t wildcard[6];
+// uint8_t wildcard_bssid[6];
+// uint32_t res = 0, present = 0;
+//
+// snprintf(wildcard_str, 18, "FF:FF:FF:FF:FF:FF");
+// hwaddr_aton(wildcard_str, wildcard);
+//
+// trace("request_mode: %d\n",
+// p->request_mode);
+//
+// if (p->request_mode == 0x00) {
+// /* Here we start the steer opportunity timer */
+// if (a->is_sta_steer_start == 1) {
+// trace("Error steering opportunity timer already running\n");
+// return 1;
+// }
+//
+// /**
+// * Here we need to check the three conditions that needs to be
+// * satisfied according to section 11.2
+// */
+// if (p->steer_opp_window == 0) {
+// trace("Error steering opportunity timer value is zero\n");
+// return 1;
+// }
+//
+// /**
+// * TODO check that the sta mac address is not included
+// * in the Local Steering Disallowed STA List in the Steering
+// * Policy TLV
+// */
+// a->is_sta_steer_start = 1;
+// a->sta_steerlist_count = 0;
+// uloop_timeout_set(&a->sta_steer_req_timer, p->steer_opp_window * 1000);
+//
+// } else if (p->request_mode != 0x01) {
+// trace("Invalid request mode");
+// return 1;
+// }
+//
+// /* TODO check the rcpi based steering rule section 11.3*/
+// agent_rcpi_steer();
+//
+// /**
+// * The src bssid is with which the STA is associated so
+// * Here we need to check that the STA is associated with the
+// * src_bssid according to section 11.1 of the steer mandate
+// * Here we trace the values
+// */
+// trace("btm_disassoc_imminent: %d\n",
+// p->btm_disassoc_imminent);
+// trace("btm_abridged: %d\n",
+// p->btm_abridged);
+// trace("reserved: %d\n",
+// p->reserved);
+// trace("steer_opp_window: %d\n",
+// p->steer_opp_window);
+// trace("btm_disassoc_timer: %d\n",
+// p->btm_disassoc_timer);
+// trace("sta_list_cnt: %d\n",
+// p->sta_list_cnt);
+// trace("target_bssid_list_cnt: %d\n",
+// p->target_bssid_list_cnt);
+// trace("src_bssid: " MACFMT "\n",
+// MAC2STR(p->bssid));
+//
+// /* Here we validate if the sta is associated with the src bssid */
+// fh = get_netif_by_bssid(a, p->bssid);
+// if (!fh) {
+// trace("[%s:%d] Error BSSID not present", __func__, __LINE__);
+// for (l = 0; l < p->sta_list_cnt; l++) {
+// memcpy(sta_resp[count].sta_mac, p->steering_req_macs[l].addr, 6);
+// sta_resp[count].response = 0x02;
+// count++;
+// goto send_ack;
+// }
+// }
+//
+// ret = validate_sta_bssid_assoc(fh, p, sta_resp, &count, a);
+// if (ret == -1)
+// goto send_ack;
+//
+// /* Number of STAs and BSSIDs are equal, map STA to BSSID */
+// if (p->sta_list_cnt > 0 && p->sta_list_cnt == p->target_bssid_list_cnt) {
+// for (l = 0; l < p->sta_list_cnt; l++) {
+// trace("sta_addr: " MACFMT "\n",
+// MAC2STR(p->steering_req_macs[l].addr));
+// trace("target bssid: " MACFMT "\n",
+// MAC2STR(p->steering_req_target_bssids[l].bssid));
+// trace("op_class: %d\n",
+// p->steering_req_target_bssids[l].op_class);
+// trace("channel: %d\n",
+// p->steering_req_target_bssids[l].channel);
+// /**
+// * Here we need to check that the STA is associated with the
+// * src bssid or not
+// */
+// present = 0;
+// trace("count of error code sta %d\n", count);
+// for (m = 0; m < count; m++) {
+// trace("steer mac: " MACFMT "\n",
+// MAC2STR(p->steering_req_macs[l].addr));
+// trace("sta error mac: " MACFMT "\n",
+// MAC2STR(sta_resp[m].sta_mac));
+// res = memcmp(p->steering_req_macs[l].addr,
+// sta_resp[m].sta_mac, 6);
+// if (res == 0) {
+// present = 1;
+// break;
+// }
+// }
+// if (present != 1) {
+// /*Here we call for transition of sta*/
+// ret = agent_transition_sta(a, p, fh, l, l);
+// }
+// }
+// }
+// /* Multiple STAs and single BSSID, send all STAs to same BSSID */
+// else if (p->sta_list_cnt > 0 && p->target_bssid_list_cnt == 1) {
+// trace("target bssid: " MACFMT "\n",
+// MAC2STR(p->steering_req_target_bssids[0].bssid));
+// trace("op_class: %d\n",
+// p->steering_req_target_bssids[0].op_class);
+// trace("channel: %d\n",
+// p->steering_req_target_bssids[0].channel);
+//
+// for (l = 0; l < p->sta_list_cnt; l++) {
+// /* Here we need to call the ubus method */
+// trace("sta_addr: " MACFMT "\n",
+// MAC2STR(p->steering_req_macs[l].addr));
+// /**
+// * Here we need to check that the STA is associated with
+// * the src bssid or not
+// */
+// present = 0;
+// for (m = 0; m < count; m++) {
+// res = memcmp(p->steering_req_macs[l].addr,
+// sta_resp[m].sta_mac, 6);
+// if (res == 0) {
+// present = 1;
+// break;
+// }
+// }
+// if (present != 1) {
+// /*Here we call for transition of sta*/
+// ret = agent_transition_sta(a, p, fh, l, 0);
+// }
+// }
+// }
+// /**
+// * No STA provided, Steering request applies to all associated STAs
+// * in the BSS, per policy setting.
+// */
+// else if (p->sta_list_cnt == 0 && p->target_bssid_list_cnt == 1) {
+// result = memcmp(p->steering_req_target_bssids[0].bssid, wildcard, 6);
+// if (result == 0) {
+// trace("[%s:%d] bssid id wildcard", __func__, __LINE__);
+// ret = agent_search_bssid_for_sta(a,
+// p->steering_req_macs[l].addr, wildcard_bssid, p->bssid);
+// if (ret != 0) {
+// list_for_each_entry(s, &fh->stalist, list) {
+// ret = agent_send_request_transition(
+// agent, s->macaddr,
+// fh, wildcard_bssid, 0);
+// }
+// }
+// } else {
+// list_for_each_entry(s, &fh->stalist, list) {
+// ret = agent_send_request_transition(
+// agent, s->macaddr,
+// fh, p->steering_req_target_bssids[0].bssid, 0);
+// }
+// }
+// }
+// /* No BSSID specified for the STAs */
+// else if (p->sta_list_cnt > 0 && p->target_bssid_list_cnt == 0) {
+// if (p->request_mode != 0x00) {
+// trace("[%s:%d]Error steer mandate target BSSID not present\n",
+// __func__, __LINE__);
+// return 1;
+// }
+// trace("[%s:%d] target BSSID not present\n", __func__, __LINE__);
+// for (l = 0; l < p->sta_list_cnt; l++) {
+// trace("sta_addr: " MACFMT "\n",
+// MAC2STR(p->steering_req_macs[l].addr));
+// /**
+// * Here we need to check that the STA is associated with the
+// * src bssid or not
+// */
+// present = 0;
+// for (m = 0; m < count; m++) {
+// res = memcmp(p->steering_req_macs[l].addr, sta_resp[m].sta_mac, 6);
+// if (res == 0) {
+// present = 1;
+// break;
+// }
+// }
+// if (present != 1) {
+// /**
+// * Here we need to get the bssids that are best
+// * for the STAs in case of steering opportunity
+// */
+// ret = agent_search_bssid_for_sta(a,
+// p->steering_req_macs[l].addr,
+// wildcard_bssid, p->bssid);
+// if (ret != 0)
+// ret = agent_send_request_transition(
+// agent, p->steering_req_macs[l].addr,
+// fh, wildcard_bssid, 0);
+// }
+// }
+// }
+// /* No BSSID or STAs */
+// else if (p->sta_list_cnt == 0 && p->target_bssid_list_cnt == 0) {
+// trace("[%s:%d] Error No STA and target BSSID present\n", __func__, __LINE__);
+// return 1;
+// } else {
+// trace("[%s:%d] Error condition\n", __func__, __LINE__);
+// return 1;
+// }
+//
+//send_ack:
+// send_1905_acknowledge(agent, cmdu, sta_resp, count);
+// return ret;
+}
+
+int handle_sta_steer_request(void *agent, struct cmdu_buff *cmdu)
+{
+ trace("%s: --->\n", __func__);
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// int ret = 0;
+// int i;
+// uint8_t *tlv = NULL;
+//
+// /* Here we first parse the steer request */
+// if (cmdu->num_tlvs != 0) {
+// for (i = 0; i < cmdu->num_tlvs; i++) {
+// tlv = (uint8_t *) cmdu->tlvs[i];
+// switch (*tlv) {
+// case MAP_TLV_STEERING_REQUEST:
+// {
+// struct tlv_steer_Req *p =
+// (struct tlv_steer_Req *)tlv;
+//
+// ret = agent_process_steer_request_tlv(agent,
+// p, cmdu);
+// break;
+// }
+////#ifdef profile2
+// case MAP_TLV_PROFILE2_STEERING_REQ:
+// {
+// //TODO here we need to call the request transmission for the
+// //STAs are Agile Multiband capable
+// struct tlv_profile2_steer_req *p =
+// (struct tlv_profile2_steer_req *)tlv;
+//
+// break;
+// }
+////#endif
+// default:
+// break;
+// }
+// }
+// }
+// return ret;
+}
+
+int agent_transition_sta(struct agent *a, uint8_t *p, struct netif_fh *fh,
+ int l, int m)
+{
+ return 0;
+// uint8_t wildcard[6];
+// uint8_t wildcard_bssid[6];
+// int result = 0;
+// char wildcard_str[18] = { 0x0 };
+// int ret = 0;
+//
+// trace("agent: %s: --->\n", __func__);
+// snprintf(wildcard_str, 18, "FF:FF:FF:FF:FF:FF");
+// hwaddr_aton(wildcard_str, wildcard);
+//
+// result = memcmp(p->steering_req_target_bssids[l].bssid, wildcard, 6);
+// if (result == 0) {
+// /**
+// * code to search bssid as the bssid is a
+// * wildcard
+// */
+// trace("[%s:%d] bssid id wildcard\n",
+// __func__, __LINE__);
+// ret = agent_search_bssid_for_sta(a,
+// p->steering_req_macs[l].addr,
+// wildcard_bssid, p->bssid);
+// if (ret == 0)
+// ret = agent_send_request_transition(a,
+// p->steering_req_macs[l].addr,
+// fh, wildcard_bssid, 0);
+// } else {
+// ret = agent_send_request_transition(a,
+// p->steering_req_macs[l].addr,
+// fh, p->steering_req_target_bssids[m].bssid, 0);
+// }
+// return 0;
+}
+
+int handle_sta_assoc_control_request(void *agent, struct cmdu_buff *cmdu)
+{
+ trace("%s: --->\n", __func__);
+ return 0;
+// struct agent *a = (struct agent *) agent;
+// int ret = 0;
+// int i;
+// uint8_t *tlv = NULL;
+//
+// /* Here we first parse the steer request */
+// if (cmdu->num_tlvs != 0) {
+// for (i = 0; i < cmdu->num_tlvs; i++) {
+// tlv = (uint8_t *) cmdu->tlvs[i];
+// switch (*tlv) {
+// case MAP_TLV_CLIENT_ASSOCIATION_CONTROL_REQUEST:
+// {
+// struct tlv_client_assoc_control_req *p =
+// (struct tlv_client_assoc_control_req *)tlv;
+//
+// ret = agent_process_assoc_cntl_tlv(agent,
+// p, cmdu);
+// }
+// default:
+// break;
+// }
+// }
+// }
+// return ret;
+}
+
+int handle_hld_message(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
int handle_backhaul_sta_steer_request(void *agent,
- struct cmdu_cstruct *rec_cmdu)
+ struct cmdu_buff *rx_cmdu)
{
trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- struct tlv_backhaul_steer_resp *p;
- struct tlv_backhaul_steer_req *req;
- struct cmdu_cstruct *cmdu;
- struct netif_bk *bk;
-
- req = (struct tlv_backhaul_steer_req *) extract_tlv_by_type(rec_cmdu,
- MAP_TLV_BACKHAUL_STEERING_REQUEST);
- if (!req)
- return -1;
-
- bk = find_bkhaul_by_bssid(a, req->addr);
- if (!bk)
- return -1;
-
- cmdu = (struct cmdu_cstruct *)calloc(1,
- sizeof(struct cmdu_cstruct));
- if (!cmdu) {
- fprintf(stderr, "Out of memory!\n");
- return -1;
- }
-
- cmdu->message_type = CMDU_BACKHAUL_STEER_RESPONSE;
- memcpy(cmdu->origin, rec_cmdu->origin, 6);
- cmdu->message_id = rec_cmdu->message_id;
- strncpy(cmdu->intf_name, rec_cmdu->intf_name, sizeof(cmdu->intf_name));
-
- p = calloc(1, sizeof(struct tlv_backhaul_steer_resp));
- if (!p)
- goto out_cmdu;
-
- p->tlv_type = MAP_TLV_BACKHAUL_STEERING_RESPONSE;
- memcpy(p->bssid, req->bssid, 6);
- memcpy(p->addr, req->addr, 6);
-
- cmdu->num_tlvs++;
- cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
- if (!cmdu->tlvs)
- goto out_p;
-
- cmdu->tlvs[0] = (uint8_t *) p;
-
- if (bk->bsta_steer.cmdu)
- map_free_cmdu(bk->bsta_steer.cmdu);
- bk->bsta_steer.cmdu = cmdu;
-
- wifi_set_iface_bssid(bk->name, req->bssid);
- uloop_timeout_set(&bk->connect_timer, BSTA_STEER_TIMEOUT);
return 0;
-out_p:
- free(p);
-out_cmdu:
- free(cmdu);
- return -1;
+// struct agent *a = (struct agent *) agent;
+// struct tlv_backhaul_steer_resp *p;
+// struct tlv_backhaul_steer_req *req;
+// struct cmdu_cstruct *cmdu;
+// struct netif_bk *bk;
+//
+// req = (struct tlv_backhaul_steer_req *) extract_tlv_by_type(rx_cmdu,
+// MAP_TLV_BACKHAUL_STEERING_REQUEST);
+// if (!req)
+// return -1;
+//
+// bk = find_bkhaul_by_bssid(a, req->addr);
+// if (!bk)
+// return -1;
+//
+// cmdu = (struct cmdu_cstruct *)calloc(1,
+// sizeof(struct cmdu_cstruct));
+// if (!cmdu) {
+// fprintf(stderr, "Out of memory!\n");
+// return -1;
+// }
+//
+// cmdu->message_type = CMDU_BACKHAUL_STEER_RESPONSE;
+// memcpy(cmdu->origin, rx_cmdu->origin, 6);
+// cmdu->message_id = rx_cmdu->message_id;
+// strncpy(cmdu->intf_name, rx_cmdu->intf_name, sizeof(cmdu->intf_name));
+//
+// p = calloc(1, sizeof(struct tlv_backhaul_steer_resp));
+// if (!p)
+// goto out_cmdu;
+//
+// p->tlv_type = MAP_TLV_BACKHAUL_STEERING_RESPONSE;
+// memcpy(p->bssid, req->bssid, 6);
+// memcpy(p->addr, req->addr, 6);
+//
+// cmdu->num_tlvs++;
+// cmdu->tlvs = (uint8_t **)calloc(cmdu->num_tlvs, sizeof(uint8_t *));
+// if (!cmdu->tlvs)
+// goto out_p;
+//
+// cmdu->tlvs[0] = (uint8_t *) p;
+//
+// if (bk->bsta_steer.cmdu)
+// map_free_cmdu(bk->bsta_steer.cmdu);
+// bk->bsta_steer.cmdu = cmdu;
+//
+// wifi_set_iface_bssid(bk->name, req->bssid);
+// uloop_timeout_set(&bk->connect_timer, BSTA_STEER_TIMEOUT);
+// return 0;
+//out_p:
+// free(p);
+//out_cmdu:
+// free(cmdu);
+// return -1;
}
void free_scanresults_neighbors(struct wifi_radio_element *re)
{
- struct wifi_scanres_element *scanres_el;
- int j;
-
- scanres_el = re->scanlist;
- if (!scanres_el)
- return;
-
- for (j = 0; j < scanres_el->num_opclass_scanned; j++) {
- int k;
- struct wifi_scanres_opclass_element *opclass = &scanres_el->opclass_scanlist[j];
-
- for (k = 0; k < opclass->num_channels_scanned; k++) {
- struct wifi_scanres_channel_element *ch_el = &opclass->channel_scanlist[k];
-
- if (ch_el->nbrlist)
- free(ch_el->nbrlist);
- ch_el->nbrlist = NULL;
- ch_el->num_neighbors = 0;
- }
- }
+// struct wifi_scanres_element *scanres_el;
+// int j;
+//
+// scanres_el = re->scanlist;
+// if (!scanres_el)
+// return;
+//
+// for (j = 0; j < scanres_el->num_opclass_scanned; j++) {
+// int k;
+// struct wifi_scanres_opclass_element *opclass = &scanres_el->opclass_scanlist[j];
+//
+// for (k = 0; k < opclass->num_channels_scanned; k++) {
+// struct wifi_scanres_channel_element *ch_el = &opclass->channel_scanlist[k];
+//
+// if (ch_el->nbrlist)
+// free(ch_el->nbrlist);
+// ch_el->nbrlist = NULL;
+// ch_el->num_neighbors = 0;
+// }
+// }
}
bool scan_supported(struct agent *a, struct tlv_ch_scan_req *query)
{
- struct tlv_ch_scan_cap *p = agent_gen_ch_scan_cap(a);
- /* m for numeration of radios in query */
- /* ri for numeration of radios in agent */
- int m, ri, ch, i, j;
- uint8_t query_channel;
- for (m = 0; m < query->nbr_radios; m++) {
- ri = wifi_get_radio_index_by_mac(a, query->radio_data[m].radio_id);
- if (query->radio_data[m].op_class_data->nbr_ch == 0)
- return 1;
-
- query_channel = query->radio_data[m].op_class_data->ch[0];
- /* the same radio and all op_class/ch in cap */
- for (i = 0; i < p->radio[ri].nbr_op_classes; i++) {
- for (j = 0; j < p->radio[ri].op_class[i].nbr_ch; j++)
- if (p->radio[ri].op_class[i].ch[j] == query_channel)
- break; /* found the op class with index i */
- break;
- }
-
- if (j == p->radio[ri].op_class[i].nbr_ch)
- return 0;
-
- /* the rest of the channels */
- for (ch = 1; ch < query->radio_data[m].op_class_data->nbr_ch; ch++) {
- query_channel = query->radio_data[m].op_class_data->ch[ch];
- for (j = 0; j < p->radio[ri].op_class[i].nbr_ch; j++)
- if (p->radio[ri].op_class[i].ch[j] == query_channel)
- goto next_ch;
- return 0;
-next_ch:
- continue;
- }
- }
- return 1;
+ return -1;
+// struct tlv_ch_scan_cap *p = agent_gen_ch_scan_cap(a);
+// /* m for numeration of radios in query */
+// /* ri for numeration of radios in agent */
+// int m, ri, ch, i, j;
+// uint8_t query_channel;
+// for (m = 0; m < query->nbr_radios; m++) {
+// ri = wifi_get_radio_index_by_mac(a, query->radio_data[m].radio_id);
+// if (query->radio_data[m].op_class_data->nbr_ch == 0)
+// return 1;
+//
+// query_channel = query->radio_data[m].op_class_data->ch[0];
+// /* the same radio and all op_class/ch in cap */
+// for (i = 0; i < p->radio[ri].nbr_op_classes; i++) {
+// for (j = 0; j < p->radio[ri].op_class[i].nbr_ch; j++)
+// if (p->radio[ri].op_class[i].ch[j] == query_channel)
+// break; /* found the op class with index i */
+// break;
+// }
+//
+// if (j == p->radio[ri].op_class[i].nbr_ch)
+// return 0;
+//
+// /* the rest of the channels */
+// for (ch = 1; ch < query->radio_data[m].op_class_data->nbr_ch; ch++) {
+// query_channel = query->radio_data[m].op_class_data->ch[ch];
+// for (j = 0; j < p->radio[ri].op_class[i].nbr_ch; j++)
+// if (p->radio[ri].op_class[i].ch[j] == query_channel)
+// goto next_ch;
+// return 0;
+//next_ch:
+// continue;
+// }
+// }
+// return 1;
}
bool scan_too_soon(struct agent *a, struct tlv_ch_scan_req *query)
{
- int i, ri;
- struct tlv_ch_scan_cap *p = agent_gen_ch_scan_cap(a);
- time_t now;
-
- time(&now);
- for (i = 0; i < query->nbr_radios; i++) {
- ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
- if (difftime(now, a->last_scan_time) < p->radio[ri].min_scan_interval)
- return 1;
- }
- return 0;
+ return 1;
+// int i, ri;
+// struct tlv_ch_scan_cap *p = agent_gen_ch_scan_cap(a);
+// time_t now;
+//
+// time(&now);
+// for (i = 0; i < query->nbr_radios; i++) {
+// ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
+// if (difftime(now, a->last_scan_time) < p->radio[ri].min_scan_interval)
+// return 1;
+// }
+// return 0;
}
void deep_copy_cmdu_for_agent(void *agent, struct cmdu_cstruct *cmdu)
{
trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- struct cmdu_cstruct *cmdu_copy = NULL;
- uint8_t *ss = NULL; /* binary cmdu->tlvs */
- char *tlv_str = NULL; /* string cmdu->tlvs */
- uint8_t *tlvs = NULL; /* binary resulting tlvs */
- char endtlvstr[7] = "000000"; /* end_of_mes tlv string */
- char *restlvstr = NULL; /* string resulting tlvs */
- uint16_t len, leng;
-
- /* Get the string value of cmdu->tlvs */
- if (cmdu->num_tlvs > 0) {
- len = 0;
- ss = map_put_tlv_cstruct(cmdu->tlvs[0], &len);
- if (!ss)
- return;
- tlv_str = (char *)calloc((2 * len) + 1,
- sizeof(char));
- if (!tlv_str) {
- dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
- goto fail_tlv_str;
- }
- btostr(ss, len, tlv_str);
- }
-
- /* Get resulting tlvs string */
- const size_t len1 = strlen(tlv_str);
- const size_t len2 = strlen(endtlvstr);
- restlvstr = malloc(len1 + len2 + 1);
- if (!restlvstr) {
- dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
- goto fail_restlvstr;
- }
- memcpy(restlvstr, tlv_str, len1);
- memcpy(restlvstr + len1, endtlvstr, len2 + 1);
-
- /* Resulting tlvs string to binary value */
- leng = len1 + len2;
- leng = (leng - 1) / 2;
- tlvs = calloc(leng, sizeof(uint8_t));
- if (!tlvs) {
- dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
- goto fail_tlvs;
- }
- strtob(restlvstr, leng, tlvs);
-
- /* Deep copy of cmdu */
- cmdu_copy = map_build_cmdu(cmdu->message_type,
- cmdu->message_id, cmdu->intf_name, cmdu->origin, tlvs);
- if (cmdu_copy) {
- fprintf(stderr, "agent: %s: map_build_cmdu() successful!\n", __func__);
- } else {
- fprintf(stderr, "agent: %s: map_build_cmdu() failed!\n", __func__);
- goto fail_cmdu_copy;
- }
-
- /* Saving the cmdu with the agent */
- a->req_channel_scan_cmdu = cmdu_copy;
- // dbg("DONE ADDING CMDU TO AGENT\n");
-
-fail_cmdu_copy:
- free(tlvs);
-fail_tlvs:
- free(restlvstr);
-fail_restlvstr:
- free(tlv_str);
-fail_tlv_str:
- free(ss);
+// struct agent *a = (struct agent *) agent;
+// struct cmdu_cstruct *cmdu_copy = NULL;
+// uint8_t *ss = NULL; /* binary cmdu->tlvs */
+// char *tlv_str = NULL; /* string cmdu->tlvs */
+// uint8_t *tlvs = NULL; /* binary resulting tlvs */
+// char endtlvstr[7] = "000000"; /* end_of_mes tlv string */
+// char *restlvstr = NULL; /* string resulting tlvs */
+// uint16_t len, leng;
+//
+// /* Get the string value of cmdu->tlvs */
+// if (cmdu->num_tlvs > 0) {
+// len = 0;
+// ss = map_put_tlv_cstruct(cmdu->tlvs[0], &len);
+// if (!ss)
+// return;
+// tlv_str = (char *)calloc((2 * len) + 1,
+// sizeof(char));
+// if (!tlv_str) {
+// dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
+// goto fail_tlv_str;
+// }
+// btostr(ss, len, tlv_str);
+// }
+//
+// /* Get resulting tlvs string */
+// const size_t len1 = strlen(tlv_str);
+// const size_t len2 = strlen(endtlvstr);
+// restlvstr = malloc(len1 + len2 + 1);
+// if (!restlvstr) {
+// dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
+// goto fail_restlvstr;
+// }
+// memcpy(restlvstr, tlv_str, len1);
+// memcpy(restlvstr + len1, endtlvstr, len2 + 1);
+//
+// /* Resulting tlvs string to binary value */
+// leng = len1 + len2;
+// leng = (leng - 1) / 2;
+// tlvs = calloc(leng, sizeof(uint8_t));
+// if (!tlvs) {
+// dbg("|%s:%d| out of memory!\n", __func__, __LINE__);
+// goto fail_tlvs;
+// }
+// strtob(restlvstr, leng, tlvs);
+//
+// /* Deep copy of cmdu */
+// cmdu_copy = map_build_cmdu(cmdu->message_type,
+// cmdu->message_id, cmdu->intf_name, cmdu->origin, tlvs);
+// if (cmdu_copy) {
+// fprintf(stderr, "agent: %s: map_build_cmdu() successful!\n", __func__);
+// } else {
+// fprintf(stderr, "agent: %s: map_build_cmdu() failed!\n", __func__);
+// goto fail_cmdu_copy;
+// }
+//
+// /* Saving the cmdu with the agent */
+// a->req_channel_scan_cmdu = cmdu_copy;
+// // dbg("DONE ADDING CMDU TO AGENT\n");
+//
+//fail_cmdu_copy:
+// free(tlvs);
+//fail_tlvs:
+// free(restlvstr);
+//fail_restlvstr:
+// free(tlv_str);
+//fail_tlv_str:
+// free(ss);
}
int handle_channel_scan_request(void *agent, struct cmdu_cstruct *cmdu)
{
trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- uint16_t tlv_index = 0;
- int i, ri;
- /* The response cmdu */
- struct cmdu_cstruct *cmdu_data = NULL;
- /* For calling the ubus method scan */
- char r_objname[32] = {0};
- const char *r_fmt = "wifi.radio.%s";
- char *radio_name;
- wifi_object_t r_wobj = WIFI_OBJECT_INVALID;
-
- /* The received TLV */
- uint8_t *tmp = NULL;
-
- tmp = cmdu->tlvs[0];
- if (*tmp != MAP_TLV_CHANNEL_SCAN_REQ) {
- dbg("Wrong received TLV type!\n");
- time(&a->last_scan_time);
- return -1;
- }
- struct tlv_ch_scan_req *query = (struct tlv_ch_scan_req *)tmp;
-
- if (a->req_channel_scan_cmdu != NULL) {
- /* Cancel the timer of available time (5min) */
- uloop_timeout_cancel(&a->available_scan_timer);
- dbg("[Status code] ONGOING SCAN ABORTED\n\n");
- a->status_code = CH_SCAN_STATUS_SCAN_ABORTED; // 0x05 //
- /* Generate the response cmdu */
- cmdu_data = agent_gen_ch_scan_response(a, a->req_channel_scan_cmdu);
- if (!cmdu_data)
- return -1;
- /* Send the response cmdu */
- agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- a->req_channel_scan_cmdu = NULL;
- map_free_cmdu(a->req_channel_scan_cmdu);
- a->ignore_scan_finished_event = query->nbr_radios;
- }
-
- if (!scan_supported(a, query)) {
- dbg("[Status code] SCAN NOT SUPPORTED\n\n");
- a->status_code = CH_SCAN_STATUS_SCAN_NOT_SUPPORTED; // 0x01 //
- /* Generate the response cmdu */
- cmdu_data = agent_gen_ch_scan_response(a, cmdu);
- if (!cmdu_data) {
- time(&a->last_scan_time);
- return -1;
- }
- /* Send the response cmdu */
- agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- a->status_code = CH_SCAN_STATUS_SUCCESS;
- time(&a->last_scan_time);
- return 0;
- }
-
- if (scan_too_soon(a, query)) {
- dbg("[Status code] SCAN TOO SOON\n\n");
- a->status_code = CH_SCAN_STATUS_TOO_SOON; // 0x02 //
- /* Generate the response cmdu */
- cmdu_data = agent_gen_ch_scan_response(a, cmdu);
- if (!cmdu_data) {
- time(&a->last_scan_time);
- return -1;
- }
- /* Send the response cmdu */
- agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- a->status_code = CH_SCAN_STATUS_SUCCESS;
- time(&a->last_scan_time);
- return 0;
- }
- time(&a->last_scan_time);
-
- /* Requested channel scan */
- for (i = 0; i < query->nbr_radios; i++) {
- radio_name = wifi_get_radio_by_mac(a, query->radio_data[i].radio_id);
- if (!radio_name)
- continue;
-
- snprintf(r_objname, 31, r_fmt, radio_name);
- r_wobj = ubus_get_object(a->ubus_ctx, r_objname);
- if (r_wobj == WIFI_OBJECT_INVALID)
- continue;
-
- ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
-
- free_scanresults_neighbors(&a->radios[ri]);
- trace("Scaning radio %s neighbors...on the request of mid: %d\n",
- wifi_get_radio_by_mac(a, query->radio_data[i].radio_id), cmdu->message_id);
- if (!ubus_call_object(a, r_wobj, "scan", NULL, &a->radios[ri])) {
- uloop_timeout_set(&a->available_scan_timer, 300000); // (5 min) // 0x04 //
- trace("Scaning started successfully.\n");
- deep_copy_cmdu_for_agent(a, cmdu);
- } else {
- /* If the reason is an ongoing scan */
- if (a->status_code == CH_SCAN_STATUS_SCAN_ABORTED) {
- /* Reset the timer of available time (5min) */
- uloop_timeout_set(&a->available_scan_timer, 300000);
- dbg("[Status code] ONGOING SCAN ABORTED\n\n");
- a->ignore_scan_finished_event = 0;
- deep_copy_cmdu_for_agent(a, cmdu);
- a->status_code = CH_SCAN_STATUS_SUCCESS;
- break;
- } else {
- dbg("[Status code] RADIO BUSY\n\n");
- a->status_code = CH_SCAN_STATUS_TOO_BUSY; // 0x03 //
- /* Generate the response cmdu */
- cmdu_data = agent_gen_ch_scan_response(a, cmdu);
- if (!cmdu_data) {
- return -1;
- }
- /* Send the response cmdu */
- agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- a->status_code = CH_SCAN_STATUS_SUCCESS;
- break;
- }
- }
- }
return 0;
+// struct agent *a = (struct agent *) agent;
+// uint16_t tlv_index = 0;
+// int i, ri;
+// /* The response cmdu */
+// struct cmdu_cstruct *cmdu_data = NULL;
+// /* For calling the ubus method scan */
+// char r_objname[32] = {0};
+// const char *r_fmt = "wifi.radio.%s";
+// char *radio_name;
+// wifi_object_t r_wobj = WIFI_OBJECT_INVALID;
+//
+// /* The received TLV */
+// uint8_t *tmp = NULL;
+//
+// tmp = cmdu->tlvs[0];
+// if (*tmp != MAP_TLV_CHANNEL_SCAN_REQ) {
+// dbg("Wrong received TLV type!\n");
+// time(&a->last_scan_time);
+// return -1;
+// }
+// struct tlv_ch_scan_req *query = (struct tlv_ch_scan_req *)tmp;
+//
+// if (a->req_channel_scan_cmdu != NULL) {
+// /* Cancel the timer of available time (5min) */
+// uloop_timeout_cancel(&a->available_scan_timer);
+// dbg("[Status code] ONGOING SCAN ABORTED\n\n");
+// a->status_code = CH_SCAN_STATUS_SCAN_ABORTED; // 0x05 //
+// /* Generate the response cmdu */
+// cmdu_data = agent_gen_ch_scan_response(a, a->req_channel_scan_cmdu);
+// if (!cmdu_data)
+// return -1;
+// /* Send the response cmdu */
+// agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// a->req_channel_scan_cmdu = NULL;
+// map_free_cmdu(a->req_channel_scan_cmdu);
+// a->ignore_scan_finished_event = query->nbr_radios;
+// }
+//
+// if (!scan_supported(a, query)) {
+// dbg("[Status code] SCAN NOT SUPPORTED\n\n");
+// a->status_code = CH_SCAN_STATUS_SCAN_NOT_SUPPORTED; // 0x01 //
+// /* Generate the response cmdu */
+// cmdu_data = agent_gen_ch_scan_response(a, cmdu);
+// if (!cmdu_data) {
+// time(&a->last_scan_time);
+// return -1;
+// }
+// /* Send the response cmdu */
+// agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// a->status_code = CH_SCAN_STATUS_SUCCESS;
+// time(&a->last_scan_time);
+// return 0;
+// }
+//
+// if (scan_too_soon(a, query)) {
+// dbg("[Status code] SCAN TOO SOON\n\n");
+// a->status_code = CH_SCAN_STATUS_TOO_SOON; // 0x02 //
+// /* Generate the response cmdu */
+// cmdu_data = agent_gen_ch_scan_response(a, cmdu);
+// if (!cmdu_data) {
+// time(&a->last_scan_time);
+// return -1;
+// }
+// /* Send the response cmdu */
+// agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// a->status_code = CH_SCAN_STATUS_SUCCESS;
+// time(&a->last_scan_time);
+// return 0;
+// }
+// time(&a->last_scan_time);
+//
+// /* Requested channel scan */
+// for (i = 0; i < query->nbr_radios; i++) {
+// radio_name = wifi_get_radio_by_mac(a, query->radio_data[i].radio_id);
+// if (!radio_name)
+// continue;
+//
+// snprintf(r_objname, 31, r_fmt, radio_name);
+// r_wobj = ubus_get_object(a->ubus_ctx, r_objname);
+// if (r_wobj == WIFI_OBJECT_INVALID)
+// continue;
+//
+// ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
+//
+// free_scanresults_neighbors(&a->radios[ri]);
+// trace("Scaning radio %s neighbors...on the request of mid: %d\n",
+// wifi_get_radio_by_mac(a, query->radio_data[i].radio_id), cmdu->message_id);
+// if (!ubus_call_object(a, r_wobj, "scan", NULL, &a->radios[ri])) {
+// uloop_timeout_set(&a->available_scan_timer, 300000); // (5 min) // 0x04 //
+// trace("Scaning started successfully.\n");
+// deep_copy_cmdu_for_agent(a, cmdu);
+// } else {
+// /* If the reason is an ongoing scan */
+// if (a->status_code == CH_SCAN_STATUS_SCAN_ABORTED) {
+// /* Reset the timer of available time (5min) */
+// uloop_timeout_set(&a->available_scan_timer, 300000);
+// dbg("[Status code] ONGOING SCAN ABORTED\n\n");
+// a->ignore_scan_finished_event = 0;
+// deep_copy_cmdu_for_agent(a, cmdu);
+// a->status_code = CH_SCAN_STATUS_SUCCESS;
+// break;
+// } else {
+// dbg("[Status code] RADIO BUSY\n\n");
+// a->status_code = CH_SCAN_STATUS_TOO_BUSY; // 0x03 //
+// /* Generate the response cmdu */
+// cmdu_data = agent_gen_ch_scan_response(a, cmdu);
+// if (!cmdu_data) {
+// return -1;
+// }
+// /* Send the response cmdu */
+// agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// a->status_code = CH_SCAN_STATUS_SUCCESS;
+// break;
+// }
+// }
+// }
+// return 0;
}
bool all_channel_scanned(struct agent *a, struct tlv_ch_scan_req *query)
{
- int ri, i;
- for (i = 0; i < query->nbr_radios; i++) {
- ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
- if (!a->radios[ri].scanned)
- return 0;
- }
- return 1;
+ return 0;
+// int ri, i;
+// for (i = 0; i < query->nbr_radios; i++) {
+// ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
+// if (!a->radios[ri].scanned)
+// return 0;
+// }
+// return 1;
}
int handle_wifi_radio_scan_finished(void *agent)
{
- // If the scan was not complited in available time (0x04)
- struct agent *a = (struct agent *) agent;
- int ret, ri, i;
- if (a->ignore_scan_finished_event) {
- for (i = 0; i < WIFI_DEVICE_MAX_NUM; i++)
- a->radios[i].scanned = 0;
- a->ignore_scan_finished_event--;
- return -1;
- }
-
- trace("%s ---> scan_finished\n", __func__);
- uloop_timeout_cancel(&a->available_scan_timer);
-
- /* The received (request) cmdu */
- struct cmdu_cstruct *cmdu = a->req_channel_scan_cmdu;
- /* The response cmdu */
- struct cmdu_cstruct *cmdu_data = NULL;
- /* For parsing the ubus method scanresults */
- char r_objname[32] = {0};
- const char *r_fmt = "wifi.radio.%s";
- wifi_object_t r_wobj = WIFI_OBJECT_INVALID;
-
- /* The received TLV */
- uint8_t *tmp = NULL;
-
- tmp = cmdu->tlvs[0];
- if (*tmp != MAP_TLV_CHANNEL_SCAN_REQ) {
- dbg("Wrong received TLV type!\n");
- return -1;
- }
- struct tlv_ch_scan_req *query = (struct tlv_ch_scan_req *)tmp;
-
- /* Response only when all channels are scanned */
- if (!all_channel_scanned(a, query)) {
- dbg("Not all radios have been scanned.\n");
- return -1;
- }
- dbg("All radios have been scanned! mid: %d\n", a->req_channel_scan_cmdu->message_id);
-
- /* Parse channel scanresults */
- for (i = 0; i < query->nbr_radios; i++) {
- snprintf(r_objname, 31, r_fmt, wifi_get_radio_by_mac(a, query->radio_data[i].radio_id));
- r_wobj = ubus_get_object(a->ubus_ctx, r_objname);
- if (r_wobj == WIFI_OBJECT_INVALID)
- continue;
-
- ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
-
- trace("...done scanning radio %s neighbors.\n",
- wifi_get_radio_by_mac(a, query->radio_data[i].radio_id));
- ubus_call_object(a, r_wobj, "scanresults", parse_scanresults, &a->radios[ri]);
- a->radios[ri].scanned = 0;
- }
-
- /* Generate cmdu */
- cmdu_data = agent_gen_ch_scan_response(a, cmdu);
- if (!cmdu_data)
- return -1;
-
- /* Send cmdu */
- ret = agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- map_free_cmdu(a->req_channel_scan_cmdu);
- a->req_channel_scan_cmdu = NULL;
- return ret;
-}
-
-
-int handle_cac_request(void *agent, struct cmdu_cstruct *cmdu)
+ return -1;
+// // If the scan was not complited in available time (0x04)
+// struct agent *a = (struct agent *) agent;
+// int ret, ri, i;
+// if (a->ignore_scan_finished_event) {
+// for (i = 0; i < WIFI_DEVICE_MAX_NUM; i++)
+// a->radios[i].scanned = 0;
+// a->ignore_scan_finished_event--;
+// return -1;
+// }
+//
+// trace("%s ---> scan_finished\n", __func__);
+// uloop_timeout_cancel(&a->available_scan_timer);
+//
+// /* The received (request) cmdu */
+// struct cmdu_cstruct *cmdu = a->req_channel_scan_cmdu;
+// /* The response cmdu */
+// struct cmdu_cstruct *cmdu_data = NULL;
+// /* For parsing the ubus method scanresults */
+// char r_objname[32] = {0};
+// const char *r_fmt = "wifi.radio.%s";
+// wifi_object_t r_wobj = WIFI_OBJECT_INVALID;
+//
+// /* The received TLV */
+// uint8_t *tmp = NULL;
+//
+// tmp = cmdu->tlvs[0];
+// if (*tmp != MAP_TLV_CHANNEL_SCAN_REQ) {
+// dbg("Wrong received TLV type!\n");
+// return -1;
+// }
+// struct tlv_ch_scan_req *query = (struct tlv_ch_scan_req *)tmp;
+//
+// /* Response only when all channels are scanned */
+// if (!all_channel_scanned(a, query)) {
+// dbg("Not all radios have been scanned.\n");
+// return -1;
+// }
+// dbg("All radios have been scanned! mid: %d\n", a->req_channel_scan_cmdu->message_id);
+//
+// /* Parse channel scanresults */
+// for (i = 0; i < query->nbr_radios; i++) {
+// snprintf(r_objname, 31, r_fmt, wifi_get_radio_by_mac(a, query->radio_data[i].radio_id));
+// r_wobj = ubus_get_object(a->ubus_ctx, r_objname);
+// if (r_wobj == WIFI_OBJECT_INVALID)
+// continue;
+//
+// ri = wifi_get_radio_index_by_mac(a, query->radio_data[i].radio_id);
+//
+// trace("...done scanning radio %s neighbors.\n",
+// wifi_get_radio_by_mac(a, query->radio_data[i].radio_id));
+// ubus_call_object(a, r_wobj, "scanresults", parse_scanresults, &a->radios[ri]);
+// a->radios[ri].scanned = 0;
+// }
+//
+// /* Generate cmdu */
+// cmdu_data = agent_gen_ch_scan_response(a, cmdu);
+// if (!cmdu_data)
+// return -1;
+//
+// /* Send cmdu */
+// ret = agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// map_free_cmdu(a->req_channel_scan_cmdu);
+// a->req_channel_scan_cmdu = NULL;
+// return ret;
+}
+
+
+int handle_cac_request(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
-int handle_cac_stop(void *agent, struct cmdu_cstruct *cmdu)
+int handle_cac_stop(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
}
-int handle_error_response(void *agent, struct cmdu_cstruct *cmdu)
+int handle_error_response(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
@@ -3499,71 +3590,74 @@ int prepare_tunneled_message(void *agent,
uint8_t protocol, const char *framestr)
{
trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *)agent;
- struct cmdu_cstruct *cmdu;
- uint8_t *frame;
- uint8_t sta_mac[6] = { 0 };
- int len;
- int index;
-
- if (!framestr)
- return -1;
-
- /* TODO/FIXME: add other protocol
- * checking (BTM/WNM/ANQP)
- * as of now checking assoc/reassoc
- * type only.
- */
- if ((protocol != 0x00) && (protocol != 0x01))
- return -1;
-
- len = strlen(framestr);
- len = (len - 1) / 2;
- frame = calloc(len, sizeof(uint8_t));
- if (!frame)
- return -1;
-
- if (!strtob((char *)framestr, len, frame))
- goto error;
-
- index = 2 + 2 + 6; /* sta mac index */
- memcpy(sta_mac, frame + index, 6);
-
- cmdu = agent_gen_tunneled_msg(a, protocol, sta_mac,
- len, frame);
- if (!cmdu)
- goto error;
-
- agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
- free(frame);
-
return 0;
-
-error:
- free(frame);
-
- return -1;
-}
-
-int handle_backhaul_sta_caps_query(void *agent, struct cmdu_cstruct *cmdu)
+// struct agent *a = (struct agent *)agent;
+// struct cmdu_cstruct *cmdu;
+// uint8_t *frame;
+// uint8_t sta_mac[6] = { 0 };
+// int len;
+// int index;
+//
+// if (!framestr)
+// return -1;
+//
+// /* TODO/FIXME: add other protocol
+// * checking (BTM/WNM/ANQP)
+// * as of now checking assoc/reassoc
+// * type only.
+// */
+// if ((protocol != 0x00) && (protocol != 0x01))
+// return -1;
+//
+// len = strlen(framestr);
+// len = (len - 1) / 2;
+// frame = calloc(len, sizeof(uint8_t));
+// if (!frame)
+// return -1;
+//
+// if (!strtob((char *)framestr, len, frame))
+// goto error;
+//
+// index = 2 + 2 + 6; /* sta mac index */
+// memcpy(sta_mac, frame + index, 6);
+//
+// cmdu = agent_gen_tunneled_msg(a, protocol, sta_mac,
+// len, frame);
+// if (!cmdu)
+// goto error;
+//
+// agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+// free(frame);
+//
+// return 0;
+//
+//error:
+// free(frame);
+//
+// return -1;
+}
+
+int handle_backhaul_sta_caps_query(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
- struct agent *a = (struct agent *) agent;
- struct cmdu_cstruct *cmdu_data;
- int ret;
-
- cmdu_data = agent_gen_bk_caps_response(a,cmdu);
- if (!cmdu_data)
- return -1;
-
- // Send cmdu
- ret = agent_send_cmdu(a, cmdu_data);
- map_free_cmdu(cmdu_data);
- return ret;
-}
-
-int handle_backhaul_sta_caps_report(void *agent, struct cmdu_cstruct *cmdu)
+ return 0;
+// trace("%s: --->\n", __func__);
+// struct agent *a = (struct agent *) agent;
+// struct cmdu_cstruct *cmdu_data;
+// int ret;
+//
+// cmdu_data = agent_gen_bk_caps_response(a,cmdu);
+// if (!cmdu_data)
+// return -1;
+//
+// // Send cmdu
+// ret = agent_send_cmdu(a, cmdu_data);
+// map_free_cmdu(cmdu_data);
+// return ret;
+}
+
+int handle_backhaul_sta_caps_report(void *agent, struct cmdu_buff *cmdu)
{
trace("%s: --->\n", __func__);
return 0;
@@ -3766,6 +3860,7 @@ static void send_cmdu_cb(struct ubus_request *req,
mid = (uint16_t *)req->priv;
str = (char *)blobmsg_format_json_indent(msg, true, -1);
+
if (str) {
jobj = json_tokener_parse(str);
free(str);
@@ -3782,7 +3877,45 @@ static void send_cmdu_cb(struct ubus_request *req,
json_object_put(jobj);
}
-uint16_t agent_send_cmdu(struct agent *a, struct cmdu_cstruct *cmdu)
+
+int agent_handle_map_event(struct agent *a, uint16_t cmdutype, uint16_t mid,
+ char *rxif, uint8_t *src, uint8_t *tlvs, int len)
+{
+ const map_cmdu_handler_t *f;
+ struct cmdu_buff *cmdu = NULL;
+ int ret = -1;
+ int idx;
+
+ trace("%s: ---> cmdu = %d\n", __func__, cmdutype);
+
+ if (cmdutype >= CMDU_TYPE_MAP_START) {
+ idx = cmdutype - CMDU_TYPE_MAP_START;
+ f = agent_mapftable;
+ } else {
+ idx = cmdutype;
+ f = i1905ftable;
+ }
+
+ if (f[idx]) {
+ dbg("mid pointer prev = %u\n", mid);
+ cmdu = cmdu_alloc_custom(cmdutype, &mid, rxif, src, tlvs, len);
+ if (cmdu) {
+ dbg("mid pointer post = %u\n", mid);
+ dbg("%s: cmdu_alloc_custom() succeeded! cmdu->cdata->hdr.mid %u\n", __func__, cmdu_get_mid(cmdu));
+ //test_cmdu(cmdu);
+ ret = f[idx](a, cmdu);
+ //map_free_cmdu(cmdu);
+ } else {
+ dbg("agent: %s: cmdu_alloc_custom() failed!\n", __func__);
+ }
+ }
+
+ //TODO: check ret
+
+ return ret;
+}
+
+uint16_t agent_send_cmdu(struct agent *a, struct cmdu_buff *cmdu)
{
char *tlv_data = NULL;
uint16_t tlv_data_len = 1;
@@ -3790,10 +3923,8 @@ uint16_t agent_send_cmdu(struct agent *a, struct cmdu_cstruct *cmdu)
int copy_index;
struct blob_buf b = { 0 };
char dst_addr[18] = { 0 };
- char *tlv_str = NULL;
uint8_t *ss = NULL;
uint16_t msgid = 0;
- uint16_t len;
int ret = 0;
size_t i;
uint32_t id;
@@ -3803,109 +3934,57 @@ uint16_t agent_send_cmdu(struct agent *a, struct cmdu_cstruct *cmdu)
memset(&b, 0, sizeof(struct blob_buf));
blob_buf_init(&b, 0);
- blobmsg_add_u32(&b, "type", cmdu->message_type);
- blobmsg_add_string(&b, "egress", cmdu->intf_name);
- if (cmdu->message_id)
- blobmsg_add_u32(&b, "mid", cmdu->message_id);
-
- hwaddr_ntoa(cmdu->origin, dst_addr);
- blobmsg_add_string(&b, "dst_macaddr", dst_addr);
-
- trace("|%s:%d|cmdu:%s|egress:%s|dst:%s|\n", __func__, __LINE__,
- map_stringify_cmdu_type(cmdu->message_type),
- cmdu->intf_name, dst_addr);
- if (cmdu->num_tlvs > 0) {
- for (i = 0; i < cmdu->num_tlvs; i++) {
- len = 0;
- ss = map_put_tlv_cstruct(cmdu->tlvs[i], &len);
- if (ss) {
- tlv_str = (char *)calloc((2 * len) + 1,
- sizeof(char));
- if (!tlv_str) {
- free(ss);
- goto out;
- }
-
- btostr(ss, len, tlv_str);
- tlv_str_len = 2 * len;
- tlv_data_len += tlv_str_len;
- tlv_data = realloc(tlv_data,
- tlv_data_len * sizeof(char));
- if (!tlv_data) {
- fprintf(stderr, "%s:%d out of memory.!\n",
- __func__, __LINE__);
- free(ss);
- free(tlv_str);
- goto out;
- }
+ blobmsg_add_u32(&b, "type", cmdu_get_type(cmdu));
- copy_index = tlv_data_len - tlv_str_len - 1;
- memcpy(tlv_data + copy_index, tlv_str,
- tlv_str_len);
- free(ss);
- free(tlv_str);
- }
- }
+ if (hwaddr_is_zero(cmdu->origin))
+ hwaddr_ntoa("\x01\x80\xC2\x00\x00\x13", dst_addr);
+ else
+ hwaddr_ntoa(cmdu->origin, dst_addr);
- if (tlv_data) {
- tlv_data[tlv_data_len - 1] = '\0';
- blobmsg_add_string(&b, "data", tlv_data);
- free(tlv_data);
- }
- }
+ blobmsg_add_string(&b, "dst", dst_addr);
+ blobmsg_add_u32(&b, "mid", (uint32_t)cmdu_get_mid(cmdu));
- if (ubus_lookup_id(a->ubus_ctx, "map.1905", &id)) {
- trace("[%s:%d] not present", __func__, __LINE__);
- goto out;
- }
+ trace("|%s:%d|cmdu:%d|egress:%s|dst:%s|mid:%u|\n", __func__, __LINE__,
+ cmdu_get_type(cmdu),
+ "TODO", dst_addr, cmdu_get_mid(cmdu));
- ret = ubus_invoke(a->ubus_ctx, id, "send",
- b.head, send_cmdu_cb,
- (void *)&msgid,
- UBUS_TIMEOUT);
- if (ret) {
- trace("[%s:%d] ubus call failed for |map.1905 send|",
- __func__, __LINE__);
- goto out;
- }
+ if (cmdu->datalen) {
+ char *tlv_str = NULL;
+ uint16_t len = 0;
- ret = msgid;
-out:
- blob_buf_free(&b);
+ //char tlv_str[1500] = {0};
- return ret;
-}
+ len = (cmdu->datalen * 2) + 1;
-int agent_handle_map_event(struct agent *a, uint16_t cmdutype, uint16_t mid,
- char *rxif, uint8_t *src, uint8_t *tlvs, int len)
-{
- const map_cmdu_handler_t *f;
- struct cmdu_cstruct *cmdu = NULL;
- int ret = -1;
- int idx;
+ tlv_str = (char *)calloc(1, len);
+ if (!tlv_str)
+ goto out;
+ btostr(cmdu->data, cmdu->datalen, tlv_str);
- trace("%s: ---> cmdu = %d\n", __func__, cmdutype);
+ tlv_str[len-1] = '\0';
- if (cmdutype >= CMDU_TYPE_MAP_START) {
- idx = cmdutype - CMDU_TYPE_MAP_START;
- f = agent_mapftable;
- } else {
- idx = cmdutype;
- f = i1905ftable;
+ blobmsg_add_string(&b, "data", tlv_str);
+ trace("|%s:%d|data:%s|\n", __func__, __LINE__, tlv_str);
+ free(tlv_str);
}
- if (f[idx]) {
- cmdu = map_build_cmdu(cmdutype, mid, rxif, src, tlvs);
- if (cmdu) {
- test_cmdu(cmdu);
- ret = f[idx](a, cmdu);
- map_free_cmdu(cmdu);
- } else {
- dbg("agent: %s: map_build_cmdu() failed!\n", __func__);
- }
+
+ if (ubus_lookup_id(a->ubus_ctx, "i1905.al.eth1", &id)) {
+ trace("[%s:%d] not present i1905.al.eth1", __func__, __LINE__);
+ goto out;
}
- //TODO: check ret
+ ret = ubus_invoke(a->ubus_ctx, id, "cmdu", b.head, send_cmdu_cb,
+ &msgid, UBUS_TIMEOUT);
+ if (ret) {
+ trace("[%s:%d] ubus call failed for |i1905.al.eth1 send| rc: %d\n",
+ __func__, __LINE__, ret);
+ goto out;
+ }
+ trace("|%s:%d| msgid = %d\n", __func__, __LINE__, msgid);
+ ret = msgid;
+out:
+ blob_buf_free(&b);
return ret;
}
diff --git a/src/core/agent_map.h b/src/core/agent_map.h
index 77db8aebebb41ffde98ffe71b42be3deb26e3c9f..1e9f2b41fec7fe03f929e1bc04853fde8dfcb920 100644
--- a/src/core/agent_map.h
+++ b/src/core/agent_map.h
@@ -4,21 +4,20 @@
struct channel_response;
-uint8_t *extract_tlv_by_type(struct cmdu_cstruct *cmdu, uint8_t tlv_type);
+uint8_t *extract_tlv_by_type(struct cmdu_buff *cmdu, uint8_t tlv_type);
extern bool is_cmdu_for_us(struct agent *a, uint16_t type);
extern int agent_handle_map_cmd(struct agent *a, char *data, int len);
-extern int agent_handle_map_event(struct agent *a, uint16_t cmdutype,
- uint16_t mid, char *rxif, uint8_t *src,
- uint8_t *tlvs, int len);
+int agent_handle_map_event(struct agent *a, uint16_t cmdutype, uint16_t mid,
+ char *rxif, uint8_t *src, uint8_t *tlvs, int len);
extern int handle_wifi_radio_scan_finished(void *agent);
int build_ap_autoconfig_wsc(void *agent, uint8_t *hwaddr,
struct wifi_radio_element *radio, int idx);
-uint16_t agent_send_cmdu(struct agent *a, struct cmdu_cstruct *cmdu);
-int send_channel_sel_response(void *agent, struct cmdu_cstruct *cmdu,
+uint16_t agent_send_cmdu(struct agent *a, struct cmdu_buff *cmdu);
+int send_channel_sel_response(void *agent, struct cmdu_buff *cmdu,
struct channel_response *rec_cmdu, uint32_t channel_response_nr);
int agent_fill_radio_max_preference(void *agent,
struct channel_response *channel_resp, uint32_t *channel_response_nr);
@@ -29,5 +28,6 @@ int send_steer_btm_report(void *agent, uint8_t *origin, const char *intf_name,
uint8_t *target_bssid, uint8_t *src_bssid,
uint8_t *sta, uint8_t status_code);
int send_sta_steer_complete(void *agent, uint8_t *origin, const char *intf_name);
+uint16_t agent_send_cmdu_unish(struct agent *a, struct cmdu_buff *cmdu);
#endif /* AGENT_MAP_H */
diff --git a/src/core/agent_tlv_generator.c b/src/core/agent_tlv_generator.c
index 36929c4aafe6e0d8cd097ced8b178c38f5e3b77c..ea6688929f894b938193f703a9052d311497b571 100644
--- a/src/core/agent_tlv_generator.c
+++ b/src/core/agent_tlv_generator.c
@@ -26,13 +26,17 @@
#include <libubox/utils.h>
#include <libubus.h>
-#include <map1905/map2.h>
-#include <map1905/maputils.h>
-#include <wsc.h>
+#include <timer_impl.h>
+#include <cmdu.h>
+#include <1905_tlvs.h>
+#include <i1905_wsc.h>
+#include <map22.h>
+
#include <uci.h>
+#include <map_module22.h>
-#include "map_module.h"
+//#include "map_module.h"
#include "utils.h"
#include "debug.h"
#include "liblist.h"
@@ -48,638 +52,890 @@
#define AP_COLLECTION_INTERVAL (10 * 1000)
struct tlv_ap_ht_cap *agent_gen_ap_ht_caps(struct agent *a,
- struct cmdu_cstruct *cmdu, uint32_t radio_index)
+ struct cmdu_buff *cmdu, uint32_t radio_index)
{
- struct tlv_ap_ht_cap *p;
- struct wifi_radio_element *radio;
- struct netif_fh *fh;
-
- radio = a->radios + radio_index;
-
- p = (struct tlv_ap_ht_cap *)calloc(1,
- sizeof(struct tlv_ap_ht_cap));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_AP_HT_CAPABILITIES;
-
- fh = wifi_radio_to_ap(a, radio->name);
- if (!fh) {
- free(p);
- return NULL;
- }
-
- memcpy(p->radio_id, radio->macaddr, 6);
- p->max_tx_streams_supported = (radio->tx_streams - 1) & 0xff;
- p->max_rx_streams_supported = (radio->rx_streams - 1) & 0xff;
- p->gi_20_support = fh->caps.ht & (1 << 3) ? 1 : 0;
- p->gi_40_support = fh->caps.ht & (1 << 2) ? 1 : 0;
- p->ht_40_support = fh->caps.ht & (1 << 1) ? 1 : 0;
-
- return p;
+ return NULL;
+// struct tlv_ap_ht_cap *p;
+// struct wifi_radio_element *radio;
+// struct netif_fh *fh;
+//
+// radio = a->radios + radio_index;
+//
+// p = (struct tlv_ap_ht_cap *)calloc(1,
+// sizeof(struct tlv_ap_ht_cap));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_HT_CAPABILITIES;
+//
+// fh = wifi_radio_to_ap(a, radio->name);
+// if (!fh) {
+// free(p);
+// return NULL;
+// }
+//
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->max_tx_streams_supported = (radio->tx_streams - 1) & 0xff;
+// p->max_rx_streams_supported = (radio->rx_streams - 1) & 0xff;
+// p->gi_20_support = fh->caps.ht & (1 << 3) ? 1 : 0;
+// p->gi_40_support = fh->caps.ht & (1 << 2) ? 1 : 0;
+// p->ht_40_support = fh->caps.ht & (1 << 1) ? 1 : 0;
+//
+// return p;
}
struct tlv_ap_cap *agent_gen_ap_caps(struct agent *a,
- struct cmdu_cstruct *cmdu)
+ struct cmdu_buff *cmdu)
{
- struct tlv_ap_cap *p;
-
- p = (struct tlv_ap_cap *)calloc(1,
- sizeof(struct tlv_ap_cap));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_AP_CAPABILITY;
- p->op_ch_metric_reporting = 0;
- p->non_op_ch_metric_reporting = 0;
- p->agent_init_rcpi_steering = 1;
-
- return p;
+ return NULL;
+// struct tlv_ap_cap *p;
+//
+// p = (struct tlv_ap_cap *)calloc(1,
+// sizeof(struct tlv_ap_cap));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_CAPABILITY;
+// p->op_ch_metric_reporting = 0;
+// p->non_op_ch_metric_reporting = 0;
+// p->agent_init_rcpi_steering = 1;
+//
+// return p;
}
-struct tlv_ap_radio_basic_cap *agent_gen_ap_radio_basic_cap(struct agent *a,
- struct cmdu_cstruct *cmdu, struct wifi_radio_element *radio)
+int agent_gen_ap_radio_basic_cap(struct agent *a,
+ struct cmdu_buff *frm, struct wifi_radio_element *radio)
{
- uint32_t j;
- struct tlv_ap_radio_basic_cap *p;
+ struct tlv *t;
+ struct tlv_ap_radio_basic_cap *data;
+ int i;
+
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- p = (struct tlv_ap_radio_basic_cap *)calloc(1,
- sizeof(struct tlv_ap_radio_basic_cap));
+ t->type = MAP_TLV_AP_RADIO_BASIC_CAPABILITIES;
+ t->len = 6 + 1 + 1;
- p->tlv_type = MAP_TLV_AP_RADIO_BASIC_CAPABILITIES;
- memcpy(p->radio_id, radio->macaddr, 6);
- p->max_bss_nr = 4; /* Max BSS per Radio */
- p->operating_classes_nr = radio->num_supp_opclass;
-
- if (p->operating_classes_nr > 0)
- p->operating_class = calloc(p->operating_classes_nr,
- sizeof(*p->operating_class));
- if (!p->operating_class) {
- fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
- p->operating_classes_nr = 0;
- return p;
- }
+ data = (struct tlv_ap_radio_basic_cap *) t->data;
- for (j = 0; j < p->operating_classes_nr; j++) {
- p->operating_class[j].op_class = radio->supp_opclass[j].id;
- p->operating_class[j].max_tx_power = radio->supp_opclass[j].max_txpower;
- p->operating_class[j].non_op_ch_nr = radio->supp_opclass[j].num_exclude_channels;
- if (p->operating_class[j].non_op_ch_nr > 0) {
- p->operating_class[j].channel =
- (uint8_t *)calloc(p->operating_class[j].non_op_ch_nr,
- sizeof(uint8_t));
- if (p->operating_class[j].channel) {
- memcpy(p->operating_class[j].channel, radio->supp_opclass[j].exclude_chanlist,
- p->operating_class[j].non_op_ch_nr);
- }
+ data->max_bssnum = 16; /* TODO: dummy: max BSS per radio */
+ data->num_opclass = radio->num_supp_opclass;
+
+ for (i = 0; i < data->num_opclass; i++) {
+ t->len += 3;
+ data->opclass[i].classid = radio->supp_opclass[i].id;
+ data->opclass[i].max_txpower = radio->supp_opclass[i].max_txpower;
+ data->opclass[i].num_nonop_channel = radio->supp_opclass[i].num_exclude_channels;
+ if (data->opclass[i].num_nonop_channel > 0) {
+ t->len += data->opclass[i].num_nonop_channel;
+ memcpy(data->opclass[i].nonop_channel, radio->supp_opclass[i].exclude_chanlist,
+ data->opclass[i].num_nonop_channel);
}
}
+ if (cmdu_put_tlv(frm, t)) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
+ }
- return p;
+ return 0;
+// uint32_t j;
+// struct tlv_ap_radio_basic_cap *p;
+//
+// p = (struct tlv_ap_radio_basic_cap *)calloc(1,
+// sizeof(struct tlv_ap_radio_basic_cap));
+//
+// p->tlv_type = MAP_TLV_AP_RADIO_BASIC_CAPABILITIES;
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->max_bss_nr = 4; /* Max BSS per Radio */
+// p->operating_classes_nr = radio->num_supp_opclass;
+//
+// if (p->operating_classes_nr > 0)
+// p->operating_class = calloc(p->operating_classes_nr,
+// sizeof(*p->operating_class));
+// if (!p->operating_class) {
+// fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
+// p->operating_classes_nr = 0;
+// return p;
+// }
+//
+// for (j = 0; j < p->operating_classes_nr; j++) {
+// p->operating_class[j].op_class = radio->supp_opclass[j].id;
+// p->operating_class[j].max_tx_power = radio->supp_opclass[j].max_txpower;
+// p->operating_class[j].non_op_ch_nr = radio->supp_opclass[j].num_exclude_channels;
+// if (p->operating_class[j].non_op_ch_nr > 0) {
+// p->operating_class[j].channel =
+// (uint8_t *)calloc(p->operating_class[j].non_op_ch_nr,
+// sizeof(uint8_t));
+// if (p->operating_class[j].channel) {
+// memcpy(p->operating_class[j].channel, radio->supp_opclass[j].exclude_chanlist,
+// p->operating_class[j].non_op_ch_nr);
+// }
+// }
+// }
+//
+// return p;
}
struct tlv_ap_vht_cap *agent_gen_ap_vht_caps(struct agent *a,
- struct cmdu_cstruct *cmdu, uint32_t radio_index)
+ struct cmdu_buff *cmdu, uint32_t radio_index)
{
- struct tlv_ap_vht_cap *p;
- struct wifi_radio_element *radio;
- struct netif_fh *fh;
-
- radio = a->radios + radio_index;
-
- fh = wifi_radio_to_ap(a, radio->name);
- if (!fh)
- return NULL;
-
- p = (struct tlv_ap_vht_cap *)calloc(1,
- sizeof(struct tlv_ap_vht_cap));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_AP_VHT_CAPABILITIES;
- memcpy(p->radio_id, radio->macaddr, 6);
- memcpy(&p->vht_tx_mcs_supported, &fh->caps.mcs.vht_mcs_txmap, 2);
- memcpy(&p->vht_rx_mcs_supported, &fh->caps.mcs.vht_mcs_rxmap, 2);
- p->max_tx_streams_supported = (fh->tx_spatial_streams - 1);
- p->max_rx_streams_supported = (fh->rx_spatial_streams - 1);
- p->gi_80_support = fh->caps.vht[4] & (1 << 1) ? 1 : 0;
- p->gi_160_support = fh->caps.vht[4] & (1 << 0) ? 1 : 0;
- p->vht_8080_support = fh->caps.vht[5] & (1 << 7) ? 1 : 0;
- p->vht_160_support = fh->caps.vht[5] & (1 << 6) ? 1 : 0;
- p->su_beamformer_capable = fh->caps.vht[5] & (1 << 5) ? 1 : 0;
- p->mu_beamformer_capable = fh->caps.vht[5] & (1 << 4) ? 1 : 0;
-
- return p;
+ return NULL;
+// struct tlv_ap_vht_cap *p;
+// struct wifi_radio_element *radio;
+// struct netif_fh *fh;
+//
+// radio = a->radios + radio_index;
+//
+// fh = wifi_radio_to_ap(a, radio->name);
+// if (!fh)
+// return NULL;
+//
+// p = (struct tlv_ap_vht_cap *)calloc(1,
+// sizeof(struct tlv_ap_vht_cap));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_VHT_CAPABILITIES;
+// memcpy(p->radio_id, radio->macaddr, 6);
+// memcpy(&p->vht_tx_mcs_supported, &fh->caps.mcs.vht_mcs_txmap, 2);
+// memcpy(&p->vht_rx_mcs_supported, &fh->caps.mcs.vht_mcs_rxmap, 2);
+// p->max_tx_streams_supported = (fh->tx_spatial_streams - 1);
+// p->max_rx_streams_supported = (fh->rx_spatial_streams - 1);
+// p->gi_80_support = fh->caps.vht[4] & (1 << 1) ? 1 : 0;
+// p->gi_160_support = fh->caps.vht[4] & (1 << 0) ? 1 : 0;
+// p->vht_8080_support = fh->caps.vht[5] & (1 << 7) ? 1 : 0;
+// p->vht_160_support = fh->caps.vht[5] & (1 << 6) ? 1 : 0;
+// p->su_beamformer_capable = fh->caps.vht[5] & (1 << 5) ? 1 : 0;
+// p->mu_beamformer_capable = fh->caps.vht[5] & (1 << 4) ? 1 : 0;
+//
+// return p;
}
-struct tlv_profile2_ap_cap *agent_gen_profile2_ap_cap(struct agent *a)
+int agent_gen_profile2_ap_cap(struct agent *a, struct cmdu_buff *frm)
{
- struct tlv_profile2_ap_cap *p;
-
- p = (struct tlv_profile2_ap_cap *)calloc(1, sizeof(*p));
- if (!p)
- return NULL;
+ struct tlv *t;
+ struct tlv_profile2_ap_cap *data;
- p->tlv_type = MAP_TLV_PROFILE2_AP_CAPABILITY;
- p->byte_counter = 0;
- p->max_vids = (uint8_t)255;
-
- return p;
-}
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
-struct tlv_ap_radio_adv_cap *agent_gen_ap_radio_adv_cap(struct agent *a,
- struct cmdu_cstruct *cmdu, struct wifi_radio_element *radio)
-{
- struct tlv_ap_radio_adv_cap *p;
+ t->type = MAP_TLV_PROFILE2_AP_CAPABILITY;
+ t->len = 4;
- p = (struct tlv_ap_radio_adv_cap *) calloc(1, sizeof(*p));
- if (!p)
- return NULL;
+ data = (struct tlv_profile2_ap_cap *) t->data;
+ data->unit = STATS_UNIT_BYTE;
+ data->max_vids = (uint8_t) 255;
- p->tlv_type = MAP_TLV_AP_RADIO_ADV_CAPABILITY;
- memcpy(p->radio_id, radio->macaddr, 6);
- p->combined_front_back = 0;
- p->combined_p1_p2 = (a->cfg.profile == 0x02);
+ if (cmdu_put_tlv(frm, t)) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
+ }
- return p;
+ return 0;
+// struct tlv_profile2_ap_cap *p;
+//
+// p = (struct tlv_profile2_ap_cap *)calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_PROFILE2_AP_CAPABILITY;
+// p->byte_counter = 0;
+// p->max_vids = (uint8_t)255;
+//
+// return p;
}
-struct tlv_wsc *agent_gen_wsc(struct agent *a, struct cmdu_cstruct *cmdu,
- struct wifi_radio_element *radio)
+int agent_gen_ap_radio_adv_cap(struct agent *a,
+ struct cmdu_buff *frm, struct wifi_radio_element *radio)
{
- struct tlv_wsc *p;
- struct wsc_key *key;
- int rv;
- uint16_t len = 0;
-
- p = (struct tlv_wsc *) calloc(1, sizeof(*p));
- if (!p)
- return NULL;
+ struct tlv *t;
+ struct tlv_ap_radio_adv_cap *data;
- p->tlv_type = TLV_TYPE_WSC;
-
- // TODO: auth_type uses dummy value (WPA2PSK)
- rv = wscBuildM1(radio->name, &p->wsc_frame, &len, (void **)&key,
- a->almac, radio->band, 0x0020, 0);
- if (!rv)
- goto fail_p;
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- p->wsc_frame_size = len;
- radio->autconfig.m1_size = len;
+ t->type = MAP_TLV_AP_RADIO_ADV_CAPABILITY;
+ t->len = 7;
- /* discard previous frame if it has not been used */
- if (radio->autconfig.m1_frame)
- free(radio->autconfig.m1_frame);
- radio->autconfig.m1_frame = calloc(1, len);
- if (!radio->autconfig.m1_frame)
- goto fail_key;
+ data = (struct tlv_ap_radio_adv_cap *) t->data;
+ memcpy(data->radio, radio->macaddr, 6);
+ if (a->cfg.profile == 0x02)
+ data->cap |= RADIO_CAP_COMBINED_P1P2; /* TODO: dummy: assume p2 implies p1 support */
- memcpy(radio->autconfig.m1_frame, p->wsc_frame, len);
+ if (!hwaddr_is_zero(radio->bksta.macaddr) && radio->num_bss > 0)
+ data->cap |= RADIO_CAP_COMBINED_FHBK;
- /* discard previous key if it has not been used */
- if (radio->autconfig.key) {
- free(radio->autconfig.key->key);
- free(radio->autconfig.key);
+ if (cmdu_put_tlv(frm, t)) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
}
- radio->autconfig.key = key;
- return p;
-fail_key:
- free(key);
-fail_p:
- map_free_tlv_cstruct((uint8_t *) p);
- return NULL;
+ return 0;
+// struct tlv_ap_radio_adv_cap *p;
+//
+// p = (struct tlv_ap_radio_adv_cap *) calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_RADIO_ADV_CAPABILITY;
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->combined_front_back = 0;
+// p->combined_p1_p2 = (a->cfg.profile == 0x02);
+//
+// return p;
}
-struct tlv_ch_scan_cap *agent_gen_ch_scan_cap(struct agent *a)
+int agent_gen_wsc(struct agent *a, struct cmdu_buff *frm,
+ struct wifi_radio_element *radio)
{
- struct tlv_ch_scan_cap *p;
- int i;
-
- if (a->num_radios <= 0)
- return NULL;
-
- p = (struct tlv_ch_scan_cap *) calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_CHANNEL_SCAN_CAPABILITY;
- p->nbr_radios = a->num_radios;
-
- p->radio = calloc(p->nbr_radios, sizeof(*p->radio));
- if (!p->radio)
- goto fail_p;
-
- for (i = 0; i < p->nbr_radios; i++) {
- struct wifi_radio_element *radio;
- struct wifi_opclass_supported_element *opclass;
- int j;
+ struct tlv *t;
+ uint8_t *m1;
+ uint16_t m1_size = 0;
+ void *key;
+ struct wps_credential wps = {0};
+ int ret;
- radio = a->radios + i;
+ wps.band = radio->band;
+ memcpy(wps.macaddr, radio->macaddr, 6);
- memcpy(p->radio[i].radio_id, radio->macaddr, 6);
- p->radio[i].on_boot = 0; // TODO: Dummy values
- p->radio[i].scan_impact = 0x03; // TODO: Dummy values
- p->radio[i].min_scan_interval = 30; // TODO: Dummy values
- p->radio[i].nbr_op_classes = radio->num_supp_opclass;
- if (p->radio[i].nbr_op_classes <= 0)
- continue;
+ ret = wsc_build_m1(&wps, &m1, &m1_size, &key);
+ if (ret)
+ return -1;
- p->radio[i].op_class = calloc(p->radio[i].nbr_op_classes,
- sizeof(*p->radio[i].op_class));
- if (!p->radio[i].op_class)
- continue;
+ t = cmdu_reserve_tlv(frm, 1024);
+ if (!t) {
+ cmdu_free(frm);
+ return -1;
+ }
- for (j = 0; j < p->radio[i].nbr_op_classes; j++) {
- int k;
+ t->type = TLV_TYPE_WSC;
+ t->len = m1_size;
+ memcpy(t->data, m1, m1_size);
- opclass = radio->supp_opclass + j;
- p->radio[i].op_class[j].op_class = opclass->id;
- p->radio[i].op_class[j].nbr_ch = opclass->num_supported_channels; // Scan on all channels
+ ret = cmdu_put_tlv(frm, t);
+ if (ret) {
+ fprintf(stderr, "%s: error: cmdu_put_tlv()\n", __func__);
+ cmdu_free(frm);
+ return -1;
+ }
- if (p->radio[i].op_class[j].nbr_ch <= 0)
- continue;
+ radio->autconfig.m1_frame = m1;
+ radio->autconfig.m1_size = m1_size;
+ radio->autconfig.key = key;
- p->radio[i].op_class[j].ch = calloc(p->radio[i].op_class[j].nbr_ch,
- sizeof(*p->radio[i].op_class[j].ch));
- if (!p->radio[i].op_class[j].ch)
- continue;
+ dbg("size = %d\n", m1_size);
- for (k = 0; k < p->radio[i].op_class[j].nbr_ch; k++)
- p->radio[i].op_class[j].ch[k] = opclass->supp_chanlist[k].channel;
- }
- }
+ return 0;
+// struct tlv_wsc *p;
+// struct wsc_key *key;
+// int rv;
+// uint16_t len = 0;
+//
+// p = (struct tlv_wsc *) calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = TLV_TYPE_WSC;
+//
+// // TODO: auth_type uses dummy value (WPA2PSK)
+// rv = wscBuildM1(radio->name, &p->wsc_frame, &len, (void **)&key,
+// a->almac, radio->band, 0x0020, 0);
+// if (!rv)
+// goto fail_p;
+//
+// p->wsc_frame_size = len;
+// radio->autconfig.m1_size = len;
+//
+// /* discard previous frame if it has not been used */
+// if (radio->autconfig.m1_frame)
+// free(radio->autconfig.m1_frame);
+// radio->autconfig.m1_frame = calloc(1, len);
+// if (!radio->autconfig.m1_frame)
+// goto fail_key;
+//
+// memcpy(radio->autconfig.m1_frame, p->wsc_frame, len);
+//
+// /* discard previous key if it has not been used */
+// if (radio->autconfig.key) {
+// free(radio->autconfig.key->key);
+// free(radio->autconfig.key);
+// }
+// radio->autconfig.key = key;
+//
+// return p;
+//fail_key:
+// free(key);
+//fail_p:
+// map_free_tlv_cstruct((uint8_t *) p);
+// return NULL;
+}
- return p;
-fail_p:
- map_free_tlv_cstruct((uint8_t *) p);
+struct tlv_ch_scan_cap *agent_gen_ch_scan_cap(struct agent *a)
+{
return NULL;
+
+/* TODO: README: @Lejla merge conflict when rebasing for prj-unish ---- please have a look */
+// struct tlv_ch_scan_cap *p;
+// int i;
+//
+// if (a->num_radios <= 0)
+// return NULL;
+//
+// p = (struct tlv_ch_scan_cap *) calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_CHANNEL_SCAN_CAPABILITY;
+// p->nbr_radios = a->num_radios;
+//
+// p->radio = calloc(p->nbr_radios, sizeof(*p->radio));
+// if (!p->radio)
+// goto fail_p;
+//
+// for (i = 0; i < p->nbr_radios; i++) {
+// struct wifi_radio_element *radio;
+// struct wifi_opclass_supported_element *opclass;
+// int j;
+//
+// radio = a->radios + i;
+//
+// memcpy(p->radio[i].radio_id, radio->macaddr, 6);
+// p->radio[i].on_boot = 0; // TODO: Dummy values
+// p->radio[i].scan_impact = 0x03; // TODO: Dummy values
+// p->radio[i].min_scan_interval = 30; // TODO: Dummy values
+// p->radio[i].nbr_op_classes = radio->num_supp_opclass;
+// if (p->radio[i].nbr_op_classes <= 0)
+// continue;
+//
+// p->radio[i].op_class = calloc(p->radio[i].nbr_op_classes,
+// sizeof(*p->radio[i].op_class));
+// if (!p->radio[i].op_class)
+// continue;
+//
+// for (j = 0; j < p->radio[i].nbr_op_classes; j++) {
+// int k;
+
+/* README: TODO: @Lejla prior to rebase below */
+// struct tlv_ch_scan_cap *p;
+// int i;
+//
+// if (a->num_radios <= 0)
+// return NULL;
+//
+// p = (struct tlv_ch_scan_cap *) calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_CHANNEL_SCAN_CAPABILITY;
+// p->nbr_radios = a->num_radios;
+//
+// p->radio = calloc(p->nbr_radios, sizeof(*p->radio));
+// if (!p->radio)
+// goto fail_p;
+//
+// for (i = 0; i < p->nbr_radios; i++) {
+// struct wifi_radio_element *radio;
+// struct wifi_opclass_supported_element *opclass;
+// int j;
+//
+// radio = a->radios + i;
+//
+// memcpy(p->radio[i].radio_id, radio->macaddr, 6);
+// p->radio[i].on_boot = 0; // TODO: Dummy values
+// p->radio[i].scan_impact = 0x03; // TODO: Dummy values
+// p->radio[i].min_scan_interval = 30; // TODO: Dummy values
+// p->radio[i].nbr_op_classes = radio->num_supp_opclass;
+//
+// if (p->radio[i].nbr_op_classes <= 0)
+// continue;
+//
+// p->radio[i].op_class = calloc(p->radio[i].nbr_op_classes,
+// sizeof(*p->radio[i].op_class));
+// if (!p->radio[i].op_class)
+// continue;
+//
+// for (j = 0; j < p->radio[i].nbr_op_classes; j++) {
+// int k;
+//
+// opclass = radio->supp_opclass + j;
+// p->radio[i].op_class[j].op_class = opclass->id;
+// p->radio[i].op_class[j].nbr_ch = opclass->num_supported_channels; // Scan on all channels
+//
+// if (p->radio[i].op_class[j].nbr_ch <= 0)
+// continue;
+//
+// p->radio[i].op_class[j].ch = calloc(p->radio[i].op_class[j].nbr_ch,
+// sizeof(*p->radio[i].op_class[j].ch));
+// if (!p->radio[i].op_class[j].ch)
+// continue;
+//
+// for (k = 0; k < p->radio[i].op_class[j].nbr_ch; k++)
+// p->radio[i].op_class[j].ch[k] = opclass->supp_chanlist[k].channel;
+// }
+// }
+//
+// return p;
+//fail_p:
+// map_free_tlv_cstruct((uint8_t *) p);
+// return NULL;
}
struct tlv_cac_cap *agent_gen_cac_cap(struct agent *a)
{
- struct tlv_cac_cap *p;
- int i;
-
- p = (struct tlv_cac_cap *) calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_CAC_CAPABILITY;
- memcpy(p->country_code, a->radios[0].country_code, 2);
- p->nbr_radios = a->num_radios;
-
- p->radio_data = calloc(p->nbr_radios, sizeof(*p->radio_data));
- if (!p->radio_data)
- goto fail_p;
-
- for (i = 0; i < p->nbr_radios; i++) {
- struct wifi_radio_element *radio;
- struct wifi_opclass_supported_element *opclass;
- int j;
-
- radio = a->radios + i;
-
- memcpy(p->radio_data[i].radio_id, radio->macaddr, 6);
- p->radio_data[i].nbr_cac_types = 1;
-
- if (p->radio_data[i].nbr_cac_types <= 0)
- continue;
-
- p->radio_data[i].cac_data = calloc(p->radio_data[i].nbr_cac_types,
- sizeof(*p->radio_data[i].cac_data));
- if (!p->radio_data[i].cac_data)
- continue;
-
- for (j = 0; j < p->radio_data[i].nbr_cac_types; j++) {
- int k;
-
- p->radio_data[i].cac_data[j].cac_method_supported = CAC_CAP_METHOD_CONTI_CAC;
- p->radio_data[i].cac_data[j].duration = 60; /* Default duration is 60, 600 for channels (120, 124 & 128) */
- // TODO: Assumption, All the supporting op_class supported continuous CAC method,
- // Currently no parmaeter/method to classify the same.
- p->radio_data[i].cac_data[j].nbr_op_classes = radio->num_supp_opclass;
-
- if (p->radio_data[i].cac_data[j].nbr_op_classes <= 0)
- continue;
-
- p->radio_data[i].cac_data[j].op_class_data =
- calloc(radio->num_supp_opclass,
- sizeof(*p->radio_data[i].cac_data[j].op_class_data));
-
- if (!p->radio_data[i].cac_data[j].op_class_data)
- continue;
-
- for (k = 0; k < radio->num_supp_opclass; k++) {
- int l;
-
- opclass = radio->supp_opclass + k;
- p->radio_data[i].cac_data[j].op_class_data[k].op_class = opclass->id;
- p->radio_data[i].cac_data[j].op_class_data[k].nbr_ch = opclass->num_supported_channels;
-
- if (opclass->num_supported_channels <= 0)
- continue;
-
- p->radio_data[i].cac_data[j].op_class_data[k].ch =
- calloc(opclass->num_supported_channels, sizeof(struct supp_channel));
-
- if (!p->radio_data[i].cac_data[j].op_class_data[k].ch)
- continue;
-
- for (l = 0; l < opclass->num_supported_channels; l++) {
- uint8_t ch;
-
- p->radio_data[i].cac_data[j].op_class_data[k].ch[l] = opclass->supp_chanlist[l].channel;
-
- ch = p->radio_data[i].cac_data[j].op_class_data[k].ch[l];
- if (ch == 120 || ch == 124 || ch == 128)
- p->radio_data[i].cac_data[j].duration = 600;
- }
- }
- }
- }
- return p;
-fail_p:
- map_free_tlv_cstruct((uint8_t *) p);
return NULL;
+// struct tlv_cac_cap *p;
+// int i;
+//
+// p = (struct tlv_cac_cap *) calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_CAC_CAPABILITY;
+// memcpy(p->country_code, a->radios[0].country_code, 2);
+// p->nbr_radios = a->num_radios;
+//
+// p->radio_data = calloc(p->nbr_radios, sizeof(*p->radio_data));
+// if (!p->radio_data)
+// goto fail_p;
+//
+// for (i = 0; i < p->nbr_radios; i++) {
+// struct wifi_radio_element *radio;
+// struct wifi_opclass_supported_element *opclass;
+// int j;
+//
+// radio = a->radios + i;
+//
+// memcpy(p->radio_data[i].radio_id, radio->macaddr, 6);
+// p->radio_data[i].nbr_cac_types = 1;
+//
+// if (p->radio_data[i].nbr_cac_types <= 0)
+// continue;
+//
+// p->radio_data[i].cac_data = calloc(p->radio_data[i].nbr_cac_types,
+// sizeof(*p->radio_data[i].cac_data));
+// if (!p->radio_data[i].cac_data)
+// continue;
+//
+// for (j = 0; j < p->radio_data[i].nbr_cac_types; j++) {
+// int k;
+//
+// p->radio_data[i].cac_data[j].cac_method_supported = CAC_CAP_METHOD_CONTI_CAC;
+// p->radio_data[i].cac_data[j].duration = 60; /* Default duration is 60, 600 for channels (120, 124 & 128) */
+// // TODO: Assumption, All the supporting op_class supported continuous CAC method,
+// // Currently no parmaeter/method to classify the same.
+// p->radio_data[i].cac_data[j].nbr_op_classes = radio->num_supp_opclass;
+//
+// if (p->radio_data[i].cac_data[j].nbr_op_classes <= 0)
+// continue;
+//
+// p->radio_data[i].cac_data[j].op_class_data =
+// calloc(radio->num_supp_opclass,
+// sizeof(*p->radio_data[i].cac_data[j].op_class_data));
+//
+// if (!p->radio_data[i].cac_data[j].op_class_data)
+// continue;
+//
+// for (k = 0; k < radio->num_supp_opclass; k++) {
+// int l;
+//
+// opclass = radio->supp_opclass + k;
+// p->radio_data[i].cac_data[j].op_class_data[k].op_class = opclass->id;
+// p->radio_data[i].cac_data[j].op_class_data[k].nbr_ch = opclass->num_supported_channels;
+//
+// if (opclass->num_supported_channels <= 0)
+// continue;
+//
+// p->radio_data[i].cac_data[j].op_class_data[k].ch =
+// calloc(opclass->num_supported_channels, sizeof(struct supp_channel));
+//
+// if (!p->radio_data[i].cac_data[j].op_class_data[k].ch)
+// continue;
+//
+// for (l = 0; l < opclass->num_supported_channels; l++) {
+// uint8_t ch;
+//
+// p->radio_data[i].cac_data[j].op_class_data[k].ch[l] = opclass->supp_chanlist[l].channel;
+//
+// ch = p->radio_data[i].cac_data[j].op_class_data[k].ch[l];
+// if (ch == 120 || ch == 124 || ch == 128)
+// p->radio_data[i].cac_data[j].duration = 600;
+// }
+// }
+// }
+// }
+// return p;
+//fail_p:
+// map_free_tlv_cstruct((uint8_t *) p);
+// return NULL;
}
struct tlv_metric_collection_interval *agent_gen_metric_collection_interval(struct agent *a)
{
- struct tlv_metric_collection_interval *p;
-
- p = (struct tlv_metric_collection_interval *) calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_METRIC_COLLECTION_INTERVAL;
- p->collection_interval = AP_COLLECTION_INTERVAL;
-
- return p;
+ return NULL;
+// struct tlv_metric_collection_interval *p;
+//
+// p = (struct tlv_metric_collection_interval *) calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_METRIC_COLLECTION_INTERVAL;
+// p->collection_interval = AP_COLLECTION_INTERVAL;
+//
+// return p;
}
struct tlv_oper_ch_report *agent_gen_operate_channel_report(struct agent *a,
- struct cmdu_cstruct *cmdu, uint32_t radio_index)
+ struct cmdu_buff *cmdu, uint32_t radio_index)
{
- struct tlv_oper_ch_report *p;
- struct wifi_radio_element *radio;
- uint32_t j = 0;
-
- radio = a->radios + radio_index;
-
- p = (struct tlv_oper_ch_report *)calloc(1,
- sizeof(struct tlv_oper_ch_report));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_OPERATING_CHANNEL_REPORT;
- memcpy(p->radio_id, radio->macaddr, 6);
- p->op_ch_op_class_nr = 1;
-
- if (p->op_ch_op_class_nr > 0)
- p->op_ch_op_class = calloc(p->op_ch_op_class_nr,
- sizeof(*p->op_ch_op_class));
-
- if (!p->op_ch_op_class) {
- fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
- p->op_ch_op_class_nr = 0;
- return NULL;
- }
-
- for (j = 0; j < p->op_ch_op_class_nr; j++) {
- p->op_ch_op_class[j].op_class = radio->current_opclass;
- p->op_ch_op_class[j].channel = radio->current_channel;
- }
-
- /* current transmit power is the (operating class tx power) *
- * (current_tx_power_percent)/100
- */
- for (j = 0; j < radio->num_supp_opclass; j++) {
- if (radio->supp_opclass[j].id == radio->current_opclass)
- p->curr_tx_power =
- radio->supp_opclass[j].max_txpower *
- ((radio->current_txpower_percent)/100);
- }
- return p;
+ return NULL;
+// struct tlv_oper_ch_report *p;
+// struct wifi_radio_element *radio;
+// uint32_t j = 0;
+//
+// radio = a->radios + radio_index;
+//
+// p = (struct tlv_oper_ch_report *)calloc(1,
+// sizeof(struct tlv_oper_ch_report));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_OPERATING_CHANNEL_REPORT;
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->op_ch_op_class_nr = 1;
+//
+// if (p->op_ch_op_class_nr > 0)
+// p->op_ch_op_class = calloc(p->op_ch_op_class_nr,
+// sizeof(*p->op_ch_op_class));
+//
+// if (!p->op_ch_op_class) {
+// fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
+// p->op_ch_op_class_nr = 0;
+// return NULL;
+// }
+//
+// for (j = 0; j < p->op_ch_op_class_nr; j++) {
+// p->op_ch_op_class[j].op_class = radio->current_opclass;
+// p->op_ch_op_class[j].channel = radio->current_channel;
+// }
+//
+// /* current transmit power is the (operating class tx power) *
+// * (current_tx_power_percent)/100
+// */
+// for (j = 0; j < radio->num_supp_opclass; j++) {
+// if (radio->supp_opclass[j].id == radio->current_opclass)
+// p->curr_tx_power =
+// radio->supp_opclass[j].max_txpower *
+// ((radio->current_txpower_percent)/100);
+// }
+// return p;
}
struct tlv_ch_selection_resp *agent_gen_operate_channel_response(struct agent *a,
- struct cmdu_cstruct *cmdu, uint8_t *radio_recvd, uint8_t reason_code)
+ struct cmdu_buff *cmdu, uint8_t *radio_recvd, uint8_t reason_code)
{
- struct tlv_ch_selection_resp *p;
-
- p = (struct tlv_ch_selection_resp *)calloc(1,
- sizeof(struct tlv_ch_selection_resp));
-
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_CHANNEL_SELECTION_RESPONSE;
- memcpy(p->radio_id, radio_recvd, 6);
- p->response_code = reason_code;
-
- return p;
+ return NULL;
+// struct tlv_ch_selection_resp *p;
+//
+// p = (struct tlv_ch_selection_resp *)calloc(1,
+// sizeof(struct tlv_ch_selection_resp));
+//
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_CHANNEL_SELECTION_RESPONSE;
+// memcpy(p->radio_id, radio_recvd, 6);
+// p->response_code = reason_code;
+//
+// return p;
}
void agent_gen_radio_channel_preference(struct agent *a,
struct tlv_channel_pref *p,
uint32_t radio_index)
{
- uint32_t j = 0, k = 0, count = 0, l = 0;
- struct wifi_radio_element *radio = a->radios + radio_index;
-
- trace("%s -----> parsing radio %s\n", __func__, radio->name);
-
- memcpy(p->radio_id, radio->macaddr, 6);
- p->ch_preference_op_class_nr = radio->num_supp_opclass;
-
- if (p->ch_preference_op_class_nr > 0)
- p->op_class = calloc(p->ch_preference_op_class_nr,
- sizeof(*p->op_class));
- if (!p->op_class) {
- fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
- p->ch_preference_op_class_nr = 0;
- return;
- }
-
- for (j = 0; j < p->ch_preference_op_class_nr; j++) {
-
- p->op_class[j].op_class = radio->supp_opclass[j].id;
- count = 0;
-
- /* Here we fill all the channels that are not having max preference 15 */
- for (k = 0; k < radio->supp_opclass[j].num_supported_channels; k++) {
- if (radio->supp_opclass[j].supp_chanlist[k].pref != 0xff)
- count++;
- }
- p->op_class[j].channel_nr = count;
-
- if (p->op_class[j].channel_nr > 0) {
- p->op_class[j].channel_list = calloc(p->op_class[j].channel_nr,
- sizeof(*p->op_class[j].channel_list));
-
- if (!p->op_class[j].channel_list) {
- fprintf(stderr, "|%s:%d| out of memory!\n",
- __func__, __LINE__);
- p->op_class[j].channel_nr = 0;
- return;
- }
- l = 0;
-
- for (k = 0; k < radio->supp_opclass[j].num_supported_channels; k++) {
- if (radio->supp_opclass[j].supp_chanlist[k].pref != 0xff) {
- p->op_class[j].channel_list[l] =
- radio->supp_opclass[j].supp_chanlist[k].channel;
- p->op_class[j].preference =
- radio->supp_opclass[j].supp_chanlist[k].pref;
- l++;
- }
- }
-
- p->op_class[j].preference_reason = 0x00;
- } else {
- p->op_class[j].channel_list = NULL;
- p->op_class[j].preference = 0xff;
- p->op_class[j].preference_reason = 0x00;
- }
- }
+ return;
+// uint32_t j = 0, k = 0, count = 0, l = 0;
+// struct wifi_radio_element *radio = a->radios + radio_index;
+//
+// trace("%s -----> parsing radio %s\n", __func__, radio->name);
+//
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->ch_preference_op_class_nr = radio->num_supp_opclass;
+//
+// if (p->ch_preference_op_class_nr > 0)
+// p->op_class = calloc(p->ch_preference_op_class_nr,
+// sizeof(*p->op_class));
+// if (!p->op_class) {
+// fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
+// p->ch_preference_op_class_nr = 0;
+// return;
+// }
+//
+// for (j = 0; j < p->ch_preference_op_class_nr; j++) {
+//
+// p->op_class[j].op_class = radio->supp_opclass[j].id;
+// count = 0;
+//
+// /* Here we fill all the channels that are not having max preference 15 */
+// for (k = 0; k < radio->supp_opclass[j].num_supported_channels; k++) {
+// if (radio->supp_opclass[j].supp_chanlist[k].pref != 0xff)
+// count++;
+// }
+// p->op_class[j].channel_nr = count;
+//
+// if (p->op_class[j].channel_nr > 0) {
+// p->op_class[j].channel_list = calloc(p->op_class[j].channel_nr,
+// sizeof(*p->op_class[j].channel_list));
+//
+// if (!p->op_class[j].channel_list) {
+// fprintf(stderr, "|%s:%d| out of memory!\n",
+// __func__, __LINE__);
+// p->op_class[j].channel_nr = 0;
+// return;
+// }
+// l = 0;
+//
+// for (k = 0; k < radio->supp_opclass[j].num_supported_channels; k++) {
+// if (radio->supp_opclass[j].supp_chanlist[k].pref != 0xff) {
+// p->op_class[j].channel_list[l] =
+// radio->supp_opclass[j].supp_chanlist[k].channel;
+// p->op_class[j].preference =
+// radio->supp_opclass[j].supp_chanlist[k].pref;
+// l++;
+// }
+// }
+//
+// p->op_class[j].preference_reason = 0x00;
+// } else {
+// p->op_class[j].channel_list = NULL;
+// p->op_class[j].preference = 0xff;
+// p->op_class[j].preference_reason = 0x00;
+// }
+// }
}
void agent_gen_radio_restrict_channel(struct agent *a,
struct tlv_radio_oper_restrict *p,
uint32_t radio_index)
{
- uint32_t j, k, l, m;
- struct wifi_radio_element *radio = a->radios + radio_index;
-
- trace("%s -----> parsing radio %s\n", __func__, radio->name);
-
- memcpy(p->radio_id, radio->macaddr, 6);
- p->op_restricted_op_class_nr = 1;
-
- if (p->op_restricted_op_class_nr > 0)
- p->restricted_op_class = calloc(p->op_restricted_op_class_nr,
- sizeof(*p->restricted_op_class));
- if (!p->restricted_op_class) {
- fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
- p->op_restricted_op_class_nr = 0;
- return;
- }
-
- for (j = 0, m = 0; j < radio->num_supp_opclass; j++) {
- if (radio->supp_opclass[j].id != radio->current_opclass)
- continue;
- p->restricted_op_class[m].op_class = radio->current_opclass;
- p->restricted_op_class[m].channel_nr = (radio->supp_opclass[j].num_supported_channels) - 1;
-
- if (p->restricted_op_class[m].channel_nr > 0)
- p->restricted_op_class[m].restricted_channels =
- calloc(p->restricted_op_class[j].channel_nr,
- sizeof(*p->restricted_op_class[m].restricted_channels));
-
- if (!p->restricted_op_class[m].restricted_channels) {
- fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
- p->restricted_op_class[m].channel_nr = 0;
- return;
- }
-
- for (k = 0, l = 0; k < radio->supp_opclass[j].num_supported_channels; k++) {
- if (radio->supp_opclass[j].supp_chanlist[k].channel == radio->current_channel)
- continue;
- p->restricted_op_class[m].restricted_channels[l].channel =
- radio->supp_opclass[j].supp_chanlist[k].channel;
- p->restricted_op_class[m].restricted_channels[l].min_freq_sep = 0; //TODO dummy value
- l++;
- }
- m++;
- }
+ return NULL;
+// uint32_t j, k, l, m;
+// struct wifi_radio_element *radio = a->radios + radio_index;
+//
+// trace("%s -----> parsing radio %s\n", __func__, radio->name);
+//
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->op_restricted_op_class_nr = 1;
+//
+// if (p->op_restricted_op_class_nr > 0)
+// p->restricted_op_class = calloc(p->op_restricted_op_class_nr,
+// sizeof(*p->restricted_op_class));
+// if (!p->restricted_op_class) {
+// fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
+// p->op_restricted_op_class_nr = 0;
+// return;
+// }
+//
+// for (j = 0, m = 0; j < radio->num_supp_opclass; j++) {
+// if (radio->supp_opclass[j].id != radio->current_opclass)
+// continue;
+// p->restricted_op_class[m].op_class = radio->current_opclass;
+// p->restricted_op_class[m].channel_nr = (radio->supp_opclass[j].num_supported_channels) - 1;
+//
+// if (p->restricted_op_class[m].channel_nr > 0)
+// p->restricted_op_class[m].restricted_channels =
+// calloc(p->restricted_op_class[j].channel_nr,
+// sizeof(*p->restricted_op_class[m].restricted_channels));
+//
+// if (!p->restricted_op_class[m].restricted_channels) {
+// fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
+// p->restricted_op_class[m].channel_nr = 0;
+// return;
+// }
+//
+// for (k = 0, l = 0; k < radio->supp_opclass[j].num_supported_channels; k++) {
+// if (radio->supp_opclass[j].supp_chanlist[k].channel == radio->current_channel)
+// continue;
+// p->restricted_op_class[m].restricted_channels[l].channel =
+// radio->supp_opclass[j].supp_chanlist[k].channel;
+// p->restricted_op_class[m].restricted_channels[l].min_freq_sep = 0; //TODO dummy value
+// l++;
+// }
+// m++;
+// }
}
void agent_gen_cac_comp_report(struct agent *a,
- struct tlv_cac_comp_report *p)
+ struct tlv_cac_complete_report *p)
{
- uint32_t j;
- struct wifi_radio_element *radio = NULL;
+ return;
+// uint32_t j;
+// struct wifi_radio_element *radio = NULL;
+//
+// trace("%s -----> Inside\n", __func__);
+// p->nbr_radios = a->num_radios;
+//
+// if (p->nbr_radios > 0)
+// p->radio_data = calloc(p->nbr_radios,
+// sizeof(*p->radio_data));
+//
+// if (!p->radio_data) {
+// fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
+// p->nbr_radios = 0;
+// return;
+// }
+//
+// for (j = 0; j < a->num_radios; j++) {
+// radio = a->radios + j;
+// memcpy(p->radio_data[j].radio_id, radio->macaddr, 6);
+//
+// p->radio_data[j].op_class = 0x01; //dummy value TODO
+// p->radio_data[j].ch = 0x01; // dummy value TODO
+//
+// p->radio_data[j].completion_status = 0x05;// dummy value TODO
+// p->radio_data[j].nbr_pairs = 0; //dummy value TODO
+// }
+}
- trace("%s -----> Inside\n", __func__);
- p->nbr_radios = a->num_radios;
+struct tlv_error_code *agent_gen_tlv_error_code(struct agent *a,
+ struct cmdu_buff *cmdu, uint8_t *sta_mac, uint8_t reason_code)
+{
+ return NULL;
+// struct tlv_error_code *p;
+//
+// p = (struct tlv_error_code *)calloc(1,
+// sizeof(struct tlv_error_code));
+//
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_ERROR_CODE;
+// p->reason_code = reason_code;
+// memcpy(p->addr, sta_mac, 6);
+//
+// return p;
+}
- if (p->nbr_radios > 0)
- p->radio_data = calloc(p->nbr_radios,
- sizeof(*p->radio_data));
+int agent_gen_al_mac(struct agent *a, struct cmdu_buff *frm, uint8_t *hwaddr)
+{
+ struct tlv *t;
+ struct tlv_aladdr *data;
- if (!p->radio_data) {
- fprintf(stderr, "|%s:%d| out of memory!\n", __func__, __LINE__);
- p->nbr_radios = 0;
- return;
- }
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- for (j = 0; j < a->num_radios; j++) {
- radio = a->radios + j;
- memcpy(p->radio_data[j].radio_id, radio->macaddr, 6);
+ t->type = TLV_TYPE_AL_MAC_ADDRESS_TYPE;
+ t->len = 6;
- p->radio_data[j].op_class = 0x01; //dummy value TODO
- p->radio_data[j].ch = 0x01; // dummy value TODO
+ data = (struct tlv_aladdr *) t->data;
+ memcpy(data->macaddr, a->almac, 6);
- p->radio_data[j].completion_status = 0x05;// dummy value TODO
- p->radio_data[j].nbr_pairs = 0; //dummy value TODO
+ if (cmdu_put_tlv(frm, t)) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
}
+
+ return 0;
}
-struct tlv_error_code *agent_gen_tlv_error_code(struct agent *a,
- struct cmdu_cstruct *cmdu, uint8_t *sta_mac, uint8_t reason_code)
+
+int agent_gen_supported_service(struct agent *a, struct cmdu_buff *frm, uint8_t service)
{
- struct tlv_error_code *p;
+ struct tlv *t;
+ int ret;
- p = (struct tlv_error_code *)calloc(1,
- sizeof(struct tlv_error_code));
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- if (!p)
- return NULL;
+ t->type = MAP_TLV_SUPPORTED_SERVICE;
+ t->len = 2;
+ t->data[0] = 0x1;
+ t->data[1] = service;
- p->tlv_type = MAP_TLV_ERROR_CODE;
- p->reason_code = reason_code;
- memcpy(p->addr, sta_mac, 6);
+ ret = cmdu_put_tlv(frm, t);
+ if (ret) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
+ }
- return p;
+ return 0;
}
-struct tlv_al_mac *agent_gen_al_mac(struct agent *a, uint8_t *hwaddr)
+int agent_gen_searched_service(struct agent *a, struct cmdu_buff *frm, uint8_t service)
{
- struct tlv_al_mac *p;
+ struct tlv *t;
+ int ret;
- p = calloc(1, sizeof(struct tlv_al_mac));
- if (!p)
- return NULL;
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- p->tlv_type = TLV_TYPE_AL_MAC_ADDRESS_TYPE;
- memcpy(p->al_mac_address, hwaddr, 6);
+ t->type = MAP_TLV_SEARCHED_SERVICE;
+ t->len = 2;
+ t->data[0] = 0x1;
+ t->data[1] = service;
- return p;
+ ret = cmdu_put_tlv(frm, t);
+ if (ret) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
+ }
+
+ return 0;
}
-struct tlv_steer_btm_report *agent_gen_steer_btm_report(struct agent *a,
- uint8_t *target_bssid, uint8_t *src_bssid,
- uint8_t *sta, uint8_t status_code)
+int agent_gen_map_profile(struct agent *a, struct cmdu_buff *frm, uint8_t profile)
{
- struct tlv_steer_btm_report *p;
-
- p = (struct tlv_steer_btm_report *)calloc(1,
- sizeof(struct tlv_steer_btm_report));
+ struct tlv *t;
+ struct tlv_map_profile *data;
+ int ret;
- if (!p)
- return NULL;
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- p->tlv_type = MAP_TLV_STEERING_BTM_REPORT;
- memcpy(p->bssid, src_bssid, 6);
- p->status_code = status_code;
+ t->type = MAP_TLV_MULTIAP_PROFILE;
+ t->len = 1;
+ data = (struct tlv_map_profile *) t->data;
+ data->profile = profile;
- if (p->status_code == 0x00)
- memcpy(p->target_bssid, target_bssid, 6);
+ ret = cmdu_put_tlv(frm, t);
+ if (ret) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
+ }
- memcpy(p->sta_mac_addr, sta, 6);
+ return 0;
+}
- return p;
+struct tlv_steer_btm_report *agent_gen_steer_btm_report(struct agent *a,
+ uint8_t *target_bssid, uint8_t *src_bssid,
+ uint8_t *sta, uint8_t status_code)
+{
+ return NULL;
+// struct tlv_steer_btm_report *p;
+//
+// p = (struct tlv_steer_btm_report *)calloc(1,
+// sizeof(struct tlv_steer_btm_report));
+//
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_STEERING_BTM_REPORT;
+// memcpy(p->bssid, src_bssid, 6);
+// p->status_code = status_code;
+//
+// if (p->status_code == 0x00)
+// memcpy(p->target_bssid, target_bssid, 6);
+//
+// memcpy(p->sta_mac_addr, sta, 6);
+//
+// return p;
}
/**
@@ -688,362 +944,389 @@ struct tlv_steer_btm_report *agent_gen_steer_btm_report(struct agent *a,
* 0x01 5GHz
* 0x02 60GHz
*/
-struct tlv_autoconf_freq_band *agent_gen_autoconf_freq_band(struct agent *a,
+int agent_gen_autoconf_freq_band(struct agent *a, struct cmdu_buff *frm,
uint8_t band)
{
- struct tlv_autoconf_freq_band *p;
+ struct tlv *t;
+ struct tlv_autoconfig_band *data;
+ int ret;
- p = calloc(1, sizeof(struct tlv_autoconf_freq_band));
- if (!p)
- return NULL;
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- p->tlv_type = TLV_TYPE_AUTOCONFIG_FREQ_BAND;
- p->freq_band = band;
+ t->type = TLV_TYPE_AUTOCONFIG_FREQ_BAND;
+ t->len = 1;
+ data = (struct tlv_autoconfig_band *) t->data;
+ data->band = band;
- return p;
+ ret = cmdu_put_tlv(frm, t);
+ if (ret) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
+ }
+
+ return 0;
}
-/**
- * role -
- * 0x00 registrar
- */
-struct tlv_searched_role *agent_gen_searched_role(struct agent *a,
+int agent_gen_searched_role(struct agent *a, struct cmdu_buff *frm,
uint8_t role)
{
- struct tlv_searched_role *p;
-
- p = calloc(1, sizeof(struct tlv_searched_role));
- if (!p)
- return NULL;
+ struct tlv *t;
+ struct tlv_searched_role *data;
+ int ret;
- p->tlv_type = TLV_TYPE_SEARCHED_ROLE;
- p->role = role;
+ t = cmdu_reserve_tlv(frm, 256);
+ if (!t)
+ return -1;
- return p;
-}
+ t->type = TLV_TYPE_SEARCHED_ROLE;
+ t->len = 1;
+ data = (struct tlv_searched_role *) t->data;
+ data->role = role;
+
+ ret = cmdu_put_tlv(frm, t);
+ if (ret) {
+ dbg("%s: error: cmdu_put_tlv()\n", __func__);
+ return -1;
+ }
+
+ return 0;
+}
struct tlv_radio_metrics *agent_gen_radio_metrics(struct agent *a,
int radio_index)
{
- struct tlv_radio_metrics *p;
- struct wifi_radio_element *radio = a->radios + radio_index;
-
- p = (struct tlv_radio_metrics *)calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_RADIO_METRICS;
- memcpy(p->radio_id, radio->macaddr, 6);
- p->noise = rssi_to_rcpi(radio->anpi);
- p->transmit = radio->tx_utilization;
- p->receive_self = radio->rx_utilization;
- p->receive_other = radio->other_utilization;
-
- return p;
+ return NULL;
+// struct tlv_radio_metrics *p;
+// struct wifi_radio_element *radio = a->radios + radio_index;
+//
+// p = (struct tlv_radio_metrics *)calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_RADIO_METRICS;
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->noise = rssi_to_rcpi(radio->anpi);
+// p->transmit = radio->tx_utilization;
+// p->receive_self = radio->rx_utilization;
+// p->receive_other = radio->other_utilization;
+//
+// return p;
}
struct tlv_ap_metrics *agent_gen_ap_metrics(struct agent *a,
int radio_index, int bss_index)
{
- struct tlv_ap_metrics *p;
- struct wifi_radio_element *radio = a->radios + radio_index;
- struct wifi_bss_element *bss = radio->bsslist + bss_index;
-
- p = (struct tlv_ap_metrics *)calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_AP_METRICS;
- memcpy(p->bssid, bss->bssid, 6);
- if (bss->is_ac_be) {
- p->is_ac_be = bss->is_ac_be;
- memcpy(p->service_param_info_be, bss->est_wmm_be, 3);
- }
- if (bss->is_ac_bk) {
- p->is_ac_bk = bss->is_ac_bk;
- memcpy(p->service_param_info_bk, bss->est_wmm_bk, 3);
- }
- if (bss->is_ac_vo) {
- p->is_ac_vo = bss->is_ac_vo;
- memcpy(p->service_param_info_vo, bss->est_wmm_vo, 3);
- }
- if (bss->is_ac_vi) {
- p->is_ac_vi = bss->is_ac_vi;
- memcpy(p->service_param_info_vi, bss->est_wmm_vi, 3);
- }
-
- return p;
+ return NULL;
+// struct tlv_ap_metrics *p;
+// struct wifi_radio_element *radio = a->radios + radio_index;
+// struct wifi_bss_element *bss = radio->bsslist + bss_index;
+//
+// p = (struct tlv_ap_metrics *)calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_METRICS;
+// memcpy(p->bssid, bss->bssid, 6);
+// if (bss->is_ac_be) {
+// p->is_ac_be = bss->is_ac_be;
+// memcpy(p->service_param_info_be, bss->est_wmm_be, 3);
+// }
+// if (bss->is_ac_bk) {
+// p->is_ac_bk = bss->is_ac_bk;
+// memcpy(p->service_param_info_bk, bss->est_wmm_bk, 3);
+// }
+// if (bss->is_ac_vo) {
+// p->is_ac_vo = bss->is_ac_vo;
+// memcpy(p->service_param_info_vo, bss->est_wmm_vo, 3);
+// }
+// if (bss->is_ac_vi) {
+// p->is_ac_vi = bss->is_ac_vi;
+// memcpy(p->service_param_info_vi, bss->est_wmm_vi, 3);
+// }
+//
+// return p;
}
struct tlv_ap_ext_metrics *agent_gen_ap_ext_metrics(struct agent *a,
int radio_index, int bss_index)
{
- struct tlv_ap_ext_metrics *p;
- struct wifi_radio_element *radio = a->radios + radio_index;
- struct wifi_bss_element *bss = radio->bsslist + bss_index;
-
- p = (struct tlv_ap_ext_metrics *)calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_AP_EXTENDED_METRICS;
- memcpy(p->bssid, bss->bssid, 6);
- p->uni_bytes_sent = bss->tx_ucast_bytes;
- p->uni_bytes_recv = bss->rx_ucast_bytes;
- p->multi_bytes_sent = bss->tx_mcast_bytes;
- p->multi_bytes_recv = bss->rx_mcast_bytes;
- p->bro_bytes_sent = bss->tx_bcast_bytes;
- p->bro_bytes_recv = bss->rx_bcast_bytes;
-
- return p;
+ return NULL;
+// struct tlv_ap_ext_metrics *p;
+// struct wifi_radio_element *radio = a->radios + radio_index;
+// struct wifi_bss_element *bss = radio->bsslist + bss_index;
+//
+// p = (struct tlv_ap_ext_metrics *)calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_EXTENDED_METRICS;
+// memcpy(p->bssid, bss->bssid, 6);
+// p->uni_bytes_sent = bss->tx_ucast_bytes;
+// p->uni_bytes_recv = bss->rx_ucast_bytes;
+// p->multi_bytes_sent = bss->tx_mcast_bytes;
+// p->multi_bytes_recv = bss->rx_mcast_bytes;
+// p->bro_bytes_sent = bss->tx_bcast_bytes;
+// p->bro_bytes_recv = bss->rx_bcast_bytes;
+//
+// return p;
}
struct tlv_assoc_sta_traffic_stats *agent_gen_assoc_sta_traffic_stats(
struct agent *a, struct sta *s)
{
- struct tlv_assoc_sta_traffic_stats *p;
-
- p = (struct tlv_assoc_sta_traffic_stats *)calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_ASSOCIATED_STA_TRAFFIC_STATS;
- memcpy(p->addr, s->macaddr, 6);
- p->bytes_sent = s->tx_bytes;
- p->bytes_received = s->rx_bytes;
- p->packets_sent = s->tx_pkts;
- p->packets_received = s->rx_pkts;
- p->tx_packets_err = s->tx_fail_pkts;
- p->rx_packets_err = s->rx_fail_pkts;
-
- return p;
+ return NULL;
+// struct tlv_assoc_sta_traffic_stats *p;
+//
+// p = (struct tlv_assoc_sta_traffic_stats *)calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_ASSOCIATED_STA_TRAFFIC_STATS;
+// memcpy(p->addr, s->macaddr, 6);
+// p->bytes_sent = s->tx_bytes;
+// p->bytes_received = s->rx_bytes;
+// p->packets_sent = s->tx_pkts;
+// p->packets_received = s->rx_pkts;
+// p->tx_packets_err = s->tx_fail_pkts;
+// p->rx_packets_err = s->rx_fail_pkts;
+//
+// return p;
}
struct tlv_assoc_sta_link_metrics *agent_gen_assoc_sta_link_metrics(
struct agent *a, struct sta *s, uint8_t *bssid)
{
- int i;
- struct tlv_assoc_sta_link_metrics *p;
-
- p = (struct tlv_assoc_sta_link_metrics *)calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_ASSOCIATED_STA_LINK_METRICS;
- memcpy(p->addr, s->macaddr, 6);
- /* Reported BSS for specific STA */
- p->bssid_nr = 1;
- p->sta_link_metrics_bssid = calloc(p->bssid_nr, sizeof(*p->sta_link_metrics_bssid));
- if (p->sta_link_metrics_bssid) {
- for (i = 0; i < p->bssid_nr; i++) {
- memcpy(p->sta_link_metrics_bssid[i].bssid, bssid, 6);
- p->sta_link_metrics_bssid[i].time_delta = s->connected_ms;
- p->sta_link_metrics_bssid[i].dl_mac_data_rate = s->rx_thput;
- p->sta_link_metrics_bssid[i].ul_mac_data_rate = s->tx_thput;
- p->sta_link_metrics_bssid[i].ul_rcpi = s->rssi[0];
- }
- }
-
- return p;
+ return NULL;
+// int i;
+// struct tlv_assoc_sta_link_metrics *p;
+//
+// p = (struct tlv_assoc_sta_link_metrics *)calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_ASSOCIATED_STA_LINK_METRICS;
+// memcpy(p->addr, s->macaddr, 6);
+// /* Reported BSS for specific STA */
+// p->bssid_nr = 1;
+// p->sta_link_metrics_bssid = calloc(p->bssid_nr, sizeof(*p->sta_link_metrics_bssid));
+// if (p->sta_link_metrics_bssid) {
+// for (i = 0; i < p->bssid_nr; i++) {
+// memcpy(p->sta_link_metrics_bssid[i].bssid, bssid, 6);
+// p->sta_link_metrics_bssid[i].time_delta = s->connected_ms;
+// p->sta_link_metrics_bssid[i].dl_mac_data_rate = s->rx_thput;
+// p->sta_link_metrics_bssid[i].ul_mac_data_rate = s->tx_thput;
+// p->sta_link_metrics_bssid[i].ul_rcpi = s->rssi[0];
+// }
+// }
+//
+// return p;
}
struct tlv_assoc_sta_ext_link_metric *agent_gen_assoc_sta_ext_link_metric(
struct agent *a, struct sta *s, uint8_t *bssid)
{
- int i;
- struct tlv_assoc_sta_ext_link_metric *p;
-
- p = (struct tlv_assoc_sta_ext_link_metric *)calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_ASSOCIATED_STA_EXT_LINK_METRICS;
- memcpy(p->mac, s->macaddr, 6);
- /* Reported BSS for specific STA */
- p->nbr_bssid = 1;
- p->data = calloc(p->nbr_bssid, sizeof(*p->data));
- if (p->data) {
- for (i = 0; i < p->nbr_bssid; i++) {
- memcpy(p->data[i].bssid, bssid, 6);
- p->data[i].last_data_dwn_rate = s->rx_rate;
- p->data[i].last_data_up_rate = s->tx_rate;
- p->data[i].uti_recv = s->rx_airtime;
- p->data[i].uti_transmit = s->tx_airtime;
- }
- }
-
- return p;
+ return NULL;
+// int i;
+// struct tlv_assoc_sta_ext_link_metric *p;
+//
+// p = (struct tlv_assoc_sta_ext_link_metric *)calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_ASSOCIATED_STA_EXT_LINK_METRICS;
+// memcpy(p->mac, s->macaddr, 6);
+// /* Reported BSS for specific STA */
+// p->nbr_bssid = 1;
+// p->data = calloc(p->nbr_bssid, sizeof(*p->data));
+// if (p->data) {
+// for (i = 0; i < p->nbr_bssid; i++) {
+// memcpy(p->data[i].bssid, bssid, 6);
+// p->data[i].last_data_dwn_rate = s->rx_rate;
+// p->data[i].last_data_up_rate = s->tx_rate;
+// p->data[i].uti_recv = s->rx_airtime;
+// p->data[i].uti_transmit = s->tx_airtime;
+// }
+// }
+//
+// return p;
}
struct tlv_ap_radio_identifier *agent_gen_ap_radio_identifier(
struct agent *a, uint8_t *radio_id)
{
- struct tlv_ap_radio_identifier *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_AP_RADIO_IDENTIFIER;
- memcpy(p->radio_id, radio_id, 6);
-
- return p;
+ return NULL;
+// struct tlv_ap_radio_identifier *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_RADIO_IDENTIFIER;
+// memcpy(p->radio_id, radio_id, 6);
+//
+// return p;
}
struct tlv_source_info *agent_gen_source_info(
struct agent *a, uint8_t *mac)
{
- struct tlv_source_info *p;
-
- if (!mac)
- return NULL;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_SOURCE_INFO;
- memcpy(p->mac, mac, 6);
- return p;
+ return NULL;
+// struct tlv_source_info *p;
+//
+// if (!mac)
+// return NULL;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_SOURCE_INFO;
+// memcpy(p->mac, mac, 6);
+// return p;
}
struct tlv_tunnel_msg_type *agent_gen_tunnel_msg_type(
struct agent *a, uint8_t protocol)
{
- struct tlv_tunnel_msg_type *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_TUNNELED_MSG_TYPE;
- p->tunnel_protocol_type = protocol;
- return p;
+ return NULL;
+// struct tlv_tunnel_msg_type *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_TUNNELED_MSG_TYPE;
+// p->tunnel_protocol_type = protocol;
+// return p;
}
struct tlv_tunneled *agent_gen_tunneled(struct agent *a,
int frame_len, uint8_t *frame_body)
{
- struct tlv_tunneled *p;
-
- if ((!frame_body) || (frame_len <= 0))
- return NULL;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_TUNNELED;
- p->tlv_len = frame_len;
- p->frame_body = calloc(frame_len, sizeof(uint8_t));
- if (!p->frame_body) {
- free(p);
- return NULL;
- }
-
- memcpy(p->frame_body, frame_body, frame_len);
- return p;
+ return NULL;
+// struct tlv_tunneled *p;
+//
+// if ((!frame_body) || (frame_len <= 0))
+// return NULL;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_TUNNELED;
+// p->tlv_len = frame_len;
+// p->frame_body = calloc(frame_len, sizeof(uint8_t));
+// if (!p->frame_body) {
+// free(p);
+// return NULL;
+// }
+//
+// memcpy(p->frame_body, frame_body, frame_len);
+// return p;
}
int fill_steering_policy_from_tlv(struct agent *a,
struct tlv_steering_policy *p,
struct uci_context *ctx, struct uci_package *pkg)
{
- int ret, i;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
-
- for (i = 0; i < p->control_policy_radio_nr; i++) {
- int j, k;
- int radio_index;
- struct wifi_radio_element *radio;
- int ifs_index = -1;
-
- radio_index = get_radio_index(a, p->control_policy[i].radio_id);
- if (radio_index == -1)
- continue;
-
- radio = a->radios + radio_index;
- for (j = 0; j < WIFI_DEVICE_MAX_NUM; j++) {
- if (!strcmp(a->ifs[j].radio, radio->name)) {
- ifs_index = j;
- break;
- }
- }
-
- if (ifs_index == -1)
- continue;
-
- /* add the configuration in each iface section for specific radio */
- for (k = 0; k < WIFI_DEVICE_MAX_NUM; k++) {
- uci_foreach_element(&pkg->sections, e) {
- char iface_name[16] = {0};
- struct uci_section *s = uci_to_section(e);
- struct uci_element *e1;
-
- if (strcmp(s->type, "fh-iface"))
- continue;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname",
- pkg->e.name, s->e.name);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ptr.value && (ret != UCI_OK)) {
- fprintf(stderr, "value not found\n");
- continue;
- }
-
- e1 = ptr.last;
- if (e1->type == UCI_TYPE_OPTION)
- strncpy(iface_name, ptr.o->v.string, 15);
-
- if (strcmp(iface_name, a->ifs[ifs_index].iface[k].name))
- continue;
-
- /* Add the policy config params */
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.policy=%d",
- pkg->e.name, s->e.name,
- p->control_policy[i].steering_policy);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.util_threshold=%d",
- pkg->e.name, s->e.name,
- p->control_policy[i].channel_utilization_thres);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.rcpi_threshold=%d",
- pkg->e.name, s->e.name,
- p->control_policy[i].rcpi_steering_thres);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- break;
- }
- }
- }
-
return 0;
+// int ret, i;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64] = {0};
+//
+// for (i = 0; i < p->control_policy_radio_nr; i++) {
+// int j, k;
+// int radio_index;
+// struct wifi_radio_element *radio;
+// int ifs_index = -1;
+//
+// radio_index = get_radio_index(a, p->control_policy[i].radio_id);
+// if (radio_index == -1)
+// continue;
+//
+// radio = a->radios + radio_index;
+// for (j = 0; j < WIFI_DEVICE_MAX_NUM; j++) {
+// if (!strcmp(a->ifs[j].radio, radio->name)) {
+// ifs_index = j;
+// break;
+// }
+// }
+//
+// if (ifs_index == -1)
+// continue;
+//
+// /* add the configuration in each iface section for specific radio */
+// for (k = 0; k < WIFI_DEVICE_MAX_NUM; k++) {
+// uci_foreach_element(&pkg->sections, e) {
+// char iface_name[16] = {0};
+// struct uci_section *s = uci_to_section(e);
+// struct uci_element *e1;
+//
+// if (strcmp(s->type, "fh-iface"))
+// continue;
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname",
+// pkg->e.name, s->e.name);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ptr.value && (ret != UCI_OK)) {
+// fprintf(stderr, "value not found\n");
+// continue;
+// }
+//
+// e1 = ptr.last;
+// if (e1->type == UCI_TYPE_OPTION)
+// strncpy(iface_name, ptr.o->v.string, 15);
+//
+// if (strcmp(iface_name, a->ifs[ifs_index].iface[k].name))
+// continue;
+//
+// /* Add the policy config params */
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.policy=%d",
+// pkg->e.name, s->e.name,
+// p->control_policy[i].steering_policy);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.util_threshold=%d",
+// pkg->e.name, s->e.name,
+// p->control_policy[i].channel_utilization_thres);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.rcpi_threshold=%d",
+// pkg->e.name, s->e.name,
+// p->control_policy[i].rcpi_steering_thres);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// break;
+// }
+// }
+// }
+//
+// return 0;
}
/* for tlv_steering_policy:
@@ -1054,302 +1337,305 @@ int fill_steering_policy_all(struct agent *a,
struct tlv_steering_policy *p,
struct uci_context *ctx, struct uci_package *pkg)
{
- int ret, i;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
-
- /* add the configuration in each iface section */
- i = 0;
- uci_foreach_element(&pkg->sections, e) {
- struct uci_section *s = uci_to_section(e);
-
- if (strcmp(s->type, "fh-iface"))
- continue;
-
- /* Add the policy config params */
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.policy=%d",
- pkg->e.name, s->e.name,
- p->control_policy[i].steering_policy);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.util_threshold=%d",
- pkg->e.name, s->e.name,
- p->control_policy[i].channel_utilization_thres);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.rcpi_threshold=%d",
- pkg->e.name, s->e.name,
- p->control_policy[i].rcpi_steering_thres);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
- }
-
return 0;
+// int ret, i;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64] = {0};
+//
+// /* add the configuration in each iface section */
+// i = 0;
+// uci_foreach_element(&pkg->sections, e) {
+// struct uci_section *s = uci_to_section(e);
+//
+// if (strcmp(s->type, "fh-iface"))
+// continue;
+//
+// /* Add the policy config params */
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.policy=%d",
+// pkg->e.name, s->e.name,
+// p->control_policy[i].steering_policy);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.util_threshold=%d",
+// pkg->e.name, s->e.name,
+// p->control_policy[i].channel_utilization_thres);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.rcpi_threshold=%d",
+// pkg->e.name, s->e.name,
+// p->control_policy[i].rcpi_steering_thres);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+// }
+//
+// return 0;
}
int agent_fill_steering_policy(struct agent *a,
struct tlv_steering_policy *p,
struct uci_context *ctx, struct uci_package *pkg)
{
- int ret, i;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
- char addr[18] = {0};
- uint8_t generic_id[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
- /* Add exclude list & btm exclude list in 'agent' section */
- uci_foreach_element(&pkg->sections, e) {
- struct uci_section *s = uci_to_section(e);
-
- if (strcmp(s->type, "agent"))
- continue;
-
- for (i = 0; i < p->local_disallowed_sta_nr; i++) {
- bool is_entry = false;
- struct uci_element *e1;
- struct uci_option *o;
-
- memset(addr, 0, sizeof(addr));
- hwaddr_ntoa(p->local_disallowed_sta_macs[i].addr, addr);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.%s", pkg->e.name,
- s->e.name, "steer_exclude");
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- o = ptr.o;
- if ((ptr.flags & UCI_LOOKUP_COMPLETE) &&
- (o->type == UCI_TYPE_LIST)) {
- uci_foreach_element(&o->v.list, e1) {
- if (!strncmp(e1->name, addr, sizeof(addr) - 1)) {
- is_entry = true;
- break;
- }
- }
- }
-
- /* skip, entry already available */
- if (is_entry)
- continue;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.steer_exclude=%s",
- pkg->e.name, s->e.name, addr);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_add_list(ctx, &ptr);
- uci_save(ctx, ptr.p);
- }
-
- for (i = 0; i < p->btm_disallowed_sta_nr; i++) {
- bool is_entry = false;
- struct uci_element *e1;
- struct uci_option *o;
-
- memset(addr, 0, sizeof(addr));
- hwaddr_ntoa(p->btm_disallowed_sta_macs[i].addr, addr);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.%s", pkg->e.name,
- s->e.name, "steer_exclude_btm");
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- o = ptr.o;
- if ((ptr.flags & UCI_LOOKUP_COMPLETE) &&
- (o->type == UCI_TYPE_LIST)) {
- uci_foreach_element(&o->v.list, e1) {
- if (!strncmp(e1->name, addr, sizeof(addr) - 1)) {
- is_entry = true;
- break;
- }
- }
- }
-
- /* skip, entry already available */
- if (is_entry)
- continue;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.steer_exclude_btm=%s",
- pkg->e.name, s->e.name, addr);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_add_list(ctx, &ptr);
- uci_save(ctx, ptr.p);
- }
-
- break;
- }
-
- if ((p->control_policy_radio_nr == 1) &&
- !memcmp(p->control_policy[0].radio_id, generic_id, 6)) {
- fill_steering_policy_all(a, p, ctx, pkg);
- } else
- fill_steering_policy_from_tlv(a, p, ctx, pkg);
-
return 0;
+// int ret, i;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64] = {0};
+// char addr[18] = {0};
+// uint8_t generic_id[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+//
+// /* Add exclude list & btm exclude list in 'agent' section */
+// uci_foreach_element(&pkg->sections, e) {
+// struct uci_section *s = uci_to_section(e);
+//
+// if (strcmp(s->type, "agent"))
+// continue;
+//
+// for (i = 0; i < p->local_disallowed_sta_nr; i++) {
+// bool is_entry = false;
+// struct uci_element *e1;
+// struct uci_option *o;
+//
+// memset(addr, 0, sizeof(addr));
+// hwaddr_ntoa(p->local_disallowed_sta_macs[i].addr, addr);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.%s", pkg->e.name,
+// s->e.name, "steer_exclude");
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// o = ptr.o;
+// if ((ptr.flags & UCI_LOOKUP_COMPLETE) &&
+// (o->type == UCI_TYPE_LIST)) {
+// uci_foreach_element(&o->v.list, e1) {
+// if (!strncmp(e1->name, addr, sizeof(addr) - 1)) {
+// is_entry = true;
+// break;
+// }
+// }
+// }
+//
+// /* skip, entry already available */
+// if (is_entry)
+// continue;
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.steer_exclude=%s",
+// pkg->e.name, s->e.name, addr);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_add_list(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+// }
+//
+// for (i = 0; i < p->btm_disallowed_sta_nr; i++) {
+// bool is_entry = false;
+// struct uci_element *e1;
+// struct uci_option *o;
+//
+// memset(addr, 0, sizeof(addr));
+// hwaddr_ntoa(p->btm_disallowed_sta_macs[i].addr, addr);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.%s", pkg->e.name,
+// s->e.name, "steer_exclude_btm");
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// o = ptr.o;
+// if ((ptr.flags & UCI_LOOKUP_COMPLETE) &&
+// (o->type == UCI_TYPE_LIST)) {
+// uci_foreach_element(&o->v.list, e1) {
+// if (!strncmp(e1->name, addr, sizeof(addr) - 1)) {
+// is_entry = true;
+// break;
+// }
+// }
+// }
+//
+// /* skip, entry already available */
+// if (is_entry)
+// continue;
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.steer_exclude_btm=%s",
+// pkg->e.name, s->e.name, addr);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_add_list(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+// }
+//
+// break;
+// }
+//
+// if ((p->control_policy_radio_nr == 1) &&
+// !memcmp(p->control_policy[0].radio_id, generic_id, 6)) {
+// fill_steering_policy_all(a, p, ctx, pkg);
+// } else
+// fill_steering_policy_from_tlv(a, p, ctx, pkg);
+//
+// return 0;
}
int fill_metric_report_policy_from_tlv(struct agent *a,
struct tlv_metric_report_policy *p, struct uci_context *ctx,
struct uci_package *pkg)
{
- int ret, i;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
-
- /* Add radio specific params in fh-iface section */
- for (i = 0; i < p->metric_reporting_policy_radio_nr; i++) {
- int j, k;
- int ifs_index = -1;
- int radio_index;
- struct wifi_radio_element *radio;
-
- radio_index = get_radio_index(a,
- p->metric_reporting_policy[i].radio_id);
- if (radio_index == -1)
- continue;
-
- radio = a->radios + radio_index;
- for (j = 0; j < WIFI_DEVICE_MAX_NUM; j++) {
- if (!strcmp(a->ifs[j].radio, radio->name)) {
- ifs_index = j;
- break;
- }
- }
-
- if (ifs_index == -1)
- continue;
-
- /* add configuration in each iface section for specific radio */
- for (k = 0; k < WIFI_DEVICE_MAX_NUM; k++) {
- uci_foreach_element(&pkg->sections, e) {
- char iface_name[16] = {0};
- struct uci_section *s = uci_to_section(e);
- struct uci_element *e1;
-
- if (strcmp(s->type, "fh-iface"))
- continue;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname",
- pkg->e.name, s->e.name);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ptr.value && (ret != UCI_OK)) {
- fprintf(stderr, "value not found\n");
- continue;
- }
-
- e1 = ptr.last;
- if (e1->type == UCI_TYPE_OPTION)
- strncpy(iface_name, ptr.o->v.string, 15);
-
- if (strcmp(iface_name, a->ifs[ifs_index].iface[k].name))
- continue;
-
- /* Add the policy config params */
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.report_rcpi_threshold=%d",
- pkg->e.name, s->e.name,
- p->metric_reporting_policy[i].rcpi_thres);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.rcpi_hysteresis_margin=%d",
- pkg->e.name, s->e.name,
- p->metric_reporting_policy[i].rcpi_hysteresis_margin);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.report_util_threshold=%d",
- pkg->e.name, s->e.name,
- p->metric_reporting_policy[i].channel_utilization_thres);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.include_sta_stats=%d",
- pkg->e.name, s->e.name,
- p->metric_reporting_policy[i].is_assoc_sta_traffic_stats);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.include_sta_metric=%d",
- pkg->e.name, s->e.name,
- p->metric_reporting_policy[i].is_assoc_sta_link_metrics);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- break;
- }
- }
-
- }
-
return 0;
+// int ret, i;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64] = {0};
+//
+// /* Add radio specific params in fh-iface section */
+// for (i = 0; i < p->metric_reporting_policy_radio_nr; i++) {
+// int j, k;
+// int ifs_index = -1;
+// int radio_index;
+// struct wifi_radio_element *radio;
+//
+// radio_index = get_radio_index(a,
+// p->metric_reporting_policy[i].radio_id);
+// if (radio_index == -1)
+// continue;
+//
+// radio = a->radios + radio_index;
+// for (j = 0; j < WIFI_DEVICE_MAX_NUM; j++) {
+// if (!strcmp(a->ifs[j].radio, radio->name)) {
+// ifs_index = j;
+// break;
+// }
+// }
+//
+// if (ifs_index == -1)
+// continue;
+//
+// /* add configuration in each iface section for specific radio */
+// for (k = 0; k < WIFI_DEVICE_MAX_NUM; k++) {
+// uci_foreach_element(&pkg->sections, e) {
+// char iface_name[16] = {0};
+// struct uci_section *s = uci_to_section(e);
+// struct uci_element *e1;
+//
+// if (strcmp(s->type, "fh-iface"))
+// continue;
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname",
+// pkg->e.name, s->e.name);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ptr.value && (ret != UCI_OK)) {
+// fprintf(stderr, "value not found\n");
+// continue;
+// }
+//
+// e1 = ptr.last;
+// if (e1->type == UCI_TYPE_OPTION)
+// strncpy(iface_name, ptr.o->v.string, 15);
+//
+// if (strcmp(iface_name, a->ifs[ifs_index].iface[k].name))
+// continue;
+//
+// /* Add the policy config params */
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.report_rcpi_threshold=%d",
+// pkg->e.name, s->e.name,
+// p->metric_reporting_policy[i].rcpi_thres);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.rcpi_hysteresis_margin=%d",
+// pkg->e.name, s->e.name,
+// p->metric_reporting_policy[i].rcpi_hysteresis_margin);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.report_util_threshold=%d",
+// pkg->e.name, s->e.name,
+// p->metric_reporting_policy[i].channel_utilization_thres);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.include_sta_stats=%d",
+// pkg->e.name, s->e.name,
+// p->metric_reporting_policy[i].is_assoc_sta_traffic_stats);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.include_sta_metric=%d",
+// pkg->e.name, s->e.name,
+// p->metric_reporting_policy[i].is_assoc_sta_link_metrics);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// break;
+// }
+// }
+//
+// }
+//
+// return 0;
}
/* for metric_reporting_policy_tlv:
@@ -1428,314 +1714,42 @@ int fill_metric_report_policy_all(struct agent *a,
pkg->e.name, s->e.name,
p->metric_reporting_policy[i].is_assoc_sta_link_metrics);
ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- }
-
- return 0;
-}
-
-
-int agent_fill_metric_report_policy(struct agent *a,
- struct tlv_metric_report_policy *p, struct uci_context *ctx,
- struct uci_package *pkg)
-{
- int ret;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
- bool is_section_found = false;
- struct uci_section *s;
- uint8_t generic_id[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
- uci_foreach_element(&pkg->sections, e) {
- s = uci_to_section(e);
-
- if (!strcmp(s->type, "policy")) {
- is_section_found = true;
- break;
- }
- }
-
- if (!is_section_found) {
- /* add a new section 'policy' */
- ret = uci_add_section(ctx, pkg, "policy", &s);
- if (ret != UCI_OK)
- return -1;
-
- uci_save(ctx, pkg);
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.report_interval=%d",
- pkg->e.name, s->e.name, p->interval);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- if ((p->metric_reporting_policy_radio_nr == 1) &&
- !memcmp(p->metric_reporting_policy[0].radio_id, generic_id, 6)) {
- fill_metric_report_policy_all(a, p, ctx, pkg);
- } else
- fill_metric_report_policy_from_tlv(a, p, ctx, pkg);
-
- return 0;
-}
-
-int agent_fill_8021q_setting(struct agent *a,
- struct tlv_default_8021q_settings *p, struct uci_context *ctx,
- struct uci_package *pkg)
-{
- int ret;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
- struct uci_section *s;
- bool is_section_found = false;
-
- uci_foreach_element(&pkg->sections, e) {
- s = uci_to_section(e);
-
- if (!strcmp(s->type, "policy")) {
- is_section_found = true;
- break;
- }
- }
-
- if (!is_section_found) {
- /* add a new section 'policy' */
- ret = uci_add_section(ctx, pkg, "policy", &s);
- if (ret != UCI_OK)
- return -1;
-
- uci_save(ctx, pkg);
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.pvid=%d",
- pkg->e.name, s->e.name,
- p->primary_vid);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.pcp_default=%d",
- pkg->e.name, s->e.name, p->pcp);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- return 0;
-}
-
-int agent_fill_traffic_sep_policy(struct agent *a,
- struct tlv_traffic_sep_policy *p, struct uci_context *ctx,
- struct uci_package *pkg)
-{
- int ret, i;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64];
-
- for (i = 0; i < p->nbr_ssid; i++) {
- uci_foreach_element(&pkg->sections, e) {
- struct uci_element *e1;
- struct uci_section *s = uci_to_section(e);
- char section_ssid[32] = {0};
-
- if (strcmp(s->type, "fh-iface") &&
- strcmp(s->type, "bk-iface"))
- continue;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.ssid",
- pkg->e.name, s->e.name);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
-
- e1 = ptr.last;
- if (e1->type == UCI_TYPE_OPTION)
- strncpy(section_ssid, ptr.o->v.string, 31);
-
- if (strcmp(section_ssid, p->data[i].ssid))
- continue;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.vid=%d",
- pkg->e.name, s->e.name,
- p->data[i].vid);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
- break;
- }
- }
-
- return 0;
-}
-
-int agent_fill_ch_scan_rep_policy(struct agent *a,
- struct tlv_ch_scan_rep_policy *p, struct uci_context *ctx,
- struct uci_package *pkg)
-{
- int ret;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
- bool is_section_found = false;
- struct uci_section *s;
-
- uci_foreach_element(&pkg->sections, e) {
- s = uci_to_section(e);
-
- if (!strcmp(s->type, "policy")) {
- is_section_found = true;
- break;
- }
- }
-
- if (!is_section_found) {
- /* add a new section 'policy' */
- ret = uci_add_section(ctx, pkg, "policy", &s);
- if (ret != UCI_OK)
- return -1;
-
- uci_save(ctx, pkg);
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.report_scan=%d",
- pkg->e.name, s->e.name,
- p->ch_scans);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
-
- return 0;
-}
-
-int agent_fill_unsuccess_assoc_policy(struct agent *a,
- struct tlv_unsuccess_assoc_policy *p, struct uci_context *ctx,
- struct uci_package *pkg)
-{
- int ret;
- struct uci_element *e;
- struct uci_ptr ptr;
- char buf[64] = {0};
- bool is_section_found = false;
- struct uci_section *s;
-
- uci_foreach_element(&pkg->sections, e) {
- s = uci_to_section(e);
-
- if (!strcmp(s->type, "policy")) {
- is_section_found = true;
- break;
- }
- }
-
- if (!is_section_found) {
- /* add a new section 'policy' */
- ret = uci_add_section(ctx, pkg, "policy", &s);
- if (ret != UCI_OK)
- return -1;
-
- uci_save(ctx, pkg);
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.report_sta_assocfails=%d",
- pkg->e.name, s->e.name, p->report);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
-
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
+ if (ret != UCI_OK)
+ return -1;
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.report_sta_assocfails_rate=%d",
- pkg->e.name, s->e.name,
- p->max_reporting_rate);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
+ uci_set(ctx, &ptr);
+ uci_save(ctx, ptr.p);
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
+ }
return 0;
}
-int agent_fill_backhaul_bss_config(struct agent *a,
- struct tlv_backhaul_bss_config *p, struct uci_context *ctx,
+
+int agent_fill_metric_report_policy(struct agent *a,
+ struct tlv_metric_report_policy *p, struct uci_context *ctx,
struct uci_package *pkg)
{
- struct netif_fh *fh;
+ int ret;
struct uci_element *e;
struct uci_ptr ptr;
- int ret;
- bool is_bksec_found = false;
- struct uci_section *s;
char buf[64] = {0};
-
- fh = wifi_get_netif_by_bssid(a, p->bssid);
- if (fh == NULL)
- return -1;
+ bool is_section_found = false;
+ struct uci_section *s;
+ uint8_t generic_id[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
uci_foreach_element(&pkg->sections, e) {
- struct uci_element *e1;
- char section_ifname[16] = {0};
-
s = uci_to_section(e);
- if (strcmp(s->type, "bk-iface"))
- continue;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname",
- pkg->e.name, s->e.name);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ptr.value && (ret != UCI_OK))
- return -1;
-
- e1 = ptr.last;
- if (e1->type == UCI_TYPE_OPTION)
- strncpy(section_ifname, ptr.o->v.string, 15);
- if (!strcmp(section_ifname, fh->name)) {
- is_bksec_found = true;
+ if (!strcmp(s->type, "policy")) {
+ is_section_found = true;
break;
}
}
- if (!is_bksec_found) {
- /* Add a new 'bk-iface section' */
- ret = uci_add_section(ctx, pkg, "bk-iface", &s);
+ if (!is_section_found) {
+ /* add a new section 'policy' */
+ ret = uci_add_section(ctx, pkg, "policy", &s);
if (ret != UCI_OK)
return -1;
@@ -1743,8 +1757,9 @@ int agent_fill_backhaul_bss_config(struct agent *a,
}
memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname=%s",
- pkg->e.name, s->e.name, fh->name);
+ snprintf(buf, sizeof(buf) - 1,
+ "%s.%s.report_interval=%d",
+ pkg->e.name, s->e.name, p->interval);
ret = uci_lookup_ptr(ctx, &ptr, buf, true);
if (ret != UCI_OK)
return -1;
@@ -1752,29 +1767,305 @@ int agent_fill_backhaul_bss_config(struct agent *a,
uci_set(ctx, &ptr);
uci_save(ctx, ptr.p);
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.disallow_bsta_p1=%d",
- pkg->e.name, s->e.name, p->p1);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
+ if ((p->metric_reporting_policy_radio_nr == 1) &&
+ !memcmp(p->metric_reporting_policy[0].radio_id, generic_id, 6)) {
+ fill_metric_report_policy_all(a, p, ctx, pkg);
+ } else
+ fill_metric_report_policy_from_tlv(a, p, ctx, pkg);
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
+ return 0;
+}
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf) - 1,
- "%s.%s.disallow_bsta_p2=%d",
- pkg->e.name, s->e.name, p->p2);
- ret = uci_lookup_ptr(ctx, &ptr, buf, true);
- if (ret != UCI_OK)
- return -1;
+int agent_fill_8021q_setting(struct agent *a,
+ struct tlv_default_8021q_settings *p, struct uci_context *ctx,
+ struct uci_package *pkg)
+{
+ return 0;
+// int ret;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64] = {0};
+// struct uci_section *s;
+// bool is_section_found = false;
+//
+// uci_foreach_element(&pkg->sections, e) {
+// s = uci_to_section(e);
+//
+// if (!strcmp(s->type, "policy")) {
+// is_section_found = true;
+// break;
+// }
+// }
+//
+// if (!is_section_found) {
+// /* add a new section 'policy' */
+// ret = uci_add_section(ctx, pkg, "policy", &s);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_save(ctx, pkg);
+// }
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.pvid=%d",
+// pkg->e.name, s->e.name,
+// p->primary_vid);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.pcp_default=%d",
+// pkg->e.name, s->e.name, p->pcp);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// return 0;
+}
- uci_set(ctx, &ptr);
- uci_save(ctx, ptr.p);
+int agent_fill_traffic_sep_policy(struct agent *a,
+ struct tlv_traffic_sep_policy *p, struct uci_context *ctx,
+ struct uci_package *pkg)
+{
+ return 0;
+// int ret, i;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64];
+//
+// for (i = 0; i < p->nbr_ssid; i++) {
+// uci_foreach_element(&pkg->sections, e) {
+// struct uci_element *e1;
+// struct uci_section *s = uci_to_section(e);
+// char section_ssid[32] = {0};
+//
+// if (strcmp(s->type, "fh-iface") &&
+// strcmp(s->type, "bk-iface"))
+// continue;
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.ssid",
+// pkg->e.name, s->e.name);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+//
+// e1 = ptr.last;
+// if (e1->type == UCI_TYPE_OPTION)
+// strncpy(section_ssid, ptr.o->v.string, 31);
+//
+// if (strcmp(section_ssid, p->data[i].ssid))
+// continue;
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.vid=%d",
+// pkg->e.name, s->e.name,
+// p->data[i].vid);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+// break;
+// }
+// }
+//
+// return 0;
+}
+
+int agent_fill_ch_scan_rep_policy(struct agent *a,
+ struct tlv_channel_scan_report_policy *p, struct uci_context *ctx,
+ struct uci_package *pkg)
+{
+ return 0;
+// int ret;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64] = {0};
+// bool is_section_found = false;
+// struct uci_section *s;
+//
+// uci_foreach_element(&pkg->sections, e) {
+// s = uci_to_section(e);
+//
+// if (!strcmp(s->type, "policy")) {
+// is_section_found = true;
+// break;
+// }
+// }
+//
+// if (!is_section_found) {
+// /* add a new section 'policy' */
+// ret = uci_add_section(ctx, pkg, "policy", &s);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_save(ctx, pkg);
+// }
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.report_scan=%d",
+// pkg->e.name, s->e.name,
+// p->ch_scans);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// return 0;
+}
+
+int agent_fill_unsuccess_assoc_policy(struct agent *a,
+ struct tlv_unsuccess_assoc_policy *p, struct uci_context *ctx,
+ struct uci_package *pkg)
+{
+ return 0;
+// int ret;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// char buf[64] = {0};
+// bool is_section_found = false;
+// struct uci_section *s;
+//
+// uci_foreach_element(&pkg->sections, e) {
+// s = uci_to_section(e);
+//
+// if (!strcmp(s->type, "policy")) {
+// is_section_found = true;
+// break;
+// }
+// }
+//
+// if (!is_section_found) {
+// /* add a new section 'policy' */
+// ret = uci_add_section(ctx, pkg, "policy", &s);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_save(ctx, pkg);
+// }
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.report_sta_assocfails=%d",
+// pkg->e.name, s->e.name, p->report);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.report_sta_assocfails_rate=%d",
+// pkg->e.name, s->e.name,
+// p->max_reporting_rate);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// return 0;
+}
+int agent_fill_backhaul_bss_config(struct agent *a,
+ struct tlv_bbss_config *p, struct uci_context *ctx,
+ struct uci_package *pkg)
+{
return 0;
+// struct netif_fh *fh;
+// struct uci_element *e;
+// struct uci_ptr ptr;
+// int ret;
+// bool is_bksec_found = false;
+// struct uci_section *s;
+// char buf[64] = {0};
+//
+// fh = wifi_get_netif_by_bssid(a, p->bssid);
+// if (fh == NULL)
+// return -1;
+//
+// uci_foreach_element(&pkg->sections, e) {
+// struct uci_element *e1;
+// char section_ifname[16] = {0};
+//
+// s = uci_to_section(e);
+// if (strcmp(s->type, "bk-iface"))
+// continue;
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname",
+// pkg->e.name, s->e.name);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ptr.value && (ret != UCI_OK))
+// return -1;
+//
+// e1 = ptr.last;
+// if (e1->type == UCI_TYPE_OPTION)
+// strncpy(section_ifname, ptr.o->v.string, 15);
+//
+// if (!strcmp(section_ifname, fh->name)) {
+// is_bksec_found = true;
+// break;
+// }
+// }
+//
+// if (!is_bksec_found) {
+// /* Add a new 'bk-iface section' */
+// ret = uci_add_section(ctx, pkg, "bk-iface", &s);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_save(ctx, pkg);
+// }
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1, "%s.%s.ifname=%s",
+// pkg->e.name, s->e.name, fh->name);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.disallow_bsta_p1=%d",
+// pkg->e.name, s->e.name, p->p1);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// memset(buf, 0, sizeof(buf));
+// snprintf(buf, sizeof(buf) - 1,
+// "%s.%s.disallow_bsta_p2=%d",
+// pkg->e.name, s->e.name, p->p2);
+// ret = uci_lookup_ptr(ctx, &ptr, buf, true);
+// if (ret != UCI_OK)
+// return -1;
+//
+// uci_set(ctx, &ptr);
+// uci_save(ctx, ptr.p);
+//
+// return 0;
}
/* for backhaul_bss_config_tlv:
@@ -1830,32 +2121,33 @@ int agent_fill_backhaul_bss_config_all(struct agent *a,
struct tlv_vendor_specific *agent_gen_vendor_specific_tlv(struct agent *a, uint8_t depth)
{
- struct tlv_vendor_specific *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = TLV_TYPE_VENDOR_SPECIFIC;
- /* IOPSYS vendor oui */
- p->vendor_oui[0] = 0x00;
- p->vendor_oui[1] = 0x22;
- p->vendor_oui[2] = 0x07;
-
- p->m_nr = 1 + 1 + 2 + 1; // number of tlvs, type, len, val
- p->m = calloc(1, p->m_nr);
- if (!p->m)
- goto error;
-
- p->m[0] = 0x01;
- p->m[1] = VENDOR_SPECIFIC_TYPE_DEPTH;
- p->m[3] = 1;
- p->m[4] = depth;
-
- return p;
-error:
- free(p);
return NULL;
+// struct tlv_vendor_specific *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = TLV_TYPE_VENDOR_SPECIFIC;
+// /* IOPSYS vendor oui */
+// p->vendor_oui[0] = 0x00;
+// p->vendor_oui[1] = 0x22;
+// p->vendor_oui[2] = 0x07;
+//
+// p->m_nr = 1 + 1 + 2 + 1; // number of tlvs, type, len, val
+// p->m = calloc(1, p->m_nr);
+// if (!p->m)
+// goto error;
+//
+// p->m[0] = 0x01;
+// p->m[1] = VENDOR_SPECIFIC_TYPE_DEPTH;
+// p->m[3] = 1;
+// p->m[4] = depth;
+//
+// return p;
+//error:
+// free(p);
+// return NULL;
}
char *get_timestamp(time_t *t, char **tbuf)
@@ -1976,103 +2268,108 @@ struct tlv_ch_scan_res *agent_gen_non_success_ch_scan_respons_tlv(struct agent *
struct tlv_backhaul_sta_radio_cap *agent_gen_bk_sta_radio_cap_tlv(struct agent *a, uint32_t radio_index)
{
- struct wifi_radio_element *radio = a->radios + radio_index;
- struct tlv_backhaul_sta_radio_cap *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_BACKHAUL_STA_RADIO_CAPABILITY;
- memcpy(p->radio_id, radio->macaddr, 6);
- p->mac_include = 0;
- struct netif_bk *bk;
- struct wifi_radio_element *bk_radio;
-
- list_for_each_entry(bk, &a->bklist, list) {
- dbg("bk ifname: %s\n", bk->cfg->name);
- bk_radio = wifi_ifname_to_radio_element(a,
- bk->cfg->name);
- if (!bk_radio)
- return NULL;
-
- dbg("bk radio name: %s\n", bk_radio->name);
- dbg("bk radio mac: " MACFMT "\n",
- MAC2STR(bk_radio->macaddr));
- if (!strcmp(radio->name, bk_radio->name)) {
- memcpy(p->mac, bk->bssid, 6);
- p->mac_include = 1;
- }
- dbg("mac_included: %d", p->mac_include);
- }
- return p;
+ return NULL;
+// struct wifi_radio_element *radio = a->radios + radio_index;
+// struct tlv_backhaul_sta_radio_cap *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_BACKHAUL_STA_RADIO_CAPABILITY;
+// memcpy(p->radio_id, radio->macaddr, 6);
+// p->mac_include = 0;
+// struct netif_bk *bk;
+// struct wifi_radio_element *bk_radio;
+//
+// list_for_each_entry(bk, &a->bklist, list) {
+// dbg("bk ifname: %s\n", bk->cfg->name);
+// bk_radio = wifi_ifname_to_radio_element(a,
+// bk->cfg->name);
+// if (!bk_radio)
+// return NULL;
+//
+// dbg("bk radio name: %s\n", bk_radio->name);
+// dbg("bk radio mac: " MACFMT "\n",
+// MAC2STR(bk_radio->macaddr));
+// if (!strcmp(radio->name, bk_radio->name)) {
+// memcpy(p->mac, bk->bssid, 6);
+// p->mac_include = 1;
+// }
+// dbg("mac_included: %d", p->mac_include);
+// }
+// return p;
}
struct tlv_client_assoc_event *agent_gen_client_assoc_event_tlv(struct agent *agent,
uint8_t *mac, uint8_t *bssid, uint8_t assoc_event)
{
- struct tlv_client_assoc_event *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_CLIENT_ASSOCIATION_EVENT;
- memcpy(p->client_addr, mac, 6);
- memcpy(p->bssid, bssid, 6);
- p->assoc_event = assoc_event;
-
- return p;
+ return NULL;
+// struct tlv_client_assoc_event *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_CLIENT_ASSOCIATION_EVENT;
+// memcpy(p->client_addr, mac, 6);
+// memcpy(p->bssid, bssid, 6);
+// p->assoc_event = assoc_event;
+//
+// return p;
}
struct tlv_sta_mac *agent_gen_sta_mac_tlv(struct agent *agent, uint8_t *mac)
{
- struct tlv_sta_mac *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_STA_MAC_ADDRESS;
- memcpy(p->addr, mac, 6);
-
- return p;
+ return NULL;
+// struct tlv_sta_mac *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_STA_MAC_ADDRESS;
+// memcpy(p->addr, mac, 6);
+//
+// return p;
}
struct tlv_reason_code *agent_gen_reason_code_tlv(struct agent *agent)
{
- struct tlv_reason_code *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_REASON_CODE;
- p->reason_code = 1; // dummy ?
-
- return p;
+ return NULL;
+// struct tlv_reason_code *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_REASON_CODE;
+// p->reason_code = 1; // dummy ?
+//
+// return p;
}
struct tlv_assoc_sta_traffic_stats *agent_gen_assoc_sta_traffic_stats_tlv(struct agent *a,
uint8_t *mac)
{
- struct tlv_assoc_sta_traffic_stats *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_ASSOCIATED_STA_TRAFFIC_STATS;
- memcpy(p->addr, mac, 6);
- p->bytes_sent = 0; // dummy ?
- p->bytes_received = 0;
- p->packets_sent = 0;
- p->packets_received = 0;
- p->tx_packets_err = 0;
- p->rx_packets_err = 0;
- p->retransmission_cnt = 0;
-
- return p;
+ return NULL;
+// struct tlv_assoc_sta_traffic_stats *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_ASSOCIATED_STA_TRAFFIC_STATS;
+// memcpy(p->addr, mac, 6);
+// p->bytes_sent = 0; // dummy ?
+// p->bytes_received = 0;
+// p->packets_sent = 0;
+// p->packets_received = 0;
+// p->tx_packets_err = 0;
+// p->rx_packets_err = 0;
+// p->retransmission_cnt = 0;
+//
+// return p;
}
/********************************************************
@@ -2082,386 +2379,397 @@ struct tlv_assoc_sta_traffic_stats *agent_gen_assoc_sta_traffic_stats_tlv(struct
static void parse_eth_devices(struct ubus_request *req, int type,
struct blob_attr *msg)
{
- struct tlv_device_info *p = (struct tlv_device_info *)req->priv;
- struct blob_attr *cur;
- void *tmp;
- int rem;
-
- blobmsg_for_each_attr(cur, msg, rem) {
- struct blob_attr *tb[2];
- static const struct blobmsg_policy attr[2] = {
- [0] = { .name = "macaddr", .type = BLOBMSG_TYPE_STRING },
- [1] = { .name = "link-supported", .type = BLOBMSG_TYPE_STRING },
- };
- int idx = p->local_interfaces_nr;
-
- blobmsg_parse(attr, 2, tb, blob_data(cur), blob_len(cur));
-
- if (!tb[0] || !tb[1])
- continue;
-
- tmp = realloc(p->local_interfaces,
- (idx + 1) * sizeof(*p->local_interfaces));
- if (!tmp)
- break;
-
- p->local_interfaces = tmp;
- p->local_interfaces_nr++;
-
- memcpy(p->local_interfaces[idx].mac_address,
- blobmsg_data(tb[0]),
- sizeof(p->local_interfaces[idx].mac_address));
-
- p->local_interfaces[idx].media_type =
- strstr(blobmsg_data(tb[1]), "1000baseT") ? 0x0001 : 0x0000;
- }
+ return;
+// struct tlv_device_info *p = (struct tlv_device_info *)req->priv;
+// struct blob_attr *cur;
+// void *tmp;
+// int rem;
+//
+// blobmsg_for_each_attr(cur, msg, rem) {
+// struct blob_attr *tb[2];
+// static const struct blobmsg_policy attr[2] = {
+// [0] = { .name = "macaddr", .type = BLOBMSG_TYPE_STRING },
+// [1] = { .name = "link-supported", .type = BLOBMSG_TYPE_STRING },
+// };
+// int idx = p->local_interfaces_nr;
+//
+// blobmsg_parse(attr, 2, tb, blob_data(cur), blob_len(cur));
+//
+// if (!tb[0] || !tb[1])
+// continue;
+//
+// tmp = realloc(p->local_interfaces,
+// (idx + 1) * sizeof(*p->local_interfaces));
+// if (!tmp)
+// break;
+//
+// p->local_interfaces = tmp;
+// p->local_interfaces_nr++;
+//
+// memcpy(p->local_interfaces[idx].mac_address,
+// blobmsg_data(tb[0]),
+// sizeof(p->local_interfaces[idx].mac_address));
+//
+// p->local_interfaces[idx].media_type =
+// strstr(blobmsg_data(tb[1]), "1000baseT") ? 0x0001 : 0x0000;
+// }
}
static uint16_t get_wifi_media_type(struct agent *a, int radio_idx, int bss_idx)
{
- struct netif_fh *fh;
- char *standard = NULL, *p1, *p2;
- uint16_t ret = 0xFFFF;
-
- // get standard from fhlist
- list_for_each_entry(fh, &a->fhlist, list) {
- if (hwaddr_equal(fh->bssid,
- a->radios[radio_idx].bsslist[bss_idx].bssid))
- standard = strdup(fh->standard);
- }
-
- if (!standard || !strncmp(standard, "802.11", strlen("802.11")))
- goto end;
-
- // parse standard to 1905 media type
- p1 = standard + strlen("802.11");
-again:
- p2 = strrchr(p1, '/');
- if (!p2)
- p2 = p1;
-
- // TODO: add sanity checks for band?
- if (!strcasecmp(p2, "b"))
- ret = 0x0100;
- else if (!strcasecmp(p2, "g"))
- ret = 0x0101;
- else if (!strcasecmp(p2, "a"))
- ret = 0x0102;
- else if (!strcasecmp(p2, "n"))
- if (a->radios[radio_idx].band == BAND_2)
- ret = 0x0103;
- else
- ret = 0x0104;
- else if (!strcasecmp(p2, "ac"))
- ret = 0x0105;
- else if (!strcasecmp(p2, "ad"))
- ret = 0x0106;
- else if (!strcasecmp(p2, "af"))
- ret = 0x0107;
- else
- // if we don't know this one, check the next one if there is one
- if (p2 != p1)
- goto again;
-end:
- free(standard);
- return ret;
+ return 0;
+// struct netif_fh *fh;
+// char *standard = NULL, *p1, *p2;
+// uint16_t ret = 0xFFFF;
+//
+// // get standard from fhlist
+// list_for_each_entry(fh, &a->fhlist, list) {
+// if (hwaddr_equal(fh->bssid,
+// a->radios[radio_idx].bsslist[bss_idx].bssid))
+// standard = strdup(fh->standard);
+// }
+//
+// if (!standard || !strncmp(standard, "802.11", strlen("802.11")))
+// goto end;
+//
+// // parse standard to 1905 media type
+// p1 = standard + strlen("802.11");
+//again:
+// p2 = strrchr(p1, '/');
+// if (!p2)
+// p2 = p1;
+//
+// // TODO: add sanity checks for band?
+// if (!strcasecmp(p2, "b"))
+// ret = 0x0100;
+// else if (!strcasecmp(p2, "g"))
+// ret = 0x0101;
+// else if (!strcasecmp(p2, "a"))
+// ret = 0x0102;
+// else if (!strcasecmp(p2, "n"))
+// if (a->radios[radio_idx].band == BAND_2)
+// ret = 0x0103;
+// else
+// ret = 0x0104;
+// else if (!strcasecmp(p2, "ac"))
+// ret = 0x0105;
+// else if (!strcasecmp(p2, "ad"))
+// ret = 0x0106;
+// else if (!strcasecmp(p2, "af"))
+// ret = 0x0107;
+// else
+// // if we don't know this one, check the next one if there is one
+// if (p2 != p1)
+// goto again;
+//end:
+// free(standard);
+// return ret;
}
static void add_wifi_media_specific_data(struct tlv_device_info *p, int int_idx,
struct agent *a, int radio_idx,
int bss_idx)
{
- struct netif_fh *fh;
-
- p->local_interfaces[int_idx].media_specific_data_size = 10;
-
- memcpy(p->local_interfaces[int_idx].media_specific_data.ieee80211.network_membership,
- a->radios[radio_idx].bsslist[bss_idx].bssid,
- sizeof(p->local_interfaces[int_idx].media_specific_data.ieee80211.network_membership));
-
- // TODO: separate backhaul STA as well
- p->local_interfaces[int_idx].media_specific_data.ieee80211.role =
- IEEE80211_SPECIFIC_INFO_ROLE_AP;
-
- // get media specific data from fhlist
- list_for_each_entry(fh, &a->fhlist, list) {
- if (hwaddr_equal(fh->bssid,
- a->radios[radio_idx].bsslist[bss_idx].bssid))
- break;
- }
-
- p->local_interfaces[int_idx].media_specific_data.ieee80211.ap_channel_band =
- fh->bandwidth;
- p->local_interfaces[int_idx].media_specific_data.ieee80211.ap_ch_freq_1 =
- fh->channel;
- /* TODO: this is only needed for 80+80
- p->local_interfaces[int_idx].media_specific_data.ieee80211.ap_ch_freq_2 =
- */
+ return;
+// struct netif_fh *fh;
+//
+// p->local_interfaces[int_idx].media_specific_data_size = 10;
+//
+// memcpy(p->local_interfaces[int_idx].media_specific_data.ieee80211.network_membership,
+// a->radios[radio_idx].bsslist[bss_idx].bssid,
+// sizeof(p->local_interfaces[int_idx].media_specific_data.ieee80211.network_membership));
+//
+// // TODO: separate backhaul STA as well
+// p->local_interfaces[int_idx].media_specific_data.ieee80211.role =
+// IEEE80211_SPECIFIC_INFO_ROLE_AP;
+//
+// // get media specific data from fhlist
+// list_for_each_entry(fh, &a->fhlist, list) {
+// if (hwaddr_equal(fh->bssid,
+// a->radios[radio_idx].bsslist[bss_idx].bssid))
+// break;
+// }
+//
+// p->local_interfaces[int_idx].media_specific_data.ieee80211.ap_channel_band =
+// fh->bandwidth;
+// p->local_interfaces[int_idx].media_specific_data.ieee80211.ap_ch_freq_1 =
+// fh->channel;
+// /* TODO: this is only needed for 80+80
+// p->local_interfaces[int_idx].media_specific_data.ieee80211.ap_ch_freq_2 =
+// */
}
struct tlv_device_info *agent_gen_device_info(struct agent *a)
{
- struct tlv_device_info *p;
- uint32_t ubus_obj;
- void *tmp;
- int i, j;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = TLV_TYPE_DEVICE_INFORMATION_TYPE;
-
- memcpy(p->al_mac_address, a->almac, sizeof(p->al_mac_address));
-
-#if 0
- /* local interfaces */
- // get eth devices from ubus network.device if available
- ubus_obj = ubus_get_object(a->ubus_ctx, "network.device");
- if (ubus_obj != WIFI_OBJECT_INVALID) {
- ubus_call_object(a, ubus_obj, "status", parse_eth_devices, p);
- }
- // get bss info same as AP Operational BSS
- for (i = 0; i < a->num_radios; i++) {
- for (j = 0; j < a->radios[i].num_bss; j++) {
- /* only report BSS in PWR_ON or PWR_SAVE mode */
- if (a->radios[i].bsslist[j].enabled) {
- int idx = p->local_interfaces_nr;
- tmp = realloc(p->local_interfaces,
- (idx + 1) * sizeof(*p->local_interfaces));
- if (!tmp)
- return NULL;
-
- p->local_interfaces = tmp;
- p->local_interfaces_nr++;
-
- memcpy(p->local_interfaces[idx].mac_address,
- a->radios[i].bsslist[j].bssid,
- sizeof(p->local_interfaces[idx].mac_address));
-
- p->local_interfaces[idx].media_type =
- get_wifi_media_type(a, i, j);
-
- if (p->local_interfaces[idx].media_type == 0xFFFF)
- continue;
-
- add_wifi_media_specific_data(p, idx, a, i, j);
- }
- }
- }
-#endif
- return p;
+ return NULL;
+// struct tlv_device_info *p;
+// uint32_t ubus_obj;
+// void *tmp;
+// int i, j;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = TLV_TYPE_DEVICE_INFORMATION_TYPE;
+//
+// memcpy(p->al_mac_address, a->almac, sizeof(p->al_mac_address));
+//
+//#if 0
+// /* local interfaces */
+// // get eth devices from ubus network.device if available
+// ubus_obj = ubus_get_object(a->ubus_ctx, "network.device");
+// if (ubus_obj != WIFI_OBJECT_INVALID) {
+// ubus_call_object(a, ubus_obj, "status", parse_eth_devices, p);
+// }
+// // get bss info same as AP Operational BSS
+// for (i = 0; i < a->num_radios; i++) {
+// for (j = 0; j < a->radios[i].num_bss; j++) {
+// /* only report BSS in PWR_ON or PWR_SAVE mode */
+// if (a->radios[i].bsslist[j].enabled) {
+// int idx = p->local_interfaces_nr;
+// tmp = realloc(p->local_interfaces,
+// (idx + 1) * sizeof(*p->local_interfaces));
+// if (!tmp)
+// return NULL;
+//
+// p->local_interfaces = tmp;
+// p->local_interfaces_nr++;
+//
+// memcpy(p->local_interfaces[idx].mac_address,
+// a->radios[i].bsslist[j].bssid,
+// sizeof(p->local_interfaces[idx].mac_address));
+//
+// p->local_interfaces[idx].media_type =
+// get_wifi_media_type(a, i, j);
+//
+// if (p->local_interfaces[idx].media_type == 0xFFFF)
+// continue;
+//
+// add_wifi_media_specific_data(p, idx, a, i, j);
+// }
+// }
+// }
+//#endif
+// return p;
}
struct tlv_device_bridge_cap *agent_gen_device_bridge_cap(struct agent *a)
{
- struct tlv_device_bridge_cap *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = TLV_TYPE_DEVICE_BRIDGING_CAPABILITIES;
-
- return p;
+ return NULL;
+// struct tlv_device_bridge_cap *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = TLV_TYPE_DEVICE_BRIDGING_CAPABILITIES;
+//
+// return p;
}
struct tlv_non1905_neighbor *agent_gen_non1905_neighbor(struct agent *a)
{
- struct tlv_non1905_neighbor *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = TLV_TYPE_NON_1905_NEIGHBOR_DEVICE_LIST;
-
- return p;
+ return NULL;
+// struct tlv_non1905_neighbor *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = TLV_TYPE_NON_1905_NEIGHBOR_DEVICE_LIST;
+//
+// return p;
}
struct tlv_neighbor_device *agent_gen_neighbor_device(struct agent *a)
{
- struct tlv_neighbor_device *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = TLV_TYPE_NEIGHBOR_DEVICE_LIST;
-
- return p;
+ return NULL;
+// struct tlv_neighbor_device *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = TLV_TYPE_NEIGHBOR_DEVICE_LIST;
+//
+// return p;
}
/* Topology Response Extension TLVs */
struct tlv_supp_service *agent_gen_supp_service_tlv(struct agent *a)
{
- struct tlv_supp_service *p;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_SUPPORTED_SERVICE;
-
- p->supported_services_list = 1;
- p->supported_services = calloc(p->supported_services_list,
- sizeof(*p->supported_services));
- if (!p->supported_services)
- return NULL;
-
- p->supported_services[0].service = SUPPORTED_SERVICE_MULTIAP_AGENT;
-
- return p;
+ return NULL;
+// struct tlv_supp_service *p;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_SUPPORTED_SERVICE;
+//
+// p->supported_services_list = 1;
+// p->supported_services = calloc(p->supported_services_list,
+// sizeof(*p->supported_services));
+// if (!p->supported_services)
+// return NULL;
+//
+// p->supported_services[0].service = SUPPORTED_SERVICE_MULTIAP_AGENT;
+//
+// return p;
}
struct tlv_ap_oper_bss *agent_gen_ap_oper_bss_tlv(struct agent *a)
{
- struct tlv_ap_oper_bss *p;
- void *tmp;
- int i, j;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_AP_OPERATIONAL_BSS;
-
- p->radios_nr = a->num_radios;
- p->radio = calloc(p->radios_nr, sizeof(*p->radio));
- if (!p->radio)
- return NULL;
-
- for (i = 0; i < p->radios_nr; i++) {
- memcpy(p->radio[i].radio_id, a->radios[i].macaddr, 6);
-
- for (j = 0; j < a->radios[i].num_bss; j++) {
- /* only report BSS in PWR_ON or PWR_SAVE mode */
- if (a->radios[i].bsslist[j].enabled) {
- int idx = p->radio[i].bss_nr;
- tmp = realloc(p->radio[i].bss,
- (idx + 1) * sizeof(*p->radio[i].bss));
- if (!tmp)
- return NULL;
-
- p->radio[i].bss = tmp;
- p->radio[i].bss_nr++;
-
- memcpy(p->radio[i].bss[idx].bssid,
- a->radios[i].bsslist[j].bssid,
- sizeof(p->radio[i].bss[idx].bssid));
- p->radio[i].bss[idx].ssid_len =
- strlen(a->radios[i].bsslist[j].ssid);
- memcpy(p->radio[i].bss[idx].ssid,
- a->radios[i].bsslist[j].ssid,
- sizeof(p->radio[i].bss[idx].ssid));
- }
- }
- }
-
- return p;
+ return NULL;
+// struct tlv_ap_oper_bss *p;
+// void *tmp;
+// int i, j;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_AP_OPERATIONAL_BSS;
+//
+// p->radios_nr = a->num_radios;
+// p->radio = calloc(p->radios_nr, sizeof(*p->radio));
+// if (!p->radio)
+// return NULL;
+//
+// for (i = 0; i < p->radios_nr; i++) {
+// memcpy(p->radio[i].radio_id, a->radios[i].macaddr, 6);
+//
+// for (j = 0; j < a->radios[i].num_bss; j++) {
+// /* only report BSS in PWR_ON or PWR_SAVE mode */
+// if (a->radios[i].bsslist[j].enabled) {
+// int idx = p->radio[i].bss_nr;
+// tmp = realloc(p->radio[i].bss,
+// (idx + 1) * sizeof(*p->radio[i].bss));
+// if (!tmp)
+// return NULL;
+//
+// p->radio[i].bss = tmp;
+// p->radio[i].bss_nr++;
+//
+// memcpy(p->radio[i].bss[idx].bssid,
+// a->radios[i].bsslist[j].bssid,
+// sizeof(p->radio[i].bss[idx].bssid));
+// p->radio[i].bss[idx].ssid_len =
+// strlen(a->radios[i].bsslist[j].ssid);
+// memcpy(p->radio[i].bss[idx].ssid,
+// a->radios[i].bsslist[j].ssid,
+// sizeof(p->radio[i].bss[idx].ssid));
+// }
+// }
+// }
+//
+// return p;
}
struct tlv_assoc_client *agent_gen_assoc_client_tlv(struct agent *a)
{
- struct tlv_assoc_client *p;
- void *tmp;
- int i, j, k;
-
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_ASSOCIATED_CLIENTS;
-
- for (i = 0; i < a->num_radios; i++) {
- int idx = p->bss_nr;
- tmp = realloc(p->bss,
- (p->bss_nr + a->radios[i].num_bss) * sizeof(*p->bss));
- if (!tmp)
- return NULL;
-
- p->bss = tmp;
- p->bss_nr += a->radios[i].num_bss;
-
- for (j = 0; j < a->radios[i].num_bss; j++) {
- memcpy(p->bss[idx + j].bssid,
- a->radios[i].bsslist[j].bssid,
- sizeof(p->bss[idx + j].bssid));
-
-#if 1
- /* TODO: replace with stalist when ready for use */
- {
- struct netif_fh *fh;
- struct sta *s;
- int num_sta = 0;
-
- fh = wifi_get_netif_by_bssid(a, a->radios[i].bsslist[j].bssid);
- if (!fh)
- continue;
-
- list_for_each_entry(s, &fh->stalist, list)
- num_sta++;
-
- p->bss[idx + j].clients =
- calloc(num_sta, sizeof(*p->bss[idx + j].clients));
- if (!p->bss[idx + j].clients)
- return NULL;
-
- p->bss[idx + j].assoc_clients_nr = num_sta;
-
- k = 0;
- list_for_each_entry(s, &fh->stalist, list) {
- memcpy(p->bss[idx + j].clients[k].client_addr,
- s->macaddr,
- sizeof(p->bss[idx + j].clients[k].client_addr));
-
- p->bss[idx + j].clients[k].uptime =
- ((s->connected_ms / 1000) > 0xFFFF)
- ? 0xFFFF
- : (s->connected_ms / 1000) & 0xFFFF;
- k++;
- }
- }
-#else
- p->bss[idx + j].clients =
- calloc(a->radios[i].bsslist[j].num_stations,
- sizeof(*p->bss[idx + j].clients));
- if (!p->bss[idx + j].clients)
- return NULL;
-
- p->bss[idx + j].assoc_clients_nr =
- a->radios[i].bsslist[j].num_stations;
-
- for (k = 0; k < p->bss[idx + j].assoc_clients_nr; k++) {
- memcpy(p->bss[idx + j].clients[k].client_addr,
- a->radios[i].bsslist[j].stalist[k].macaddr,
- sizeof(p->bss[idx + j].clients[k].client_addr));
-
- /* Note: cap at 0xFFFF, see above */
- p->bss[idx + j].clients[k].uptime =
- a->radios[i].bsslist[j].stalist[k].conn_time;
- }
-#endif
- }
- }
-
- return p;
+ return NULL;
+// struct tlv_assoc_client *p;
+// void *tmp;
+// int i, j, k;
+//
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_ASSOCIATED_CLIENTS;
+//
+// for (i = 0; i < a->num_radios; i++) {
+// int idx = p->bss_nr;
+// tmp = realloc(p->bss,
+// (p->bss_nr + a->radios[i].num_bss) * sizeof(*p->bss));
+// if (!tmp)
+// return NULL;
+//
+// p->bss = tmp;
+// p->bss_nr += a->radios[i].num_bss;
+//
+// for (j = 0; j < a->radios[i].num_bss; j++) {
+// memcpy(p->bss[idx + j].bssid,
+// a->radios[i].bsslist[j].bssid,
+// sizeof(p->bss[idx + j].bssid));
+//
+//#if 1
+// /* TODO: replace with stalist when ready for use */
+// {
+// struct netif_fh *fh;
+// struct sta *s;
+// int num_sta = 0;
+//
+// fh = wifi_get_netif_by_bssid(a, a->radios[i].bsslist[j].bssid);
+// if (!fh)
+// continue;
+//
+// list_for_each_entry(s, &fh->stalist, list)
+// num_sta++;
+//
+// p->bss[idx + j].clients =
+// calloc(num_sta, sizeof(*p->bss[idx + j].clients));
+// if (!p->bss[idx + j].clients)
+// return NULL;
+//
+// p->bss[idx + j].assoc_clients_nr = num_sta;
+//
+// k = 0;
+// list_for_each_entry(s, &fh->stalist, list) {
+// memcpy(p->bss[idx + j].clients[k].client_addr,
+// s->macaddr,
+// sizeof(p->bss[idx + j].clients[k].client_addr));
+//
+// p->bss[idx + j].clients[k].uptime =
+// ((s->connected_ms / 1000) > 0xFFFF)
+// ? 0xFFFF
+// : (s->connected_ms / 1000) & 0xFFFF;
+// k++;
+// }
+// }
+//#else
+// p->bss[idx + j].clients =
+// calloc(a->radios[i].bsslist[j].num_stations,
+// sizeof(*p->bss[idx + j].clients));
+// if (!p->bss[idx + j].clients)
+// return NULL;
+//
+// p->bss[idx + j].assoc_clients_nr =
+// a->radios[i].bsslist[j].num_stations;
+//
+// for (k = 0; k < p->bss[idx + j].assoc_clients_nr; k++) {
+// memcpy(p->bss[idx + j].clients[k].client_addr,
+// a->radios[i].bsslist[j].stalist[k].macaddr,
+// sizeof(p->bss[idx + j].clients[k].client_addr));
+//
+// /* Note: cap at 0xFFFF, see above */
+// p->bss[idx + j].clients[k].uptime =
+// a->radios[i].bsslist[j].stalist[k].conn_time;
+// }
+//#endif
+// }
+// }
+//
+// return p;
}
struct tlv_map_profile *agent_gen_map_profile_tlv(struct agent *a)
{
- struct tlv_map_profile *p = NULL;
-
- if (a->cfg.profile == MAP_PROFILE_2) {
- p = calloc(1, sizeof(*p));
- if (!p)
- return NULL;
-
- p->tlv_type = MAP_TLV_MULTIAP_PROFILE;
-
- p->profile = MAP_PROFILE_2;
- }
-
- return p;
+ return NULL;
+// struct tlv_map_profile *p = NULL;
+//
+// if (a->cfg.profile == MAP_PROFILE_2) {
+// p = calloc(1, sizeof(*p));
+// if (!p)
+// return NULL;
+//
+// p->tlv_type = MAP_TLV_MULTIAP_PROFILE;
+//
+// p->profile = MAP_PROFILE_2;
+// }
+//
+// return p;
}
diff --git a/src/core/agent_tlv_generator.h b/src/core/agent_tlv_generator.h
index c5f18daaaad8eb3b2812691eb748c049f7f8c7a4..aaf398888552258f7352f8d5d8e1673d12868afa 100644
--- a/src/core/agent_tlv_generator.h
+++ b/src/core/agent_tlv_generator.h
@@ -19,25 +19,25 @@ uint8_t rssi_to_rcpi(int rssi);
struct netif_fh *wifi_get_netif_by_bssid(struct agent *a, uint8_t *bssid);
struct tlv_ap_ht_cap *agent_gen_ap_ht_caps(struct agent *a,
- struct cmdu_cstruct *cmdu, uint32_t radio_index);
+ struct cmdu_buff *cmdu, uint32_t radio_index);
struct tlv_ap_cap *agent_gen_ap_caps(struct agent *a,
- struct cmdu_cstruct *cmdu);
-struct tlv_ap_radio_basic_cap *agent_gen_ap_radio_basic_cap(struct agent *a,
- struct cmdu_cstruct *cmdu, struct wifi_radio_element *radio);
+ struct cmdu_buff *cmdu);
+int agent_gen_ap_radio_basic_cap(struct agent *a,
+ struct cmdu_buff *frm, struct wifi_radio_element *radio);
struct tlv_ap_vht_cap *agent_gen_ap_vht_caps(struct agent *a,
- struct cmdu_cstruct *cmdu, uint32_t radio_index);
-struct tlv_profile2_ap_cap *agent_gen_profile2_ap_cap(struct agent *a);
-struct tlv_ap_radio_adv_cap *agent_gen_ap_radio_adv_cap(struct agent *a,
- struct cmdu_cstruct *cmdu, struct wifi_radio_element *radio);
-struct tlv_wsc *agent_gen_wsc(struct agent *a, struct cmdu_cstruct *cmdu,
+ struct cmdu_buff *cmdu, uint32_t radio_index);
+int agent_gen_profile2_ap_cap(struct agent *a, struct cmdu_buff *frm);
+int agent_gen_ap_radio_adv_cap(struct agent *a,
+ struct cmdu_buff *cmdu, struct wifi_radio_element *radio);
+int agent_gen_wsc(struct agent *a, struct cmdu_buff *cmdu,
struct wifi_radio_element *radio);
struct tlv_ch_scan_cap *agent_gen_ch_scan_cap(struct agent *a);
struct tlv_cac_cap *agent_gen_cac_cap(struct agent *a);
struct tlv_metric_collection_interval *agent_gen_metric_collection_interval(struct agent *a);
struct tlv_oper_ch_report *agent_gen_operate_channel_report(struct agent *a,
- struct cmdu_cstruct *cmdu, uint32_t radio_index);
+ struct cmdu_buff *cmdu, uint32_t radio_index);
struct tlv_ch_selection_resp *agent_gen_operate_channel_response(struct agent *a,
- struct cmdu_cstruct *cmdu, uint8_t *radio_recvd, uint8_t reason_code);
+ struct cmdu_buff *cmdu, uint8_t *radio_recvd, uint8_t reason_code);
void agent_gen_radio_channel_preference(struct agent *a,
struct tlv_channel_pref *p,
uint32_t radio_index);
@@ -45,16 +45,19 @@ void agent_gen_radio_restrict_channel(struct agent *a,
struct tlv_radio_oper_restrict *p,
uint32_t radio_index);
void agent_gen_cac_comp_report(struct agent *a,
- struct tlv_cac_comp_report *p);
+ struct tlv_cac_complete_report *p);
struct tlv_error_code *agent_gen_tlv_error_code(struct agent *a,
- struct cmdu_cstruct *cmdu, uint8_t *sta_mac, uint8_t reason_code);
+ struct cmdu_buff *cmdu, uint8_t *sta_mac, uint8_t reason_code);
struct tlv_steer_btm_report *agent_gen_steer_btm_report(struct agent *a,
uint8_t *target_bssid, uint8_t *src_bssid,
uint8_t *sta, uint8_t status_code);
-struct tlv_al_mac *agent_gen_al_mac(struct agent *a, uint8_t *hwaddr);
-struct tlv_autoconf_freq_band *agent_gen_autoconf_freq_band(struct agent *a,
+int agent_gen_al_mac(struct agent *a, struct cmdu_buff *frm, uint8_t *hwaddr);
+int agent_gen_supported_service(struct agent *a, struct cmdu_buff *frm, uint8_t service);
+int agent_gen_searched_service(struct agent *a, struct cmdu_buff *frm, uint8_t service);
+int agent_gen_map_profile(struct agent *a, struct cmdu_buff *frm, uint8_t profile);
+int agent_gen_autoconf_freq_band(struct agent *a, struct cmdu_buff *frm,
uint8_t band);
-struct tlv_searched_role *agent_gen_searched_role(struct agent *a,
+int agent_gen_searched_role(struct agent *a, struct cmdu_buff *frm,
uint8_t role);
struct tlv_radio_metrics *agent_gen_radio_metrics(struct agent *a,
int radio_index);
@@ -106,13 +109,13 @@ int agent_fill_traffic_sep_policy(struct agent *a,
struct tlv_traffic_sep_policy *p,
struct uci_context *ctx, struct uci_package *pkg);
int agent_fill_ch_scan_rep_policy(struct agent *a,
- struct tlv_ch_scan_rep_policy *p,
+ struct tlv_channel_scan_report_policy *p,
struct uci_context *ctx, struct uci_package *pkg);
int agent_fill_unsuccess_assoc_policy(struct agent *a,
struct tlv_unsuccess_assoc_policy *p,
struct uci_context *ctx, struct uci_package *pkg);
int agent_fill_backhaul_bss_config(struct agent *a,
- struct tlv_backhaul_bss_config *p,
+ struct tlv_bbss_config *p,
struct uci_context *ctx, struct uci_package *pkg);
int agent_fill_backhaul_bss_config_all(struct agent *a,
struct tlv_backhaul_bss_config *p,
diff --git a/src/core/agent_ubus.c b/src/core/agent_ubus.c
index c2af82fba523fc225f0840d50cfd1ddb45c3210c..a2363f9d3d4b74a0779ced4a928456c6fbfcf175 100644
--- a/src/core/agent_ubus.c
+++ b/src/core/agent_ubus.c
@@ -16,11 +16,14 @@
#include <libubus.h>
#include <uci.h>
-#include <map1905/map2.h>
-#include <map1905/maputils.h>
+#include <timer_impl.h>
+#include <cmdu.h>
+#include <1905_tlvs.h>
#include <easy/easy.h>
#include <wifi.h>
+#include <map_module22.h>
+
#include "utils.h"
#include "debug.h"
#include "config.h"
@@ -378,91 +381,91 @@ static int agent_config_ap(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
- struct agent *a = container_of(obj, struct agent, obj);
- struct blob_attr *tb[__CFG_POLICY_MAX];
- char agent[18] = {0}, bssidstr[18] = {0};
- struct wifi_radio_element *radio, *found = NULL;
- uint8_t hwaddr[6] = {0}, bssid[6] = {0};
- int i;
-
- blobmsg_parse(config_policy_params, __CFG_POLICY_MAX, tb,
- blob_data(msg), blob_len(msg));
-
- if (!tb[CFG_POLICY_AGENT] || !tb[CFG_POLICY_BSSID]) {
- fprintf(stderr, "STA Capability Query: provide BSSID " \
- "address in format 11:22:33...\n");
- return UBUS_STATUS_INVALID_ARGUMENT;
- }
-
- strncpy(agent, blobmsg_data(tb[CFG_POLICY_AGENT]), sizeof(agent) - 1);
- if (!hwaddr_aton(agent, hwaddr))
- return UBUS_STATUS_UNKNOWN_ERROR;
-
- strncpy(bssidstr, blobmsg_data(tb[CFG_POLICY_BSSID]),
- sizeof(bssidstr) - 1);
- if (!hwaddr_aton(bssidstr, bssid))
- return UBUS_STATUS_UNKNOWN_ERROR;
-
- for (i = 0; i < a->num_radios; i++) {
- radio = a->radios + i;
-
- if (memcmp(radio->macaddr, bssid, 6))
- continue;
- found = radio;
- }
- if (!found)
- return UBUS_STATUS_UNKNOWN_ERROR;
-
- build_ap_autoconfig_wsc(a, hwaddr, radio, i);
-
- return 0;
+// struct agent *a = container_of(obj, struct agent, obj);
+// struct blob_attr *tb[__CFG_POLICY_MAX];
+// char agent[18] = {0}, bssidstr[18] = {0};
+// struct wifi_radio_element *radio, *found = NULL;
+// uint8_t hwaddr[6] = {0}, bssid[6] = {0};
+// int i;
+//
+// blobmsg_parse(config_policy_params, __CFG_POLICY_MAX, tb,
+// blob_data(msg), blob_len(msg));
+//
+// if (!tb[CFG_POLICY_AGENT] || !tb[CFG_POLICY_BSSID]) {
+// fprintf(stderr, "STA Capability Query: provide BSSID " \
+// "address in format 11:22:33...\n");
+// return UBUS_STATUS_INVALID_ARGUMENT;
+// }
+//
+// strncpy(agent, blobmsg_data(tb[CFG_POLICY_AGENT]), sizeof(agent) - 1);
+// if (!hwaddr_aton(agent, hwaddr))
+// return UBUS_STATUS_UNKNOWN_ERROR;
+//
+// strncpy(bssidstr, blobmsg_data(tb[CFG_POLICY_BSSID]),
+// sizeof(bssidstr) - 1);
+// if (!hwaddr_aton(bssidstr, bssid))
+// return UBUS_STATUS_UNKNOWN_ERROR;
+//
+// for (i = 0; i < a->num_radios; i++) {
+// radio = a->radios + i;
+//
+// if (memcmp(radio->macaddr, bssid, 6))
+// continue;
+// found = radio;
+// }
+// if (!found)
+// return UBUS_STATUS_UNKNOWN_ERROR;
+//
+// build_ap_autoconfig_wsc(a, hwaddr, radio, i);
+//
+// return 0;
}
static int agent_ap_search(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
- struct agent *a = container_of(obj, struct agent, obj);
- struct blob_attr *tb[__SEARCH_POLICY_MAX];
- int i, band = 0;
-
- blobmsg_parse(search_policy_params, __SEARCH_POLICY_MAX, tb,
- blob_data(msg), blob_len(msg));
-
- if (tb[SEARCH_POLICY_BAND]) {
- band = blobmsg_get_u32(tb[SEARCH_POLICY_BAND]);
-
- if (band == 2)
- band = BAND_2;
- else if (band == 5)
- band = BAND_5;
- else {
- trace("|%s:%d| Please provide band as '2', '5' or N/A\n",
- __func__, __LINE__);
- return UBUS_STATUS_UNKNOWN_ERROR;
- }
- }
-
- for (i = 0; i < a->num_radios; i++) {
- struct cmdu_cstruct *cmdu;
- struct wifi_radio_element *radio = &a->radios[i];
-
- if (tb[SEARCH_POLICY_BAND])
- if (band != radio->band)
- continue;
-
- cmdu = agent_gen_ap_autoconfig_search(a, radio, NULL, 0x02);
- if (!cmdu)
- continue;
-
- trace("|%s:%d| Sending Autoconfig Search for radio %s(%s)\n",
- __func__, __LINE__, radio->name,
- (radio->band == BAND_2 ? "2.4GHz" : "5GHz"));
- agent_send_cmdu(a, cmdu);
- map_free_cmdu(cmdu);
- }
-
- return 0;
+// struct agent *a = container_of(obj, struct agent, obj);
+// struct blob_attr *tb[__SEARCH_POLICY_MAX];
+// int i, band = 0;
+//
+// blobmsg_parse(search_policy_params, __SEARCH_POLICY_MAX, tb,
+// blob_data(msg), blob_len(msg));
+//
+// if (tb[SEARCH_POLICY_BAND]) {
+// band = blobmsg_get_u32(tb[SEARCH_POLICY_BAND]);
+//
+// if (band == 2)
+// band = BAND_2;
+// else if (band == 5)
+// band = BAND_5;
+// else {
+// trace("|%s:%d| Please provide band as '2', '5' or N/A\n",
+// __func__, __LINE__);
+// return UBUS_STATUS_UNKNOWN_ERROR;
+// }
+// }
+//
+// for (i = 0; i < a->num_radios; i++) {
+// struct cmdu_cstruct *cmdu;
+// struct wifi_radio_element *radio = &a->radios[i];
+//
+// if (tb[SEARCH_POLICY_BAND])
+// if (band != radio->band)
+// continue;
+//
+// cmdu = agent_gen_ap_autoconfig_search(a, radio, NULL, 0x02);
+// if (!cmdu)
+// continue;
+//
+// trace("|%s:%d| Sending Autoconfig Search for radio %s(%s)\n",
+// __func__, __LINE__, radio->name,
+// (radio->band == BAND_2 ? "2.4GHz" : "5GHz"));
+// agent_send_cmdu(a, cmdu);
+// map_free_cmdu(cmdu);
+// }
+//
+// return 0;
}
int agent_publish_object(struct agent *a, const char *objname)
@@ -486,13 +489,8 @@ int agent_publish_object(struct agent *a, const char *objname)
int ret;
#define agent_sign "f6dfa346957f45cb8d82dc6b77e2df61"
uint8_t agent_sig[16];
- char data[2 * sizeof(struct map_module) + 1] = {0};
uint32_t map_id;
struct blob_buf bb = {};
- struct map_module mm = {
- .role = MAP_ROLE_AGENT,
- .profile = MAP_PROFILE_2,
- };
const char *map_plugin = "map.1905";
obj = &a->obj;
@@ -529,31 +527,6 @@ int agent_publish_object(struct agent *a, const char *objname)
info("Published '%s' object\n", objname);
- strtob(agent_sign, strlen(agent_sign) / 2, agent_sig);
- memcpy(&mm.sign, agent_sig, 16);
-
- /* register with 1905-map plugin */
- ret = ubus_lookup_id(a->ubus_ctx, map_plugin, &map_id);
- if (ret) {
- /* TODO: if map plugin is not installed, retry
- * after some time.
- */
- dbg("plugin '%s' lookup failed. %s\n", map_plugin,
- ubus_strerror(ret));
- return ret;
- }
-
- blob_buf_init(&bb, 0);
- blobmsg_add_u32(&bb, "module", obj->id);
- btostr((unsigned char *)&mm, sizeof(struct map_module), data);
- blobmsg_add_string(&bb, "data", data);
- ret = ubus_invoke(a->ubus_ctx, map_id, "register", bb.head, NULL, 0,
- 3000);
- if (ret) {
- warn("Failed to 'register' with %s (err = %s)\n",
- map_plugin, ubus_strerror(ret));
- }
-
blob_buf_free(&bb);
return ret;
diff --git a/src/core/config.c b/src/core/config.c
index 85350c234693b77d770f47917390d92579f9a84f..99e752a95331a5bf01e9ba7c3a20f47be532f6be 100644
--- a/src/core/config.c
+++ b/src/core/config.c
@@ -28,7 +28,7 @@
#include <libubus.h>
#include <uci.h>
-#include <wsc.h>
+#include <i1905_wsc.h>
#include <easy/easy.h>
@@ -713,10 +713,7 @@ int uci_apply_wps_credentials(struct agent_config *cfg, enum wifi_band band)
/* TODO: batch the changes arther than commit oneby one */
int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device,
- uint8_t *ssid, uint16_t auth_type, uint16_t encryption_type,
- uint8_t *network_key, uint8_t mapie, uint8_t band,
- uint8_t *bridge, uint8_t *proto, uint8_t vid, uint32_t br_ip,
- uint8_t *bk_ssid, uint8_t *bk_key, bool onboarded)
+ struct wps_credential *out, bool onboarded)
{
bool ret;
char auth_type_str[20] = {0};
@@ -725,44 +722,60 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device,
char band_str[2] = {0};
char agent_section[16] = {0};
char ipaddr_str[INET_ADDRSTRLEN] = {0};
-
+ char ssid[33] = {0}, network_key[65] = {0}, bridge_buf[16] = {0}, *bridge;
/* step past br- prefix if present*/
+
+ bridge = bridge_buf;
if (!strncmp("br-", bridge, 3))
bridge += 3;
- inet_ntop(AF_INET, &br_ip, ipaddr_str, INET_ADDRSTRLEN);
+ dbg("%s %d band = %d\n", __func__, __LINE__, out->band);
+ if (out->band == BAND_5)
+ strncpy(band_str, "5", 1);
+ else if (out->band == BAND_2)
+ strncpy(band_str, "2", 1);
+ else /* TODO: 60 */
+ return M2_PROCESS_ERROR;
+
+ memcpy(ssid, out->ssid, out->ssidlen);
+ memcpy(network_key, out->key, out->keylen);
+ memcpy(bridge, out->bridge, 15);
+
+ inet_ntop(AF_INET, &out->br_ip, ipaddr_str, INET_ADDRSTRLEN);
dbg("Applying WSC configuration (%s):\n", interface_name);
dbg(" - SSID : %s\n", ssid);
- dbg(" - AUTH_TYPE : 0x%04x\n", auth_type);
- dbg(" - ENCRYPTION_TYPE : 0x%04x\n", encryption_type);
+ dbg(" - AUTH_TYPE : 0x%04x\n", out->auth_type);
+ dbg(" - ENCRYPTION_TYPE : 0x%04x\n", out->enc_type);
dbg(" - NETWORK_KEY : %s\n", network_key);
- dbg(" - MAPIE_EXTENSION : 0x%02x\n", mapie);
+ dbg(" - MAPIE_EXTENSION : 0x%02x\n", out->mapie);
dbg(" - BRIDGE : %s\n", bridge);
- dbg(" - PROTO : %s\n", proto);
- dbg(" - VID : 0x%02x\n", vid);
+ dbg(" - PROTO : %s\n", out->proto);
+ dbg(" - VID : 0x%02x\n", out->vid);
dbg(" - BR_IP : %s\n", ipaddr_str);
- dbg(" - BK_SSID : %s\n", bk_ssid);
- dbg(" - BK_KEY : %s\n", bk_key);
+ dbg(" - BK_SSID : %s\n", out->bk_ssid);
+ dbg(" - BK_KEY : %s\n", out->bk_key);
+ dbg(" - BAND : %s\n", band_str);
+
// if teardown bit is set, return
- if (BIT(4, mapie))
+ if (BIT(4, out->mapie))
return M2_PROCESS_TEARDOWN;
- multi_ap |= (BIT(5, mapie) << 1);
- multi_ap |= BIT(6, mapie);
+ multi_ap |= (BIT(5, out->mapie) << 1);
+ multi_ap |= BIT(6, out->mapie);
snprintf(multiap_str, sizeof(multiap_str), "%d", multi_ap);
//snprintf(ipaddr_str, sizeof(ipaddr_str), "%d.%d.%d.%d", br_ip[0],
// br_ip[1], br_ip[2], br_ip[3]);
- if (!get_encryption_value(auth_type, encryption_type,
+ if (!get_encryption_value(out->auth_type, out->enc_type,
auth_type_str, 20)) {
info("Unsupported encryption or cipher received!!\n");
return M2_PROCESS_ERROR;
}
- ret = uci_set_bridge("network", bridge, proto, ipaddr_str);
+ ret = uci_set_bridge("network", bridge, out->proto, ipaddr_str);
if (ret) {
info("Error seting up bridge from M2!\n");
return M2_PROCESS_ERROR;
@@ -780,13 +793,6 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device,
return M2_PROCESS_ERROR;
}
- if (band == BAND_5)
- strncpy(band_str, "5", 1);
- else if (band == BAND_2)
- strncpy(band_str, "2", 1);
- else /* TODO: 60 */
- return M2_PROCESS_ERROR;
-
uci_set_wireless_interface_option(UCI_AGENT, agent_section, "ifname",
interface_name, "band", band_str);
uci_set_wireless_interface_option(UCI_AGENT, agent_section, "ifname",
@@ -801,7 +807,7 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device,
char disallow_str[2] = {0};
snprintf(disallow_str, sizeof(disallow_str), "%d",
- ((mapie >> 2) & 0x03));
+ ((out->mapie >> 2) & 0x03));
uci_set_wireless_interface_option(UCI_AGENT,
agent_section, "ifname",
interface_name,
@@ -837,9 +843,9 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device,
uci_set_wireless_interface_option(UCI_WIRELESS, UCI_WLAN_IFACE, "ifname",
interface_name, "multi_ap", multiap_str);
uci_set_wireless_interface_option(UCI_WIRELESS, UCI_WLAN_IFACE, "ifname",
- interface_name, "multi_ap_backhaul_key", bk_key);
+ interface_name, "multi_ap_backhaul_key", out->bk_key);
uci_set_wireless_interface_option(UCI_WIRELESS, UCI_WLAN_IFACE, "ifname",
- interface_name, "multi_ap_backhaul_ssid", bk_ssid);
+ interface_name, "multi_ap_backhaul_ssid", out->bk_ssid);
uci_set_wireless_interface_option(UCI_WIRELESS, UCI_WLAN_IFACE, "ifname",
interface_name, "ieee80211k", "1");
uci_set_wireless_interface_option(UCI_WIRELESS, UCI_WLAN_IFACE, "ifname",
diff --git a/src/core/config.h b/src/core/config.h
index 43e6dedc8d9bb9ddb78aa0d0131077bb540cedc7..04e132a986c1383ce407f66d2455c254f0219d06 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -257,10 +257,7 @@ void clean_fh(struct netif_fhcfg *p);
int clean_all_fh(struct agent_config *cfg);
int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device,
- uint8_t *ssid, uint16_t auth_type, uint16_t encryption_type,
- uint8_t *network_key, uint8_t mapie, uint8_t band,
- uint8_t *bridge, uint8_t *proto, uint8_t vid, uint32_t br_ip,
- uint8_t *bk_ssid, uint8_t *bk_key, bool onboaded);
+ struct wps_credential *out, bool onboarded);
int uci_apply_wps_credentials(struct agent_config *cfg, enum wifi_band band);
int wifi_reorder_interfaces_by_device(struct agent_config *ac,
struct uci_context *ctx, struct uci_package *pkg, char *device);
diff --git a/src/utils/debug.c b/src/utils/debug.c
index 061df0a5785187ce36f6c08849b1318874349ebc..ce64d69bed72e2e7bb477a158a6b52fe1361c599 100644
--- a/src/utils/debug.c
+++ b/src/utils/debug.c
@@ -21,8 +21,6 @@
#include "utils.h"
#include "debug.h"
-#include <map1905/map2.h>
-#include <map1905/maputils.h>
static int ffd, tfd;
extern const char *outfile_path;
@@ -142,82 +140,86 @@ void dump(unsigned char *buf, int len, char *label)
// TODO: duplicate of start_logging
void start_test_logging(void)
{
- if (!testfile) {
- if (testfile_path) {
- if (usefifo) {
- struct stat st;
- int rfd;
-
- if (stat(testfile_path, &st))
- unlink(testfile_path);
-
- mkfifo(testfile_path, 0600);
- if (stat(testfile_path, &st) == -1 ||
- !S_ISFIFO(st.st_mode))
- return;
-
- rfd = open(testfile_path,
- O_RDONLY | O_NONBLOCK);
- if (rfd) {
- tfd = open(testfile_path,
- O_WRONLY | O_NONBLOCK);
- close(rfd);
- }
- } else {
- testfile = fopen(testfile_path, "w+");
- }
- } else {
- testfile = stderr;
- }
- }
+ return;
+// if (!testfile) {
+// if (testfile_path) {
+// if (usefifo) {
+// struct stat st;
+// int rfd;
+//
+// if (stat(testfile_path, &st))
+// unlink(testfile_path);
+//
+// mkfifo(testfile_path, 0600);
+// if (stat(testfile_path, &st) == -1 ||
+// !S_ISFIFO(st.st_mode))
+// return;
+//
+// rfd = open(testfile_path,
+// O_RDONLY | O_NONBLOCK);
+// if (rfd) {
+// tfd = open(testfile_path,
+// O_WRONLY | O_NONBLOCK);
+// close(rfd);
+// }
+// } else {
+// testfile = fopen(testfile_path, "w+");
+// }
+// } else {
+// testfile = stderr;
+// }
+// }
}
void stop_test_logging(void)
{
- if (testfile)
- fclose(testfile);
-
- if (tfd) {
- close(tfd);
- unlink(testfile_path);
- }
+ return;
+// if (testfile)
+// fclose(testfile);
+//
+// if (tfd) {
+// close(tfd);
+// unlink(testfile_path);
+// }
}
void log_test(int level, void *var, int len)
{
- char *bstr;
-
- if (level > verbose)
- return;
-
- bstr = calloc(1, (len * 2) + 1);
- if (!bstr)
- return;
-
- btostr(var, len, bstr);
-
- fprintf(testfile, "%s\n", bstr);
- fflush(testfile);
- free(bstr);
+ return;
+// char *bstr;
+//
+// if (level > verbose)
+// return;
+//
+// bstr = calloc(1, (len * 2) + 1);
+// if (!bstr)
+// return;
+//
+// btostr(var, len, bstr);
+//
+// fprintf(testfile, "%s\n", bstr);
+// fflush(testfile);
+// free(bstr);
}
void log_cmdu(int level, void *var)
{
- struct cmdu_cstruct *cmdu = (struct cmdu_cstruct *) var;
- int i;
-
- if (level > verbose)
- return;
-
- for (i = 0; i < cmdu->num_tlvs; i++) {
- uint16_t len;
- uint8_t *btlv;
-
- btlv = map_put_tlv_cstruct(cmdu->tlvs[i], &len);
- if (!btlv)
- continue;
-
- log_test(level, btlv, len);
- free(btlv);
- }
+ return;
+// struct cmdu_cstruct *cmdu = (struct cmdu_cstruct *) var;
+// int i;
+//
+// if (level > verbose)
+// return;
+//
+// for (i = 0; i < cmdu->num_tlvs; i++) {
+// uint16_t len;
+// uint8_t *btlv;
+//
+// btlv = map_put_tlv_cstruct(cmdu->tlvs[i], &len);
+// if (!btlv)
+// continue;
+//
+// log_test(level, btlv, len);
+// free(btlv);
+// }
}