完成後,先啟動 daemon : mdnsd
然後隨便 run 一個 client app:
pi@raspberrypi ~/mDNSResponder-544/mDNSPosix/build/prod $ ./mDNSClientPosix socket AF_INET6: Address family not supported by protocol mDNSClientPosix: Finished with status -65537, result 2
所以要 enable ipv6, 不然就要修改 Makefile, 把 ipv6 disable掉
ref: https://www.raspbian.org/RaspbianFAQ#How_do_I_enable_or_use_IPv6.3F
就 sudo modprobe ipv6
再 run mdnsd 和,,
pi@raspberrypi ~/mDNSResponder-544/mDNSPosix/build/prod $ ./mDNSClientPosix Hit ^C when you're bored waiting for responses.
... 不一樣了...
在 jessie 下 build, error:
../mDNSShared/dnsextd_parser.y:188:22: note: each undeclared identifier is reported only once for each function it appears in
../mDNSShared/dnsextd_parser.y: In function ‘ParseConfig’:
../mDNSShared/dnsextd_parser.y:448:8: error: too many arguments to function ‘yyparse’
err = yyparse( ( void* ) d );
^
objects/prod/dnsextd_parser.c:1125:1: note: declared here
yyparse (void)
^
make: *** [objects/prod/dnsextd_parser.y.o] Error 1
.. 這個先跳過...ref: https://github.com/changyy/mDNSResponder-cmake
原來是這樣用的...mDNSResponderPosix 和 mDNSClientPosix
Makefile 這兩個 ap 的 source:
SPECIALOBJ = $(OBJDIR)/mDNSPosix.c.o $(OBJDIR)/mDNSUNP.c.o $(OBJDIR)/mDNSDebug.c.o $(OBJDIR)/GenLinkedList.c.o \
$(OBJDIR)/DNSDigest.c.o $(OBJDIR)/uDNS.c.o $(OBJDIR)/DNSCommon.c.o $(OBJDIR)/PlatformCommon.c.o \
$(OBJDIR)/CryptoAlg.c.o $(OBJDIR)/anonymous.c.o
COMMONOBJ = $(SPECIALOBJ) $(OBJDIR)/mDNS.c.o
APPOBJ = $(COMMONOBJ) $(OBJDIR)/ExampleClientApp.c.o
$(BUILDDIR)/mDNSClientPosix: $(APPOBJ) $(OBJDIR)/Client.c.o
$(CC) $+ -o $@ $(LINKOPTS)
$(BUILDDIR)/mDNSResponderPosix: $(COMMONOBJ) $(OBJDIR)/Responder.c.o
$(CC) $+ -o $@ $(LINKOPTS)
follow ref 的作法,看看 option :
$ ./mDNSResponderPosix -h
./mDNSResponderPosix: invalid option -- 'h'
Usage: mDNSResponderPosix [-v level ] [-r] [-n name] [-t type] [-d domain] [-p port] [-f file] [-b] [-P pidfile] [-x name=val ...]
-v verbose mode, level is a number from 0 to 2
0 = no debugging info (default)
1 = standard debugging info
2 = intense debugging info
can be cycled kill -USR1
-r also bind to port 53 (port 5353 is always bound)
-n uses 'name' as the service name (required)
-t uses 'type' as the service type (default is '_afpovertcp._tcp.')
-d uses 'domain' as the service domain (default is 'local.')
-p uses 'port' as the port number (default is '548')
-f reads a service list from 'file'
-b forces daemon (background) mode
-P uses 'pidfile' as the PID file
(default is '/var/run/mDNSResponder.pid')
only meaningful if -b also specified
-x stores name=val in TXT record (default is empty).
MUST be the last command-line argument;
all subsequent arguments after -x are treated as name=val pairs.
和..
$ ./mDNSClientPosix -h
./mDNSClientPosix: invalid option -- 'h'
Usage: mDNSClientPosix [-v level] [-t type] [-d domain]
-v verbose mode, level is a number from 0 to 2
0 = no debugging info (default)
1 = standard debugging info
2 = intense debugging info
-t uses 'type' as the service type (default is '_afpovertcp._tcp')
-d uses 'domain' as the domain to browse (default is 'local.')
所以最簡單的就是:
$ ./mDNSResponder -n mytest因為沒有加上 -b, 所以要用另一台機器(在同一個 lan)..
$ ./mDNSClientPosix Hit ^C when you're bored waiting for responses. *** Found name = 'mytest', type = '_afpovertcp._tcp.', domain = 'local.'完成。
****
Debian Jessie 真的不能build...@_@.. 拿部份build成功的 mDNSResponder 來 run, 會出現 Address in use error
實際測試是用 raspberry pi 和 ubuntu 12.10 接在 LAN 上測試成功。
-- 都 disable IPV6.
另外, Bananapi + Android 4.2 和 raspberry pi + raspbian 用 NCM (Usb) 連線測試也 OK
Bananapi + Android 4.2 用的是 Android 內建的..mdnsresponder..
修改 Android.mk:
include $(CLEAR_VARS)
LOCAL_SRC_FILES := mDNSPosix/mDNSPosix.c \
mDNSPosix/mDNSUNP.c \
mDNSShared/mDNSDebug.c \
mDNSShared/GenLinkedList.c \
mDNSCore/DNSDigest.c \
mDNSCore/uDNS.c \
mDNSCore/DNSCommon.c \
mDNSShared/PlatformCommon.c \
mDNSCore/mDNS.c \
mDNSPosix/ExampleClientApp.c \
mDNSPosix/Client.c \
LOCAL_MODULE := mDNSClientPosix
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := external/mdnsresponder/mDNSPosix \
external/mdnsresponder/mDNSCore \
external/mdnsresponder/mDNSShared
LOCAL_CFLAGS := -O2 -g -W -Wall -D__ANDROID__ -D_GNU_SOURCE -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DTARGET_OS_LINUX -fno-strict-aliasing -DHAVE_LINUX -DMDNS_DEBUGMSGS=0 -DMDNS_UDS_SERVERPATH=\"/dev/socket/mdnsd\" -DMDNS_USERNAME=\"mdnsr\" -DPLATFORM_NO_RLIMIT
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libcutils
include $(BUILD_EXECUTABLE)
沒有留言:
張貼留言