pass ifname to the shell proto handler
[project/netifd.git] / proto-shell.c
index d014b430421a822877450e496decf9a076cfe720..574d969992e438c1009934a6dcdd9dc4e71ed676 100644 (file)
@@ -57,7 +57,7 @@ proto_shell_handler(struct interface_proto_state *proto,
 {
        struct proto_shell_state *state;
        struct proto_shell_handler *handler;
-       const char *argv[5];
+       const char *argv[6];
        char *config;
        int ret;
 
@@ -73,6 +73,10 @@ proto_shell_handler(struct interface_proto_state *proto,
        argv[2] = "teardown";
        argv[3] = config;
        argv[4] = NULL;
+       if (proto->iface->main_dev.dev) {
+               argv[4] = proto->iface->main_dev.dev->ifname;
+               argv[5] = NULL;
+       }
 
        switch(cmd) {
        case PROTO_CMD_SETUP:
@@ -230,6 +234,10 @@ proto_shell_add_handler(const char *script, json_object *obj)
        proto->config_params = &handler->config;
        proto->attach = proto_shell_attach;
 
+       tmp = get_field(obj, "no-device", json_type_boolean);
+       if (tmp && json_object_get_boolean(tmp))
+               handler->proto.flags |= PROTO_FLAG_NODEV;
+
        config = get_field(obj, "config", json_type_array);
        if (config)
                handler->config_buf = proto_shell_parse_config(&handler->config, config);