diff --git a/src/dynbh/dbh_nl.c b/src/dynbh/dbh_nl.c index dcd49d41fca8922028d157d7aa0a523817380b46..46b40c3f8b7ba4e5eca70c756448e39ebdfc9c88 100644 --- a/src/dynbh/dbh_nl.c +++ b/src/dynbh/dbh_nl.c @@ -85,68 +85,13 @@ static struct event_socket rtnl_event = { .sock_bufsize = 0x20000, }; -#if 0 -static int if_openlink(const char *ifname, struct nl_sock **s, struct rtnl_link **l) -{ - struct rtnl_link *link; - struct nl_sock *sk; - int ret = 0; - - sk = nl_socket_alloc(); - if (sk == NULL) { - ret = -errno; - return ret; - } - - nl_connect(sk, NETLINK_ROUTE); - if (rtnl_link_get_kernel(sk, 0, ifname, &link) < 0) { - ret = -1; - goto out; - } - - *l = link; - *s = sk; - return 0; - -out: - nl_socket_free(sk); - return ret; -} - -static int if_closelink(struct nl_sock *s, struct rtnl_link *l) -{ - rtnl_link_put(l); - nl_socket_free(s); - - return 0; -} - -static int if_get_bridge_interface_port(char *ifname, uint8_t *state) -{ - struct nl_sock *s; - struct rtnl_link *l; - - if_openlink(ifname, &s, &l); - if (!s || !l) { - fprintf(stderr, "fail due to init of s & l\n"); - return -1; - } - - fprintf(stderr, "%s ifname", ifname); - - *state = rtnl_link_bridge_get_port_state(l); - - if_closelink(s, l); - return 0; -} -#endif static int i1905_handle_nlevents_link(struct dynbh_ctx *priv, struct nlmsghdr *hdr, bool add) { struct ifinfomsg *ifi = nlmsg_data(hdr); struct nlattr *nla[__IFLA_MAX]; - struct ethport *ap; + struct ethport *port; uint8_t macaddr[6] = {0}; char ifname[16] = {0}; int br_ifindex = 0; @@ -165,8 +110,8 @@ static int i1905_handle_nlevents_link(struct dynbh_ctx *priv, nla_memcpy(macaddr, nla[IFLA_ADDRESS], sizeof(macaddr)); nla_memcpy(&operstate, nla[IFLA_OPERSTATE], 1); - ap = ethport_by_ifname(priv, ifname); - if (!ap) + port = ethport_by_ifname(priv, ifname); + if (!port) return NL_SKIP; @@ -191,12 +136,12 @@ static int i1905_handle_nlevents_link(struct dynbh_ctx *priv, ifi->ifi_flags, operstate); if (br_ifindex > 0 && ifi->ifi_family == AF_BRIDGE && - !ap->connected && operstate == IF_OPER_UP) { + !port->connected && operstate == IF_OPER_UP) { /* port got connected */ - dynbh_handle_port_up(ap); - } else if (ap->connected && operstate != IF_OPER_UP) { + dynbh_handle_port_up(port); + } else if (port->connected && operstate != IF_OPER_UP) { /* port got disconnected */ - dynbh_handle_port_down(priv, ap); + dynbh_handle_port_down(priv, port); } return NL_OK; } diff --git a/src/dynbh/dynbh.c b/src/dynbh/dynbh.c index 36f323ed5da54cd5aa7e0ebc22b77028b7bb2546..968609baca2be443dc288e54b381337508abfbba 100644 --- a/src/dynbh/dynbh.c +++ b/src/dynbh/dynbh.c @@ -48,11 +48,11 @@ const char *objname; * create /var/run/multiap/map.agent.bsta_global_disable * write active iface to /var/run/multiap/ file */ -static void link_up(struct ethport *ap) +static void link_up(struct ethport *port) { fprintf(stderr, "|%s:%d|\n", __func__, __LINE__); - runCmd("/lib/wifi/dynbhd/api up %s", ap->ifname); - runCmd("/lib/wifi/multiap set_uplink eth %s", ap->ifname); + runCmd("/lib/wifi/dynbhd/api up %s", port->ifname); + runCmd("/lib/wifi/multiap set_uplink eth %s", port->ifname); } /** @@ -89,31 +89,31 @@ static int controller_discovery_dhcp(void) } #endif -void delif(struct ethport *ap) +void delif(struct ethport *port) { - runCmd("/lib/wifi/dynbhd/api bridge_delif %s", ap->ifname); - runCmd("ubus call ieee1905 add_interface '{\"ifname\":\"%s\"}'", ap->ifname); - fprintf(stderr, "brctl delif %s %s\n", ap->ctx->al_bridge, ap->ifname); + runCmd("/lib/wifi/dynbhd/api bridge_delif %s", port->ifname); + runCmd("ubus call ieee1905 add_interface '{\"ifname\":\"%s\"}'", port->ifname); + fprintf(stderr, "brctl delif %s %s\n", port->ctx->al_bridge, port->ifname); } -void addif(struct ethport *ap) +void addif(struct ethport *port) { - if (if_isbridge_interface(ap->ifname)) + if (if_isbridge_interface(port->ifname)) return; - runCmd("ubus call ieee1905 del_interface '{\"ifname\":\"%s\"}'", ap->ifname); - runCmd("/lib/wifi/dynbhd/api bridge_addif %s", ap->ifname); /* add back to bridge */ - fprintf(stderr, "cmd: brctl addif %s %s\n", ap->ctx->al_bridge, ap->ifname); /* add back to bridge */ + runCmd("ubus call ieee1905 del_interface '{\"ifname\":\"%s\"}'", port->ifname); + runCmd("/lib/wifi/dynbhd/api bridge_addif %s", port->ifname); /* add back to bridge */ + fprintf(stderr, "cmd: brctl addif %s %s\n", port->ctx->al_bridge, port->ifname); /* add back to bridge */ } struct ethport *ethport_by_ifname(struct dynbh_ctx *p, const char *ifname) { - struct ethport *ap = NULL; + struct ethport *port = NULL; - list_for_each_entry(ap, &p->ethportlist, list) { - if (!strncmp(ap->ifname, ifname, 16)) - return ap; + list_for_each_entry(port, &p->ethportlist, list) { + if (!strncmp(port->ifname, ifname, 16)) + return port; } return NULL; @@ -121,18 +121,18 @@ struct ethport *ethport_by_ifname(struct dynbh_ctx *p, struct ethport *ethport_by_mid(struct dynbh_ctx *p, uint16_t mid) { - struct ethport *ap = NULL; + struct ethport *port = NULL; fprintf(stderr, "%s %d mid %d\n", __func__, __LINE__, mid); - list_for_each_entry(ap, &p->ethportlist, list) { + list_for_each_entry(port, &p->ethportlist, list) { int i; - for (i = 0; i < ap->num_mid; i++) { - fprintf(stderr, "%s %d mid[%d] %d\n", __func__, __LINE__, i, ap->mid[i]); + for (i = 0; i < port->num_mid; i++) { + fprintf(stderr, "%s %d mid[%d] %d\n", __func__, __LINE__, i, port->mid[i]); - if (ap->mid[i] == mid) - return ap; + if (port->mid[i] == mid) + return port; } } @@ -142,31 +142,31 @@ struct ethport *ethport_by_mid(struct dynbh_ctx *p, uint16_t mid) /* if link times out, no loop was found */ static void bridge_readd(atimer_t *t) { - struct ethport *ap = container_of(t, struct ethport, + struct ethport *port = container_of(t, struct ethport, bridge_add); - int timeout = 5 * ap->retries; + int timeout = 5 * port->retries; - if (ap->active_uplink) + if (port->active_uplink) link_down(); - fprintf(stderr, "|%s:%d| link timed out for iface:%s mid:%d, %d, add back to bridge\n", __func__, __LINE__, ap->ifname, ap->mid[0], ap->mid[1]); - ap->loop = false; - ap->active_uplink = false; - addif(ap); + fprintf(stderr, "|%s:%d| link timed out for iface:%s mid:%d, %d, add back to bridge\n", __func__, __LINE__, port->ifname, port->mid[0], port->mid[1]); + port->loop = false; + port->active_uplink = false; + addif(port); - ap->num_mid = 0; + port->num_mid = 0; if (timeout > HEARTBEAT_PROBE_TIMEOUT) timeout = HEARTBEAT_PROBE_TIMEOUT; fprintf(stderr, "|%s:%d| timeout = %d\n", __func__, __LINE__, timeout); - ap->retries++; - timer_set(&ap->send_apconf, timeout * 1000); - timer_set(&ap->bridge_add, + port->retries++; + timer_set(&port->send_apconf, timeout * 1000); + timer_set(&port->bridge_add, ((APCONF_MAX_RETRIES * APCONF_INTERVAL) + timeout) * 1000); #ifdef PERSIST_CONTROLLER - if (ap->ctx->discovery_mode == DYNAMIC_CNTLR_MODE_AUTO) { + if (port->ctx->discovery_mode == DYNAMIC_CNTLR_MODE_AUTO) { int t; time_t now; @@ -178,7 +178,7 @@ static void bridge_readd(atimer_t *t) */ srand(time(&now)); t = rand() % 3000; - timer_set(&ap->send_dhcp_discovery, t); + timer_set(&port->send_dhcp_discovery, t); } #endif } @@ -186,43 +186,43 @@ static void bridge_readd(atimer_t *t) /* callback to send ap autoconfig search */ static void send_apconf_cb(atimer_t *t) { - struct ethport *ap = container_of(t, struct ethport, send_apconf); + struct ethport *port = container_of(t, struct ethport, send_apconf); char mid[16] = {0}; - fprintf(stderr, "|%s:%d| sending query num %d for ifname:%s alid:%s \n", __func__, __LINE__, (ap->num_mid+1), ap->ifname, ap->ctx->alidstr); - runCmd("[ -n \"$(ubus list ieee1905.al.%s)\" ] || ubus call ieee1905 add_interface '{\"ifname\":\"%s\"}'", ap->ifname, ap->ifname); + fprintf(stderr, "|%s:%d| sending query num %d for ifname:%s alid:%s \n", __func__, __LINE__, (port->num_mid+1), port->ifname, port->ctx->alidstr); + runCmd("[ -n \"$(ubus list ieee1905.al.%s)\" ] || ubus call ieee1905 add_interface '{\"ifname\":\"%s\"}'", port->ifname, port->ifname); /* ubus call ieee1905 cmdu '{"ifname":"eth0", "dst":"01:80:C2:00:00:13", "type":7, "mid":0, "data":"010006A6CEDA6DAF8412s0d0001000e00010080000201018100020100b3000102000000"}' */ - chrCmd(mid, 16, "ubus call ieee1905.al.%s cmdu '{\"dst\":\"01:80:C2:00:00:13\", \"type\":7, \"mid\":0, \"data\":\"010006%12s0d0001000e00010080000201018100020100b3000102000000\"}' | grep mid | cut -d' ' -f2", ap->ifname, ap->ctx->alidstr); - runCmd("ubus list ieee1905.al.%s", ap->ifname); + chrCmd(mid, 16, "ubus call ieee1905.al.%s cmdu '{\"dst\":\"01:80:C2:00:00:13\", \"type\":7, \"mid\":0, \"data\":\"010006%12s0d0001000e00010080000201018100020100b3000102000000\"}' | grep mid | cut -d' ' -f2", port->ifname, port->ctx->alidstr); + runCmd("ubus list ieee1905.al.%s", port->ifname); fprintf(stderr, "mid = %s\n", mid); errno = 0; - ap->mid[ap->num_mid] = (uint16_t) strtoul(mid, NULL, 10); + port->mid[port->num_mid] = (uint16_t) strtoul(mid, NULL, 10); if (errno) { fprintf(stderr, "Invalid mid value: %s\n", mid); - ap->mid[ap->num_mid] = 0; + port->mid[port->num_mid] = 0; } - fprintf(stderr, "mid[%d] = %u\n", ap->num_mid, ap->mid[ap->num_mid]); - if (ap->num_mid < 31) - ap->num_mid++; + fprintf(stderr, "mid[%d] = %u\n", port->num_mid, port->mid[port->num_mid]); + if (port->num_mid < 31) + port->num_mid++; - if (ap->num_mid < APCONF_MAX_RETRIES) - timer_set(&ap->send_apconf, 2000); + if (port->num_mid < APCONF_MAX_RETRIES) + timer_set(&port->send_apconf, 2000); } #ifdef PERSIST_CONTROLLER /* callback to do DHCP discovery */ static void send_dhcp_discovery_cb(atimer_t *t) { - struct ethport *ap = container_of(t, struct ethport, + struct ethport *port = container_of(t, struct ethport, send_dhcp_discovery); int rc; - ap->dhcp_retries++; + port->dhcp_retries++; - if (ap->ctx->discovery_mode != DYNAMIC_CNTLR_MODE_AUTO) + if (port->ctx->discovery_mode != DYNAMIC_CNTLR_MODE_AUTO) return; @@ -233,15 +233,15 @@ static void send_dhcp_discovery_cb(atimer_t *t) * uplink and take no action */ - fprintf(stderr, "%s: sending dhcp discovery num:%d\n", __func__, ap->dhcp_retries); + fprintf(stderr, "%s: sending dhcp discovery num:%d\n", __func__, port->dhcp_retries); rc = controller_discovery_dhcp(); if (rc) { - if (ap->dhcp_retries < 3) - timer_set(&ap->send_dhcp_discovery, 1 * 1000); + if (port->dhcp_retries < 3) + timer_set(&port->send_dhcp_discovery, 1 * 1000); } else { controller_discovery_persist(); - ap->ctx->discovery_mode = DYNAMIC_CNTLR_MODE_CONTROLLER; + port->ctx->discovery_mode = DYNAMIC_CNTLR_MODE_CONTROLLER; } } #endif @@ -318,56 +318,56 @@ void dynbh_handle_port_down(struct dynbh_ctx *priv, struct ethport *port) } } -void dynbh_handle_port_up(struct ethport *p) +void dynbh_handle_port_up(struct ethport *port) { - p->connected = true; + port->connected = true; /* immediately send apconf search */ - p->retries = 1; - p->num_mid = 0; + port->retries = 1; + port->num_mid = 0; #ifdef PERSIST_CONTROLLER - p->dhcp_retries = 0; + port->dhcp_retries = 0; #endif - timer_set(&p->send_apconf, 0); + timer_set(&port->send_apconf, 0); /* re-add iface to bridge in 10s if no answer */ - timer_set(&p->bridge_add, (APCONF_MAX_RETRIES * APCONF_INTERVAL) * 1000); + timer_set(&port->bridge_add, (APCONF_MAX_RETRIES * APCONF_INTERVAL) * 1000); /* remove iface from brdige */ - delif(p); + delif(port); } struct ethport *alloc_ethport_search(struct dynbh_ctx *priv, char *ifname) { - struct ethport *p; + struct ethport *port; uint8_t operstate; - p = calloc(1, sizeof(struct ethport)); - if (!p) + port = calloc(1, sizeof(struct ethport)); + if (!port) return NULL; - p->ctx = priv; - strncpy(p->ifname, ifname, sizeof(p->ifname) - 1); - timer_init(&p->send_apconf, send_apconf_cb); - timer_init(&p->bridge_add, bridge_readd); + port->ctx = priv; + strncpy(port->ifname, ifname, sizeof(port->ifname) - 1); + timer_init(&port->send_apconf, send_apconf_cb); + timer_init(&port->bridge_add, bridge_readd); #ifdef PERSIST_CONTROLLER - timer_init(&p->send_dhcp_discovery, send_dhcp_discovery_cb); + timer_init(&port->send_dhcp_discovery, send_dhcp_discovery_cb); #endif - list_add_tail(&p->list, &priv->ethportlist); + list_add_tail(&port->list, &priv->ethportlist); if_getoperstate(ifname, &operstate); if (operstate == IF_OPER_UP) - dynbh_handle_port_up(p); + dynbh_handle_port_up(port); - return p; + return port; } -void free_ethport_search(struct ethport *p) +void free_ethport_search(struct ethport *port) { - timer_del(&p->send_apconf); - timer_del(&p->bridge_add); - list_del(&p->list); - free(p); + timer_del(&port->send_apconf); + timer_del(&port->bridge_add); + list_del(&port->list); + free(port); } #ifdef PERSIST_CONTROLLER @@ -417,8 +417,6 @@ static void mapagent_event_handler(void *agent, struct blob_attr *msg) runCmd("/etc/init.d/mapcontroller reload"); } } - - } } #endif @@ -493,7 +491,7 @@ static int handle_autoconfig_response(const char *ifname, uint8_t *src, { struct dynbh_ctx *p = (struct dynbh_ctx *) priv; char almac_str[18] = {0}; - struct ethport *ap; + struct ethport *port; struct tlv_policy a_policy[] = { [0] = { .type = TLV_TYPE_SUPPORTED_ROLE, @@ -547,15 +545,15 @@ static int handle_autoconfig_response(const char *ifname, uint8_t *src, } - ap = ethport_by_mid(p, mid); - if (!ap) { + port = ethport_by_mid(p, mid); + if (!port) { fprintf(stderr, "No matching mid found\n"); - ap = ethport_by_ifname(p, ifname); - if (!ap) { + port = ethport_by_ifname(p, ifname); + if (!port) { fprintf(stderr, "No interface matching %s found - no action\n", ifname); return -1; - } else if (ap->active_uplink || ap->loop) { + } else if (port->active_uplink || port->loop) { fprintf(stderr, "Interface %s already known to be connected to a controller - no action\n", ifname); goto out; } else { @@ -563,50 +561,50 @@ static int handle_autoconfig_response(const char *ifname, uint8_t *src, } } - memcpy(ap->backhaul_mac, src, 6); - memcpy(ap->backhaul_device_id, from, 6); + memcpy(port->backhaul_mac, src, 6); + memcpy(port->backhaul_device_id, from, 6); if (!is_backhaul_type_eth()) { /* if there is no active eth backhaul use this link as backhaul */ - ap->active_uplink = true; - ap->loop = false; - link_up(ap); - fprintf(stderr, "|%s:%d| Interface %s is active uplink\n", __func__, __LINE__, ap->ifname); - addif(ap); + port->active_uplink = true; + port->loop = false; + link_up(port); + fprintf(stderr, "|%s:%d| Interface %s is active uplink\n", __func__, __LINE__, port->ifname); + addif(port); #ifdef PERSIST_CONTROLLER - if (ap->ctx->discovery_mode == DYNAMIC_CNTLR_MODE_AUTO) { + if (port->ctx->discovery_mode == DYNAMIC_CNTLR_MODE_AUTO) { controller_discovery_disable(); - ap->ctx->discovery_mode = DYNAMIC_CNTLR_MODE_DISABLED; + port->ctx->discovery_mode = DYNAMIC_CNTLR_MODE_DISABLED; } #endif goto out; - } else if (ap->active_uplink) { + } else if (port->active_uplink) { char ul_ifname[16] = {0}; if (agent_get_backhaul_ifname(ul_ifname)) { - if (strncmp(ul_ifname, ap->ifname, 16)) - link_up(ap); + if (strncmp(ul_ifname, port->ifname, 16)) + link_up(port); } else - link_up(ap); + link_up(port); - fprintf(stderr, "|%s:%d| Interface %s is already known as active uplink\n", __func__, __LINE__, ap->ifname); + fprintf(stderr, "|%s:%d| Interface %s is already known as active uplink\n", __func__, __LINE__, port->ifname); goto out; } fprintf(stderr, "|%s:%d| active controller (%s) found for iface:%s mid:%d, keep out of bridge\n", - __func__, __LINE__, almac_str, ap->ifname, mid); + __func__, __LINE__, almac_str, port->ifname, mid); - if (if_isbridge_interface(ap->ifname)) - runCmd("/lib/wifi/dynbhd/api bridge_delif %s", ap->ifname); /* add back to bridge */ + if (if_isbridge_interface(port->ifname)) + runCmd("/lib/wifi/dynbhd/api bridge_delif %s", port->ifname); /* add back to bridge */ - runCmd("ubus call ieee1905 del_interface '{\"ifname\":\"%s\"}'", ap->ifname); + runCmd("ubus call ieee1905 del_interface '{\"ifname\":\"%s\"}'", port->ifname); - ap->loop = true; + port->loop = true; out: - ap->retries = ap->num_mid = 0; - ap->retries++; - timer_set(&ap->send_apconf, timeout * 1000); - timer_set(&ap->bridge_add, + port->retries = port->num_mid = 0; + port->retries++; + timer_set(&port->send_apconf, timeout * 1000); + timer_set(&port->bridge_add, ((APCONF_INTERVAL * APCONF_MAX_RETRIES) + timeout) * 1000); return 0; } @@ -618,7 +616,7 @@ static int handle_autoconfig_search(const char *ifname, uint8_t *src, { struct dynbh_ctx *p = (struct dynbh_ctx *) priv; char almac_str[18] = {0}; - struct ethport *ap; + struct ethport *port; struct tlv_policy a_policy[] = { [0] = { .type = TLV_TYPE_AL_MAC_ADDRESS_TYPE, .present = TLV_PRESENT_ONE, @@ -680,61 +678,61 @@ static int handle_autoconfig_search(const char *ifname, uint8_t *src, } - ap = ethport_by_ifname(p, ifname); - if (!ap) { + port = ethport_by_ifname(p, ifname); + if (!port) { fprintf(stderr, "No interface matching %s found - no action\n", ifname); return -1; - } else if (ap->active_uplink || ap->loop) { + } else if (port->active_uplink || port->loop) { fprintf(stderr, "Interface %s already known to be connected to a controller - no action\n", ifname); return -1; } else { fprintf(stderr, "Interface %s is not known to have a controller\n", ifname); } - memcpy(ap->backhaul_mac, src, 6); - memcpy(ap->backhaul_device_id, from, 6); + memcpy(port->backhaul_mac, src, 6); + memcpy(port->backhaul_device_id, from, 6); if (!is_backhaul_type_eth()) { /* if there is no active eth backhaul use this link as backhaul */ - ap->active_uplink = true; - ap->loop = false; - link_up(ap); - fprintf(stderr, "|%s:%d| Interface %s is active uplink\n", __func__, __LINE__, ap->ifname); - addif(ap); + port->active_uplink = true; + port->loop = false; + link_up(port); + fprintf(stderr, "|%s:%d| Interface %s is active uplink\n", __func__, __LINE__, port->ifname); + addif(port); #ifdef PERSIST_CONTROLLER - if (ap->ctx->discovery_mode == DYNAMIC_CNTLR_MODE_AUTO) { + if (port->ctx->discovery_mode == DYNAMIC_CNTLR_MODE_AUTO) { controller_discovery_disable(); - ap->ctx->discovery_mode = DYNAMIC_CNTLR_MODE_DISABLED; + port->ctx->discovery_mode = DYNAMIC_CNTLR_MODE_DISABLED; } #endif goto out; - } else if (ap->active_uplink) { + } else if (port->active_uplink) { char ul_ifname[16] = {0}; if (agent_get_backhaul_ifname(ul_ifname)) { - if (strncmp(ul_ifname, ap->ifname, 16)) - link_up(ap); + if (strncmp(ul_ifname, port->ifname, 16)) + link_up(port); } else - link_up(ap); + link_up(port); - fprintf(stderr, "|%s:%d| Interface %s is already known as active uplink\n", __func__, __LINE__, ap->ifname); + fprintf(stderr, "|%s:%d| Interface %s is already known as active uplink\n", __func__, __LINE__, port->ifname); goto out; } fprintf(stderr, "|%s:%d| active controller (%s) found for iface:%s mid:%d, keep out of bridge\n", - __func__, __LINE__, almac_str, ap->ifname, mid); + __func__, __LINE__, almac_str, port->ifname, mid); - if (if_isbridge_interface(ap->ifname)) - runCmd("/lib/wifi/dynbhd/api bridge_delif %s", ap->ifname); /* add back to bridge */ + if (if_isbridge_interface(port->ifname)) + runCmd("/lib/wifi/dynbhd/api bridge_delif %s", port->ifname); /* add back to bridge */ - runCmd("ubus call ieee1905 del_interface '{\"ifname\":\"%s\"}'", ap->ifname); + runCmd("ubus call ieee1905 del_interface '{\"ifname\":\"%s\"}'", port->ifname); - ap->loop = true; + port->loop = true; out: - ap->retries = ap->num_mid = 0; - ap->retries++; - timer_set(&ap->send_apconf, timeout * 1000); - timer_set(&ap->bridge_add, + port->retries = port->num_mid = 0; + port->retries++; + timer_set(&port->send_apconf, timeout * 1000); + timer_set(&port->bridge_add, ((APCONF_INTERVAL * APCONF_MAX_RETRIES) + timeout) * 1000); return 0; } @@ -960,21 +958,21 @@ static int dynbhd_status(struct ubus_context *ctx, struct ubus_object *obj, { struct dynbh_ctx *c = container_of(obj, struct dynbh_ctx, obj); struct blob_buf bb; - struct ethport *n; + struct ethport *port; void *a; memset(&bb, 0, sizeof(bb)); blob_buf_init(&bb, 0); a = blobmsg_open_array(&bb, "ports"); - list_for_each_entry(n, &c->ethportlist, list) { + list_for_each_entry(port, &c->ethportlist, list) { void *t; t = blobmsg_open_table(&bb, ""); - blobmsg_add_string(&bb, "ifname", n->ifname); - blobmsg_add_u8(&bb, "connected", n->connected); - blobmsg_add_u8(&bb, "active_uplink", n->active_uplink); - blobmsg_add_u8(&bb, "loop", n->loop); + blobmsg_add_string(&bb, "ifname", port->ifname); + blobmsg_add_u8(&bb, "connected", port->connected); + blobmsg_add_u8(&bb, "active_uplink", port->active_uplink); + blobmsg_add_u8(&bb, "loop", port->loop); blobmsg_close_table(&bb, t); } diff --git a/src/dynbh/dynbh.h b/src/dynbh/dynbh.h index 619cc60a22b287a8a2e00ad2fcc619a5b6c53744..68b14ed12459d9e12435cc36ea956e113c3b14b2 100644 --- a/src/dynbh/dynbh.h +++ b/src/dynbh/dynbh.h @@ -55,16 +55,17 @@ struct dynbh_ctx { }; -void delif(struct ethport *ap); -void addif(struct ethport *ap); +void delif(struct ethport *port); +void addif(struct ethport *port); struct ethport *ethport_by_ifname(struct dynbh_ctx *p, const char *ifname); -struct ethport *loop_by_ifname(struct dynbh_ctx *p, char *ifname); struct ethport *ethport_by_mid(struct dynbh_ctx *p, uint16_t mid); -void dynbh_handle_port_up(struct ethport *ap); + +void dynbh_handle_port_up(struct ethport *port); void dynbh_handle_port_down(struct dynbh_ctx *priv, struct ethport *port); -void free_ethport_search(struct ethport *ap); + +void free_ethport_search(struct ethport *port); #endif