diff --git a/src/Makefile b/src/Makefile index d660f5e4de86a0ec7aa1cceb599d38e643f00464..76c5367c7b69bd143f4bb59af7a805447c6900e9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 ] || { \ diff --git a/src/cntlr_apis.c b/src/cntlr_apis.c new file mode 100644 index 0000000000000000000000000000000000000000..9a4d5992811486591174dfdfaa761b6b2f85b93a --- /dev/null +++ b/src/cntlr_apis.c @@ -0,0 +1,76 @@ +/* + * 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; +} diff --git a/src/cntlr_apis.h b/src/cntlr_apis.h new file mode 100644 index 0000000000000000000000000000000000000000..382294d185b48b7916a8c925444eacb6bbf1de0d --- /dev/null +++ b/src/cntlr_apis.h @@ -0,0 +1,27 @@ +/* + * 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 */