summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiraj Kumar Goit <niraj.g@samsung.com>2016-06-16 14:26:45 (GMT)
committerNiraj Kumar Goit <niraj.g@samsung.com>2016-06-17 10:34:47 (GMT)
commit9c59ca5a99768d876fb5e12366f158bc2110ba9c (patch)
tree8f48de9e0c9dcf50fd7a1d81c3782c62d7c33605
parent814e3cff8ca46e92090d2f9e2abcede7471de2c3 (diff)
downloadconnman-accepted/tizen/tv/20160620.081531.zip
connman-accepted/tizen/tv/20160620.081531.tar.gz
connman-accepted/tizen/tv/20160620.081531.tar.bz2
Change-Id: Icc887f469e77eea24915c89efcf216aff466fa98 Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
-rwxr-xr-xMakefile.am6
-rwxr-xr-xconfigure.ac5
-rwxr-xr-xpackaging/connman.spec1
-rwxr-xr-xsrc/dnsproxy.c49
4 files changed, 45 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am
index f5535da..dd2474c 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -111,7 +111,7 @@ src_connmand_SOURCES = $(gdhcp_sources) $(gweb_sources) \
src/peer_service.c src/machine.c src/util.c
src_connmand_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
- @GLIB_LIBS@ @DBUS_LIBS@ @XTABLES_LIBS@ @GNUTLS_LIBS@ \
+ @GLIB_LIBS@ @DBUS_LIBS@ @XTABLES_LIBS@ @GNUTLS_LIBS@ @LIBSYSTEMD_LIBS@ \
@TPKP_GNUTLS_LIBS@ \
-lresolv -ldl -lrt
@@ -155,7 +155,7 @@ vpn_connman_vpnd_SOURCES = $(gdhcp_sources) $(builtin_vpn_sources) \
vpn_connman_vpnd_LDADD = gdbus/libgdbus-internal.la $(builtin_vpn_libadd) \
@GLIB_LIBS@ @DBUS_LIBS@ @XTABLES_LIBS@ @GNUTLS_LIBS@ \
- @TPKP_GNUTLS_LIBS@ \
+ @TPKP_GNUTLS_LIBS@ @LIBSYSTEMD_LIBS@\
-lresolv -ldl
vpn_connman_vpnd_LDFLAGS = -Wl,--export-dynamic \
@@ -200,7 +200,7 @@ build_vpn_plugindir = $(vpn_plugindir)
endif
endif
-AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @XTABLES_CFLAGS@ \
+AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @XTABLES_CFLAGS@ @LIBSYSTEMD_CFLAGS@\
@GNUTLS_CFLAGS@ @TPKP_GNUTLS_CFLAGS@ $(builtin_cflags) \
-DCONNMAN_PLUGIN_BUILTIN \
-DSTATEDIR=\""$(statedir)"\" \
diff --git a/configure.ac b/configure.ac
index ca70ac5..e765625 100755
--- a/configure.ac
+++ b/configure.ac
@@ -222,6 +222,11 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
+PKG_CHECK_MODULES(LIBSYSTEMD, libsystemd-daemon, dummy=yes,
+ AC_MSG_ERROR(libsystemd-daemon library is required))
+AC_SUBST(LIBSYSTEMD_CFLAGS)
+AC_SUBST(LIBSYSTEMD_LIBS)
+
PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4, dummy=yes,
AC_MSG_ERROR(D-Bus >= 1.4 is required))
AC_SUBST(DBUS_CFLAGS)
diff --git a/packaging/connman.spec b/packaging/connman.spec
index a988b8c..fcad6f7 100755
--- a/packaging/connman.spec
+++ b/packaging/connman.spec
@@ -17,6 +17,7 @@ BuildRequires: pkgconfig(libiptc)
BuildRequires: pkgconfig(xtables)
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(tpkp-gnutls)
+BuildRequires: pkgconfig(libsystemd-daemon)
%if %{with connman_openconnect}
BuildRequires: openconnect
%endif
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index f047c05..58ce442 100755
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -43,6 +43,7 @@
#if defined TIZEN_EXT
#include <sys/smack.h>
+#include <systemd/sd-daemon.h>
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -3824,18 +3825,22 @@ static GIOChannel *get_listener(int family, int protocol, int index)
{
GIOChannel *channel;
const char *proto;
+#if !defined TIZEN_EXT
union {
struct sockaddr sa;
struct sockaddr_in6 sin6;
struct sockaddr_in sin;
} s;
socklen_t slen;
+#endif
int sk, type;
#if !defined TIZEN_EXT
char *interface;
#endif
#if defined TIZEN_EXT
int option;
+ int sd_num = 0;
+ int rv;
#endif
DBG("family %d protocol %d index %d", family, protocol, index);
@@ -3854,7 +3859,32 @@ static GIOChannel *get_listener(int family, int protocol, int index)
default:
return NULL;
}
+#if defined TIZEN_EXT
+ sd_num = sd_listen_fds(0);
+ DBG("socket type(%s) systemd number of fds(%d)", proto, sd_num);
+ if(sd_num < 1){
+ DBG("fail to get the fd from systemd");
+ return NULL;
+ }
+
+ if(protocol == IPPROTO_TCP)
+ type = SOCK_STREAM;
+ else
+ type = SOCK_DGRAM;
+
+ for(sk = SD_LISTEN_FDS_START; sk < SD_LISTEN_FDS_START+sd_num; ++sk){
+ rv = sd_is_socket_inet(sk, family, type, -1, 53);
+ if(rv > 0){
+ DBG("socket fd (%d) is passed by systemd", sk);
+ break;
+ }
+ }
+ if(sk >= SD_LISTEN_FDS_START+sd_num){
+ DBG("socket fd is not matched what connman requests");
+ return NULL;
+ }
+#else
sk = socket(family, type, protocol);
if (sk < 0 && family == AF_INET6 && errno == EAFNOSUPPORT) {
connman_error("No IPv6 support");
@@ -3866,7 +3896,6 @@ static GIOChannel *get_listener(int family, int protocol, int index)
return NULL;
}
-#if !defined TIZEN_EXT
/* ConnMan listens DNS from multiple interfaces
* E.g. various technology based and tethering interfaces
*/
@@ -3883,16 +3912,13 @@ static GIOChannel *get_listener(int family, int protocol, int index)
return NULL;
}
g_free(interface);
-#endif
if (family == AF_INET6) {
memset(&s.sin6, 0, sizeof(s.sin6));
s.sin6.sin6_family = AF_INET6;
s.sin6.sin6_port = htons(53);
slen = sizeof(s.sin6);
-#if defined TIZEN_EXT
- s.sin6.sin6_addr = in6addr_any;
-#else
+
if (__connman_inet_get_interface_address(index,
AF_INET6,
&s.sin6.sin6_addr) < 0) {
@@ -3903,49 +3929,46 @@ static GIOChannel *get_listener(int family, int protocol, int index)
close(sk);
return NULL;
}
-#endif
} else if (family == AF_INET) {
memset(&s.sin, 0, sizeof(s.sin));
s.sin.sin_family = AF_INET;
s.sin.sin_port = htons(53);
slen = sizeof(s.sin);
-#if defined TIZEN_EXT
- s.sin.sin_addr.s_addr = htonl(INADDR_ANY);
-#else
if (__connman_inet_get_interface_address(index,
AF_INET,
&s.sin.sin_addr) < 0) {
close(sk);
return NULL;
}
-#endif
} else {
close(sk);
return NULL;
}
-
+#endif
#if defined TIZEN_EXT
/* When ConnMan crashed,
* probably DNS listener cannot bind existing address */
option = 1;
setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
#endif
+#if !defined TIZEN_EXT
if (bind(sk, &s.sa, slen) < 0) {
connman_error("Failed to bind %s listener socket", proto);
close(sk);
return NULL;
}
+#endif
if (protocol == IPPROTO_TCP) {
-
+#if !defined TIZEN_EXT
if (listen(sk, 10) < 0) {
connman_error("Failed to listen on TCP socket %d/%s",
-errno, strerror(errno));
close(sk);
return NULL;
}
-
+#endif
fcntl(sk, F_SETFL, O_NONBLOCK);
}