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: 41345master
parent
3a9bfa5938
commit
d3be71e141
@ -0,0 +1,41 @@ |
|||||||
|
#
|
||||||
|
# Copyright (C) 2014 OpenWrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
|
# See /LICENSE for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk |
||||||
|
|
||||||
|
PKG_NAME:=mdns
|
||||||
|
PKG_VERSION:=2014-06-25
|
||||||
|
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||||
|
|
||||||
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||||
|
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||||
|
PKG_SOURCE_URL:=git://git.openwrt.org/project/mdnsd.git
|
||||||
|
PKG_SOURCE_PROTO:=git
|
||||||
|
PKG_SOURCE_VERSION:=902e2d1eaaff0d3d33dee605a4746fd5d4b6b999
|
||||||
|
|
||||||
|
PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
|
||||||
|
|
||||||
|
include $(INCLUDE_DIR)/package.mk |
||||||
|
include $(INCLUDE_DIR)/cmake.mk |
||||||
|
|
||||||
|
define Package/mdns |
||||||
|
SECTION:=net
|
||||||
|
CATEGORY:=Network
|
||||||
|
TITLE:=OpenWrt Multicast DNS Daemon
|
||||||
|
DEPENDS:=+libubox +libubus +libblobmsg-json
|
||||||
|
endef |
||||||
|
|
||||||
|
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
|
||||||
|
|
||||||
|
define Package/mdns/install |
||||||
|
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config
|
||||||
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mdns $(1)/usr/sbin/
|
||||||
|
$(INSTALL_BIN) ./files/mdns.init $(1)/etc/init.d/mdns
|
||||||
|
$(INSTALL_BIN) ./files/mdns.config $(1)/etc/config/mdns
|
||||||
|
endef |
||||||
|
|
||||||
|
$(eval $(call BuildPackage,mdns)) |
@ -0,0 +1,2 @@ |
|||||||
|
config mdns |
||||||
|
list network lan |
@ -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 |
||||||
|
} |
Loading…
Reference in new issue