aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base
diff options
context:
space:
mode:
Diffstat (limited to 'package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base')
-rw-r--r--package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base49
1 files changed, 49 insertions, 0 deletions
diff --git a/package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base b/package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base
new file mode 100644
index 0000000..3830878
--- /dev/null
+++ b/package/network/config/netifd/files/lib/netifd/proto/.svn/text-base/dhcp.sh.svn-base
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_dhcp_init_config() {
+ proto_config_add_string "ipaddr"
+ proto_config_add_string "netmask"
+ proto_config_add_string "hostname"
+ proto_config_add_string "clientid"
+ proto_config_add_string "vendorid"
+ proto_config_add_boolean "broadcast"
+ proto_config_add_string "reqopts"
+}
+
+proto_dhcp_setup() {
+ local config="$1"
+ local iface="$2"
+
+ local ipaddr hostname clientid vendorid broadcast reqopts
+ json_get_vars ipaddr hostname clientid vendorid broadcast reqopts
+
+ local opt dhcpopts
+ for opt in $reqopts; do
+ append dhcpopts "-O $opt"
+ done
+
+ [ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
+ [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
+
+ proto_export "INTERFACE=$config"
+ proto_run_command "$config" udhcpc \
+ -p /var/run/udhcpc-$iface.pid \
+ -s /lib/netifd/dhcp.script \
+ -f -t 0 -i "$iface" \
+ ${ipaddr:+-r $ipaddr} \
+ ${hostname:+-H $hostname} \
+ ${vendorid:+-V $vendorid} \
+ $clientid $broadcast $dhcpopts
+}
+
+proto_dhcp_teardown() {
+ local interface="$1"
+ proto_kill_command "$interface"
+}
+
+add_protocol dhcp
+