Bump to mdnsresponder 878.70.2 10/270710/1 submit/tizen/20220208.033846
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 8 Feb 2022 03:32:23 +0000 (12:32 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Tue, 8 Feb 2022 03:32:30 +0000 (12:32 +0900)
Change-Id: If2556b2a3939cc69dde228680f9b8764948e53ac

12 files changed:
mDNSPosix/Makefile
mDNSPosix/mDNSPosix.c
mDNSPosix/mDNSUNP.c
mDNSShared/dnssd_clientstub.c
mDNSShared/mDNSDebug.c
mdnsd.service [new file with mode: 0644]
mdnsresponder-server.sh.in [new file with mode: 0755]
packaging/libdns_sd.manifest [new file with mode: 0644]
packaging/mdnsresponder.manifest [new file with mode: 0644]
packaging/mdnsresponder.spec [new file with mode: 0755]
pkgconfig/lib/dns_sd.pc.in [new file with mode: 0755]
pkgconfig/lib64/dns_sd.pc.in [new file with mode: 0755]

index 4f98e90..ede1196 100755 (executable)
@@ -48,7 +48,7 @@
 
 #############################################################################
 
-LIBVERS = 1
+LIBVERS = 765.50.9
 
 COREDIR = ../mDNSCore
 SHAREDDIR ?= ../mDNSShared
@@ -157,8 +157,19 @@ JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Header
 OPTIONALTARG = dnsextd
 else
 
+ifeq ($(os),tizen)
+CFLAGS_OS = -D_GNU_SOURCE -DHAVE_IPV6 -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX -DTARGET_OS_LINUX -DTIZEN_EXT -DCONFIG_DISABLE_REUSEPORT -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE
+CFLAGS_ASLR = -fPIE
+LINKOPTS_ASLR = -pie
+LINKOPTS = -Wl,-z,relro
+LD = $(CC) -shared
+FLEXFLAGS_OS = -l
+INSTBASE = $(DESTDIR)/usr
+else
+
 $(error ERROR: Must specify target OS on command-line, e.g. "make os=x [target]".\
-Supported operating systems include: x, linux, linux-uclibc, netbsd, freebsd, openbsd, solaris)
+Supported operating systems include: x, linux, linux-uclibc, netbsd, freebsd, openbsd, solaris, tizen)
+endif
 endif
 endif
 endif
@@ -214,12 +225,17 @@ endif
 endif
 
 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_OS) $(CFLAGS_DEBUG)
+CFLAGS_DAEMON = $(CFLAGS) $(CFLAGS_ASLR)
 
-#############################################################################
+LINKOPTS_DAEMON = $(LINKOPTS) $(LINKOPTS_ASLR)
 
-all: setup Daemon libdns_sd Clients SAClient SAResponder SAProxyResponder Identify NetMonitor $(OPTIONALTARG)
+#############################################################################
+#In Tizen Clients needs to be build after installation of library libdns_sd.so
+#all: setup Daemon libdns_sd Clients SAClient SAResponder SAProxyResponder Identify NetMonitor $(OPTIONALTARG)
+all: setup Daemon libdns_sd SAClient SAResponder SAProxyResponder Identify NetMonitor $(OPTIONALTARG)
 
-install: setup InstalledStartup InstalledDaemon InstalledLib InstalledManPages InstalledClients $(OPTINSTALL)
+#install: setup InstalledStartup InstalledDaemon InstalledLib InstalledManPages InstalledClients $(OPTINSTALL)
+install: setup InstalledDaemon InstalledLib $(OPTINSTALL)
 
 # 'setup' sets up the build directory structure the way we want
 setup:
@@ -249,7 +265,7 @@ Daemon: setup $(BUILDDIR)/mdnsd
        @echo "Responder daemon done"
 
 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
-       $(CC) -o $@ $+ $(LINKOPTS)
+       $(CC) -o $@ $+ $(LINKOPTS_DAEMON) -pie
        @$(STRIP) $@
 
 # libdns_sd target builds the client library
@@ -282,7 +298,7 @@ $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
 InstalledDaemon: $(INSTBASE)/sbin/mdnsd
        @echo $+ " installed"
 
-InstalledLib: $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h
+InstalledLib: $(INSTBASE)$(LIBDIR)/libdns_sd.$(LDSUFFIX).$(LIBVERS) $(INSTBASE)/include/dns_sd.h $(INSTBASE)$(LIBDIR)/pkgconfig/dns_sd.pc
        @echo $+ " installed"
 
 InstalledStartup: $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
@@ -298,14 +314,15 @@ InstalledNSS: $(NSSINSTPATH)/$(NSSLINKNAME) /etc/nss_mdns.conf $(MANPATH)/man5/n
        @echo $+ " installed"
 
 # Note: If daemon already installed, we make sure it's stopped before overwriting it
-$(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
+#$(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME)
+$(INSTBASE)/sbin/mdnsd: $(BUILDDIR)/mdnsd
        @if test -x $@; then $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) stop; fi
        $(CP) $< $@
-       @$(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) start
+       #@$(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME) start
 
-$(INSTBASE)/lib/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
+$(INSTBASE)$(LIBDIR)/libdns_sd.$(LDSUFFIX).$(LIBVERS): $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
        $(CP) $< $@
-       $(LN) $@ $(INSTBASE)/lib/libdns_sd.$(LDSUFFIX)
+       $(LN) $@ $(INSTBASE)$(LIBDIR)/libdns_sd.$(LDSUFFIX)
 ifdef LDCONFIG
     # -m means 'merge into existing database', -R means 'rescan directories'
        $(LDCONFIG) -mR
@@ -313,6 +330,16 @@ endif
 
 $(INSTBASE)/include/dns_sd.h: $(SHAREDDIR)/dns_sd.h
        $(CP) $< $@
+ifdef CONFIG_TIZEN_64BIT
+$(warning 64bit build)
+$(INSTBASE)$(LIBDIR)/pkgconfig/dns_sd.pc: ../pkgconfig/lib64/dns_sd.pc.in
+       $(CP) $< $@
+else
+$(warning 32bit build)
+$(INSTBASE)$(LIBDIR)/pkgconfig/dns_sd.pc: ../pkgconfig/lib/dns_sd.pc.in
+       $(CP) $< $@
+endif
+
 
 $(STARTUPSCRIPTDIR)/$(STARTUPSCRIPTNAME): mdnsd.sh $(STARTUPSCRIPTDIR)
        $(CP) $< $@
@@ -495,19 +522,19 @@ $(BUILDDIR)/dnsextd:                 $(DNSEXTDOBJ) $(OBJDIR)/dnsextd.c.threadsaf
 
 # Implicit rules
 $(OBJDIR)/%.c.o:       %.c
-       $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CFLAGS_DAEMON) -c -o $@ $<
 
 $(OBJDIR)/%.c.o:       $(COREDIR)/%.c
-       $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CFLAGS_DAEMON) -c -o $@ $<
 
 $(OBJDIR)/%.c.o:       $(SHAREDDIR)/%.c
-       $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CFLAGS_DAEMON) -c -o $@ $<
 
 $(OBJDIR)/%.c.threadsafe.o:    %.c
-       $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
+       $(CC) $(CFLAGS_DAEMON) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
 
 $(OBJDIR)/%.c.threadsafe.o:    $(SHAREDDIR)/%.c
-       $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
+       $(CC) $(CFLAGS_DAEMON) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
 
 $(OBJDIR)/%.c.so.o:    %.c
        $(CC) $(CFLAGS) -c -fPIC -o $@ $<
@@ -517,8 +544,8 @@ $(OBJDIR)/%.c.so.o: $(SHAREDDIR)/%.c
 
 $(OBJDIR)/%.y.o: $(SHAREDDIR)/%.y
        $(BISON)              -o $(OBJDIR)/$*.c -d $<
-       $(CC) $(CFLAGS) -c -o $@ $(OBJDIR)/$*.c
+       $(CC) $(CFLAGS_DAEMON) -c -o $@ $(OBJDIR)/$*.c
 
 $(OBJDIR)/%.l.o: $(SHAREDDIR)/%.l
        $(FLEX) $(FLEXFLAGS_OS) -i             -o$(OBJDIR)/$*.l.c $<
-       $(CC) $(CFLAGS) -Wno-error -c -o $@ $(OBJDIR)/$*.l.c
+       $(CC) $(CFLAGS_DAEMON) -Wno-error -c -o $@ $(OBJDIR)/$*.l.c
index 0e10bd5..4ea304b 100755 (executable)
@@ -1083,6 +1083,29 @@ mDNSlocal void      PrintNetLinkMsg(const struct nlmsghdr *pNLMsg)
 }
 #endif
 
+#if defined TIZEN_EXT
+static int extract_link(struct ifinfomsg *msg, int bytes, const char **ifname, unsigned char *operstate)
+{
+        struct rtattr *attr;
+
+        for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes); attr = RTA_NEXT(attr, bytes)) {
+                switch (attr->rta_type) {
+                case IFLA_IFNAME:
+                        *ifname = RTA_DATA(attr);
+                        break;
+                case IFLA_OPERSTATE:
+                        *operstate = *((unsigned char *) RTA_DATA(attr));
+                        break;
+                case IFLA_WIRELESS:
+                        /* Ignore RTM_NEWLINK with IFLA_WIRELESS */
+                        return 0;
+                }
+        }
+
+        return 1;
+}
+#endif
+
 mDNSlocal mDNSu32       ProcessRoutingNotification(int sd)
 // Read through the messages on sd and if any indicate that any interface records should
 // be torn down and rebuilt, return affected indices as a bitmask. Otherwise return 0.
@@ -1091,6 +1114,10 @@ mDNSlocal mDNSu32       ProcessRoutingNotification(int sd)
     char buff[4096];
     struct nlmsghdr         *pNLMsg = (struct nlmsghdr*) buff;
     mDNSu32 result = 0;
+#if defined TIZEN_EXT
+    unsigned char operstate = 0xff;
+    const char *ifname = NULL;
+#endif
 
     // The structure here is more complex than it really ought to be because,
     // unfortunately, there's no good way to size a buffer in advance large
@@ -1124,6 +1151,19 @@ mDNSlocal mDNSu32       ProcessRoutingNotification(int sd)
         PrintNetLinkMsg(pNLMsg);
 #endif
 
+#if defined TIZEN_EXT
+        if (pNLMsg->nlmsg_type == RTM_NEWLINK) {
+            struct ifinfomsg *msg = (struct ifinfomsg *) NLMSG_DATA(pNLMsg);
+
+            /* Check if RTM_NEWLINK contains IFLA_WIRELESS */
+            if (extract_link(msg, IFA_PAYLOAD(pNLMsg), &ifname, &operstate) == 0)
+                return result;
+#if MDNS_DEBUGMSGS
+            printf("Interface Name %s Operstate %d\n", ifname, operstate);
+#endif
+        }
+#endif
+
         // Process the NetLink message
         if (pNLMsg->nlmsg_type == RTM_GETLINK || pNLMsg->nlmsg_type == RTM_NEWLINK)
             result |= 1 << ((struct ifinfomsg*) NLMSG_DATA(pNLMsg))->ifi_index;
index 17a37c6..624e35c 100755 (executable)
@@ -86,7 +86,11 @@ struct ifi_info *get_ifi_info_linuxv6(int family, int doaliases)
     FILE *fp = NULL;
     char addr[8][5];
     int flags, myflags, index, plen, scope;
+#if defined TIZEN_EXT
+    char ifname[IFNAMSIZ], lastname[IFNAMSIZ];
+#else
     char ifname[9], lastname[IFNAMSIZ];
+#endif
     char addr6[32+7+1]; /* don't forget the seven ':' */
     struct addrinfo hints, *res0;
     int err;
index 27e90ee..01decc7 100644 (file)
@@ -101,7 +101,11 @@ static void syslog( int priority, const char * message, ...)
 // Note: Timeout of 3 secs should be sufficient in normal scenarios, but 60 secs is chosen as a safeguard since
 // some clients may come up before mDNSResponder itself after a BOOT and on rare ocassions IOPM/Keychain/D2D calls
 // in mDNSResponder's INIT may take a much longer time to return
+#if defined TIZEN_EXT
+#define DNSSD_CLIENT_TIMEOUT 20
+#else
 #define DNSSD_CLIENT_TIMEOUT 60
+#endif
 
 #ifndef CTL_PATH_PREFIX
 #define CTL_PATH_PREFIX "/var/tmp/dnssd_result_socket."
index 1243ae7..5e9aadc 100644 (file)
 
 #include "mDNSEmbeddedAPI.h"
 
-mDNSexport int mDNS_LoggingEnabled       = 0;
-mDNSexport int mDNS_PacketLoggingEnabled = 0;
-mDNSexport int mDNS_McastLoggingEnabled  = 0;
-mDNSexport int mDNS_McastTracingEnabled  = 0; 
+mDNSexport int mDNS_LoggingEnabled       = 1;
+mDNSexport int mDNS_PacketLoggingEnabled = 1;
+mDNSexport int mDNS_McastLoggingEnabled  = 1;
+mDNSexport int mDNS_McastTracingEnabled  = 1;
 
 #if MDNS_DEBUGMSGS
 mDNSexport int mDNS_DebugMode = mDNStrue;
diff --git a/mdnsd.service b/mdnsd.service
new file mode 100644 (file)
index 0000000..0074c96
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=DNS Service Discovery mDNSResponder
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/mdnsd -debug
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mdnsresponder-server.sh.in b/mdnsresponder-server.sh.in
new file mode 100755 (executable)
index 0000000..bc86232
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+program="mdnsd"
+target=`/bin/ps -eo comm|/bin/grep ${program}`
+
+start_mdnsd()
+{
+       if [ "X${target}" == "X" ]; then
+               echo "${program} is not running"
+               echo "Launching ${program}"
+               /usr/sbin/${program}
+#              /bin/sleep 1
+       else
+               echo "${program} is already running"
+       fi
+}
+
+stop_mdnsd()
+{
+       if [ "X${target}" == "X" ]; then
+               echo "${program} is not running"
+       else
+               echo "${program} is running.. Killing it"
+               /usr/bin/pkill -x ${program}
+       fi
+}
+
+case $1 in
+"start")
+start_mdnsd
+;;
+"stop")
+stop_mdnsd
+;;
+*)
+/bin/echo mdnsresponder-server.sh [start/stop]
+exit 1
+;;
+esac
diff --git a/packaging/libdns_sd.manifest b/packaging/libdns_sd.manifest
new file mode 100644 (file)
index 0000000..c00c25b
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+        <request>
+                <domain name="_" />
+        </request>
+</manifest>
diff --git a/packaging/mdnsresponder.manifest b/packaging/mdnsresponder.manifest
new file mode 100644 (file)
index 0000000..c00c25b
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+        <request>
+                <domain name="_" />
+        </request>
+</manifest>
diff --git a/packaging/mdnsresponder.spec b/packaging/mdnsresponder.spec
new file mode 100755 (executable)
index 0000000..10635c6
--- /dev/null
@@ -0,0 +1,113 @@
+Name:       mdnsresponder
+Summary:    DNS Service Discovery service with dns-sd library
+Version:    878.70.2
+Release:    1
+Group:      System/Network
+License:    Apache-2.0 or BSD-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1001:    mdnsresponder.manifest
+Source1002:    libdns_sd.manifest
+BuildRequires: bison
+BuildRequires: flex
+Requires(post):        /sbin/ldconfig
+Requires(postun):      /sbin/ldconfig
+
+%description
+The DNS Service Discovery is part of Bonjour, Apple's implementation of
+zero-configuration networking(ZEROCONF).
+
+%package -n libdns_sd
+Summary:    DNS-SD - client libraries
+%if "%{?_lib}" == "lib64"
+Provides: libdns_sd.so()(64bit)
+%else
+Provides: libdns_sd.so
+%endif
+Requires:   mdnsresponder = %{version}-%{release}
+
+%description -n libdns_sd
+Client libraries for DNS-SD: synchronous and asynchronous
+
+%package devel
+Summary:  DNS Service Discovery (Development)
+Requires:   libdns_sd = %{version}-%{release}
+Requires: pkgconfig
+
+%description devel
+DNS-SD development files
+
+%prep
+%setup -q
+cp -a %{SOURCE1001} .
+cp -a %{SOURCE1002} .
+
+%build
+%if "%{?_lib}" == "lib64"
+CONFIG_TIZEN_64BIT=y; export CONFIG_TIZEN_64BIT
+%endif
+
+cd mDNSPosix
+make os=tizen %{?_smp_mflags}
+
+%install
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{_sbindir}/
+mkdir -p %{buildroot}%{_bindir}/
+mkdir -p %{buildroot}%{_libdir}/
+mkdir -p %{buildroot}%{_libdir}/pkgconfig/
+
+#mkdir -p %{buildroot}%{_libdir}/systemd/system/
+#cp mdnsd.service %{buildroot}%{_libdir}/systemd/system/mdnsd.service
+#mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/
+#ln -s mdnsd.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/mdnsd.service
+
+cp mdnsresponder-server.sh.in %{buildroot}%{_bindir}/mdnsresponder-server.sh
+
+mkdir -p %{buildroot}%{_includedir}/
+%if "%{?_lib}" == "lib64"
+CONFIG_TIZEN_64BIT=y; export CONFIG_TIZEN_64BIT
+%endif
+cd mDNSPosix
+make install os=tizen DESTDIR=%{buildroot} LIBDIR=/%{?_lib}
+ln -sf %{_libdir}/libdns_sd.so.%{version} %{buildroot}%{_libdir}/libdns_sd.so.765
+ln -sf %{_libdir}/libdns_sd.so.%{version} %{buildroot}%{_libdir}/libdns_sd.so
+
+%post
+chmod 755 %{_bindir}/mdnsresponder-server.sh
+#systemctl daemon-reload
+
+#if [ $1 = 1 ]; then
+#    systemctl enable mdnsd.service
+#fi
+
+#systemctl restart mdnsd.service
+
+#%preun
+#if [ $1 = 0 ]; then
+#    # unistall
+#    systemctl stop mdnsd.service
+#fi
+
+%post -n libdns_sd -p /sbin/ldconfig
+
+%postun -n libdns_sd -p /sbin/ldconfig
+
+%files
+%manifest mdnsresponder.manifest
+%license LICENSE
+%attr(755,root,root) %{_sbindir}/mdnsd
+%attr(-,root,root) %{_bindir}/mdnsresponder-server.sh
+#%attr(-,root,root) %{_libdir}/systemd/system/mdnsd.service
+#%attr(-,root,root) %{_libdir}/systemd/system/multi-user.target.wants/mdnsd.service
+
+%files devel
+%{_includedir}/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/*.so
+
+%files -n libdns_sd
+%manifest libdns_sd.manifest
+%license LICENSE
+%{_libdir}/libdns_sd.so*
diff --git a/pkgconfig/lib/dns_sd.pc.in b/pkgconfig/lib/dns_sd.pc.in
new file mode 100755 (executable)
index 0000000..7542d7f
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/
+
+Name: dns_sd
+Description: @PACKAGE_DESCRIPTION@
+Version: 765.50.9
+Requires: glib-2.0
+Libs: -L${libdir} -ldns_sd
+Cflags: -I${includedir}
+
diff --git a/pkgconfig/lib64/dns_sd.pc.in b/pkgconfig/lib64/dns_sd.pc.in
new file mode 100755 (executable)
index 0000000..1c96623
--- /dev/null
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=/usr
+libdir=/usr/lib64
+includedir=/usr/include/
+
+Name: dns_sd
+Description: @PACKAGE_DESCRIPTION@
+Version: 765.50.9
+Requires: glib-2.0
+Libs: -L${libdir} -ldns_sd
+Cflags: -I${includedir}
+