Skip to content
Snippets Groups Projects
Commit fda08cd4 authored by Nevadita's avatar Nevadita
Browse files

map-controller: Added the channel ubus method

parent 9b8c16fc
No related branches found
No related tags found
1 merge request!2Added Changes for ticket 3595 section 8.1
Pipeline #5019 failed
...@@ -62,6 +62,15 @@ static const struct blobmsg_policy sta_caps_policy_params[__STA_POLICY_MAX] = { ...@@ -62,6 +62,15 @@ static const struct blobmsg_policy sta_caps_policy_params[__STA_POLICY_MAX] = {
[STA_POLICY_BSSID] = { .name = "bssid", .type = BLOBMSG_TYPE_STRING } [STA_POLICY_BSSID] = { .name = "bssid", .type = BLOBMSG_TYPE_STRING }
}; };
enum {
CHANNEL_PREF_POLICY_AGENT,
__CHANNEL_PREF_POLICY_MAX,
};
static const struct blobmsg_policy channel_pref_policy_params[__CHANNEL_PREF_POLICY_MAX] = {
[CHANNEL_PREF_POLICY_AGENT] = { .name = "agent", .type = BLOBMSG_TYPE_STRING }
};
static void send_cmdu_cb(struct ubus_request *req, static void send_cmdu_cb(struct ubus_request *req,
int type, struct blob_attr *msg) int type, struct blob_attr *msg)
{ {
...@@ -304,6 +313,46 @@ static int cntlr_ap_caps(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -304,6 +313,46 @@ static int cntlr_ap_caps(struct ubus_context *ctx, struct ubus_object *obj,
return 0; return 0;
} }
static int cntlr_channel_pref(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
struct blob_attr *tb[__CHANNEL_PREF_POLICY_MAX];
struct controller *c = container_of(obj, struct controller, obj);
char agent[18] = {0};
struct cmdu_cstruct *cmdu_data;
cmdu_data = (struct cmdu_cstruct *)calloc(1,
sizeof(struct cmdu_cstruct));
if (!cmdu_data) {
fprintf(stderr, "failed to malloc cmdu\n");
return UBUS_STATUS_UNKNOWN_ERROR;
}
blobmsg_parse(channel_pref_policy_params, __CHANNEL_PREF_POLICY_MAX, tb,
blob_data(msg), blob_len(msg));
if (tb[CHANNEL_PREF_POLICY_AGENT]) {
strncpy(agent, blobmsg_data(tb[CHANNEL_PREF_POLICY_AGENT]),
sizeof(agent) - 1);
if (!hwaddr_aton(agent, cmdu_data->origin))
return UBUS_STATUS_UNKNOWN_ERROR;
}
// TODO: ff:ff:ff:ff:ff:ff = send to all agents
cmdu_data->message_type = CMDU_CHANNEL_PREFERENCE_QUERY;
cmdu_data->message_id = 1;
cmdu_data->num_tlvs = 0;
send_cmdu(c, cmdu_data);
return 0;
}
static int cntlr_sta_caps(struct ubus_context *ctx, struct ubus_object *obj, static int cntlr_sta_caps(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct ubus_request_data *req, const char *method,
struct blob_attr *msg) struct blob_attr *msg)
...@@ -385,10 +434,11 @@ int cntlr_publish_object(struct controller *c, const char *objname) ...@@ -385,10 +434,11 @@ int cntlr_publish_object(struct controller *c, const char *objname)
struct ubus_object *obj; struct ubus_object *obj;
struct ubus_object_type *obj_type; struct ubus_object_type *obj_type;
struct ubus_method *obj_methods; struct ubus_method *obj_methods;
struct ubus_method m[3] = { struct ubus_method m[4] = {
UBUS_METHOD_NOARG("status", cntlr_status), UBUS_METHOD_NOARG("status", cntlr_status),
UBUS_METHOD("ap_caps", cntlr_ap_caps, ap_caps_policy_params), UBUS_METHOD("ap_caps", cntlr_ap_caps, ap_caps_policy_params),
UBUS_METHOD("sta_caps", cntlr_sta_caps, sta_caps_policy_params), UBUS_METHOD("sta_caps", cntlr_sta_caps, sta_caps_policy_params),
UBUS_METHOD("channels", cntlr_channel_pref, channel_pref_policy_params)
}; };
int num_methods = ARRAY_SIZE(m); int num_methods = ARRAY_SIZE(m);
int ret; int ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment