extend vlist code to allow keeping the old data structure instead of the new one...
[project/netifd.git] / proto / netifd-proto.sh
index 3764281..d15505c 100755 (executable)
@@ -26,17 +26,25 @@ add_default_handler() {
        esac
 }
 
-case "$1" in
+proto="$1"; shift
+cmd="$1"; shift
+interface="$1"; shift
+data="$1"; shift
+ifname="$1"; shift
+
+case "$cmd" in
        dump)
                add_protocol() {
-                       immediate=0
+                       no_device=0
+                       available=0
 
                        add_default_handler "$1_init_config"
 
                        json_init
                        json_add_string "name" "$1"
                        eval "$1_init"
-                       json_add_boolean immediate "$immediate"
+                       json_add_boolean no-device "$no_device"
+                       json_add_boolean available "$available"
                        json_add_array "config"
                        eval "$1_init_config"
                        json_close_array
@@ -45,7 +53,13 @@ case "$1" in
        ;;
        *)
                add_protocol() {
-                       return;
+                       [[ "$proto" == "$1" ]] || return 0
+
+                       case "$cmd" in
+                               setup) eval "$1_setup \"\$interface\" \"\$data\" \"\$ifname\"" ;;
+                               teardown) eval "$1_teardown \"\$interface\" \"\$data\" \"\$ifname\"" ;;
+                               *) return 1 ;;
+                       esac
                }
        ;;
 esac