add config state tracking
authorFelix Fietkau <nbd@openwrt.org>
Mon, 5 Sep 2011 04:30:05 +0000 (06:30 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 5 Sep 2011 04:30:05 +0000 (06:30 +0200)
config.c
config.h
interface.c
interface.h

index 2fba534..31ebb8d 100644 (file)
--- 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 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,
 
 
 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;
 }
 
        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)
 {
 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);
                uci_to_blob(&b, s, iface->proto_handler->config_params);
 
        proto_init_interface(iface, b.head);
+       iface->config.version = config_version;
 }
 
 void
 }
 
 void
index 83d7c25..49a81e4 100644 (file)
--- a/config.h
+++ b/config.h
@@ -23,4 +23,12 @@ struct config_param_list {
        const struct config_param_list *next[];
 };
 
        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
 #endif
index 570e046..2d62bb0 100644 (file)
@@ -238,6 +238,7 @@ interface_alloc(const char *name, struct blob_attr *attr)
        }
 
        netifd_ubus_add_interface(iface);
        }
 
        netifd_ubus_add_interface(iface);
+       config_set_state(&iface->config, attr);
 
        return iface;
 }
 
        return iface;
 }
index bde069c..0f2eb85 100644 (file)
@@ -46,6 +46,8 @@ struct interface {
        /* interface that layer 3 communication will go through */
        struct device_user *l3_iface;
 
        /* 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;
        /* primary protocol state */
        const struct proto_handler *proto_handler;
        struct interface_proto_state *proto;