summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/hotplug-cmd1
-rwxr-xr-xexamples/proto/ppp.sh71
-rwxr-xr-xexamples/proto/pptp.sh42
3 files changed, 114 insertions, 0 deletions
diff --git a/examples/hotplug-cmd b/examples/hotplug-cmd
new file mode 100755
index 0000000..2488a77
--- /dev/null
+++ b/examples/hotplug-cmd
@@ -0,0 +1 @@
+echo "Action: $ACTION, Interface: $INTERFACE"
diff --git a/examples/proto/ppp.sh b/examples/proto/ppp.sh
new file mode 100755
index 0000000..f0d0ca3
--- /dev/null
+++ b/examples/proto/ppp.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+DUMMY=1
+. ../../scripts/netifd-proto.sh
+
+init_proto "$@"
+
+ppp_generic_init_config() {
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_int "keepalive"
+}
+
+proto_ppp_init_config() {
+ no_device=1
+ available=1
+ ppp_generic_init_config
+}
+
+proto_ppp_setup() {
+ echo "ppp_setup($1): $2"
+}
+
+proto_ppp_teardown() {
+ return
+}
+
+add_protocol ppp
+
+proto_pppoe_init_config() {
+ ppp_generic_init_config
+}
+
+proto_pppoe_setup() {
+ local interface="$1"
+ local device="$2"
+
+ json_get_var username username
+ json_get_var password password
+ echo "pppoe_setup($interface, $device), username=$username, password=$password"
+ proto_init_update pppoe-$interface 1
+ proto_set_keep 1
+ proto_add_ipv4_address "192.168.2.1" 32
+ proto_add_dns_server "192.168.2.2"
+ proto_add_ipv4_route "0.0.0.0" 0 192.168.2.2
+ proto_add_data
+ json_add_string "ppp-type" "pppoe"
+ proto_close_data
+ proto_send_update "$interface"
+
+ proto_init_update pppoe-$interface 1
+ proto_set_keep 1
+ proto_add_ipv6_address "fe80::2" 64
+ proto_add_ipv6_route "::0" 0 "fe80::1"
+ proto_add_data
+ json_add_string "ppp-type" "pppoe"
+ proto_close_data
+ proto_send_update "$interface"
+
+ proto_run_command "$interface" sleep 30
+}
+
+proto_pppoe_teardown() {
+ [ "$ERROR" = 9 ] && {
+ proto_notify_error "$interface" PROCESS_KILLED
+ proto_block_restart "$interface"
+ }
+ proto_kill_command "$interface"
+ return
+}
+
+add_protocol pppoe
diff --git a/examples/proto/pptp.sh b/examples/proto/pptp.sh
new file mode 100755
index 0000000..5189e95
--- /dev/null
+++ b/examples/proto/pptp.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+. ../../scripts/netifd-proto.sh
+init_proto "$@"
+
+proto_pptp_init_config() {
+ no_device=1
+ available=1
+
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_string server
+}
+
+proto_pptp_setup() {
+ local interface="$1"
+ local device="$2"
+
+ json_get_var server server
+ proto_add_host_dependency "$interface" "$server"
+
+ json_get_var username username
+ json_get_var password password
+ echo "pptp_setup($interface), username=$username, password=$password"
+ proto_init_update "pptp-$interface" 1
+ proto_set_keep 1
+ proto_add_ipv4_address "192.168.9.1" 32
+ proto_add_dns_server "192.168.9.2"
+ proto_add_ipv4_route "0.0.0.0" 0 192.168.9.2
+ proto_add_data
+ json_add_string "ppp-type" "pptp"
+ proto_close_data
+ proto_send_update "$interface"
+
+ proto_run_command "$interface" sleep 30
+}
+
+proto_pptp_teardown() {
+ return
+}
+
+add_protocol pptp
+