summaryrefslogtreecommitdiffhomepage
path: root/interface.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-10-05 21:41:52 +0200
committerFelix Fietkau <nbd@openwrt.org>2013-10-19 17:31:55 +0200
commit6843870670b8a68c98528faf638c6b3938cab55d (patch)
treeb63d960f42a5354909fc48f26691993ad7176ec0 /interface.c
parent65963f0ad2207b55dc7715015839b59b58855a67 (diff)
interface: rework code to get rid of arbitrary IFNAMSIZ limitation for interface names
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/interface.c b/interface.c
index 18322d7..5649324 100644
--- a/interface.c
+++ b/interface.c
@@ -536,15 +536,17 @@ void interface_set_proto_state(struct interface *iface, struct interface_proto_s
state->iface = iface;
}
-void
-interface_init(struct interface *iface, const char *name,
- struct blob_attr *config)
+struct interface *
+interface_alloc(const char *name, struct blob_attr *config)
{
+ struct interface *iface;
struct blob_attr *tb[IFACE_ATTR_MAX];
struct blob_attr *cur;
const char *proto_name = NULL;
+ char *iface_name;
- strncpy(iface->name, name, sizeof(iface->name) - 1);
+ iface = calloc_a(sizeof(*iface), &iface_name, strlen(name) + 1);
+ iface->name = strcpy(iface_name, name);
INIT_LIST_HEAD(&iface->errors);
INIT_LIST_HEAD(&iface->users);
INIT_LIST_HEAD(&iface->hotplug_list);
@@ -610,6 +612,7 @@ interface_init(struct interface *iface, const char *name,
iface->proto_ip.no_delegation = !blobmsg_get_bool_default(tb[IFACE_ATTR_DELEGATE], true);
iface->config_autostart = iface->autostart;
+ return iface;
}
void interface_set_dynamic(struct interface *iface)