The scripts were based on the netifd dhcp scripts, and should add zeroconf support to /etc/config/network Example: config interface 'lan' option ifname 'eth0' option auto '0' option proto 'zeroconf'
Optionally, the desired IP address can be added by: option ipaddr '169.254.200.100' any extra commandline arguments can be added by: option cmdline '-v' Note that zcip in Busybox must be enabled for this to work. Signed-off-by: Michel Stam <m.s...@fugro.nl> --- .../netifd/files/lib/netifd/proto/zeroconf.sh | 33 ++++++++++++++++++++++ .../config/netifd/files/lib/netifd/zeroconf.script | 29 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100755 package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh create mode 100755 package/network/config/netifd/files/lib/netifd/zeroconf.script diff --git a/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh new file mode 100755 index 0000000..cec7605 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/proto/zeroconf.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +. /lib/functions.sh +. ../netifd-proto.sh +init_proto "$@" + +proto_zeroconf_init_config() { + proto_config_add_string 'ipaddr:ipaddr' + proto_config_add_string cmdline +} + +proto_zeroconf_setup() { + local config="$1" + local iface="$2" + + local ipaddr + json_get_vars ipaddr cmdline + + proto_export "INTERFACE=$config" + proto_run_command "$config" zcip \ + ${ipaddr:+-r $ipaddr} \ + ${cmdline} \ + -f "$iface" \ + /lib/netifd/zeroconf.script +} + +proto_zeroconf_teardown() { + local interface="$1" + proto_kill_command "$INTERFACE" +} + +add_protocol zeroconf + diff --git a/package/network/config/netifd/files/lib/netifd/zeroconf.script b/package/network/config/netifd/files/lib/netifd/zeroconf.script new file mode 100755 index 0000000..8d34a67 --- /dev/null +++ b/package/network/config/netifd/files/lib/netifd/zeroconf.script @@ -0,0 +1,29 @@ +#!/bin/sh +[ -z "$1" ] && echo "Error: should be run by zcip" && exit 1 + +. /lib/functions.sh +. /lib/netifd/netifd-proto.sh + +setup_interface () { + proto_init_update "*" 1 + proto_add_ipv4_address "$ip" '255.255.0.0' + proto_send_update "$INTERFACE" +} + +deconfig_interface() { + proto_init_update "*" 0 + proto_send_update "$INTERFACE" +} + +case "$1" in + deconfig) + deconfig_interface + ;; + config) + setup_interface + ;; + *|init) + ;; +esac + +exit 0 -- 1.7.12.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel