[Fawkes Git] branch/timn/netcomm-ipv6: 12 revs updated. (0.5.0-3403-g9005350)

Tim Niemueller niemueller at kbsg.rwth-aachen.de
Fri Dec 16 18:32:27 CET 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, timn/netcomm-ipv6 has been updated
        to  90053507c52485ba66d72ec219c8005f05568e72 (commit)
       via  6dbdcd62c21667a6cd65aad0354878379e42a739 (commit)
       via  02a92760f1a714d80f8c3e57f1310c69504ce6cc (commit)
       via  97ef4170bddcec9a9d58a33d37deb5017039c794 (commit)
       via  5e91a4aca55e081d5134d09fb9fb7dae587b40f7 (commit)
       via  0eade76a552045c9becda1f1c3d4b3fcedd180cc (commit)
       via  78447f12861948ad0fff5ef9c31344e1917c06b9 (commit)
       via  a2dc8899fbc5d4dbc114a3811057d661b896497c (commit)
       via  43a0a89ddd7dfbff81f6599efeb118a14f7ecbf9 (commit)
       via  dda02509a742c7bb8c37ac89116668f49fe02029 (commit)
       via  1206fb5cc1e6d27151d05b163a73ceaa9b5fce0e (commit)
       via  ec6d5428a4ed91dea2d5f1b8bf8cad83875a737a (commit)
      from  ad4ccda804139b913dda9cb981bf1013c372ec9e (commit)

http://git.fawkesrobotics.org/fawkes.git/timn/netcomm-ipv6

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit ec6d5428a4ed91dea2d5f1b8bf8cad83875a737a
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 17:20:46 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 17:20:46 2016 +0100

    netcomm: proper scope IDs for IPv6 addresses
    
    For IPv6 it is more common to have prefix overlap, especially for
    link-local addresses (fe80: prefix) of multiple network devices.
    This causes connect() to fail with an "invalid argument" error. Fix this
    by determining the interface through which the connection would be
    established (translate interface index to name), create a prefix string
    of the form IP%device, and run this through getaddrinfo to get a
    properly setup sockaddr_in6 struct. Pass that along to event receivers.

http://git.fawkesrobotics.org/fawkes.git/commit/ec6d542
http://trac.fawkesrobotics.org/changeset/ec6d542

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 1206fb5cc1e6d27151d05b163a73ceaa9b5fce0e
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 17:24:01 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 17:24:01 2016 +0100

    netcomm: throw SocketException in Socket

http://git.fawkesrobotics.org/fawkes.git/commit/1206fb5
http://trac.fawkesrobotics.org/changeset/1206fb5

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit dda02509a742c7bb8c37ac89116668f49fe02029
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 17:24:25 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 17:24:25 2016 +0100

    netcomm: fix address family handling in Socket

http://git.fawkesrobotics.org/fawkes.git/commit/dda0250
http://trac.fawkesrobotics.org/changeset/dda0250

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 43a0a89ddd7dfbff81f6599efeb118a14f7ecbf9
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 17:26:37 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 17:26:37 2016 +0100

    netcomm: support connecting to specific endpoint in fawkes client

http://git.fawkesrobotics.org/fawkes.git/commit/43a0a89
http://trac.fawkesrobotics.org/changeset/43a0a89

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit a2dc8899fbc5d4dbc114a3811057d661b896497c
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 17:27:00 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 17:27:00 2016 +0100

    netcomm: further improve connect error message for socket

http://git.fawkesrobotics.org/fawkes.git/commit/a2dc889
http://trac.fawkesrobotics.org/changeset/a2dc889

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 78447f12861948ad0fff5ef9c31344e1917c06b9
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 17:27:12 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 17:27:12 2016 +0100

    netcomm: add missing freeaddrinfo

http://git.fawkesrobotics.org/fawkes.git/commit/78447f1
http://trac.fawkesrobotics.org/changeset/78447f1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 0eade76a552045c9becda1f1c3d4b3fcedd180cc
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 17:29:01 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 17:29:01 2016 +0100

    gui_utils: store IP addr and addr:port separately
    
    It might still be useful to access the IP separately, therefore add new
    column to store addr:port string.

http://git.fawkesrobotics.org/fawkes.git/commit/0eade76
http://trac.fawkesrobotics.org/changeset/0eade76

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 5e91a4aca55e081d5134d09fb9fb7dae587b40f7
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:05:32 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:05:32 2016 +0100

    gui_utils: service chooser connect directly to discovered endpoint
    
    Now that the service model can record the proper sockaddr structure use
    that as endpoint when connecting to the remote. This has a few benefits.
    Mostly, we profit from the proper interface scope ID determination in
    the avahi thread, additionally we gain a little speed avoiding going
    through another lookup step.

http://git.fawkesrobotics.org/fawkes.git/commit/5e91a4a
http://trac.fawkesrobotics.org/changeset/5e91a4a

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 97ef4170bddcec9a9d58a33d37deb5017039c794
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:27:15 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:27:15 2016 +0100

    config: move network settings to network.yaml
    
    Move network settings out of config.yaml into their own file and
    concentrate them there. Treat IPv4/IPv6 settings as more general
    settings similar to the tf frames in frames.yaml.

http://git.fawkesrobotics.org/fawkes.git/commit/97ef417
http://trac.fawkesrobotics.org/changeset/97ef417

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 02a92760f1a714d80f8c3e57f1310c69504ce6cc
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:27:59 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:27:59 2016 +0100

    libbaseapp: adapt to move network related config values

http://git.fawkesrobotics.org/fawkes.git/commit/02a9276
http://trac.fawkesrobotics.org/changeset/02a9276

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 6dbdcd62c21667a6cd65aad0354878379e42a739
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:28:42 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:31:20 2016 +0100

    libwebview: support enabling/disabling of IPv4/IPv6

http://git.fawkesrobotics.org/fawkes.git/commit/6dbdcd6
http://trac.fawkesrobotics.org/changeset/6dbdcd6

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 90053507c52485ba66d72ec219c8005f05568e72
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:31:34 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:31:34 2016 +0100

    webview: support central IPv4/IPv6 config values
    
    For now this concerns enabling or disabling of IPv4/IPv6. Unfortunately
    setting the listener address in dual stack mode is not supported.

http://git.fawkesrobotics.org/fawkes.git/commit/9005350
http://trac.fawkesrobotics.org/changeset/9005350

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 cfg/conf.d/network.yaml                       |   29 ++++++++++++
 cfg/config.yaml                               |   23 +--------
 src/libs/baseapp/run.cpp                      |   12 +++---
 src/libs/gui_utils/service_chooser_dialog.cpp |   52 ++++++++++++++++++---
 src/libs/gui_utils/service_chooser_dialog.h   |    2 +
 src/libs/gui_utils/service_model.cpp          |   37 ++++++++-------
 src/libs/gui_utils/service_model.h            |   29 ++++++------
 src/libs/netcomm/dns-sd/avahi_thread.cpp      |   60 ++++++++++++++++++++----
 src/libs/netcomm/dns-sd/avahi_thread.h        |   11 +++--
 src/libs/netcomm/fawkes/client.cpp            |   52 ++++++++++++++++++++-
 src/libs/netcomm/fawkes/client.h              |    6 +++
 src/libs/netcomm/socket/socket.cpp            |   34 +++++++++-----
 src/libs/webview/server.cpp                   |   38 ++++++++++++++--
 src/libs/webview/server.h                     |    7 ++-
 src/plugins/webview/webview_thread.cpp        |   23 +++++++---
 src/plugins/webview/webview_thread.h          |    2 +
 16 files changed, 307 insertions(+), 110 deletions(-)
 create mode 100644 cfg/conf.d/network.yaml


- *Diffs* -------------------------------------------------------------

- *commit* ec6d5428a4ed91dea2d5f1b8bf8cad83875a737a - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 17:20:46 2016 +0100
Subject: netcomm: proper scope IDs for IPv6 addresses

 src/libs/netcomm/dns-sd/avahi_thread.cpp |   60 +++++++++++++++++++++++++-----
 src/libs/netcomm/dns-sd/avahi_thread.h   |   11 +++--
 2 files changed, 56 insertions(+), 15 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/dns-sd/avahi_thread.cpp b/src/libs/netcomm/dns-sd/avahi_thread.cpp
index 93ac8d9..7971fca 100644
--- a/src/libs/netcomm/dns-sd/avahi_thread.cpp
+++ b/src/libs/netcomm/dns-sd/avahi_thread.cpp
@@ -40,6 +40,9 @@
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <netinet/in.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <netdb.h>
 #include <cstdlib>
 #include <cstddef>
 #include <cstring>
@@ -632,13 +635,14 @@ AvahiThread::call_handler_service_removed( const char *name,
  */
 void
 AvahiThread::call_handler_service_added( const char *name,
-					  const char *type,
-					  const char *domain,
-					  const char *host_name,
-					  const AvahiAddress *address,
-					  uint16_t port,
-					  std::list<std::string> &txt,
-					  AvahiLookupResultFlags flags)
+                                         const char *type,
+                                         const char *domain,
+                                         const char *host_name,
+                                         const AvahiIfIndex interface,
+                                         const AvahiAddress *address,
+                                         uint16_t port,
+                                         std::list<std::string> &txt,
+                                         AvahiLookupResultFlags flags)
 {
   struct sockaddr *s = NULL;
   socklen_t slen;
@@ -648,13 +652,49 @@ AvahiThread::call_handler_service_added( const char *name,
     struct sockaddr_in *sin = (struct sockaddr_in *)malloc(slen);
     sin->sin_family = AF_INET;
     sin->sin_addr.s_addr = address->data.ipv4.address;
+    sin->sin_port = htons(port);
     s = (struct sockaddr *)sin;
   } else if ( address->proto == AVAHI_PROTO_INET6 ) {
 	  if (! enable_ipv6)  return;
     slen = sizeof(struct sockaddr_in6);
     struct sockaddr_in6 *sin = (struct sockaddr_in6 *)malloc(slen);
     sin->sin6_family = AF_INET6;
-	  memcpy(&sin->sin6_addr, &address->data.ipv6.address, sizeof(in6_addr));
+    memcpy(&sin->sin6_addr, &address->data.ipv6.address, sizeof(in6_addr));
+
+    char ifname[IF_NAMESIZE];
+    if (if_indextoname(interface, ifname) != NULL) {
+	    char ipaddr[INET6_ADDRSTRLEN];
+	    if (inet_ntop(AF_INET6, &sin->sin6_addr, ipaddr, sizeof(ipaddr)) != NULL) {
+		    std::string addr_with_scope = std::string(ipaddr) + "%" + ifname;
+		    std::string port_s = StringConversions::to_string((unsigned int)port);
+
+		    // use getaddrinfo to fill especially to determine scope ID
+		    struct addrinfo hints, *res;
+		    memset(&hints, 0, sizeof(hints));
+		    hints.ai_family = AF_INET6;
+		    hints.ai_flags = AI_NUMERICHOST;
+		    if (getaddrinfo(addr_with_scope.c_str(), port_s.c_str(), &hints, &res) == 0) {
+			    if (slen == res[0].ai_addrlen) {
+				    memcpy(sin, res[0].ai_addr, slen);
+				    freeaddrinfo(res);
+			    } else {
+				    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 address lengths different");
+				    freeaddrinfo(res);
+				    return;
+			    }
+		    } else {
+			    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 getaddrinfo failed");
+			    return;
+		    }
+	    } else {
+		    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 inet_ntop failed");
+		    return;
+	    }
+    } else {
+	    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 if_indextoname failed");
+	    return;
+
+    }
     s = (struct sockaddr *)sin;
   } else {
     // ignore
@@ -805,7 +845,7 @@ AvahiThread::browse_callback( AvahiServiceBrowser *b,
  */
 void
 AvahiThread::resolve_callback( AvahiServiceResolver *r,
-			       AVAHI_GCC_UNUSED AvahiIfIndex interface,
+			       AvahiIfIndex interface,
 			       AVAHI_GCC_UNUSED AvahiProtocol protocol,
 			       AvahiResolverEvent event,
 			       const char *name,
@@ -838,7 +878,7 @@ AvahiThread::resolve_callback( AvahiServiceResolver *r,
 	l = avahi_string_list_get_next( l );
       }
 
-      at->call_handler_service_added(name, type, domain, host_name, address, port, txts, flags);
+      at->call_handler_service_added(name, type, domain, host_name, interface, address, port, txts, flags);
     }
     break;
   }
diff --git a/src/libs/netcomm/dns-sd/avahi_thread.h b/src/libs/netcomm/dns-sd/avahi_thread.h
index 15ddc8a..c502155 100644
--- a/src/libs/netcomm/dns-sd/avahi_thread.h
+++ b/src/libs/netcomm/dns-sd/avahi_thread.h
@@ -134,11 +134,12 @@ class AvahiThread
 				     const char *type,
 				     const char *domain);
   void call_handler_service_added( const char *name,
-				   const char *type,
-				   const char *domain,
-				   const char *host_name,
-				   const AvahiAddress *address,
-				   uint16_t port,
+                                   const char *type,
+                                   const char *domain,
+                                   const char *host_name,
+                                   const AvahiIfIndex interface,
+                                   const AvahiAddress *address,
+                                   uint16_t port,
 				   std::list<std::string> &txt,
 				   AvahiLookupResultFlags flags);
   void call_handler_failed( const char *name,

- *commit* 1206fb5cc1e6d27151d05b163a73ceaa9b5fce0e - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 17:24:01 2016 +0100
Subject: netcomm: throw SocketException in Socket

 src/libs/netcomm/socket/socket.cpp |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/socket/socket.cpp b/src/libs/netcomm/socket/socket.cpp
index c3b11d3..ae476ed 100644
--- a/src/libs/netcomm/socket/socket.cpp
+++ b/src/libs/netcomm/socket/socket.cpp
@@ -169,14 +169,14 @@ Socket::Socket(AddrType addr_type, SocketType sock_type, float timeout)
   } else if (addr_type == IPv6) {
 	  socket_addr_family_ = PF_INET6;
   } else {
-	  throw Exception("Unknown address type");
+	  throw SocketException("Unknown address type");
   }
   if (sock_type == TCP) {
 	  socket_type_ = SOCK_STREAM;
   } else if (sock_type == UDP) {
 	  socket_type_ = SOCK_DGRAM;
   } else {
-	  throw Exception("Unknown socket type");
+	  throw SocketException("Unknown socket type");
   }
 }
 
@@ -197,7 +197,7 @@ Socket::Socket(SocketType sock_type, float timeout)
   } else if (sock_type == UDP) {
 	  socket_type_ = SOCK_DGRAM;
   } else {
-	  throw Exception("Unknown socket type");
+	  throw SocketException("Unknown socket type");
   }
 }
 
@@ -395,7 +395,7 @@ Socket::connect(const char *hostname, unsigned short int port)
 	}
 
 	if (p == NULL || sock_fd == -1) {
-		throw Exception("Failed to connect to any endpoint (tried:%s)", tried_endpoints.c_str());
+		throw SocketException("Failed to connect to any endpoint (tried:%s)", tried_endpoints.c_str());
 	}
 }
 

- *commit* dda02509a742c7bb8c37ac89116668f49fe02029 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 17:24:25 2016 +0100
Subject: netcomm: fix address family handling in Socket

 src/libs/netcomm/socket/socket.cpp |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/socket/socket.cpp b/src/libs/netcomm/socket/socket.cpp
index ae476ed..79c4445 100644
--- a/src/libs/netcomm/socket/socket.cpp
+++ b/src/libs/netcomm/socket/socket.cpp
@@ -165,9 +165,9 @@ Socket::Socket(AddrType addr_type, SocketType sock_type, float timeout)
 	  client_addr(NULL), client_addr_len(0), socket_protocol_(0)
 {
   if (addr_type == IPv4) {
-	  socket_addr_family_ = PF_INET;
+	  socket_addr_family_ = AF_INET;
   } else if (addr_type == IPv6) {
-	  socket_addr_family_ = PF_INET6;
+	  socket_addr_family_ = AF_INET6;
   } else {
 	  throw SocketException("Unknown address type");
   }
@@ -305,9 +305,10 @@ void
 Socket::connect(const struct sockaddr *addr_port, socklen_t struct_size)
 {
 	if ( sock_fd != -1 )  throw SocketException("Socket already initialized and connected");
+	socket_addr_family_ = addr_port->sa_family;
 
 	create();
-  
+
 	if (timeout == 0.f) {
 		if ( ::connect(sock_fd, addr_port, struct_size) < 0 ) {
 			throw SocketException(errno, "Could not connect");

- *commit* 43a0a89ddd7dfbff81f6599efeb118a14f7ecbf9 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 17:26:37 2016 +0100
Subject: netcomm: support connecting to specific endpoint in fawkes client

 src/libs/netcomm/fawkes/client.cpp |   52 +++++++++++++++++++++++++++++++++--
 src/libs/netcomm/fawkes/client.h   |    6 ++++
 2 files changed, 55 insertions(+), 3 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/fawkes/client.cpp b/src/libs/netcomm/fawkes/client.cpp
index 0b278f9..88d6e9a 100644
--- a/src/libs/netcomm/fawkes/client.cpp
+++ b/src/libs/netcomm/fawkes/client.cpp
@@ -299,6 +299,8 @@ FawkesNetworkClient::FawkesNetworkClient(const char *host, unsigned short int po
 {
   __host = strdup(host);
   __port = port;
+  addr_  = NULL;
+  addr_len_ = 0;
 
   s = NULL;
   __send_slave = NULL;
@@ -330,6 +332,8 @@ FawkesNetworkClient::FawkesNetworkClient()
 {
   __host = NULL;
   __port = 0;
+  addr_  = NULL;
+  addr_len_ = 0;
 
   s = NULL;
   __send_slave = NULL;
@@ -363,6 +367,8 @@ FawkesNetworkClient::FawkesNetworkClient(unsigned int id, const char *host,
 {
   __host = strdup(host);
   __port = port;
+  addr_  = NULL;
+  addr_len_ = 0;
 
   s = NULL;
   __send_slave = NULL;
@@ -393,6 +399,7 @@ FawkesNetworkClient::~FawkesNetworkClient()
 
   delete s;
   if (__host) free(__host);
+  if (addr_) free(addr_);
   delete slave_status_mutex;
 
   delete __connest_waitcond;
@@ -409,8 +416,8 @@ FawkesNetworkClient::~FawkesNetworkClient()
 void
 FawkesNetworkClient::connect()
 {
-  if ( __host == NULL ) {
-    throw NullPointerException("Hostname not set. Cannot connect.");
+  if ( __host == NULL && addr_ == NULL) {
+    throw NullPointerException("Neither hostname nor sockaddr set. Cannot connect.");
   }
 
   if ( s != NULL ) {
@@ -422,7 +429,13 @@ FawkesNetworkClient::connect()
 
   try {
     s = new StreamSocket();
-    s->connect(__host, __port);
+    if (addr_) {
+	    s->connect(addr_, addr_len_);
+    } else if (__host) {
+	    s->connect(__host, __port);
+    } else {
+	    throw NullPointerException("Nothing to connect to!?");
+    }
     __send_slave = new FawkesNetworkClientSendThread(s, this);
     __send_slave->start();
     __recv_slave = new FawkesNetworkClientRecvThread(s, this, __recv_mutex);
@@ -478,6 +491,39 @@ FawkesNetworkClient::connect(const char *host, unsigned short int port)
   connect();
 }
 
+/** Connect to specific endpoint.
+ * @param hostname hostname, informational only and not used for connecting
+ * @param addr sockaddr structure of specific endpoint to connect to
+ * @param addr_len length of @p addr
+ */
+void
+FawkesNetworkClient::connect(const char *hostname, const struct sockaddr *addr, socklen_t addr_len)
+{
+  if (__host)  free(__host);
+  if (addr_) free(addr_);
+	addr_ = (struct sockaddr *)malloc(addr_len);
+	addr_len_ = addr_len;
+	memcpy(addr_, addr, addr_len);
+	__host = strdup(hostname);
+  connect();
+}
+
+/** Connect to specific endpoint.
+ * @param hostname hostname, informational only and not used for connecting
+ * @param addr sockaddr_storage structure of specific endpoint to connect to
+ */
+void
+FawkesNetworkClient::connect(const char *hostname, const struct sockaddr_storage &addr)
+{
+  if (__host)  free(__host);
+  if (addr_) free(addr_);
+  addr_ = (struct sockaddr *)malloc(sizeof(sockaddr_storage));
+  addr_len_ = sizeof(sockaddr_storage);
+	memcpy(addr_, &addr, addr_len_);
+	__host = strdup(hostname);
+  connect();
+}
+
 /** Disconnect socket. */
 void
 FawkesNetworkClient::disconnect()
diff --git a/src/libs/netcomm/fawkes/client.h b/src/libs/netcomm/fawkes/client.h
index 773bc77..f08f8ab 100644
--- a/src/libs/netcomm/fawkes/client.h
+++ b/src/libs/netcomm/fawkes/client.h
@@ -30,6 +30,7 @@
 
 #include <core/exception.h>
 #include <core/utils/lock_map.h>
+#include <sys/socket.h>
 
 namespace fawkes {
 
@@ -62,6 +63,8 @@ class FawkesNetworkClient
   void connect();
   void disconnect();
   void connect(const char *host, unsigned short int port);
+  void connect(const char *hostname, const struct sockaddr *addr, socklen_t addrlen);
+  void connect(const char *hostname, const struct sockaddr_storage &addr);
 
   void enqueue(FawkesNetworkMessage *message);
   void enqueue_and_wait(FawkesNetworkMessage *message, unsigned int timeout_sec = 15);
@@ -117,6 +120,9 @@ class FawkesNetworkClient
   Mutex *slave_status_mutex;
   bool _has_id;
   unsigned int _id;
+
+  struct sockaddr *addr_;
+  socklen_t        addr_len_;
 };
 
 } // end namespace fawkes

- *commit* a2dc8899fbc5d4dbc114a3811057d661b896497c - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 17:27:00 2016 +0100
Subject: netcomm: further improve connect error message for socket

 src/libs/netcomm/socket/socket.cpp |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/socket/socket.cpp b/src/libs/netcomm/socket/socket.cpp
index 79c4445..e032a64 100644
--- a/src/libs/netcomm/socket/socket.cpp
+++ b/src/libs/netcomm/socket/socket.cpp
@@ -352,17 +352,24 @@ Socket::connect(const char *hostname, unsigned short int port)
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = socket_type_;
 	if ((rv = getaddrinfo(hostname, port_s.c_str(), &hints, &servinfo)) != 0) {
-		throw SocketException("getaddrinfo failed: %s", gai_strerror(rv));
+		throw SocketException("getaddrinfo for %s:%s failed: %s",
+		                      hostname, port_s.c_str(), gai_strerror(rv));
 	}
 
 	for (p = servinfo; p != NULL; p = p->ai_next) {
 		bool failed = false;
+		std::string what;
+		int lerrno = 0;
 		if ((sock_fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
+			what="socket";
+			lerrno = errno;
 			failed = true;
 		}
 
 		if (! failed) {
 			if (::connect(sock_fd, p->ai_addr, p->ai_addrlen) == -1) {
+				what="connect";
+				lerrno = errno;
 				::close(sock_fd);
 				sock_fd = -1;
 				failed = true;
@@ -373,16 +380,16 @@ Socket::connect(const char *hostname, unsigned short int port)
 			if (p->ai_family == AF_INET) {
 				char tmp[INET_ADDRSTRLEN];
 				if (inet_ntop(p->ai_family, &((struct sockaddr_in *)p->ai_addr)->sin_addr, tmp, INET_ADDRSTRLEN) != NULL) {
-					tried_endpoints += std::string(" IPv4:") + tmp + ":" + port_s;
+					tried_endpoints += std::string(" IPv4:") + tmp + ":" + port_s + "|" + what + "|" + strerror(lerrno);
 				} else {
-					tried_endpoints += std::string(" IPv4:FAIL") + tmp + ":" + port_s;
+					tried_endpoints += std::string(" IPv4:FAIL") + tmp + ":" + port_s + "|" + what + "|" + strerror(lerrno);
 				}
 			} else if (p->ai_family == AF_INET6) {
 				char tmp[INET6_ADDRSTRLEN];
 				if (inet_ntop(p->ai_family, &((struct sockaddr_in6 *) p->ai_addr)->sin6_addr, tmp, INET6_ADDRSTRLEN) != NULL) {
-					tried_endpoints += std::string(" IPv6:[") + tmp + "]:" + port_s;
+					tried_endpoints += std::string(" IPv6:[") + tmp + "]:" + port_s + "|" + what + "|" + strerror(lerrno);
 				} else {
-					tried_endpoints += std::string(" IPv6:FAIL") + tmp + ":" + port_s;
+					tried_endpoints += std::string(" IPv6:FAIL") + tmp + ":" + port_s + "|" + what + "|" + strerror(lerrno);
 				}
 			} else {
 				tried_endpoints += std::string(" UNKNOWN_AF:") + port_s;

- *commit* 78447f12861948ad0fff5ef9c31344e1917c06b9 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 17:27:12 2016 +0100
Subject: netcomm: add missing freeaddrinfo

 src/libs/netcomm/socket/socket.cpp |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/socket/socket.cpp b/src/libs/netcomm/socket/socket.cpp
index e032a64..592d3f3 100644
--- a/src/libs/netcomm/socket/socket.cpp
+++ b/src/libs/netcomm/socket/socket.cpp
@@ -402,6 +402,8 @@ Socket::connect(const char *hostname, unsigned short int port)
 		}
 	}
 
+	freeaddrinfo(servinfo);
+	
 	if (p == NULL || sock_fd == -1) {
 		throw SocketException("Failed to connect to any endpoint (tried:%s)", tried_endpoints.c_str());
 	}

- *commit* 0eade76a552045c9becda1f1c3d4b3fcedd180cc - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 17:29:01 2016 +0100
Subject: gui_utils: store IP addr and addr:port separately

 src/libs/gui_utils/service_chooser_dialog.cpp |    4 +-
 src/libs/gui_utils/service_model.cpp          |   35 ++++++++++++-------------
 src/libs/gui_utils/service_model.h            |   26 ++++++++----------
 3 files changed, 30 insertions(+), 35 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/gui_utils/service_chooser_dialog.cpp b/src/libs/gui_utils/service_chooser_dialog.cpp
index ce7b61c..257586b 100644
--- a/src/libs/gui_utils/service_chooser_dialog.cpp
+++ b/src/libs/gui_utils/service_chooser_dialog.cpp
@@ -112,7 +112,7 @@ ServiceChooserDialog::ctor()
 
   __treeview.set_model(__service_model->get_list_store());
   __treeview.append_column("Service", __service_model->get_column_record().name);
-  __treeview.append_column("Address/Port", __service_model->get_column_record().ipaddr);
+  __treeview.append_column("Address/Port", __service_model->get_column_record().addrport);
   __scrollwin.add(__treeview);
   __scrollwin.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   __treeview.show();
@@ -189,7 +189,7 @@ ServiceChooserDialog::get_selected_service(Glib::ustring &name,
   if (iter) {
     Gtk::TreeModel::Row row = *iter;
     name     = row[__service_model->get_column_record().name];
-    hostname = row[__service_model->get_column_record().hostname];
+    hostname = row[__service_model->get_column_record().ipaddr];
     port     = row[__service_model->get_column_record().port];
 
   } else {
diff --git a/src/libs/gui_utils/service_model.cpp b/src/libs/gui_utils/service_model.cpp
index ee371b4..f48144a 100644
--- a/src/libs/gui_utils/service_model.cpp
+++ b/src/libs/gui_utils/service_model.cpp
@@ -157,35 +157,35 @@ ServiceModel::browse_failed( const char* name,
 }
 
 void
-ServiceModel::service_added( const char* name,
-			    const char* type,
-			    const char* domain,
-			    const char* host_name,
-			    const struct sockaddr* addr,
-			    const socklen_t addr_size,
-			    uint16_t port,
-			    std::list<std::string>& txt,
-			    int flags )
+ServiceModel::service_added( const char* name, const char* type,
+                             const char* domain, const char* host_name,
+                             const struct sockaddr* addr, const socklen_t addr_size,
+                             uint16_t port, std::list<std::string>& txt, int flags )
 {
   ServiceAddedRecord s;
   if (addr->sa_family == AF_INET) {
 	  char ipaddr[INET_ADDRSTRLEN];
 	  struct sockaddr_in *saddr = (struct sockaddr_in *)addr;
 	  if (inet_ntop(AF_INET, &(saddr->sin_addr), ipaddr, sizeof(ipaddr)) != NULL) {
-		  s.ipaddr = std::string(ipaddr) + ":" + StringConversions::to_string(port);
+		  s.ipaddr   = ipaddr;
+		  s.addrport = std::string(ipaddr) + ":" + StringConversions::to_string(port);
 	  } else {
-		  s.ipaddr = std::string("Failed to convert IPv4: ") + strerror(errno);
+		  s.ipaddr = "";
+		  s.addrport = std::string("Failed to convert IPv4: ") + strerror(errno);
 	  }
   } else if (addr->sa_family == AF_INET6) {
 	  char ipaddr[INET6_ADDRSTRLEN];
 	  struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)addr;
 	  if (inet_ntop(AF_INET6, &(saddr->sin6_addr), ipaddr, sizeof(ipaddr)) != NULL) {
-		  s.ipaddr = std::string("[") + ipaddr + "]:" + StringConversions::to_string(port);
+		  s.ipaddr   = ipaddr;
+		  s.addrport = std::string("[") + ipaddr + "]:" + StringConversions::to_string(port);
 	  } else {
-		  s.ipaddr = std::string("Failed to convert IPv6: ") + strerror(errno);
+		  s.ipaddr = "";
+		  s.addrport = std::string("Failed to convert IPv6: ") + strerror(errno);
 	  }
   } else {
-	  s.ipaddr = "Unknown address family";
+	  s.ipaddr = "";
+	  s.addrport = "Unknown address family";
   }
 
   s.name = string(name);
@@ -200,9 +200,7 @@ ServiceModel::service_added( const char* name,
 }
 
 void
-ServiceModel::service_removed( const char* name,
-			      const char* type,
-			      const char* domain )
+ServiceModel::service_removed(const char* name, const char* type, const char* domain)
 {
   ServiceRemovedRecord s;
   s.name = string(name);
@@ -232,7 +230,8 @@ ServiceModel::on_service_added()
       row[m_service_record.hostname] = s.hostname;
       row[m_service_record.ipaddr]   = s.ipaddr;
       row[m_service_record.port]     = s.port;
-
+      row[m_service_record.addrport] = s.addrport;
+      
       m_added_services.pop();
     }
 
diff --git a/src/libs/gui_utils/service_model.h b/src/libs/gui_utils/service_model.h
index 17d5fcd..69a11ea 100644
--- a/src/libs/gui_utils/service_model.h
+++ b/src/libs/gui_utils/service_model.h
@@ -51,6 +51,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
 	  add(hostname);
 	  add(ipaddr);
 	  add(port);
+	  add(addrport);
 	}
       
       Gtk::TreeModelColumn<Glib::ustring> name;      /**< The name of the service */
@@ -58,7 +59,8 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
       Gtk::TreeModelColumn<Glib::ustring> domain;    /**< The domain of the service */
       Gtk::TreeModelColumn<Glib::ustring> hostname;  /**< The name of the host the service is running on */
       Gtk::TreeModelColumn<Glib::ustring> ipaddr;    /**< The IP address as string of the host the service is running on */
-      Gtk::TreeModelColumn<unsigned short> port;     /**< The port the service is running on */
+      Gtk::TreeModelColumn<unsigned short>  port;     /**< The port the service is running on */
+      Gtk::TreeModelColumn<Glib::ustring>   addrport;    /**< Address:port string */
     };
 
   ServiceRecord& get_column_record();
@@ -68,20 +70,13 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
   void all_for_now();
   void cache_exhausted();
   void browse_failed( const char* name,
-		      const char* type,
-		      const char* domain );
-  void service_added( const char* name,
-		      const char* type,
-		      const char* domain,
-		      const char* host_name,
-		      const struct sockaddr* addr,
-		      const socklen_t addr_size,
-		      uint16_t port,
-		      std::list<std::string>& txt,
-		      int flags );
-  void service_removed( const char* name,
-			const char* type,
-			const char* domain );
+                      const char* type,
+                      const char* domain );
+  void service_added( const char* name, const char* type,
+                      const char* domain, const char* host_name,
+                      const struct sockaddr* addr, const socklen_t addr_size,
+                      uint16_t port, std::list<std::string>& txt, int flags );
+  void service_removed( const char* name, const char* type, const char* domain );
   
   struct ServiceAddedRecord
   {
@@ -91,6 +86,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
     std::string hostname;  /**< the hostname of the new service */
     std::string ipaddr;    /**< the IP address of the new service */
     unsigned short port;   /**< the port the new service is running on */
+    std::string addrport;    /**< address:port */
   };
 
   struct ServiceRemovedRecord

- *commit* 5e91a4aca55e081d5134d09fb9fb7dae587b40f7 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:05:32 2016 +0100
Subject: gui_utils: service chooser connect directly to discovered endpoint

 src/libs/gui_utils/service_chooser_dialog.cpp |   48 +++++++++++++++++++++---
 src/libs/gui_utils/service_chooser_dialog.h   |    2 +
 src/libs/gui_utils/service_model.cpp          |    2 +
 src/libs/gui_utils/service_model.h            |    3 ++
 4 files changed, 49 insertions(+), 6 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/gui_utils/service_chooser_dialog.cpp b/src/libs/gui_utils/service_chooser_dialog.cpp
index 257586b..c5c3f5e 100644
--- a/src/libs/gui_utils/service_chooser_dialog.cpp
+++ b/src/libs/gui_utils/service_chooser_dialog.cpp
@@ -197,6 +197,35 @@ ServiceChooserDialog::get_selected_service(Glib::ustring &name,
   }
 }
 
+/** Get selected service.
+ * If a service has been selected use this method to get the IP Address as
+ * string of the host that has the service and the port.
+ * May not be called for manual entry since this would require hostname resolution within
+ * the dialog. That should be handled on the caller's side.
+ * @param hostname hostname of the host associated with the service
+ * @param sockaddr upon successful return contains the sockaddr structure of the specific endpoint
+ * @exception Exception thrown if no service has been selected
+ */
+void
+ServiceChooserDialog::get_selected_service(Glib::ustring &hostname,
+                                           struct sockaddr_storage &sockaddr)
+{
+  Glib::RefPtr<Gtk::TreeSelection> treesel = __treeview.get_selection();
+  if (__expander.get_expanded() && !__treeview.has_focus() &&  __entry.get_text_length() > 0) {
+	  throw Exception("May not be called for manual entry");
+  }
+
+  Gtk::TreeModel::iterator iter = treesel->get_selected();
+  if (iter) {
+    Gtk::TreeModel::Row row = *iter;
+    hostname = row[__service_model->get_column_record().ipaddr];
+    sockaddr = row[__service_model->get_column_record().sockaddr];
+
+  } else {
+    throw Exception("No host selected");
+  }
+}
+
 
 /** Get raw address.
  * @param addr upon returns contains the raw representation of the IP address
@@ -260,12 +289,19 @@ ServiceChooserDialog::run_and_connect()
 
   if ( run() ) {
     try {
-      Glib::ustring name;
-      Glib::ustring hostname;
-      unsigned short int port = 1910;
-      get_selected_service(name, hostname, port);
-
-      __client->connect(hostname.c_str(), port);
+	    if (__expander.get_expanded() && !__treeview.has_focus() &&  __entry.get_text_length() > 0 ) {
+		    Glib::ustring name, hostname;
+		    unsigned short int port;
+		    get_selected_service(name, hostname, port);
+		    __client->connect(hostname.c_str(), port);
+		    
+	    } else {
+		    struct sockaddr_storage sockaddr;
+		    Glib::ustring hostname;
+		    get_selected_service(hostname, sockaddr);
+		    __client->connect(hostname.c_str(), sockaddr);
+
+	    }
     } catch (Exception &e) {
       Glib::ustring message = *(e.begin());
       Gtk::MessageDialog md(__parent, message, /* markup */ false,
diff --git a/src/libs/gui_utils/service_chooser_dialog.h b/src/libs/gui_utils/service_chooser_dialog.h
index dbe9e3c..dabd4eb 100644
--- a/src/libs/gui_utils/service_chooser_dialog.h
+++ b/src/libs/gui_utils/service_chooser_dialog.h
@@ -60,6 +60,8 @@ class ServiceChooserDialog
 
   void get_selected_service(Glib::ustring &name, Glib::ustring &hostname,
                             unsigned short int &port);
+  void get_selected_service(Glib::ustring &hostname, struct sockaddr_storage &sockaddr);
+  
   void get_raw_address(struct sockaddr *addr, socklen_t addr_size);
 
   void run_and_connect();
diff --git a/src/libs/gui_utils/service_model.cpp b/src/libs/gui_utils/service_model.cpp
index f48144a..3e1f017 100644
--- a/src/libs/gui_utils/service_model.cpp
+++ b/src/libs/gui_utils/service_model.cpp
@@ -193,6 +193,7 @@ ServiceModel::service_added( const char* name, const char* type,
   s.domain = string(domain);
   s.hostname = string(host_name);
   s.port = port;
+  memcpy(&s.sockaddr, addr, addr_size);
 
   m_added_services.push_locked(s);
 
@@ -231,6 +232,7 @@ ServiceModel::on_service_added()
       row[m_service_record.ipaddr]   = s.ipaddr;
       row[m_service_record.port]     = s.port;
       row[m_service_record.addrport] = s.addrport;
+      row[m_service_record.sockaddr] = s.sockaddr;
       
       m_added_services.pop();
     }
diff --git a/src/libs/gui_utils/service_model.h b/src/libs/gui_utils/service_model.h
index 69a11ea..3e7b46a 100644
--- a/src/libs/gui_utils/service_model.h
+++ b/src/libs/gui_utils/service_model.h
@@ -52,6 +52,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
 	  add(ipaddr);
 	  add(port);
 	  add(addrport);
+	  add(sockaddr);
 	}
       
       Gtk::TreeModelColumn<Glib::ustring> name;      /**< The name of the service */
@@ -61,6 +62,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
       Gtk::TreeModelColumn<Glib::ustring> ipaddr;    /**< The IP address as string of the host the service is running on */
       Gtk::TreeModelColumn<unsigned short>  port;     /**< The port the service is running on */
       Gtk::TreeModelColumn<Glib::ustring>   addrport;    /**< Address:port string */
+      Gtk::TreeModelColumn<struct sockaddr_storage> sockaddr;    /**< sockaddr structure */
     };
 
   ServiceRecord& get_column_record();
@@ -87,6 +89,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
     std::string ipaddr;    /**< the IP address of the new service */
     unsigned short port;   /**< the port the new service is running on */
     std::string addrport;    /**< address:port */
+	  struct sockaddr_storage sockaddr; /**< sockaddr structure */
   };
 
   struct ServiceRemovedRecord

- *commit* 97ef4170bddcec9a9d58a33d37deb5017039c794 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:27:15 2016 +0100
Subject: config: move network settings to network.yaml

 cfg/conf.d/network.yaml |   29 +++++++++++++++++++++++++++++
 cfg/config.yaml         |   23 +++--------------------
 2 files changed, 32 insertions(+), 20 deletions(-)

_Diff for modified files_:
diff --git a/cfg/config.yaml b/cfg/config.yaml
index 82635c4..7e4953b 100644
--- a/cfg/config.yaml
+++ b/cfg/config.yaml
@@ -31,26 +31,9 @@ fawkes:
     # going on for later analysis.
     log_stderr_as_warn: true
 
-    net:
-      # Port for Fawkes Network Protocol service; TCP port
-      tcp_port: !tcp-port 1910
-
-      # Name for Fawkes service, announced via Avahi,
-      # %h is replaced by short hostname
-      service_name: "Fawkes on %h"
-
-      # Enable or disable IPv4 or IPv6 server port
-
-      # Set "listen" value to bind to a specific IP address of the
-      # host, rather than to "any" address, example shows how to bind
-      # for connections from the local host only
-      ipv4:
-        enable: true
-        #listen: !ipv4 127.0.0.1
-
-      ipv6:
-        enable: true
-        #listen: !ipv6 "::1"
+
+    # *** Network settings
+    # Moved to conf.d/network.yaml
 
 # Log level for ballposlog example plugin; sum of any of
 # debug=0, info=1, warn=2, error=4, none=8

- *commit* 02a92760f1a714d80f8c3e57f1310c69504ce6cc - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:27:59 2016 +0100
Subject: libbaseapp: adapt to move network related config values

 src/libs/baseapp/run.cpp |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/baseapp/run.cpp b/src/libs/baseapp/run.cpp
index d5ce64d..fbc9118 100644
--- a/src/libs/baseapp/run.cpp
+++ b/src/libs/baseapp/run.cpp
@@ -299,7 +299,7 @@ init(InitOptions options, int & retval)
     net_tcp_port = options.net_tcp_port();
   } else {
     try {
-      net_tcp_port = config->get_uint("/fawkes/mainapp/net/tcp_port");
+      net_tcp_port = config->get_uint("/network/fawkes/tcp_port");
     } catch (Exception &e) {}  // ignore, we stick with the default
   }
 
@@ -307,7 +307,7 @@ init(InitOptions options, int & retval)
     net_service_name = options.net_service_name();
   } else {
     try {
-      net_service_name = config->get_string("/fawkes/mainapp/net/service_name");
+      net_service_name = config->get_string("/network/fawkes/service_name");
     } catch (Exception &e) {}  // ignore, we stick with the default
   }
 
@@ -318,17 +318,17 @@ init(InitOptions options, int & retval)
   }
 
   try {
-	  enable_ipv4 = config->get_bool("/fawkes/mainapp/net/ipv4/enable");
+	  enable_ipv4 = config->get_bool("/network/ipv4/enable");
   } catch (Exception &e) {}  // ignore, we stick with the default
   try {
-	  enable_ipv6 = config->get_bool("/fawkes/mainapp/net/ipv6/enable");
+	  enable_ipv6 = config->get_bool("/network/ipv6/enable");
   } catch (Exception &e) {}  // ignore, we stick with the default
 
   try {
-	  listen_ipv4 = config->get_string("/fawkes/mainapp/net/ipv4/listen");
+	  listen_ipv4 = config->get_string("/network/ipv4/listen");
   } catch (Exception &e) {}  // ignore, we stick with the default
   try {
-	  listen_ipv6 = config->get_string("/fawkes/mainapp/net/ipv6/listen");
+	  listen_ipv6 = config->get_string("/network/ipv6/listen");
   } catch (Exception &e) {}  // ignore, we stick with the default
 
   if (! enable_ipv4) {

- *commit* 6dbdcd62c21667a6cd65aad0354878379e42a739 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:28:42 2016 +0100
Subject: libwebview: support enabling/disabling of IPv4/IPv6

 src/libs/webview/server.cpp |   38 +++++++++++++++++++++++++++++++++-----
 src/libs/webview/server.h   |    7 +++++--
 2 files changed, 38 insertions(+), 7 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/webview/server.cpp b/src/libs/webview/server.cpp
index 483d990..878136a 100644
--- a/src/libs/webview/server.cpp
+++ b/src/libs/webview/server.cpp
@@ -52,9 +52,12 @@ namespace fawkes {
  * @param port TCP port to listen on
  * @param dispatcher dispatcher to call for requests
  * @param logger optional logger, used to output possible run-time problems
+ * @param enable_ipv4 enable IPv4 support
+ * @param enable_ipv6 enable IPv6 support
  */
 WebServer::WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
-		     fawkes::Logger *logger)
+                     fawkes::Logger *logger,
+                     bool enable_ipv4, bool enable_ipv6)
 {
   __port         = port;
   __dispatcher   = dispatcher;
@@ -64,7 +67,18 @@ WebServer::WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
   __ssl_key_mem  = NULL;
   __ssl_cert_mem = NULL;
 
-  __daemon = MHD_start_daemon(MHD_NO_FLAG,
+  unsigned int flags = MHD_NO_FLAG;
+#if MHD_VERSION >= 0x00090280
+  if (enable_ipv4 && enable_ipv6) {
+	  flags |= MHD_USE_DUAL_STACK;
+  } else if (enable_ipv6) {
+	  flags |= MHD_USE_IPv6;
+  } else if (! enable_ipv4 && ! enable_ipv6) {
+	  throw fawkes::Exception("WebServer: neither IPv4 nor IPv6 enabled");
+  }
+#endif
+
+  __daemon = MHD_start_daemon(flags,
 			      __port,
 			      NULL,
 			      NULL,
@@ -89,10 +103,13 @@ WebServer::WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
  * @param cert_pem_filepath path to PEM formatted file containing the certificate
  * @param cipher_suite which cipers to use for SSL/TLS connections
  * @param logger optional logger, used to output possible run-time problems
+ * @param enable_ipv4 enable IPv4 support
+ * @param enable_ipv6 enable IPv6 support
  */
 WebServer::WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
-		     const char *key_pem_filepath, const char *cert_pem_filepath,
-		     const char *cipher_suite, fawkes::Logger *logger)
+                     const char *key_pem_filepath, const char *cert_pem_filepath,
+                     const char *cipher_suite, fawkes::Logger *logger,
+                     bool enable_ipv4, bool enable_ipv6)
 {
   __port       = port;
   __dispatcher = dispatcher;
@@ -105,7 +122,18 @@ WebServer::WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
     cipher_suite = WEBVIEW_DEFAULT_CIPHERS;
   }
 
-  __daemon = MHD_start_daemon(MHD_USE_SSL,
+  unsigned int flags = MHD_USE_SSL;
+#if MHD_VERSION >= 0x00090280
+  if (enable_ipv4 && enable_ipv6) {
+	  flags |= MHD_USE_DUAL_STACK;
+  } else if (enable_ipv6) {
+	  flags |= MHD_USE_IPv6;
+  } else if (! enable_ipv4 && ! enable_ipv6) {
+	  throw fawkes::Exception("WebServer: neither IPv4 nor IPv6 enabled");
+  }
+#endif
+
+  __daemon = MHD_start_daemon(flags,
 			      __port,
 			      NULL,
 			      NULL,
diff --git a/src/libs/webview/server.h b/src/libs/webview/server.h
index d63c80c..b5154f3 100644
--- a/src/libs/webview/server.h
+++ b/src/libs/webview/server.h
@@ -43,11 +43,14 @@ class WebRequestManager;
 class WebServer {
  public:
   WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
-	    fawkes::Logger *logger = 0);
+            fawkes::Logger *logger = 0,
+            bool enable_ipv4 = true, bool enable_ipv6 = true);
+
   WebServer(unsigned short int port, WebRequestDispatcher *dispatcher,
 	    const char *key_pem_filepath, const char *cert_pem_filepath,
 	    const char *cipher_suite = WEBVIEW_DEFAULT_CIPHERS,
-	    fawkes::Logger *logger = 0);
+            fawkes::Logger *logger = 0,
+            bool enable_ipv4 = true, bool enable_ipv6 = true);
   ~WebServer();
 
   void process();

- *commit* 90053507c52485ba66d72ec219c8005f05568e72 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:31:34 2016 +0100
Subject: webview: support central IPv4/IPv6 config values

 src/plugins/webview/webview_thread.cpp |   23 +++++++++++++++++------
 src/plugins/webview/webview_thread.h   |    2 ++
 2 files changed, 19 insertions(+), 6 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/webview/webview_thread.cpp b/src/plugins/webview/webview_thread.cpp
index 6c174e5..ee2d158 100644
--- a/src/plugins/webview/webview_thread.cpp
+++ b/src/plugins/webview/webview_thread.cpp
@@ -101,6 +101,9 @@ WebviewThread::init()
     __cfg_use_ssl = config->get_bool("/webview/use_ssl");
   } catch (Exception &e) {}
 
+  __cfg_use_ipv4 = config->get_bool("/network/ipv4/enable");
+  __cfg_use_ipv6 = config->get_bool("/network/ipv6/enable");
+
   if (__cfg_use_ssl) {
     __cfg_ssl_create = false;
     try {
@@ -173,11 +176,11 @@ WebviewThread::init()
   try {
     if (__cfg_use_ssl) {
       __webserver  = new WebServer(__cfg_port, __dispatcher,
-				   __cfg_ssl_key.c_str(), __cfg_ssl_cert.c_str(),
-				   __cfg_ssl_cipher_suite.empty() ? NULL : __cfg_ssl_cipher_suite.c_str(),
-				   logger);
+                                   __cfg_ssl_key.c_str(), __cfg_ssl_cert.c_str(),
+                                   __cfg_ssl_cipher_suite.empty() ? NULL : __cfg_ssl_cipher_suite.c_str(),
+                                   logger, __cfg_use_ipv4, __cfg_use_ipv6);
     } else {
-      __webserver  = new WebServer(__cfg_port, __dispatcher, logger);
+      __webserver  = new WebServer(__cfg_port, __dispatcher, logger, __cfg_use_ipv4, __cfg_use_ipv6);
     }
 
     if (__cfg_use_basic_auth) {
@@ -240,8 +243,16 @@ WebviewThread::init()
   webview_nav_manager->add_nav_entry(IMAGE_URL_PREFIX, "Images");
 #endif
 
-  logger->log_info("WebviewThread", "Listening for HTTP%s connections on port %u",
-		   __cfg_use_ssl ? "S" : "", __cfg_port);
+  std::string afs;
+  if (__cfg_use_ipv4 && __cfg_use_ipv6) {
+	  afs = "IPv4,IPv6";
+  } else if (__cfg_use_ipv4) {
+	  afs = "IPv4";
+  } else if (__cfg_use_ipv6) {
+	  afs = "IPv6";
+  }
+  logger->log_info("WebviewThread", "Listening for HTTP%s connections on port %u (%s)",
+                   __cfg_use_ssl ? "S" : "", __cfg_port, afs.c_str());
 
   service_publisher->publish_service(__webview_service);
   service_browser->watch_service("_http._tcp", __service_browse_handler);
diff --git a/src/plugins/webview/webview_thread.h b/src/plugins/webview/webview_thread.h
index b4da1f2..50365a8 100644
--- a/src/plugins/webview/webview_thread.h
+++ b/src/plugins/webview/webview_thread.h
@@ -117,6 +117,8 @@ class WebviewThread
   WebviewUserVerifier                *__user_verifier;
 
   unsigned int __cfg_port;
+  bool         __cfg_use_ipv4;
+  bool         __cfg_use_ipv6;
   bool         __cfg_use_ssl;
   bool         __cfg_ssl_create;
   std::string  __cfg_ssl_key;




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list