move protocol flags to the handler, add a pointer to the handler in the proto state...
[project/netifd.git] / proto-static.c
index 04e2118..bbe304b 100644 (file)
@@ -89,14 +89,13 @@ parse_addr(struct interface_proto_state *state, const char *str, bool v6, int ma
 
        addr = calloc(1, sizeof(*addr));
        addr->flags = v6 ? DEVADDR_INET6 : DEVADDR_INET4;
-       addr->ctx = state;
        addr->mask = mask;
        if (!parse_ip_and_netmask(af, str, &addr->addr, &addr->mask)) {
                interface_add_error(state->iface, "proto-static", "INVALID_ADDRESS", &str, 1);
                free(addr);
                return false;
        }
-       interface_add_address(state->iface, addr);
+       vlist_add(&state->iface->proto_addr, &addr->node);
        return true;
 }
 
@@ -132,7 +131,7 @@ parse_gateway_option(struct interface_proto_state *state, struct blob_attr *attr
        }
        route->mask = 0;
        route->flags = DEVADDR_DEVICE | (v6 ? DEVADDR_INET6 : DEVADDR_INET4);
-       interface_add_route(state->iface, route);
+       vlist_add(&state->iface->proto_route, &route->node);
 
        return true;
 }
@@ -206,12 +205,11 @@ static_handler(struct interface_proto_state *proto,
 
        switch (cmd) {
        case PROTO_CMD_SETUP:
-               if (static_proto_setup(state))
-                       break;
+               if (!static_proto_setup(state))
+                       return -1;
 
-               /* fall through */
+               break;
        case PROTO_CMD_TEARDOWN:
-               interface_del_ctx_addr(state->proto.iface, proto);
                break;
        }
        return ret;
@@ -243,8 +241,7 @@ static_attach(const struct proto_handler *h, struct interface *iface,
 
        memcpy(state->config, attr, blob_pad_len(attr));
        state->proto.free = static_free;
-       state->proto.handler = static_handler;
-       state->proto.flags = PROTO_FLAG_IMMEDIATE;
+       state->proto.cb = static_handler;
 
        return &state->proto;
 
@@ -255,6 +252,7 @@ error:
 
 static struct proto_handler static_proto = {
        .name = "static",
+       .flags = PROTO_FLAG_IMMEDIATE,
        .config_params = &static_attr_list,
        .attach = static_attach,
 };