summaryrefslogtreecommitdiffhomepage
path: root/proto
diff options
context:
space:
mode:
Diffstat (limited to 'proto')
-rwxr-xr-xproto/netifd-proto.sh44
-rwxr-xr-xproto/ppp.sh25
2 files changed, 69 insertions, 0 deletions
diff --git a/proto/netifd-proto.sh b/proto/netifd-proto.sh
new file mode 100755
index 0000000..f850216
--- /dev/null
+++ b/proto/netifd-proto.sh
@@ -0,0 +1,44 @@
+. /usr/share/libubox/jshn.sh
+
+proto_config_add_int() {
+ json_add_int "$1" 5
+}
+
+proto_config_add_string() {
+ json_add_int "$1" 3
+}
+
+proto_config_add_boolean() {
+ json_add_int "$1" 7
+}
+
+add_default_handler() {
+ case "$(type $1 2>/dev/null)" in
+ *function*) return;;
+ *) eval "$1() { return; }"
+ esac
+}
+
+case "$1" in
+ dump)
+ add_protocol() {
+ immediate=0
+
+ add_default_handler "$1_init_config"
+
+ json_init
+ json_add_string "name" "$1"
+ eval "$1_init"
+ json_add_boolean immediate "$immediate"
+ json_add_object "config"
+ eval "$1_init_config"
+ json_close_object
+ json_dump
+ }
+ ;;
+ *)
+ add_protocol() {
+ return;
+ }
+ ;;
+esac
diff --git a/proto/ppp.sh b/proto/ppp.sh
new file mode 100755
index 0000000..76df2f3
--- /dev/null
+++ b/proto/ppp.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+. netifd-proto.sh
+
+ppp_init_config() {
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_int "keepalive"
+}
+
+ppp_init() {
+ return
+}
+
+add_protocol ppp
+
+pppoe_init_config() {
+ ppp_init_config
+}
+
+pppoe_init() {
+ return
+}
+
+add_protocol pppoe