#############################################################################
-LIBVERS = 1
+LIBVERS = 765.50.9
COREDIR = ../mDNSCore
SHAREDDIR ?= ../mDNSShared
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
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:
@echo "Responder daemon done"
$(BUILDDIR)/mdnsd: $(DAEMONOBJS)
- $(CC) -o $@ $+ $(LINKOPTS)
+ $(CC) -o $@ $+ $(LINKOPTS_DAEMON) -pie
@$(STRIP) $@
# libdns_sd target builds the client library
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)
@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
$(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) $< $@
# 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 $@ $<
$(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
}
#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.
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
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;
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;
// 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."
#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;
--- /dev/null
+[Unit]
+Description=DNS Service Discovery mDNSResponder
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/mdnsd -debug
+
+[Install]
+WantedBy=multi-user.target
--- /dev/null
+#!/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
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
--- /dev/null
+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*
--- /dev/null
+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}
+
--- /dev/null
+
+# 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}
+