[Fawkes Git] branch/timn/netcomm-ipv6: 7 revs updated. (0.5.0-3391-gad4ccda)

Tim Niemueller niemueller at kbsg.rwth-aachen.de
Wed Dec 14 22:04:45 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  ad4ccda804139b913dda9cb981bf1013c372ec9e (commit)
       via  2ebef0258d26485f943597f77a183b396c4e347c (commit)
       via  90fe9e077fe80a0c9c96d015005aefa7f92965e1 (commit)
       via  084abb59f3c1c9398d20e2a99243aeb5ebbf9848 (commit)
       via  32e8cabb3d79baebec942e6fd6ff43be3fe04383 (commit)
       via  a5c08125501ca1e10a68643a1785aaf94373c24b (commit)
       via  e4836d89926974d8d4b7159745781ba6196e18d1 (commit)
      from  b62bc0d3c98028c2a5b5b9427b35b9c8e47e5c2e (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 e4836d89926974d8d4b7159745781ba6196e18d1
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Dec 14 21:48:50 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 14 21:48:50 2016 +0100

    netcomm: make service disconvery IPv6 capable
    
    Adapt the Avahi-based service discovery implementation to fully support
    IPv6. It was so far explicitly disabled or ignored.
    
    Along the way improve readability and simplify in several places. It is
    still a mess, but now a mess that supports IPv6.

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit a5c08125501ca1e10a68643a1785aaf94373c24b
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Dec 14 21:50:18 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 14 21:50:59 2016 +0100

    gui_utils: fix annoying GConf invalid key error

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 32e8cabb3d79baebec942e6fd6ff43be3fe04383
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Dec 14 22:00:12 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 14 22:00:12 2016 +0100

    gui_utils: support IPv6 addresses in service chooser dialog
    
    Additionally also show port number of remote.

http://git.fawkesrobotics.org/fawkes.git/commit/32e8cab
http://trac.fawkesrobotics.org/changeset/32e8cab

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 084abb59f3c1c9398d20e2a99243aeb5ebbf9848
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Dec 14 22:01:07 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 14 22:01:07 2016 +0100

    utils: parse_host funcs no longer modify port if not given
    
    If the host:port string does not actually contain a port do not modify
    the input value. Allows to pass in a default value.

http://git.fawkesrobotics.org/fawkes.git/commit/084abb5
http://trac.fawkesrobotics.org/changeset/084abb5

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 90fe9e077fe80a0c9c96d015005aefa7f92965e1
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Dec 14 22:02:04 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 14 22:02:04 2016 +0100

    ffplugin: better error message on connect fail

http://git.fawkesrobotics.org/fawkes.git/commit/90fe9e0
http://trac.fawkesrobotics.org/changeset/90fe9e0

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 2ebef0258d26485f943597f77a183b396c4e347c
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Dec 14 22:02:32 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 14 22:02:32 2016 +0100

    libbaseapp: informative messages regarding IPv4/IPv6
    
    Print a warning if either is disabled. Print informative message if a
    specific address has been specified to bind to. Both of these could be
    potential pitfalls.

http://git.fawkesrobotics.org/fawkes.git/commit/2ebef02
http://trac.fawkesrobotics.org/changeset/2ebef02

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit ad4ccda804139b913dda9cb981bf1013c372ec9e
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Wed Dec 14 22:03:33 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 14 22:03:33 2016 +0100

    skillgui: fix invalid icon size warning
    
    You would not think that there is an explicit setting "invalid" in Glade
    for the toolbar icon size... and then it produces a warning.

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

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


- *Summary* -----------------------------------------------------------
 res/guis/skillgui/skillgui.ui                      |    3 +-
 src/libs/baseapp/run.cpp                           |   13 ++
 src/libs/gui_utils/service_chooser_dialog.cpp      |    9 +-
 src/libs/gui_utils/service_model.cpp               |   24 +++-
 src/libs/netcomm/dns-sd/avahi_resolver_handler.cpp |    4 +-
 src/libs/netcomm/dns-sd/avahi_resolver_handler.h   |   10 +-
 src/libs/netcomm/dns-sd/avahi_thread.cpp           |  174 ++++++++++++++------
 src/libs/netcomm/dns-sd/avahi_thread.h             |   12 +-
 src/libs/netcomm/fawkes/network_manager.cpp        |    2 +-
 src/libs/netcomm/service_discovery/service.cpp     |   53 ++++---
 src/libs/netcomm/service_discovery/service.h       |    3 +-
 src/libs/netcomm/utils/addr_comp.h                 |   74 +++++++++
 .../pointcloud.h => netcomm/utils/addr_size.h}     |   46 +++---
 src/libs/netcomm/utils/resolver.cpp                |   43 ++---
 src/libs/netcomm/utils/resolver.h                  |   33 +---
 src/libs/netcomm/utils/resolver_thread.cpp         |  114 +++++--------
 src/libs/netcomm/utils/resolver_thread.h           |   30 ++--
 src/libs/utils/system/argparser.cpp                |   11 +-
 src/tools/plugin/main.cpp                          |    2 +-
 19 files changed, 389 insertions(+), 271 deletions(-)
 create mode 100644 src/libs/netcomm/utils/addr_comp.h
 copy src/libs/{aspect/pointcloud.h => netcomm/utils/addr_size.h} (61%)


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

- *commit* e4836d89926974d8d4b7159745781ba6196e18d1 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Dec 14 21:48:50 2016 +0100
Subject: netcomm: make service disconvery IPv6 capable

 src/libs/netcomm/dns-sd/avahi_resolver_handler.cpp |    4 +-
 src/libs/netcomm/dns-sd/avahi_resolver_handler.h   |   10 +-
 src/libs/netcomm/dns-sd/avahi_thread.cpp           |  174 ++++++++++++++------
 src/libs/netcomm/dns-sd/avahi_thread.h             |   12 +-
 src/libs/netcomm/fawkes/network_manager.cpp        |    2 +-
 src/libs/netcomm/service_discovery/service.cpp     |   53 ++++---
 src/libs/netcomm/service_discovery/service.h       |    3 +-
 src/libs/netcomm/utils/addr_comp.h                 |   74 +++++++++
 .../pointcloud.h => netcomm/utils/addr_size.h}     |   46 +++---
 src/libs/netcomm/utils/resolver.cpp                |   43 ++---
 src/libs/netcomm/utils/resolver.h                  |   33 +---
 src/libs/netcomm/utils/resolver_thread.cpp         |  114 +++++--------
 src/libs/netcomm/utils/resolver_thread.h           |   30 ++--
 13 files changed, 343 insertions(+), 255 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/dns-sd/avahi_resolver_handler.cpp b/src/libs/netcomm/dns-sd/avahi_resolver_handler.cpp
index 1e84627..400c9b8 100644
--- a/src/libs/netcomm/dns-sd/avahi_resolver_handler.cpp
+++ b/src/libs/netcomm/dns-sd/avahi_resolver_handler.cpp
@@ -42,7 +42,7 @@ namespace fawkes {
  * especially that the handler is responsible for freeing the associated memory
  * after it is done with the result using free() on name and addr.
  * @param name name that was resolved
- * @param addr resulting addr record, currently always of type struct sockaddr_in (only IPv4)
+ * @param addr resulting addr record
  * @param addrlen length of addr in bytes
  *
  * @fn void AvahiResolverHandler::resolved_address(struct sockaddr_in *addr, socklen_t addrlen, char *name) = 0
@@ -53,7 +53,7 @@ namespace fawkes {
  * especially that the handler is responsible for freeing the associated memory
  * after it is done with the result using free() on name and addr.
  * @param name the resulting hostname
- * @param addr addr record, currently always of type struct sockaddr_in (only IPv4)
+ * @param addr addr record
  * @param addrlen length of addr in bytes
  *
  * @fn void AvahiResolverHandler::name_resolution_failed(char *name) = 0
diff --git a/src/libs/netcomm/dns-sd/avahi_resolver_handler.h b/src/libs/netcomm/dns-sd/avahi_resolver_handler.h
index ba79534..09175d3 100644
--- a/src/libs/netcomm/dns-sd/avahi_resolver_handler.h
+++ b/src/libs/netcomm/dns-sd/avahi_resolver_handler.h
@@ -33,13 +33,13 @@ class AvahiResolverHandler
  public:
   virtual ~AvahiResolverHandler();
   virtual void resolved_name(char *name,
-			     struct sockaddr *addr, socklen_t addrlen)   = 0;
-  virtual void resolved_address(struct sockaddr_in *addr, socklen_t addrlen,
-				char *name)                              = 0;
+                             struct sockaddr *addr, socklen_t addrlen)   = 0;
+  virtual void resolved_address(struct sockaddr *addr, socklen_t addrlen,
+                                char *name)                              = 0;
 
   virtual void name_resolution_failed(char *name)                        = 0;
-  virtual void address_resolution_failed(struct sockaddr_in *addr,
-					 socklen_t addrlen)              = 0;
+  virtual void address_resolution_failed(struct sockaddr *addr,
+                                         socklen_t addrlen)              = 0;
 };
 
 } // end namespace fawkes
diff --git a/src/libs/netcomm/dns-sd/avahi_thread.cpp b/src/libs/netcomm/dns-sd/avahi_thread.cpp
index 399c4c7..93ac8d9 100644
--- a/src/libs/netcomm/dns-sd/avahi_thread.cpp
+++ b/src/libs/netcomm/dns-sd/avahi_thread.cpp
@@ -55,9 +55,17 @@ namespace fawkes {
  * @author Tim Niemueller
  */
 
-/** Constructor. */
-AvahiThread::AvahiThread()
-  : Thread("AvahiThread")
+/** Constructor.
+ * You can choose whether to announce IPv4 or IPv6 only or both.
+ * If you select both, new service will be created with the "unspecified"
+ * address family in Avahi, causing it to announce the service on all
+ * supported protocols (which may or may not include both).
+ * @param enable_ipv4 enable IPv4 support
+ * @param enable_ipv6 enable IPv6 support
+ */
+AvahiThread::AvahiThread(bool enable_ipv4, bool enable_ipv6)
+	: Thread("AvahiThread"),
+	  enable_ipv4(enable_ipv4), enable_ipv6(enable_ipv6)
 {
   simple_poll = NULL;
   client = NULL;
@@ -65,6 +73,16 @@ AvahiThread::AvahiThread()
   need_recover = false;
   do_reset_groups = false;
 
+  if (enable_ipv4 && enable_ipv6) {
+	  service_protocol = AVAHI_PROTO_UNSPEC;
+  } else if (enable_ipv4) {
+	  service_protocol = AVAHI_PROTO_INET;
+  } else if (enable_ipv6) {
+	  service_protocol = AVAHI_PROTO_INET6;
+  } else {
+	  throw Exception("Neither IPv4 nor IPv6 enabled");
+  }
+  
   init_wc = new WaitCondition();
 
   set_prepfin_conc_loop(true);
@@ -282,12 +300,12 @@ AvahiThread::create_service(const NetworkService &service, AvahiEntryGroup *exgr
   std::string name = service.modified_name() ? service.modified_name() : service.name();
   for (int i = 1; (i <= 100) && (rv == AVAHI_ERR_COLLISION); ++i) {
     rv = avahi_entry_group_add_service_strlst(group, AVAHI_IF_UNSPEC,
-					      AVAHI_PROTO_INET,
-					      AVAHI_PUBLISH_USE_MULTICAST,
-					      name.c_str(), service.type(),
-					      service.domain(),
-					      service.host(),
-					      service.port(), al);
+                                              service_protocol,
+                                              (AvahiPublishFlags)0,
+                                              name.c_str(), service.type(),
+                                              service.domain(),
+                                              service.host(),
+                                              service.port(), al);
 
     if (rv == AVAHI_ERR_COLLISION) {
       char *n = avahi_alternative_service_name(name.c_str());
@@ -514,9 +532,9 @@ AvahiThread::create_browser(const char *service_type)
   if ( __browsers.find(service_type) == __browsers.end() ) {
     if ( client ) {
       AvahiServiceBrowser *b = avahi_service_browser_new(client, AVAHI_IF_UNSPEC,
-							 AVAHI_PROTO_UNSPEC,
-							 service_type, NULL, (AvahiLookupFlags)0,
-							 AvahiThread::browse_callback, this);
+                                                         service_protocol, service_type,
+                                                         NULL, (AvahiLookupFlags)0,
+                                                         AvahiThread::browse_callback, this);
 
       if ( ! b ) {
 	__handlers[service_type].pop_back();
@@ -622,12 +640,22 @@ AvahiThread::call_handler_service_added( const char *name,
 					  std::list<std::string> &txt,
 					  AvahiLookupResultFlags flags)
 {
-  struct sockaddr_in *s = NULL;
+  struct sockaddr *s = NULL;
   socklen_t slen;
   if ( address->proto == AVAHI_PROTO_INET ) {
+	  if (! enable_ipv4)  return;
     slen = sizeof(struct sockaddr_in);
-    s = (struct sockaddr_in *)malloc(slen);
-    s->sin_addr.s_addr = address->data.ipv4.address;
+    struct sockaddr_in *sin = (struct sockaddr_in *)malloc(slen);
+    sin->sin_family = AF_INET;
+    sin->sin_addr.s_addr = address->data.ipv4.address;
+    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));
+    s = (struct sockaddr *)sin;
   } else {
     // ignore
     return;
@@ -635,8 +663,8 @@ AvahiThread::call_handler_service_added( const char *name,
   if ( __handlers.find(type) != __handlers.end() ) {
     std::list<ServiceBrowseHandler *>::iterator i;
     for ( i = __handlers[type].begin(); i != __handlers[type].end(); ++i) {
-      (*i)->service_added(name, type, domain, host_name,
-			  (struct sockaddr *)s, slen, port, txt, (int)flags);
+	    (*i)->service_added(name, type, domain, host_name,
+	                        (struct sockaddr *)s, slen, port, txt, (int)flags);
     }
   }
   free(s);
@@ -848,7 +876,7 @@ AvahiThread::start_hostname_resolver(const char *name, AvahiResolverCallbackData
 {
   AvahiHostNameResolver *resolver;
   if ( (resolver = avahi_host_name_resolver_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
-						name, AVAHI_PROTO_INET,
+						name, service_protocol,
 						AVAHI_LOOKUP_USE_MULTICAST,
 						AvahiThread::host_name_resolver_callback,
 						data) ) == NULL ) {
@@ -863,8 +891,9 @@ AvahiThread::start_hostname_resolver(const char *name, AvahiResolverCallbackData
 void
 AvahiThread::start_hostname_resolvers()
 {
-  for (__phrit = __pending_hostname_resolves.begin(); __phrit != __pending_hostname_resolves.end(); ++__phrit) {
-    start_hostname_resolver((*__phrit).first.c_str(), (*__phrit).second);
+	LockMap<std::string, AvahiResolverCallbackData * >::iterator phrit;
+  for (phrit = __pending_hostname_resolves.begin(); phrit != __pending_hostname_resolves.end(); ++phrit) {
+    start_hostname_resolver(phrit->first.c_str(), phrit->second);
   }
   __pending_hostname_resolves.clear();
 }
@@ -873,8 +902,10 @@ AvahiThread::start_hostname_resolvers()
 void
 AvahiThread::start_address_resolvers()
 {
-  for (__parit = __pending_address_resolves.begin(); __parit != __pending_address_resolves.end(); ++__parit) {
-    start_address_resolver((*__parit).first, (*__parit).second);
+	LockMap<struct ::sockaddr_storage *, AvahiResolverCallbackData *>::iterator  parit;
+
+  for (parit = __pending_address_resolves.begin(); parit != __pending_address_resolves.end(); ++parit) {
+    start_address_resolver(parit->first, parit->second);
   }
   __pending_address_resolves.clear();
 }
@@ -883,7 +914,7 @@ AvahiThread::start_address_resolvers()
 /** Order address resolution.
  * This initiates resolution of an address. The method immediately returns and will not
  * wait for the result.
- * @param addr address to resolve, currently only struct sockaddr_in is supported (IPv4)
+ * @param addr address to resolve
  * @param addrlen length of addr in bytes
  * @param handler handler to call for the result
  */
@@ -891,25 +922,42 @@ void
 AvahiThread::resolve_address(struct sockaddr *addr, socklen_t addrlen,
 			     AvahiResolverHandler *handler)
 {
-  if ( addrlen != sizeof(struct sockaddr_in) ) {
-    throw Exception("Only IPv4 is currently supported");
+	struct ::sockaddr_storage *sstor =
+		(struct ::sockaddr_storage *)malloc(sizeof(struct ::sockaddr_storage));
+  if (addr->sa_family == AF_INET) {
+	  if (addrlen != sizeof(sockaddr_in)) {
+		  throw Exception("Invalid size for IPv4 address struct");
+	  }
+	  memcpy(&sstor, addr, sizeof(sockaddr_in));
+  } else if (addr->sa_family == AF_INET6) {
+	  if (addrlen != sizeof(sockaddr_in6)) {
+		  throw Exception("Invalid size for IPv6 address struct");
+	  }
+	  memcpy(&sstor, addr, sizeof(sockaddr_in6));
+  } else {
+	  throw Exception("Unknown address family");
   }
-
-  struct sockaddr_in *in_addr = (struct sockaddr_in *)calloc(1, sizeof(struct sockaddr_in));
-  memcpy(in_addr, addr, sizeof(struct sockaddr_in));
   AvahiResolverCallbackData *data = new AvahiResolverCallbackData(this, handler);
 
-  __pending_address_resolves[in_addr] = data;
+  __pending_address_resolves[sstor] = data;
   wake_poller();
 }
 
 
 void
-AvahiThread::start_address_resolver(struct sockaddr_in *in_addr, AvahiResolverCallbackData *data)
+AvahiThread::start_address_resolver(const struct sockaddr_storage *in_addr, AvahiResolverCallbackData *data)
 {
-  AvahiAddress a;
-  a.proto = AVAHI_PROTO_INET;
-  a.data.ipv4.address = in_addr->sin_addr.s_addr;
+	AvahiAddress a;
+
+	if (in_addr->ss_family == AF_INET) {
+		a.proto = AVAHI_PROTO_INET;
+		a.data.ipv4.address = ((sockaddr_in *)in_addr)->sin_addr.s_addr;
+	} else if (in_addr->ss_family == AF_INET6) {
+		a.proto = AVAHI_PROTO_INET6;
+		memcpy(&a.data.ipv6.address, &((sockaddr_in6 *)in_addr)->sin6_addr, sizeof(in6_addr));
+	} else {
+	  throw Exception("Unknown address family");
+	}
 
   AvahiAddressResolver *resolver;
   if ( (resolver = avahi_address_resolver_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
@@ -968,17 +1016,25 @@ AvahiThread::host_name_resolver_callback(AvahiHostNameResolver *r,
   switch (event) {
   case AVAHI_RESOLVER_FOUND:
     {
-      struct sockaddr_in *res = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
-      res->sin_family = (unsigned short)avahi_proto_to_af(protocol);
-      res->sin_addr.s_addr = a->data.ipv4.address;
-      
-      cd->second->resolved_name(strdup(name), (struct sockaddr *)res, sizeof(struct sockaddr_in));
+	    if (protocol == AVAHI_PROTO_INET) {
+		    struct sockaddr_in *res = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
+		    res->sin_family = (unsigned short)avahi_proto_to_af(protocol);
+		    res->sin_addr.s_addr = a->data.ipv4.address;
+		    cd->second->resolved_name(strdup(name), (struct sockaddr *)res, sizeof(struct sockaddr_in));
+	    } else if (protocol == AVAHI_PROTO_INET6) {
+		    struct sockaddr_in6 *res = (struct sockaddr_in6 *)malloc(sizeof(struct sockaddr_in6));
+		    res->sin6_family = (unsigned short)avahi_proto_to_af(protocol);
+		    memcpy(&res->sin6_addr, &a->data.ipv6.address, sizeof(in6_addr));
+		    cd->second->resolved_name(strdup(name), (struct sockaddr *)res, sizeof(struct sockaddr_in6));
+	    } else { // don't know
+		    cd->second->name_resolution_failed(strdup(name));
+	    }
     }
     break;
     
   case AVAHI_RESOLVER_FAILURE:
   default:
-    cd->second->name_resolution_failed(strdup(name));
+	  cd->second->name_resolution_failed(strdup(name));
     break;
   }
 
@@ -1004,21 +1060,35 @@ AvahiThread::address_resolver_callback(AvahiAddressResolver *r,
   cd->first->remove_address_resolver(r);
   avahi_address_resolver_free(r);
 
-  struct sockaddr_in *res = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
-  res->sin_family = (unsigned short)avahi_proto_to_af(protocol);
-  res->sin_addr.s_addr = a->data.ipv4.address;
+  struct sockaddr *res = NULL;
+  socklen_t res_size = 0;
+
+  if (protocol == AVAHI_PROTO_INET) {
+	  res_size = sizeof(struct sockaddr_in);
+	  res = (struct sockaddr *)malloc(res_size);
+	  sockaddr_in *res_4 = (struct sockaddr_in *)res;
+	  res_4->sin_family = (unsigned short)avahi_proto_to_af(protocol);
+	  res_4->sin_addr.s_addr = a->data.ipv4.address;
+  } else if (protocol == AVAHI_PROTO_INET6) {
+	  res_size = sizeof(struct sockaddr_in6);
+	  res = (struct sockaddr *)malloc(res_size);
+	  sockaddr_in6 *res_6 = (struct sockaddr_in6 *)res;
+	  res_6->sin6_family = (unsigned short)avahi_proto_to_af(protocol);
+	  memcpy(&res_6->sin6_addr, &a->data.ipv6.address, sizeof(in6_addr));
+  }
 
    switch (event) {
-  case AVAHI_RESOLVER_FOUND:
-    cd->second->resolved_address((struct sockaddr_in *)res, sizeof(struct sockaddr_in),
-				 strdup(name));
-    break;
-  case AVAHI_RESOLVER_FAILURE:
-  default:
-    cd->second->address_resolution_failed((struct sockaddr_in *)res,
-					  sizeof(struct sockaddr_in));
-    break;
-  }
+   case AVAHI_RESOLVER_FOUND:
+	   cd->second->resolved_address(res, res_size, strdup(name));
+	   break;
+   case AVAHI_RESOLVER_FAILURE:
+	   cd->second->address_resolution_failed(res, res_size);
+	   break;
+
+   default:
+	   cd->second->address_resolution_failed(NULL, 0);
+	   break;
+   }
 
   delete cd;
 }
diff --git a/src/libs/netcomm/dns-sd/avahi_thread.h b/src/libs/netcomm/dns-sd/avahi_thread.h
index 48ca4ff..15ddc8a 100644
--- a/src/libs/netcomm/dns-sd/avahi_thread.h
+++ b/src/libs/netcomm/dns-sd/avahi_thread.h
@@ -43,7 +43,6 @@ struct AvahiServiceBrowser;
 struct AvahiServiceResolver;
 struct AvahiHostNameResolver;
 struct AvahiAddressResolver;
-struct sockaddr_in;
 
 namespace fawkes {
 
@@ -58,7 +57,7 @@ class AvahiThread
   public ServiceBrowser
 {
  public:
-  AvahiThread();
+  AvahiThread(bool enable_ipv4 = true, bool enable_ipv6 = true);
   ~AvahiThread();
 
   void wait_initialized();
@@ -183,8 +182,10 @@ class AvahiThread
   void start_address_resolvers();
   void start_hostname_resolvers();
   void start_hostname_resolver(const char *name, AvahiResolverCallbackData *data);
-  void start_address_resolver(struct sockaddr_in *in_addr, AvahiResolverCallbackData *data);
+  void start_address_resolver(const struct sockaddr_storage *in_addr, AvahiResolverCallbackData *data);
 
+  bool enable_ipv4;
+  bool enable_ipv6;
 
   bool need_recover;
   bool do_erase_browsers;
@@ -193,6 +194,7 @@ class AvahiThread
   AvahiSimplePoll  *simple_poll;
   AvahiClient      *client;
   AvahiClientState  client_state;
+  AvahiProtocol     service_protocol;
 
   WaitCondition         *init_wc;
 
@@ -210,9 +212,7 @@ class AvahiThread
   LockList<AvahiAddressResolver *>  __running_address_resolvers;
 
   LockMap<std::string, AvahiResolverCallbackData * >      __pending_hostname_resolves;
-  LockMap<std::string, AvahiResolverCallbackData * >::iterator __phrit;
-  LockMap<struct sockaddr_in *, AvahiResolverCallbackData *>  __pending_address_resolves;
-  LockMap<struct sockaddr_in *, AvahiResolverCallbackData *>::iterator  __parit;
+  LockMap<struct ::sockaddr_storage *, AvahiResolverCallbackData *>  __pending_address_resolves;
 };
 
 } // end namespace fawkes
diff --git a/src/libs/netcomm/fawkes/network_manager.cpp b/src/libs/netcomm/fawkes/network_manager.cpp
index 16de25c..5ffe435 100644
--- a/src/libs/netcomm/fawkes/network_manager.cpp
+++ b/src/libs/netcomm/fawkes/network_manager.cpp
@@ -75,7 +75,7 @@ FawkesNetworkManager::FawkesNetworkManager(ThreadCollector *thread_collector,
                                                           __thread_collector);
   __thread_collector->add(__fawkes_network_thread);
 #ifdef HAVE_AVAHI
-  __avahi_thread          = new AvahiThread();
+  __avahi_thread          = new AvahiThread(enable_ipv4, enable_ipv6);
   __service_publisher     = __avahi_thread;
   __service_browser       = __avahi_thread;
   __thread_collector->add(__avahi_thread);
diff --git a/src/libs/netcomm/service_discovery/service.cpp b/src/libs/netcomm/service_discovery/service.cpp
index 568666d..ffd975f 100644
--- a/src/libs/netcomm/service_discovery/service.cpp
+++ b/src/libs/netcomm/service_discovery/service.cpp
@@ -71,8 +71,7 @@ NetworkService::NetworkService(const char         *name,
 
   _modified_name = NULL;
 
-  _addr = NULL;
-  _addr_size = 0;
+  memset(&_addr, 0, sizeof(_addr));
 }
 
 
@@ -105,9 +104,10 @@ NetworkService::NetworkService(const char         *name,
 
   _modified_name = NULL;
 
-  _addr = (struct sockaddr *)malloc(addr_size);
-  memcpy(_addr, addr, addr_size);
-  _addr_size = addr_size;
+  if (addr_size > sizeof(_addr)) {
+	  throw Exception("Address size too large");
+  }
+  memcpy(&_addr, addr, addr_size);
   list = txt;
 }
 
@@ -121,8 +121,8 @@ NetworkService::NetworkService(const char         *name,
  * @param port port of service
  */
 NetworkService::NetworkService(const char         *name,
-			       const char         *type,
-			       unsigned short int  port)
+                               const char         *type,
+                               unsigned short int  port)
 {
   _name   = strdup(name);
   _type   = strdup(type);
@@ -132,8 +132,7 @@ NetworkService::NetworkService(const char         *name,
 
   _modified_name = NULL;
 
-  _addr = NULL;
-  _addr_size = 0;
+  memset(&_addr, 0, sizeof(_addr));
 }
 
 
@@ -167,8 +166,7 @@ NetworkService::NetworkService(NetworkNameResolver *nnresolver,
 
   _modified_name = NULL;
 
-  _addr = NULL;
-  _addr_size = 0;
+  memset(&_addr, 0, sizeof(_addr));
 }
 
 /** Constructor.
@@ -189,8 +187,8 @@ NetworkService::NetworkService(const char         *name,
 
   _host   = NULL;
   _port   = 0;
-  _addr = NULL;
-  _addr_size = 0;
+
+  memset(&_addr, 0, sizeof(_addr));
 }
 
 
@@ -201,7 +199,6 @@ NetworkService::~NetworkService()
   if ( _type   != NULL)  free( _type );
   if ( _domain != NULL)  free( _domain );
   if ( _host   != NULL)  free( _host );
-  if ( _addr   != NULL)  free( _addr );
   if ( _modified_name   != NULL)  free( _modified_name );
 }
 
@@ -231,8 +228,7 @@ NetworkService::NetworkService(const NetworkService *s)
     _modified_name = strdup(s->_modified_name);
   }
 
-  _addr = NULL;
-  _addr_size = 0;
+  memcpy(&_addr, &s->_addr, sizeof(_addr));
 
   list = s->list;
 }
@@ -263,8 +259,7 @@ NetworkService::NetworkService(const NetworkService &s)
     _modified_name = strdup(s._modified_name);
   }
 
-  _addr = NULL;
-  _addr_size = 0;
+  memcpy(&_addr, &s._addr, sizeof(_addr));
 
   list = s.list;
 }
@@ -393,9 +388,25 @@ NetworkService::port() const
 std::string
 NetworkService::addr_string() const
 {
-  char ipaddr[INET_ADDRSTRLEN];
-  struct sockaddr_in *saddr = (struct sockaddr_in *)_addr;
-  return std::string(inet_ntop(AF_INET, &(saddr->sin_addr), ipaddr, sizeof(ipaddr)));
+	if (_addr.ss_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) {
+			return ipaddr;
+		} else {
+			throw Exception("Failed to convert IPv4 address to string");
+		}
+	} else if (_addr.ss_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) {
+			return ipaddr;
+		} else {
+			throw Exception("Failed to convert IPv6 address to string");
+		}
+	} else {
+		throw Exception("Unknown address family");
+	}
 }
 
 
diff --git a/src/libs/netcomm/service_discovery/service.h b/src/libs/netcomm/service_discovery/service.h
index 6f46719..b7f86f2 100644
--- a/src/libs/netcomm/service_discovery/service.h
+++ b/src/libs/netcomm/service_discovery/service.h
@@ -94,8 +94,7 @@ class NetworkService
   char *              _domain;
   char *              _host;
   unsigned short int  _port;
-  struct sockaddr    *_addr;
-  socklen_t           _addr_size;
+  struct sockaddr_storage _addr;
 
   mutable char *      _modified_name;
 };
diff --git a/src/libs/netcomm/utils/resolver.cpp b/src/libs/netcomm/utils/resolver.cpp
index b496766..7e83dca 100644
--- a/src/libs/netcomm/utils/resolver.cpp
+++ b/src/libs/netcomm/utils/resolver.cpp
@@ -141,19 +141,13 @@ void
 NetworkNameResolver::flush_cache()
 {
   addr2name_cache.lock();
-  while ( ! addr2name_cache.empty() ) {
-    a2ncit = addr2name_cache.begin();
-    free((*a2ncit).second.first);
-    addr2name_cache.erase(a2ncit);
-  }
+  addr2name_cache.clear();
   addr2name_cache.unlock();
   name2addr_cache.lock();
   while ( ! name2addr_cache.empty() ) {
     n2acit = name2addr_cache.begin();
-    char *name = (*n2acit).first;
-    free((*n2acit).second.first);
+    free(n2acit->second.first);
     name2addr_cache.erase(n2acit);
-    free(name);
   }
   name2addr_cache.unlock();
   __host_info->update();
@@ -254,7 +248,7 @@ NetworkNameResolver::resolve_address(struct sockaddr *addr, socklen_t addr_len,
 
   if ( addr2name_cache.find( saddr->sin_addr.s_addr ) != addr2name_cache.end() ) {
     // the name is in the cache, refetch?
-    std::pair<char *, time_t> &nrec = addr2name_cache[saddr->sin_addr.s_addr];
+	  std::pair<std::string, time_t> &nrec = addr2name_cache[saddr->sin_addr.s_addr];
     name = nrec.first;
     if ( nrec.second <= time(NULL) ) {
       // entry outdated, retry
@@ -308,16 +302,14 @@ NetworkNameResolver::resolve_address(struct sockaddr *addr, socklen_t addr_len,
  * @param addrlen length in bytes of addr
  */
 void
-NetworkNameResolver::name_resolved(char *name, struct sockaddr *addr,
-				   socklen_t addrlen)
+NetworkNameResolver::name_resolved(std::string name, struct sockaddr *addr,
+                                   socklen_t addrlen)
 {
   name2addr_cache.lock();
-  if ( (n2acit = name2addr_cache.find( name )) != name2addr_cache.end() ) {
+  if ( (n2acit = name2addr_cache.find(name)) != name2addr_cache.end() ) {
     // delete old entry
-    char *n = (*n2acit).first;
-    free((*n2acit).second.first);
+    free(n2acit->second.first);
     name2addr_cache.erase(n2acit);
-    free(n);
   }
   name2addr_cache[name] = std::pair<struct sockaddr *, time_t>(addr, time(NULL) + __cache_timeout);
   name2addr_cache.unlock();
@@ -326,25 +318,21 @@ NetworkNameResolver::name_resolved(char *name, struct sockaddr *addr,
 
 void
 NetworkNameResolver::addr_resolved(struct sockaddr *addr,
-				   socklen_t addrlen,
-				   char *name, bool namefound)
+                                   socklen_t addrlen,
+                                   std::string name, bool namefound)
 {
   addr2name_cache.lock();
   struct sockaddr_in *saddr = (struct sockaddr_in *)addr;
   if (namefound) {
     if ((a2ncit = addr2name_cache.find( saddr->sin_addr.s_addr )) != addr2name_cache.end() ) {
       // delete old entry
-      free(a2ncit->second.first);
       addr2name_cache.erase(a2ncit);
-      addr2name_cache[saddr->sin_addr.s_addr] = std::pair<char *, time_t>(name, time(NULL) + __cache_timeout);
-    } else {
-      free(name);
+      addr2name_cache[saddr->sin_addr.s_addr] =
+	      std::make_pair(name, time(NULL) + __cache_timeout);
     }
   } else {
     if ((a2ncit = addr2name_cache.find( saddr->sin_addr.s_addr )) == addr2name_cache.end() ) {
-      addr2name_cache[saddr->sin_addr.s_addr] = std::pair<char *, time_t>(name, 0);
-    } else {
-      free(name);
+      addr2name_cache[saddr->sin_addr.s_addr] = std::make_pair(name, 0);
     }
   }
   free(addr);
@@ -353,17 +341,16 @@ NetworkNameResolver::addr_resolved(struct sockaddr *addr,
 
 
 void
-NetworkNameResolver::name_resolution_failed(char *name)
+NetworkNameResolver::name_resolution_failed(std::string name)
 {
-  free(name);
 }
 
 
 void
 NetworkNameResolver::address_resolution_failed(struct sockaddr *addr,
-					       socklen_t addrlen)
+                                               socklen_t addrlen)
 {
-  free(addr);
+	free(addr);
 }
 
 
diff --git a/src/libs/netcomm/utils/resolver.h b/src/libs/netcomm/utils/resolver.h
index fcf6b3b..89f48e8 100644
--- a/src/libs/netcomm/utils/resolver.h
+++ b/src/libs/netcomm/utils/resolver.h
@@ -65,9 +65,9 @@ class NetworkNameResolver
   const char * short_hostname();
 
  private:
-  void name_resolved(char *name, struct sockaddr *addr, socklen_t addrlen);
-  void addr_resolved(struct sockaddr *addr, socklen_t addrlen, char *name, bool namefound);
-  void name_resolution_failed(char *name);
+  void name_resolved(std::string name, struct sockaddr *addr, socklen_t addrlen);
+  void addr_resolved(struct sockaddr *addr, socklen_t addrlen, std::string name, bool namefound);
+  void name_resolution_failed(std::string name);
   void address_resolution_failed(struct sockaddr *addr, socklen_t addrlen);
 
  private:
@@ -75,28 +75,11 @@ class NetworkNameResolver
   HostInfo *__host_info;
   unsigned int __cache_timeout;
 
-  LockHashMap<uint32_t, std::pair<char *, time_t> >       addr2name_cache;
-  LockHashMap<char *,
-    std::pair<struct sockaddr *, time_t>,
-#if __cplusplus >= 201103L || defined(_LIBCPP_VERSION)
-             std::hash<char *>,
-#elif __GLIBCXX__ > 20080305
-             std::tr1::hash<char *>,
-#else
-             __gnu_cxx::hash<char *>,
-#endif
-             StringEquality >                             name2addr_cache;
-
-  LockHashMap<uint32_t, std::pair<char *, time_t> >::iterator  a2ncit;
-  LockHashMap<char *, std::pair<struct sockaddr *, time_t>,
-#if __cplusplus >= 201103L || defined(_LIBCPP_VERSION)
-    std::hash<char *>,
-#elif __GLIBCXX__ > 20080305
-    std::tr1::hash<char *>,
-#else
-    __gnu_cxx::hash<char *>,
-#endif
-    StringEquality >::iterator                                 n2acit;
+  LockHashMap<uint32_t, std::pair<std::string, time_t> >          addr2name_cache;
+  LockHashMap<std::string, std::pair<struct sockaddr *, time_t> > name2addr_cache;
+
+  LockHashMap<uint32_t, std::pair<std::string, time_t> >::iterator  a2ncit;
+  LockHashMap<std::string, std::pair<struct sockaddr *, time_t> >::iterator n2acit;
 };
 
 } // end namespace fawkes
diff --git a/src/libs/netcomm/utils/resolver_thread.cpp b/src/libs/netcomm/utils/resolver_thread.cpp
index bf00d7d..d905a86 100644
--- a/src/libs/netcomm/utils/resolver_thread.cpp
+++ b/src/libs/netcomm/utils/resolver_thread.cpp
@@ -23,11 +23,13 @@
 
 #include <netcomm/utils/resolver_thread.h>
 #include <netcomm/utils/resolver.h>
+#include <netcomm/utils/addr_size.h>
 #ifdef HAVE_AVAHI
 #include <netcomm/dns-sd/avahi_thread.h>
 #endif
 #include <core/exceptions/system.h>
 
+#include <algorithm>
 #include <sys/types.h>
 #include <netdb.h>
 #include <netinet/in.h>
@@ -82,31 +84,21 @@ NetworkNameResolverThread::NetworkNameResolverThread(NetworkNameResolver *resolv
 NetworkNameResolverThread::~NetworkNameResolverThread()
 {
   __namesq_mutex->lock();
-  while ( ! __namesq->empty() ) {
-    NamesQMap::iterator nqit = __namesq->begin();
-    char *nqn = (*nqit);
-    __namesq->erase(nqit);
-    free(nqn);
-  }
-  while ( ! __namesq_proc->empty() ) {
-    NamesQMap::iterator nqit = __namesq_proc->begin();
-    char *nqn = (*nqit);
-    __namesq->erase(nqit);
-    free(nqn);
-  }
+  __namesq->clear();
+  __namesq_proc->clear();
   __namesq_mutex->unlock();
   __addrq_mutex->lock();
   while ( ! __addrq->empty() ) {
-    AddrQMap::iterator nqit = __addrq->begin();
-    free(nqit->second.first);
+    AddrQList::iterator nqit = __addrq->begin();
+    free(*nqit);
     __addrq->erase(nqit);
   }
   // The next operation cannot be locked, but we make the (valid) assumption
   // that the thread is not running when it is destructed, this situation is
   // an error anyway
   while ( ! __addrq_proc->empty() ) {
-    AddrQMap::iterator nqit = __addrq_proc->begin();
-    free(nqit->second.first);
+    AddrQList::iterator nqit = __addrq_proc->begin();
+    free(*nqit);
     __addrq->erase(nqit);
   }
   __addrq_mutex->unlock();
@@ -128,14 +120,14 @@ NetworkNameResolverThread::~NetworkNameResolverThread()
  * addr_len carry the result, false otherwise
  */
 bool
-NetworkNameResolverThread::resolve_name_immediately(const char *name,
-						    struct sockaddr **addr, socklen_t *addr_len)
+NetworkNameResolverThread::resolve_name_immediately(const std::string &name,
+                                                    struct sockaddr **addr, socklen_t *addr_len)
 {
   bool found = false;
 
   // First try a regular lookup
   struct addrinfo *ai;
-  if ( getaddrinfo(name, NULL, NULL, &ai) == 0 ) {
+  if ( getaddrinfo(name.c_str(), NULL, NULL, &ai) == 0 ) {
     // return the first result
     struct sockaddr *tmp = (struct sockaddr *)malloc(ai->ai_addrlen);
     memcpy(tmp, ai->ai_addr, ai->ai_addrlen);
@@ -147,10 +139,8 @@ NetworkNameResolverThread::resolve_name_immediately(const char *name,
 
 #ifdef HAVE_AVAHI
   // resolve names in .local domain with Avahi if available
-  char *n = (char *)name + strlen(name) - 6; // 6 == strlen(".local")
-  const char *f = strstr(name, ".local");
-  if ( __avahi_thread && f && (f == n) ) {
-    __avahi_thread->resolve_name(name, this);          
+  if ( __avahi_thread && name.find(".local") == name.length() - 6) { // 6 == strlen(".local")
+	  __avahi_thread->resolve_name(name.c_str(), this);          
   /*
   } else {
     printf("NOT ordering avahi_thread lookup\n");
@@ -173,9 +163,8 @@ NetworkNameResolverThread::resolve_name_immediately(const char *name,
 /** Immediately resolve address.
  * This tries to lookup the address with the getnameinfo(). If that fails a textual
  * representation of the address is created. Additionally if an Avahi thread has
- * @param addr pointer to a struct of type struct sockaddr_in with the address to
+ * @param addr pointer to a struct of type struct sockaddr with the address to
  * lookup
- * @param addr_len length of addr in bytes
  * @param name contains a newly allocated buffer upon successful return that you have
  * to free after use using free().
  * @param namefound true, if the name could be resolved, false if it was just transformed
@@ -184,28 +173,20 @@ NetworkNameResolverThread::resolve_name_immediately(const char *name,
  * carries the result, false otherwise
  */
 bool
-NetworkNameResolverThread::resolve_address_immediately(struct sockaddr *addr, socklen_t addr_len,
-						       char **name, bool *namefound)
+NetworkNameResolverThread::resolve_address_immediately(struct sockaddr *addr,
+                                                       std::string &name, bool &namefound)
 {
   bool found = false;
   char hbuf[NI_MAXHOST];
+  socklen_t addr_len = addr->sa_family == AF_INET ? sizeof(sockaddr_in) : sizeof(sockaddr_in6);
+  
   if ( getnameinfo(addr, addr_len, hbuf, sizeof(hbuf), NULL, 0, NI_NAMEREQD) == 0 ) {
-    char *tmp = (char *)malloc(strlen(hbuf) + 1);
-    if ( ! tmp ) {
-      throw OutOfMemoryException();
-    }
-    strcpy(tmp, hbuf);
-    *name = tmp;
-    *namefound = true;
+	  name = hbuf;
+    namefound = true;
     found = true;
   } else if ( getnameinfo(addr, addr_len, hbuf, sizeof(hbuf), NULL, 0, 0) == 0 ) {
-    char *tmp = (char *)malloc(strlen(hbuf) + 1);
-    if ( ! tmp ) {
-      throw OutOfMemoryException();
-    }
-    strcpy(tmp, hbuf);
-    *name = tmp;
-    *namefound = false;
+	  name = hbuf;
+    namefound = false;
     found = true;
   }
 
@@ -225,12 +206,11 @@ NetworkNameResolverThread::resolve_address_immediately(struct sockaddr *addr, so
  * @param name name to resolve
  */
 void
-NetworkNameResolverThread::resolve_name(const char *name)
+NetworkNameResolverThread::resolve_name(const std::string &name)
 {
   __namesq_mutex->lock();
-  if ( __namesq->find((char *)name) == __namesq->end() ) {
-    char *tmp = strdup(name);
-    __namesq->insert(tmp);
+  if ( __namesq->find(name) == __namesq->end() ) {
+    __namesq->insert(name);
     __namesq_mutex->unlock();
     wakeup();
   } else {
@@ -242,18 +222,18 @@ NetworkNameResolverThread::resolve_name(const char *name)
 /** Enqueue address for resolution.
  * The address is enqueued and the resolver thread woken up. The result is reported
  * to the resolver given to the constructor.
- * @param addr address to resolve, must be a struct sockaddr_in
+ * @param addr address to resolve, must be a struct sockaddr
  * @param addrlen length of addr
  */
 void
 NetworkNameResolverThread::resolve_address(struct sockaddr *addr, socklen_t addrlen)
 {
-  struct ::sockaddr_in *saddr = (struct ::sockaddr_in *)addr;
+	
   __addrq_mutex->lock();
-  if ( __addrq->find(saddr->sin_addr.s_addr) == __addrq->end() ) {
+  if ( std::find(__addrq->begin(), __addrq->end(), addr) == __addrq->end() ) {
     struct sockaddr *taddr = (struct sockaddr *)malloc(addrlen);
     memcpy(taddr, addr, addrlen);
-    (*__addrq)[saddr->sin_addr.s_addr] = std::make_pair(taddr, addrlen);
+    __addrq->push_back(taddr);
     __addrq_mutex->unlock();
     wakeup();
   } else {
@@ -274,7 +254,7 @@ NetworkNameResolverThread::resolve_address(struct sockaddr *addr, socklen_t addr
  */
 void
 NetworkNameResolverThread::resolved_name(char *name,
-					 struct sockaddr *addr, socklen_t addrlen)
+                                         struct sockaddr *addr, socklen_t addrlen)
 {
   __resolver->name_resolved(name, addr, addrlen);
 }
@@ -291,10 +271,10 @@ NetworkNameResolverThread::resolved_name(char *name,
  * @param addrlen length of addr in bytes
  */
 void
-NetworkNameResolverThread::resolved_address(struct sockaddr_in *addr, socklen_t addrlen,
-					    char *name)
+NetworkNameResolverThread::resolved_address(struct sockaddr *addr, socklen_t addrlen,
+                                            char *name)
 {
-  __resolver->addr_resolved((struct sockaddr *)addr, addrlen, name, true);
+  __resolver->addr_resolved(addr, addrlen, name, true);
 }
 
 
@@ -321,9 +301,9 @@ NetworkNameResolverThread::name_resolution_failed(char *name)
  * @param addrlen length of address
  */
 void
-NetworkNameResolverThread::address_resolution_failed(struct sockaddr_in *addr, socklen_t addrlen)
+NetworkNameResolverThread::address_resolution_failed(struct sockaddr *addr, socklen_t addrlen)
 {
-  __resolver->address_resolution_failed((struct sockaddr *)addr, addrlen);
+  __resolver->address_resolution_failed(addr, addrlen);
 }
 
 
@@ -338,17 +318,17 @@ NetworkNameResolverThread::loop()
   __addrq_active = 1 - __addrq_active;
   __addrq = &__addrqs[__addrq_active];
   __addrq_mutex->unlock();
-  AddrQMap::iterator aqit;
+  AddrQList::iterator aqit;
   while ( ! __addrq_proc->empty() ) {
     aqit = __addrq_proc->begin();
     
-    char *name;
+    std::string name;
     bool  namefound;
 
-    if ( resolve_address_immediately(aqit->second.first, aqit->second.second, &name, &namefound) ) {
-      __resolver->addr_resolved(aqit->second.first, aqit->second.second, name, namefound);
+    if ( resolve_address_immediately(*aqit, name, namefound) ) {
+	    __resolver->addr_resolved(*aqit, sock_addr_size(*aqit), name, namefound);
     } else {
-      __resolver->address_resolution_failed(aqit->second.first, aqit->second.second);
+      __resolver->address_resolution_failed(*aqit, sock_addr_size(*aqit));
     }
     __addrq_proc->erase(aqit);
   }
@@ -361,23 +341,15 @@ NetworkNameResolverThread::loop()
   NamesQMap::iterator nqit;
   while ( ! __namesq_proc->empty() ) {
     nqit = __namesq_proc->begin();
-    char *nqn = (*nqit);
-
     struct sockaddr *addr;
     socklen_t addrlen;
 
-    // we strdup here because otherwise we could not ensure
-    // that the erase operation below can still suceed!
-    // And even if we make it mandatory that the name_resolved will not
-    // free the memory we would have the problem that it would be
-    // unknown when the resolver may free the variable
-    if ( resolve_name_immediately(nqn, &addr, &addrlen) ) {
-      __resolver->name_resolved(strdup(nqn), addr, addrlen);
+    if ( resolve_name_immediately(*nqit, &addr, &addrlen) ) {
+      __resolver->name_resolved(*nqit, addr, addrlen);
     } else {
-      __resolver->name_resolution_failed(strdup(nqn));
+      __resolver->name_resolution_failed(*nqit);
     }
     __namesq_proc->erase(nqit);
-    free(nqn);
   }
 }
 
diff --git a/src/libs/netcomm/utils/resolver_thread.h b/src/libs/netcomm/utils/resolver_thread.h
index 45e80dd..17f8d80 100644
--- a/src/libs/netcomm/utils/resolver_thread.h
+++ b/src/libs/netcomm/utils/resolver_thread.h
@@ -37,6 +37,7 @@
 #include <cstddef>
 #include <utility>
 #include <map>
+#include <list>
 
 namespace fawkes {
 
@@ -55,18 +56,17 @@ class NetworkNameResolverThread : public Thread
                             AvahiThread *avahi_thread = NULL);
   ~NetworkNameResolverThread();
 
-  void resolve_name(const char *name);
+  void resolve_name(const std::string &name);
   void resolve_address(struct sockaddr *addr, socklen_t addrlen);
 
-  bool resolve_name_immediately(const char *name,
-				struct sockaddr **addr, socklen_t *addr_len);
-  bool resolve_address_immediately(struct sockaddr *addr, socklen_t addr_len,
-				   char **name, bool *namefound);
+  bool resolve_name_immediately(const std::string &name,
+                                struct sockaddr **addr, socklen_t *addr_len);
+  bool resolve_address_immediately(struct sockaddr *addr, std::string &name, bool &namefound);
 
   virtual void resolved_name(char *name, struct sockaddr *addr, socklen_t addrlen);
-  virtual void resolved_address(struct sockaddr_in *addr, socklen_t addrlen, char *name);
+  virtual void resolved_address(struct sockaddr *addr, socklen_t addrlen, char *name);
   virtual void name_resolution_failed(char *name);
-  virtual void address_resolution_failed(struct sockaddr_in *addr, socklen_t addrlen);
+  virtual void address_resolution_failed(struct sockaddr *addr, socklen_t addrlen);
 
   virtual void loop();
 
@@ -81,13 +81,7 @@ class NetworkNameResolverThread : public Thread
 
   Mutex *__namesq_mutex;
   unsigned int __namesq_active;
-#if __cplusplus >= 201103L || defined(_LIBCPP_VERSION)
-  typedef LockHashSet<char *, std::hash<char *>, StringEquality>  NamesQMap;
-#elif __GLIBCXX__ > 20080305
-  typedef LockHashSet<char *, std::tr1::hash<char *>, StringEquality>  NamesQMap;
-#else
-  typedef LockHashSet<char *, __gnu_cxx::hash<char *>, StringEquality> NamesQMap;
-#endif
+  typedef LockHashSet<std::string>  NamesQMap;
   NamesQMap   __namesqs[2];
   NamesQMap  *__namesq;
   NamesQMap  *__namesq_proc;
@@ -95,10 +89,10 @@ class NetworkNameResolverThread : public Thread
 
   Mutex *__addrq_mutex;
   unsigned int __addrq_active;
-  typedef std::map<uint32_t, std::pair<struct sockaddr *, socklen_t> > AddrQMap;
-  AddrQMap   __addrqs[2];
-  AddrQMap  *__addrq;
-  AddrQMap  *__addrq_proc;
+  typedef std::list<struct sockaddr *> AddrQList;
+  AddrQList   __addrqs[2];
+  AddrQList  *__addrq;
+  AddrQList  *__addrq_proc;
 };
 
 } // end namespace fawkes

- *commit* a5c08125501ca1e10a68643a1785aaf94373c24b - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Dec 14 21:50:18 2016 +0100
Subject: gui_utils: fix annoying GConf invalid key error

 src/libs/gui_utils/service_chooser_dialog.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 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 64bd732..a89fa84 100644
--- a/src/libs/gui_utils/service_chooser_dialog.cpp
+++ b/src/libs/gui_utils/service_chooser_dialog.cpp
@@ -37,7 +37,8 @@
 #include <netinet/in.h>
 
 #ifdef HAVE_GCONFMM
-#  define GCONF_PREFIX "/apps/fawkes/service_chooser_dialog/"
+#  define GCONF_DIR "/apps/fawkes/service_chooser_dialog"
+#  define GCONF_PREFIX GCONF_DIR"/"
 #endif
 
 namespace fawkes {
@@ -122,7 +123,7 @@ ServiceChooserDialog::ctor()
   Glib::ustring default_host("localhost");
 #ifdef HAVE_GCONFMM
   __gconf = Gnome::Conf::Client::get_default_client();
-  __gconf->add_dir(GCONF_PREFIX);
+  __gconf->add_dir(GCONF_DIR);
   Gnome::Conf::Value host_val =
     __gconf->get_without_default(GCONF_PREFIX"manual_host");
   if (host_val.get_type() == Gnome::Conf::VALUE_STRING) {

- *commit* 32e8cabb3d79baebec942e6fd6ff43be3fe04383 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Dec 14 22:00:12 2016 +0100
Subject: gui_utils: support IPv6 addresses in service chooser dialog

 src/libs/gui_utils/service_chooser_dialog.cpp |    4 ++--
 src/libs/gui_utils/service_model.cpp          |   24 +++++++++++++++++++++---
 2 files changed, 23 insertions(+), 5 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 a89fa84..ce7b61c 100644
--- a/src/libs/gui_utils/service_chooser_dialog.cpp
+++ b/src/libs/gui_utils/service_chooser_dialog.cpp
@@ -108,11 +108,11 @@ ServiceChooserDialog::~ServiceChooserDialog()
 void
 ServiceChooserDialog::ctor()
 {
-  set_default_size(400, 300);
+  set_default_size(480, 300);
 
   __treeview.set_model(__service_model->get_list_store());
   __treeview.append_column("Service", __service_model->get_column_record().name);
-  __treeview.append_column("IP Address", __service_model->get_column_record().ipaddr);
+  __treeview.append_column("Address/Port", __service_model->get_column_record().ipaddr);
   __scrollwin.add(__treeview);
   __scrollwin.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   __treeview.show();
diff --git a/src/libs/gui_utils/service_model.cpp b/src/libs/gui_utils/service_model.cpp
index 5fbf051..ee371b4 100644
--- a/src/libs/gui_utils/service_model.cpp
+++ b/src/libs/gui_utils/service_model.cpp
@@ -23,6 +23,7 @@
 
 #include <gui_utils/service_model.h>
 #include <netcomm/dns-sd/avahi_thread.h>
+#include <utils/misc/string_conversions.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -167,13 +168,30 @@ ServiceModel::service_added( const char* name,
 			    int flags )
 {
   ServiceAddedRecord s;
-  char ipaddr[INET_ADDRSTRLEN];
-  struct sockaddr_in *saddr = (struct sockaddr_in *)addr;
+  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);
+	  } else {
+		  s.ipaddr = 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);
+	  } else {
+		  s.ipaddr = std::string("Failed to convert IPv6: ") + strerror(errno);
+	  }
+  } else {
+	  s.ipaddr = "Unknown address family";
+  }
+
   s.name = string(name);
   s.type = string(type);
   s.domain = string(domain);
   s.hostname = string(host_name);
-  s.ipaddr = inet_ntop(AF_INET, &(saddr->sin_addr), ipaddr, sizeof(ipaddr));
   s.port = port;
 
   m_added_services.push_locked(s);

- *commit* 084abb59f3c1c9398d20e2a99243aeb5ebbf9848 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Dec 14 22:01:07 2016 +0100
Subject: utils: parse_host funcs no longer modify port if not given

 src/libs/utils/system/argparser.cpp |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/utils/system/argparser.cpp b/src/libs/utils/system/argparser.cpp
index 68f0583..29088ce 100644
--- a/src/libs/utils/system/argparser.cpp
+++ b/src/libs/utils/system/argparser.cpp
@@ -271,7 +271,9 @@ ArgumentParser::parse_hostport_s(const char *s, char **host,
 	if (num_colons == 1) {
 		idx = tmp.find(':');
 		*host = strdup(tmp.substr(0, idx).c_str());
-		*port = atoi(tmp.substr(idx+1).c_str());
+		if (! tmp.substr(idx+1).empty()) {
+			*port = atoi(tmp.substr(idx+1).c_str());
+		}
 	} else if (num_colons > 1) {
 		// IPv6
 		if (tmp[0] == '[') {
@@ -292,17 +294,14 @@ ArgumentParser::parse_hostport_s(const char *s, char **host,
 			} else {
 				// Just an IPv6 in bracket notation
 				*host = strdup(tmp.substr(1, closing_idx - 2).c_str());
-				*port = 0;
 			}
 		} else {
 			// no port, just an IPv6 address
 			*host = strdup(tmp.c_str());
-			*port = 0;
 		}
 	} else {
 		// no port given
 		*host = strdup(tmp.c_str());
-		*port = 0;
 	}
 }
 
@@ -326,7 +325,7 @@ ArgumentParser::parse_hostport(const char *argn, std::string &host, unsigned sho
   if ((__opts.count(argn) == 0) || (__opts[argn] == NULL)) return false;
 
   char *tmp_host = NULL;
-  unsigned short int tmp_port = 0;
+  unsigned short int tmp_port = port;
   if (parse_hostport(argn, &tmp_host, &tmp_port)) {
 	  host = tmp_host;
 	  port = tmp_port;
@@ -352,7 +351,7 @@ void
 ArgumentParser::parse_hostport_s(const char *s, std::string &host, unsigned short int &port)
 {
   char *tmp_host = NULL;
-  unsigned short int tmp_port = 0;
+  unsigned short int tmp_port = port;
   parse_hostport_s(s, &tmp_host, &tmp_port);
   host = tmp_host;
   port = tmp_port;

- *commit* 90fe9e077fe80a0c9c96d015005aefa7f92965e1 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Dec 14 22:02:04 2016 +0100
Subject: ffplugin: better error message on connect fail

 src/tools/plugin/main.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/plugin/main.cpp b/src/tools/plugin/main.cpp
index 7e98717..c48eff0 100644
--- a/src/tools/plugin/main.cpp
+++ b/src/tools/plugin/main.cpp
@@ -55,7 +55,7 @@ main(int argc, char **argv)
   try {
     c->connect();
   } catch( Exception &e ) {
-    printf("Could not connect to host: %s\n", host.c_str());
+	  printf("Could not connect to host: %s (%s)\n", host.c_str(), e.what_no_backtrace());
     exit(1);
   }
 

- *commit* 2ebef0258d26485f943597f77a183b396c4e347c - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Dec 14 22:02:32 2016 +0100
Subject: libbaseapp: informative messages regarding IPv4/IPv6

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

_Diff for modified files_:
diff --git a/src/libs/baseapp/run.cpp b/src/libs/baseapp/run.cpp
index 5cda9cb..d5ce64d 100644
--- a/src/libs/baseapp/run.cpp
+++ b/src/libs/baseapp/run.cpp
@@ -331,6 +331,19 @@ init(InitOptions options, int & retval)
 	  listen_ipv6 = config->get_string("/fawkes/mainapp/net/ipv6/listen");
   } catch (Exception &e) {}  // ignore, we stick with the default
 
+  if (! enable_ipv4) {
+	  logger->log_warn("FawkesMainThread", "Disabling IPv4 support");
+  }
+  if (! enable_ipv6) {
+	  logger->log_warn("FawkesMainThread", "Disabling IPv6 support");
+  }
+  if (! listen_ipv4.empty()) {
+	  logger->log_info("FawkesMainThread", "Listening on IPv4 address %s", listen_ipv4.c_str());
+  }
+  if (! listen_ipv6.empty()) {
+	  logger->log_info("FawkesMainThread", "Listening on IPv6 address %s", listen_ipv4.c_str());
+  }
+  
   // *** Setup blackboard
   std::string bb_magic_token = "";
   unsigned int bb_size = 2097152;

- *commit* ad4ccda804139b913dda9cb981bf1013c372ec9e - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Wed Dec 14 22:03:33 2016 +0100
Subject: skillgui: fix invalid icon size warning

 res/guis/skillgui/skillgui.ui |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

_Diff for modified files_:
diff --git a/res/guis/skillgui/skillgui.ui b/res/guis/skillgui/skillgui.ui
index 50e4bff..57fe4b7 100644
--- a/res/guis/skillgui/skillgui.ui
+++ b/res/guis/skillgui/skillgui.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
   <object class="GtkMenu" id="menu_graphdir">
@@ -21,7 +21,6 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="toolbar_style">icons</property>
-            <property name="icon_size">0</property>
             <child>
               <object class="GtkToolButton" id="tb_connection">
                 <property name="use_action_appearance">False</property>




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


More information about the fawkes-commits mailing list