Skip to content
Snippets Groups Projects
Commit ca078afb authored by Anjan Chanda's avatar Anjan Chanda
Browse files

cntlr-apis: provide well defined APIs to plugins and other applications

parent 8fbf3b37
No related branches found
No related tags found
No related merge requests found
Pipeline #209716 passed
......@@ -34,9 +34,9 @@ OBJS = \
main.o \
dpp.o \
scan.o \
steer.o
steer.o \
steer_module.o
OBJS += steer_module.o
LIBS = -lubus -lubox -ljson-c -lblobmsg_json -luci -pthread
LIBS += -rdynamic -ldl
......@@ -53,11 +53,14 @@ HOOKS = pre-commit
.PHONY: all version.h check clean plugins FORCE
all: version $(EXECS) plugins
all: version $(EXECS) libcntlr-apis.so plugins
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
libcntlr-apis.so: cntlr_apis.o
$(CC) -shared -Wl,-soname,libcntlr-apis.so $^ -o $@ $(LIBS) -L.
version.h:
@(\
[ command -v git > /dev/null 2>&1 ] || { \
......
/*
* cntlr_apis.c - public APIs available to Controller plugins.
*
* Copyright (C) 2025 Genexis Sweden AB.
*
* See LICENSE file for source code license information.
*
*/
#include "cntlr.h"
#include "sta.h"
#include "cntlr_apis.h"
int cntlr_register_module(void **controller, void *module)
{
//TODO
return -1;
}
void cntlr_unregister_module(void *module)
{
//TODO
}
struct wifi_radio_element *cntlr_get_radio_element(void *cntlr, uint8_t *ruid)
{
struct controller *c = (struct controller *)cntlr;
struct netif_radio *r;
r = cntlr_find_radio(c, ruid);
return r ? r->radio_el : NULL;
}
struct wifi_radio_element *cntlr_get_radio_element_by_bssid(void *cntlr, uint8_t *bssid)
{
struct controller *c = (struct controller *)cntlr;
struct netif_radio *r = NULL;
struct netif_iface *p = NULL;
struct node *n = NULL;
list_for_each_entry(n, &c->nodelist, list) {
list_for_each_entry(r, &n->radiolist, list) {
list_for_each_entry(p, &r->iflist, list) {
if (!memcmp(p->bss->bssid, bssid, 6))
return r->radio_el;
}
}
}
return NULL;
}
struct wifi_radio_element *cntlr_get_radio_element_in_node_by_band(void *cntlr,
uint8_t *node_almacaddr,
enum wifi_band band)
{
struct controller *c = (struct controller *)cntlr;
struct netif_radio *r = NULL;
struct node *n;
n = cntlr_find_node(c, node_almacaddr);
if (!n)
return NULL;
r = cntlr_find_radio_in_node_by_band(c, n, band);
return r ? r->radio_el : NULL;
}
struct wifi_sta_element *cntlr_get_sta_element(void *cntlr, uint8_t *macaddr)
{
struct controller *c = (struct controller *)cntlr;
struct sta *s;
s = cntlr_find_sta(c->sta_table, macaddr);
return s ? s->de_sta : NULL;
}
/*
* cntlr_apis.h
* Library header file for libcntlr-apis.so.
*
* Copyright (C) 2025 Genexis Sweden AB.
*
*/
#ifndef CNTLR_APIS_H
#define CNTLR_APIS_H
#include "wifi_dataelements.h"
int cntlr_register_module(void **controller, void *module);
void cntlr_unregister_module(void *module);
struct wifi_radio_element *cntlr_get_radio_element(void *cntlr, uint8_t *ruid);
struct wifi_radio_element *cntlr_get_radio_element_by_bssid(void *cntlr, uint8_t *bssid);
struct wifi_radio_element *cntlr_get_radio_element_in_node_by_band(void *cntlr,
uint8_t *node_almacaddr,
enum wifi_band band);
struct wifi_sta_element *cntlr_get_sta_element(void *cntlr, uint8_t *macaddr);
#endif /* CNTLR_APIS_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment