diff options
author | John Crispin <john@openwrt.org> | 2014-06-26 11:43:34 +0000 |
---|---|---|
committer | John Crispin <john@openwrt.org> | 2014-06-26 11:43:34 +0000 |
commit | d3be71e141c754ab5e1fbb2c14ce1876d931e6a3 (patch) | |
tree | 41a8a4637aceb0d721c73c4a9375ad81f766139a /package/network/services/mdns/files | |
parent | 3a9bfa5938ab4d98a7c7ee10fca4b25101bbc0f9 (diff) | |
download | upstream-d3be71e141c754ab5e1fbb2c14ce1876d931e6a3.tar.gz upstream-d3be71e141c754ab5e1fbb2c14ce1876d931e6a3.tar.bz2 upstream-d3be71e141c754ab5e1fbb2c14ce1876d931e6a3.zip |
mdns: add the new openwrt mdns daemon
this is still wip, you can use the following ubus calls.
ubus call mdns scan # triggers a scan
ubus call mdns browse # look at the currenlty cached records
ubus call mdns hosts # look at the currenlty cached hosts
TODO
- ipv6, currenlty AAAA records are handled but only on v4 sockets
- finish the service announce code
Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 41345
Diffstat (limited to 'package/network/services/mdns/files')
-rw-r--r-- | package/network/services/mdns/files/mdns.config | 2 | ||||
-rw-r--r-- | package/network/services/mdns/files/mdns.init | 51 |
2 files changed, 53 insertions, 0 deletions
diff --git a/package/network/services/mdns/files/mdns.config b/package/network/services/mdns/files/mdns.config new file mode 100644 index 0000000000..d64ba6768c --- /dev/null +++ b/package/network/services/mdns/files/mdns.config @@ -0,0 +1,2 @@ +config mdns + list network lan diff --git a/package/network/services/mdns/files/mdns.init b/package/network/services/mdns/files/mdns.init new file mode 100644 index 0000000000..f66de11d3f --- /dev/null +++ b/package/network/services/mdns/files/mdns.init @@ -0,0 +1,51 @@ +#!/bin/sh /etc/rc.common +# Copyright (c) 2014 OpenWrt.org + +. /lib/functions/network.sh + +START=80 + +USE_PROCD=1 +PROG=/usr/sbin/mdns +IFACES="" + +load_ifaces() { + local network="$(uci get mdns.@mdns[-1].network)" + for n in $network; do + local device + json_load "$(ifstatus $network)" + json_get_var device l3_device + echo -n "$device " + done +} + +reload_service() { + json_init + json_add_array interfaces + for i in $(load_ifaces); do + json_add_string "" "$i" + done + json_close_array + + ubus call mdns set_config "$(json_dump)" +} + +start_service() { + local network="$(uci get mdns.@mdns[-1].network)" + + procd_open_instance + procd_set_param command "$PROG" + procd_set_param respawn + procd_open_trigger + procd_add_config_trigger "config.change" "mdns" /etc/init.d/mdns reload + for n in $network; do + procd_add_interface_trigger "interface.*" $n /etc/init.d/mdns reload + done + procd_close_trigger + procd_close_instance +} + +service_started() { + ubus wait_for -t 5 mdns + [ $? = 0 ] && reload_service +} |