8 struct uci_context *uci_ctx;
9 bool config_init = false;
11 static void config_parse_interface(struct uci_section *s)
13 struct interface *iface;
16 DPRINTF("Create interface '%s'\n", s->e.name);
18 iface = alloc_interface(s->e.name);
19 type = uci_lookup_option_string(uci_ctx, s, "type");
24 if (!strcmp(type, "bridge"))
25 interface_attach_bridge(iface, s);
28 void config_init_interfaces(const char *name)
30 struct uci_context *ctx;
31 struct uci_package *p = NULL;
32 struct uci_element *e;
34 ctx = uci_alloc_context();
37 uci_set_confdir(ctx, "./config");
39 if (uci_load(ctx, "network", &p)) {
40 fprintf(stderr, "Failed to load network config\n");
45 uci_foreach_element(&p->sections, e) {
46 struct uci_section *s = uci_to_section(e);
48 if (name && strcmp(s->e.name, name) != 0)
51 if (!strcmp(s->type, "interface"))
52 config_parse_interface(s);
56 start_pending_interfaces();