mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-28 01:28:59 +00:00
d3be71e141
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
52 lines
991 B
Bash
52 lines
991 B
Bash
#!/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
|
|
}
|