- uci_foreach_element(&dhcp->sections, e) {
- struct uci_section *s = uci_to_section(e);
- if (!strcmp(s->type, "dhcp"))
- set_interface(s);
- }
+ if (!uci)
+ return;
+
+ list_for_each_entry(i, &interfaces, head)
+ clean_interface(i);
+
+ struct uci_package *dhcp = NULL;
+ if (!uci_load(uci, "dhcp", &dhcp)) {
+ struct uci_element *e;
+ uci_foreach_element(&dhcp->sections, e) {
+ struct uci_section *s = uci_to_section(e);
+ if (!strcmp(s->type, "host"))
+ set_lease(s);
+ else if (!strcmp(s->type, "odhcpd"))
+ set_config(s);
+ }
+
+ uci_foreach_element(&dhcp->sections, e) {
+ struct uci_section *s = uci_to_section(e);
+ if (!strcmp(s->type, "dhcp"))
+ set_interface(s);