Skip to content
Snippets Groups Projects
Commit d955a8f3 authored by Filip Matusiak's avatar Filip Matusiak Committed by Marek Puzyniak
Browse files

Add cntlr_ubus_dbg

parent 7cb4a6f0
No related branches found
No related tags found
1 merge request!214Draft: backhaul steering
......@@ -11,6 +11,7 @@ OBJS = \
wifi_opclass.o \
allsta.o \
cntlr_ubus.o \
cntlr_ubus_dbg.o \
cntlr.o \
cntlr_map.o \
cntlr_tlv.o \
......
......@@ -36,6 +36,7 @@
#include "cntlr.h"
#include "allsta.h"
#include "cntlr_ubus.h"
#include "cntlr_ubus_dbg.h"
#include "cntlr_map.h"
#include "cntlr_cmdu.h"
#include "steer_module.h"
......@@ -1670,6 +1671,7 @@ static void cntlr_start(atimer_t *t)
if (c->state == CNTLR_INIT) {
c->state = CNTLR_START;
cntlr_publish_object(c, "map.controller");
cntlr_publish_dbg_object(c, "map.controller.dbg");
}
}
......@@ -1993,6 +1995,7 @@ out_exit:
cntlr_clean_nodelist(c);
ubus_unregister_event_handler(ctx, &c->evh);
cntlr_remove_object(c);
cntlr_remove_dbg_object(c);
cmdu_ackq_free(&c->cmdu_ack_q);
cntlr_config_clean(&c->cfg);
uloop_done();
......
......@@ -283,6 +283,7 @@ struct controller {
unsigned char almac[6];
void *comm;
struct ubus_object obj;
struct ubus_object obj_dbg; /* ubus debug object */
struct ubus_context *ubus_ctx;
struct ubus_event_handler evh;
atimer_t heartbeat;
......
/*
* cntlr_ubus_dbg.c - for testing purpose only
*
* Copyright (C) 2022 IOPSYS Software Solutions AB. All rights reserved.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <libubox/blobmsg.h>
#include <libubox/blobmsg_json.h>
#include <libubox/uloop.h>
#include <libubox/ustream.h>
#include <libubox/utils.h>
#include <libubus.h>
#include <uci.h>
#include <easy/easy.h>
#include <cmdu.h>
#include <i1905_wsc.h>
#include <1905_tlvs.h>
#include <easymesh.h>
#include <map_module.h>
#include <wifidefs.h>
#include "wifi_dataelements.h"
#include "timer.h"
#include "utils/utils.h"
#include "utils/debug.h"
#include "config.h"
#include "cntlr.h"
#include "allsta.h"
#include "cntlr_map.h"
#include "cntlr_ubus.h"
#include "cntlr_tlv.h"
#include "cntlr_tlv.h"
#include "cntlr_cmdu.h"
#include "cntlr_acs.h"
#define OBJECT_INVALID ((uint32_t)-1)
#ifndef MAP_CNTLR_DISABLE_UBUS_DBG
static int cntlr_debug(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
/* does nothing */
return 0;
}
int cntlr_publish_dbg_object(struct controller *c, const char *objname)
{
struct ubus_object *obj;
struct ubus_object_type *obj_type;
struct ubus_method *obj_methods;
struct ubus_method m[] = {
UBUS_METHOD_NOARG("debug", cntlr_debug),
};
int num_methods = ARRAY_SIZE(m);
int ret;
obj = &c->obj_dbg;
memset(obj, 0, sizeof(*obj));
obj_type = calloc(1, sizeof(struct ubus_object_type));
if (!obj_type)
return -1;
obj_methods = calloc(num_methods, sizeof(struct ubus_method));
if (!obj_methods) {
free(obj_type);
return -1;
}
obj->name = objname;
memcpy(obj_methods, m, num_methods * sizeof(struct ubus_method));
obj->methods = obj_methods;
obj->n_methods = num_methods;
obj_type->name = obj->name;
obj_type->n_methods = obj->n_methods;
obj_type->methods = obj->methods;
obj->type = obj_type;
ret = ubus_add_object(c->ubus_ctx, obj);
if (ret) {
err("Failed to add '%s' err = %s\n",
objname, ubus_strerror(ret));
free(obj_methods);
free(obj_type);
return ret;
}
info("Published '%s' object\n", objname);
return 0;
}
void cntlr_remove_dbg_object(struct controller *c)
{
if (c->ubus_ctx && c->obj_dbg.id != OBJECT_INVALID) {
ubus_remove_object(c->ubus_ctx, &c->obj_dbg);
free(c->obj_dbg.type);
free((void *) c->obj_dbg.methods);
}
}
#else
int cntlr_publish_dbg_object(struct controller *c, const char *objname)
{
return 0;
}
void cntlr_remove_object(struct controller *c)
{
return;
}
#endif /* MAP_CNTLR_DISABLE_UBUS_DBG */
/*
* cntlr_ubus_dbg.h - for testing purpose only
*
* Copyright (C) 2022 IOPSYS Software Solutions AB. All rights reserved.
*
*/
#ifndef CNTLR_UBUS_DBG_H
#define CNTLR_UBUS_DBG_H
int cntlr_publish_dbg_object(struct controller *c, const char *objname);
void cntlr_remove_dbg_object(struct controller *c);
#endif /* CNTLR_UBUS_DBG_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment