diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh index d6f8b277ba609ce6cde5ed1a336f6489000d79f6..e1821635a770b68c91d5f8c35c1b38d9c8aa6c88 100755 --- a/gitlab-ci/install-dependencies.sh +++ b/gitlab-ci/install-dependencies.sh @@ -42,3 +42,8 @@ exec_cmd cp -a ieee1905d /usr/sbin/ cd /builds/iopsys/map-topology exec_cmd ./gitlab-ci/setup.sh + +cd /etc/config +exec_cmd touch hosts + +cd /builds/iopsys/map-topology diff --git a/src/Makefile b/src/Makefile index 67e7dd2714bb5f132687998163318758ae8a9734..37fb88a72cc7dcaaef39228b197982ccce9e50e6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,6 +4,7 @@ CFLAGS+=-I. -D_GNU_SOURCE CFLAGS+= -g3 -Wall -pthread OBJS = main.o debug.o config.o json_utils.o nodes.o topo_ieee1905.o topologyd.o mdns_avahi.o +OBJS+= host.o host_nodes.o host_config.o LIBS = -lubus -lubox -ljson-c -lblobmsg_json -luci -pthread -leasy -lieee1905 -lavahi-core -lavahi-common diff --git a/src/host.c b/src/host.c new file mode 100644 index 0000000000000000000000000000000000000000..da4748c975310d59cf6c1a6a5cec15b30a078860 --- /dev/null +++ b/src/host.c @@ -0,0 +1,182 @@ +/* + * host.c - host for multiap network ubus interface + * + * Copyright (C) 2021 IOPSYS Software Solutions AB. All rights reserved. + * + * See LICENSE file for license related information. + * + */ + +#include <stdbool.h> +#include <pthread.h> +#include <json-c/json.h> +#include <libubox/blobmsg.h> +#include <libubox/blobmsg_json.h> +#include <libubox/uloop.h> +#include <libubus.h> + +#include <easy/easy.h> +#include "host.h" +#include "host_config.h" +#include "debug.h" +#include "config.h" +#include "json_utils.h" + +static int signal_pending; +extern const char *ubus_socket; + +int host_nodes(struct ubus_context *ctx, + struct ubus_object *obj, + struct ubus_request_data *req, + const char *method, + struct blob_attr *msg) +{ + struct blob_buf bb; + struct topologyd_private *priv = + container_of(obj, struct topologyd_private, obj); + + memset(&bb, 0, sizeof(struct blob_buf)); + blob_buf_init(&bb, 0); + + host_dump_node_nbr(priv, &bb); + + ubus_send_reply(ctx, req, bb.head); + blob_buf_free(&bb); + + return 0; +} + +void host_dump_node_nbr(struct topologyd_private *priv, struct blob_buf *b) +{ + char mac_str[18] = { 0x0 }; + void *nodes_array; + struct host_node *p; + int i; + + nodes_array = blobmsg_open_array(b, "hosts"); + for (i = 0; i < NODE_HTABLE_SIZE; i++) { + if (hlist_empty(&priv->host.node_htable[i])) + continue; + + hlist_for_each_entry(p, &priv->host.node_htable[i], hlist) { + + if (hwaddr_is_zero(p->hwaddr)) // TODO: unlikely.. + continue; + + hwaddr_ntoa(p->hwaddr, mac_str); + blobmsg_add_string(b, NULL, mac_str); + } + } + blobmsg_close_array(b, nodes_array); +} + +int host_topo_node_add(struct topologyd_private *priv, struct node *node, uint8_t *mac_addr) +{ + struct host_node *p = NULL; + char mac_str[18] = { 0 }; + + if (!priv) + return -1; + + if (priv->host.num_nodes >= HOST_NODE_MAX) + return -1; + + if (node != NULL) + { + if (!memcmp(node->hwaddr, priv->ieee1905_macaddr, 6)) { + p = &priv->selfnode; + //Here the node is the selfnode + //self node does not get added in the hosts + return 0; + } + + /* Add node if not present in host. + * + * In case the node is present, update the node's values + * and the timestamp. + */ + p = host_node_lookup(priv->host.node_htable, node->hwaddr); + if (!p) { + p = host_node_add(priv->host.node_htable, node->hwaddr); + if (p == NULL) + return -1; + //here we need to write this info in the config file + hwaddr_ntoa(node->hwaddr, mac_str); + config_add_default_host_mac("hosts", "host", mac_str); + //config_set_host_option("hosts", "host", "mac_addr", mac_str, "mac_addr", mac_str); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active", "1"); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active_last_change", "1"); + + } else { + + } + } else if (mac_addr != NULL) { + p = host_node_lookup(priv->host.node_htable, mac_addr); + if (!p) { + p = host_node_add(priv->host.node_htable, mac_addr); + if (p == NULL) + return -1; + + } else { + + } + //here we need to write this info in the config file + hwaddr_ntoa(mac_addr, mac_str); + config_add_default_host_mac("hosts", "host", mac_str); + //config_set_host_option("hosts", "host", "mac_addr", mac_str, "mac_addr", mac_str); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active", "1"); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active_last_change", "1"); + } + + return 0; +} + +int host_topo_node_del(struct topologyd_private *priv, struct node *node, uint8_t *mac_addr) +{ + struct host_node *p = NULL; + char mac_str[18] = { 0 }; + + if (!priv) + return -1; + + if (priv->host.num_nodes >= HOST_NODE_MAX) + return -1; + + if (node != NULL) + { + if (!memcmp(node->hwaddr, priv->ieee1905_macaddr, 6)) { + p = &priv->selfnode; + //Here the node is the selfnode + //self node does not get added in the hosts + return 0; + } + + /* + * In case the node is present, update the node's values + * and the timestamp. + */ + p = host_node_lookup(priv->host.node_htable, node->hwaddr); + if (p) { + hwaddr_ntoa(node->hwaddr, mac_str); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active", "0"); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active_last_change", "0"); + + } else { + return -1; + + } + } else if (mac_addr != NULL) { + p = host_node_lookup(priv->host.node_htable, mac_addr); + if (p) { + /*Here we need to write in the config file*/ + hwaddr_ntoa(mac_addr, mac_str); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active", "0"); + config_set_host_option("hosts", "host", "macaddr", mac_str, "active_last_change", "0"); + + } else { + return -1; + } + } + + return 0; +} diff --git a/src/host.h b/src/host.h new file mode 100644 index 0000000000000000000000000000000000000000..af53d0d3aee7e1e1fe8c9f4a4c02e195639d2ef4 --- /dev/null +++ b/src/host.h @@ -0,0 +1,31 @@ +/* + * host.h - topologyd header file + * + * Copyright (C) 2020 IOPSYS Software Solutions AB. All rights reserved. + * + * Author: nevadita.chatterjee@iopsys.eu + * + */ +#ifndef HOSTD_H +#define HOSTD_H + +#include "hlist.h" +#include "topologyd.h" + +#define HOST_NODE_MAX 500 + +struct host_node { + uint8_t hwaddr[6]; //macaddress of the node + struct hlist_node hlist; +}; + +int host_nodes(struct ubus_context *ctx, + struct ubus_object *obj, + struct ubus_request_data *req, + const char *method, + struct blob_attr *msg); +void host_dump_node_nbr(struct topologyd_private *priv, struct blob_buf *b); +int host_topo_node_add(struct topologyd_private *priv, struct node *node, uint8_t *mac_addr); +int host_topo_node_del(struct topologyd_private *priv, struct node *node, uint8_t *mac_addr); + +#endif /* HOSTD_H */ diff --git a/src/host_config.c b/src/host_config.c new file mode 100644 index 0000000000000000000000000000000000000000..0c56c583ac9b2c24773b477dca7e5289f38245e3 --- /dev/null +++ b/src/host_config.c @@ -0,0 +1,254 @@ +/* + * host.c - host for multiap network ubus interface + * + * Copyright (C) 2021 IOPSYS Software Solutions AB. All rights reserved. + * + * See LICENSE file for license related information. + * + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include <json-c/json.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 "debug.h" + +struct uci_section *config_get_section(struct uci_context *ctx, + struct uci_package *pkg, const char *type, const char *key, + const char *value) +{ + struct uci_element *e; + struct uci_section *section; + + /* get the wet iface section */ + uci_foreach_element(&pkg->sections, e) { + const char *c_value; + + section = uci_to_section(e); + if (strcmp(section->type, type)) + continue; + + c_value = uci_lookup_option_string(ctx, section, key); + if (c_value && !strcmp(c_value, value)) + return section; + } + + return NULL; +} + +struct uci_section *config_add_section(struct uci_context *ctx, + struct uci_package *pkg, const char *config, const char *type, + char *name, const char *key, const char *value) +{ + struct uci_section *section = NULL; + struct uci_ptr ptr = {0}; + int rv = -1, ret = 0; + char name_section[50] = { 0 }; + + //snprintf(name_section, 50, "mac_%s", value); + const char s[2] = ":"; + char *token; + char mac_name[18] = { 0 }; + strcpy(mac_name, value); + /* get the first token */ + token = strtok(mac_name, s); + + /* walk through other tokens */ + while( token != NULL ) { + //printf( " %s\n", token ); + strcat(name_section,token); + token = strtok(NULL, s); + } + + section = config_get_section(ctx, pkg, type, key, value); + if (!section) { + rv = uci_add_section(ctx, pkg, type, §ion); + if (rv) + goto out_pkg; + + ptr.p = pkg; + ptr.s = section; + ptr.value = name_section; + ret = uci_rename(ctx, &ptr); + + rv = uci_save(ctx, pkg); + if (rv) + goto out_pkg; + } + ptr.value = value; + ptr.package = config; + ptr.section = section->e.name; + ptr.option = key; + ptr.target = UCI_TYPE_OPTION; + + //memset(buf, 0, sizeof(buf)); + //sprintf(buf, "%s.%s=haha", pkg->e.name, section->e.name); + uci_lookup_ptr(ctx, &ptr, NULL, false); + uci_set(ctx, &ptr); + uci_save(ctx, ptr.p); + uci_commit(ctx, &pkg, false); + + /*memset(buf, 0, sizeof(buf)); + sprintf(buf, "%s.%s=haha", pkg->e.name, s->e.name); + ret = uci_lookup_ptr(ctx, &ptr, buf, "true"); + uci_rename(ctx, &ptr);*/ + + // Rename section from its auto-assigned name + /*ptr.p = pkg; + ptr.s = section; + ptr.value = "nev"; + ret = uci_rename(ctx, &ptr); + + ret = uci_save(ctx, pkg); + uci_commit(ctx, &pkg, true); + return NULL;*/ + +out_pkg: + return section; +} + + + +int config_add_default_host_mac(const char *config, const char *type, + const char *macaddr) +{ + struct uci_context *ctx; + struct uci_package *pkg; + struct uci_section *section; + int rv = -1; + + ctx = uci_alloc_context(); + if (!ctx) + goto out; + + if (uci_load(ctx, config, &pkg) != UCI_OK) { + dbg("config file 'host' not found!\n"); + goto out_uci; + } + + section = config_add_section(ctx, pkg, config, type,"mac_addr", "macaddr", macaddr); + if (!section) + return -1; + + // uci_commit(ctx, &pkg, false); + +out_pkg: + uci_unload(ctx, pkg); +out_uci: + uci_free_context(ctx); +out: +// rename_section(config, type); + return 0; +} + +bool config_set_host_option(char *package_name, + char *section_type, char *search_key, char *search_val, + char *option, char *value) +{ + struct uci_context *ctx; + struct uci_package *pkg; + struct uci_element *e; + + if (!package_name || !search_val || !option || !value) + return false; + + ctx = uci_alloc_context(); + if (!ctx) + return false; + + if (uci_load(ctx, package_name, &pkg)) { + uci_free_context(ctx); + return false; + } + + uci_foreach_element(&pkg->sections, e) { + struct uci_section *s = uci_to_section(e); + + if (!strcmp(s->type, section_type)) { + struct uci_option *opt = uci_lookup_option(ctx, s, + search_key); + + if (!opt || opt->type != UCI_TYPE_STRING) + continue; + if (strcmp(opt->v.string, search_val) == 0) { + struct uci_ptr ptr = {0}; + + ptr.value = value; + ptr.package = package_name; + ptr.section = s->e.name; + ptr.option = option; + ptr.target = UCI_TYPE_OPTION; + if (uci_lookup_ptr(ctx, &ptr, NULL, false) || + !UCI_LOOKUP_COMPLETE) + break; + if (uci_set(ctx, &ptr) == UCI_OK) + uci_save(ctx, ptr.p); + break; + } + } + } + uci_commit(ctx, &pkg, false); + uci_unload(ctx, pkg); + uci_free_context(ctx); + return false; +} +#if 0 +bool config_init_host_data(char *package_name, char *macaddr, + char *section) +{ + bool ret; + struct uci_context *ctx; + struct uci_package *pkg; + struct uci_element *e; + + if (!package_name || !ifname) + return false; + + ctx = uci_alloc_context(); + if (!ctx) + return false; + + if (uci_load(ctx, package_name, &pkg)) { + uci_free_context(ctx); + return false; + } + + ret = false; + uci_foreach_element(&pkg->sections, e) { + struct uci_section *s = uci_to_section(e); + + if (!strcmp(s->type, section)) { + struct uci_option *opt = uci_lookup_option(ctx, s, + "macaddr"); + + if (!opt || opt->type != UCI_TYPE_STRING) + continue; + strcpy(macaddr, opt->v.string, 18); + ret = true; + break; + } + } + } + uci_unload(ctx, pkg); + uci_free_context(ctx); + + return ret; +} +#endif diff --git a/src/host_config.h b/src/host_config.h new file mode 100644 index 0000000000000000000000000000000000000000..b5363a58ca660364ee4aa70597b58cc368a1d27d --- /dev/null +++ b/src/host_config.h @@ -0,0 +1,23 @@ +/* + * host_config.h - topologyd header file + * + * Copyright (C) 2020 IOPSYS Software Solutions AB. All rights reserved. + * + * Author: nevadita.chatterjee@iopsys.eu + * + */ +#ifndef HOSTD_CONFIG_H +#define HOSTD_CONFIG_H +struct uci_section *config_get_section(struct uci_context *ctx, + struct uci_package *pkg, const char *type, const char *key, + const char *value); +struct uci_section *config_add_section(struct uci_context *ctx, + struct uci_package *pkg, const char *config, const char *type, + char *name, const char *key, const char *value); +int config_add_default_host_mac(const char *config, const char *type, + const char *macaddr); +bool config_set_host_option(char *package_name, + char *section_type, char *search_key, char *search_val, + char *option, char *value); + +#endif /* HOSTD_CONFIG_H */ diff --git a/src/host_nodes.c b/src/host_nodes.c new file mode 100644 index 0000000000000000000000000000000000000000..5db1265f605af50e9aa9b9b089c13447285c6958 --- /dev/null +++ b/src/host_nodes.c @@ -0,0 +1,112 @@ +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <time.h> +#include <unistd.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <net/if_arp.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <libubox/list.h> +#include <libubox/uloop.h> +#include <libubus.h> + +#include <easy/easy.h> +#include "debug.h" +#include "hlist.h" +#include "topologyd.h" +#include "mdns_avahi.h" + + +void host_node_destroy(struct host_node *n) +{ + //clean_mdns_services(n->device_ipv4); + free(n); +} + +struct host_node *host_node_create(uint8_t *hwaddr) +{ + struct host_node *n; + + n = calloc(1, sizeof(struct host_node)); + if (!n) { + warn("OOM: Node alloc failed!\n"); + return NULL; + } + + memcpy(n->hwaddr, hwaddr, 6); + + return n; +} + +struct host_node *host_node_lookup(struct hlist_head *table, uint8_t *hwaddr) +{ + int hidx = node_hash(hwaddr); + struct host_node *n; + + if (hwaddr_is_zero(hwaddr)) + return NULL; + + hlist_for_each_entry(n, &table[hidx], hlist) { + if (!memcmp(hwaddr, n->hwaddr, 6)) + return n; + } + + return NULL; +} + +int host_node_del(struct hlist_head *table, uint8_t *hwaddr) +{ + int hidx = node_hash(hwaddr); + struct host_node *n; + + n = host_node_lookup(table, hwaddr); + if (!n) + return -1; + + hlist_del(&n->hlist, &table[hidx]); + dbg("Node " MACFMT " removed from topology\n", MAC2STR(n->hwaddr)); + + host_node_destroy(n); + return 0; +} + +struct host_node *host_node_add(struct hlist_head *table, uint8_t *hwaddr) +{ + struct host_node *n; + + n = host_node_lookup(table, hwaddr); + if (n) { + dbg("Node " MACFMT " already in topology\n", MAC2STR(hwaddr)); + return n; + } + + n = host_node_create(hwaddr); + if (n) { + int hidx = node_hash(hwaddr); + + hlist_add_head(&n->hlist, &table[hidx]); + dbg("Node " MACFMT " added to topology\n", MAC2STR(hwaddr)); + } + + return n; +} + +void host_node_print_all(struct hlist_head *table) +{ + struct host_node *n; + int i; + + dbg("Nodes:\n"); + for (i = 0; i < NODE_HTABLE_SIZE; i++) { + if (hlist_empty(&table[i])) + continue; + + hlist_for_each_entry(n, &table[i], hlist) { + dbg("Node: " MACFMT "\n", MAC2STR(n->hwaddr)); + } + } +} diff --git a/src/host_nodes.h b/src/host_nodes.h new file mode 100644 index 0000000000000000000000000000000000000000..d028c63f9da047f13ccb9d9afbc6478d25eb0dee --- /dev/null +++ b/src/host_nodes.h @@ -0,0 +1,17 @@ + +#ifndef NODES_H +#define NODES_H + +#include <stdint.h> +#include "hlist.h" + + +struct host_node *host_node_create(uint8_t *hwaddr); +void host_node_free(struct host_node *n); + +struct host_node *host_node_add(struct hlist_head *table, uint8_t *hwaddr); +int host_node_del(struct hlist_head *table, uint8_t *hwaddr); +struct host_node *host_node_lookup(struct hlist_head *table, uint8_t *hwaddr); +void host_node_print_all(struct hlist_head *table); + +#endif /* NODES_H */ diff --git a/src/topo_ieee1905.c b/src/topo_ieee1905.c index 6bf97f4e87bf5d1ce1823ddba3077f606757d286..129467507d903d4d9653f1df6aa98836579607b9 100644 --- a/src/topo_ieee1905.c +++ b/src/topo_ieee1905.c @@ -102,7 +102,7 @@ static void topologyd_node_expired(struct uloop_timeout *t) { struct node *p = container_of(t, struct node, validity_timer); struct topologyd_private *priv = p->priv; - int i = 0; + int i = 0i, ret = 0; struct topology_changelog elem; //Here before deleting a ieee1905 node @@ -117,6 +117,10 @@ static void topologyd_node_expired(struct uloop_timeout *t) enqueue_changelog(&(priv->topo), &elem); //Send event topology_send_node_event(&elem, p->ingress_ifr_name); + /*Here we need to change the status of node in hosts*/ + ret = host_topo_node_del(priv, NULL, elem.nbr_macaddr); + if (ret != 0) + err("Failed to add node in the hosts\n"); } //Here we log in the changelog as the node will be deleted diff --git a/src/topologyd.c b/src/topologyd.c index 41802f2abfb2b5a3c605cfdad7340c41f72dd89c..3431a86f50b3a671e15ac125e78de0da7f0efd54 100644 --- a/src/topologyd.c +++ b/src/topologyd.c @@ -402,6 +402,7 @@ void topologyd_process_topology_response(struct cmdu_cstruct *cstruct, struct to dbg("Updating Node" MACFMT " from topology response\n", MAC2STR(n.hwaddr)); topologyd_node_add(priv, &n); + } void topologyd_process_higherlayer_response(struct cmdu_cstruct *cstruct, struct topologyd_private *priv) @@ -1341,12 +1342,13 @@ int topologyd_publish_object(struct topologyd_private *priv, const char *objname struct ubus_object *obj; struct ubus_object_type *obj_type; struct ubus_method *obj_methods; - struct ubus_method m[5] = { + struct ubus_method m[6] = { UBUS_METHOD_NOARG("refresh", topologyd_refresh), UBUS_METHOD_NOARG("status", topologyd_status), UBUS_METHOD_NOARG("dump", topologyd_dump), UBUS_METHOD_NOARG("changelog", topologyd_changelog), UBUS_METHOD_NOARG("nodes", topologyd_nodes), + UBUS_METHOD_NOARG("hosts", host_nodes), }; int num_methods = ARRAY_SIZE(m); int ret; @@ -1515,6 +1517,7 @@ void changelog_copy_node_info(struct topologyd_private *t, struct node *p, int32 { dbg("Inside %s...\n", __func__); struct topology_changelog elem; + int ret = 0; if (t == NULL || p == NULL) return; @@ -1534,6 +1537,17 @@ void changelog_copy_node_info(struct topologyd_private *t, struct node *p, int32 //Send event topology_send_node_event(&elem, p->ingress_ifr_name); + + //Here we add or del the node in the host + if (event == 0) { + ret = host_topo_node_add(t, p, NULL); + if (ret != 0) + err("Failed to add node in the hosts\n"); + } else if (event == 1) { + ret = host_topo_node_del(t, p, NULL); + if (ret != 0) + err("Failed to delete node in the hosts\n"); + } } void update_changelog_info(struct topologyd_private *priv, struct node *dest, struct node *src) @@ -1541,6 +1555,7 @@ void update_changelog_info(struct topologyd_private *priv, struct node *dest, st dbg("Inside %s..\n", __func__); int i = 0, j = 0, found = 0; struct topology_changelog elem; + int ret = 0; if (dest == NULL || src == NULL || priv == NULL) return; @@ -1569,6 +1584,10 @@ void update_changelog_info(struct topologyd_private *priv, struct node *dest, st enqueue_changelog(&(priv->topo), &elem); //Send event topology_send_node_event(&elem, src->ingress_ifr_name); + /*Here we need to change the status of node in hosts*/ + ret = host_topo_node_del(priv, NULL, elem.nbr_macaddr); + if (ret != 0) + err("Failed to del node in the hosts\n"); } } } else { @@ -1592,6 +1611,10 @@ void update_changelog_info(struct topologyd_private *priv, struct node *dest, st enqueue_changelog(&(priv->topo), &elem); //Send event topology_send_node_event(&elem, src->ingress_ifr_name); + /*Here we need to add the node in the host*/ + ret = host_topo_node_add(priv, NULL, elem.nbr_macaddr); + if (ret != 0) + err("Failed to add node in the hosts\n"); } } } @@ -1793,6 +1816,8 @@ void topologyd_update_changelog_firstentry(struct topologyd_private *priv, struc dbg("Inside %s..\n", __func__); int i = 0; struct topology_changelog elem; + uint8_t node_mac[6]; + int ret = 0; if (dest == NULL || priv == NULL) return; @@ -1802,6 +1827,7 @@ void topologyd_update_changelog_firstentry(struct topologyd_private *priv, struc //Here add non ieee1905 neighbor for (i = 0; i < dest->non1905_nbr_num ; i++) { memcpy(elem.nbr_macaddr, dest->non1905_nbrlist[i], 6); + memcpy(node_mac, dest->non1905_nbrlist[i], 6); memcpy(elem.rpt_macaddr, dest->hwaddr, 6); memcpy(elem.rpt_ifmacaddr, dest->non1905_nbr_localintf, 6); elem.is1905_nbr = 0; @@ -1809,6 +1835,10 @@ void topologyd_update_changelog_firstentry(struct topologyd_private *priv, struc enqueue_changelog(&(priv->topo), &elem); //Send event topology_send_node_event(&elem, dest->ingress_ifr_name); + /*Here we need to add the node in the host*/ + ret = host_topo_node_add(priv, NULL, node_mac); + if (ret != 0) + err("Failed to add node in the hosts\n"); } } } diff --git a/src/topologyd.h b/src/topologyd.h index 1ea2dfbc8e3d8c6f6378422b42f99a75fd2595f7..4510c9085e0c204114411aed30fa0f7979bfe644 100644 --- a/src/topologyd.h +++ b/src/topologyd.h @@ -15,6 +15,7 @@ #include "hlist.h" #include "ieee1905/1905_cmdus.h" #include "ieee1905/1905_tlvs.h" +#include "host.h" #define IEEE1905_OBJECT "ieee1905" @@ -201,6 +202,13 @@ struct topologyd_config { uint32_t maxlog; }; +struct host_ntwk { + void *priv; + uint32_t state; + int32_t num_nodes; + struct hlist_head node_htable[NODE_HTABLE_SIZE]; +}; + struct topologyd_private { int debug; bool algo_running; @@ -216,6 +224,7 @@ struct topologyd_private { uint8_t ieee1905_macaddr[6]; struct node selfnode; struct topology topo; + struct host_ntwk host; void *avahi_serv; void *simple_poll; };