X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=wireless.c;h=8bdfc4b10ec1b5b1b04afef78ca0eb8418c64a49;hp=c0f3b710fcefff9b50505931ca6a1eb2445262a9;hb=9d8dd091f8f336b111364ed211165b5ec9842a24;hpb=a3bf8cbe10b0bad85475f4c3dc2bae4afb65774b diff --git a/wireless.c b/wireless.c index c0f3b71..8bdfc4b 100644 --- a/wireless.c +++ b/wireless.c @@ -51,9 +51,9 @@ static const struct uci_blob_param_list vif_param = { static void put_container(struct blob_buf *buf, struct blob_attr *attr, const char *name) { - void *c = blobmsg_open_table(&b, name); - blob_put_raw(&b, blob_data(attr), blob_len(attr)); - blobmsg_close_table(&b, c); + void *c = blobmsg_open_table(buf, name); + blob_put_raw(buf, blob_data(attr), blob_len(attr)); + blobmsg_close_table(buf, c); } static void @@ -215,7 +215,7 @@ static void wireless_interface_handle_link(struct wireless_interface *vif, bool if (!iface) continue; - interface_handle_link(iface, vif->ifname, up); + interface_handle_link(iface, vif->ifname, up, true); } } @@ -544,7 +544,8 @@ vif_update(struct vlist_tree *tree, struct vlist_node *node_new, wdev = vif_new->wdev; if (vif_old && vif_new) { - vif_old->section = vif_new->section; + free((void *) vif_old->section); + vif_old->section = strdup(vif_new->section); if (blob_attr_equal(vif_old->config, vif_new->config)) { free(vif_new); return; @@ -557,10 +558,12 @@ vif_update(struct vlist_tree *tree, struct vlist_node *node_new, free(vif_new); } else if (vif_new) { D(WIRELESS, "Create new wireless interface %s on device %s\n", vif_new->name, wdev->name); + vif_new->section = strdup(vif_new->section); vif_new->config = blob_memdup(vif_new->config); wireless_interface_init_config(vif_new); } else if (vif_old) { D(WIRELESS, "Delete wireless interface %s on device %s\n", vif_old->name, wdev->name); + free((void *) vif_old->section); free(vif_old->config); free(vif_old); } @@ -671,7 +674,8 @@ void wireless_interface_create(struct wireless_device *wdev, struct blob_attr *d sprintf(name, "%d", wdev->vif_idx++); - vif = calloc_a(sizeof(*vif), &name_buf, strlen(name) + 1); + vif = calloc_a(sizeof(*vif), + &name_buf, strlen(name) + 1); vif->name = strcpy(name_buf, name); vif->wdev = wdev; vif->config = data; @@ -689,8 +693,7 @@ wireless_interface_status(struct wireless_interface *iface, struct blob_buf *b) blobmsg_add_string(b, "section", iface->section); if (iface->ifname) blobmsg_add_string(b, "ifname", iface->ifname); - if (iface->data) - blob_put_raw(b, blob_data(iface->data), blob_len(iface->data)); + put_container(b, iface->config, "config"); blobmsg_close_table(b, i); } @@ -705,6 +708,7 @@ wireless_device_status(struct wireless_device *wdev, struct blob_buf *b) blobmsg_add_u8(b, "pending", wdev->state == IFS_SETUP || wdev->state == IFS_TEARDOWN); blobmsg_add_u8(b, "autostart", wdev->autostart); blobmsg_add_u8(b, "disabled", wdev->disabled); + put_container(b, wdev->config, "config"); i = blobmsg_open_array(b, "interfaces"); vlist_for_each_element(&wdev->interfaces, iface, node)