From: Felix Fietkau Date: Mon, 5 Sep 2011 04:30:05 +0000 (+0200) Subject: add config state tracking X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=df13b3ade3f366446033214b3a85228005c014ea add config state tracking --- diff --git a/config.c b/config.c index 2fba534..31ebb8d 100644 --- a/config.c +++ b/config.c @@ -10,6 +10,7 @@ struct uci_context *uci_ctx; static struct uci_package *uci_network; bool config_init = false; static struct blob_buf b; +static unsigned int config_version = 1; static void uci_attr_to_blob(struct blob_buf *b, const char *str, @@ -138,6 +139,16 @@ config_parse_bridge_interface(struct uci_section *s) return 0; } +void +config_set_state(struct config_state *state, struct blob_attr *attr) +{ + state->data = malloc(blob_pad_len(attr)); + if (!state->data) + return; + + memcpy(state->data, attr, blob_pad_len(attr)); +} + static void config_parse_interface(struct uci_section *s) { @@ -163,6 +174,7 @@ config_parse_interface(struct uci_section *s) uci_to_blob(&b, s, iface->proto_handler->config_params); proto_init_interface(iface, b.head); + iface->config.version = config_version; } void diff --git a/config.h b/config.h index 83d7c25..49a81e4 100644 --- a/config.h +++ b/config.h @@ -23,4 +23,12 @@ struct config_param_list { const struct config_param_list *next[]; }; +struct config_state { + struct blob_attr *data; + unsigned int version; +}; + +void config_set_state(struct config_state *state, struct blob_attr *attr); + + #endif diff --git a/interface.c b/interface.c index 570e046..2d62bb0 100644 --- a/interface.c +++ b/interface.c @@ -238,6 +238,7 @@ interface_alloc(const char *name, struct blob_attr *attr) } netifd_ubus_add_interface(iface); + config_set_state(&iface->config, attr); return iface; } diff --git a/interface.h b/interface.h index bde069c..0f2eb85 100644 --- a/interface.h +++ b/interface.h @@ -46,6 +46,8 @@ struct interface { /* interface that layer 3 communication will go through */ struct device_user *l3_iface; + struct config_state config; + /* primary protocol state */ const struct proto_handler *proto_handler; struct interface_proto_state *proto;