[Fawkes Git] branch/timn/netcomm-ipv6: 6 revs updated. (0.5.0-3409-g993f1e4)

Tim Niemueller niemueller at kbsg.rwth-aachen.de
Fri Dec 16 18:53:34 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  993f1e4bc92b6487cde1647b2af9fbab1d6a3c06 (commit)
       via  c0078babe157fa105328a0cda3e226c88ead2a0f (commit)
       via  be2af409be1f0a093008c9982136078f2ef83e56 (commit)
       via  a021c3a96854b92a53e1301a7e50676dab9c4082 (commit)
       via  ef50309622fdb59ff93e74a3133491e06a9c862f (commit)
       via  23df43bc2532b5881ea0feebe310c33517001c19 (commit)
      from  90053507c52485ba66d72ec219c8005f05568e72 (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 23df43bc2532b5881ea0feebe310c33517001c19
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:49:25 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:49:25 2016 +0100

    netcomm: change service handler signature to include interface
    
    Always determine the interface for a given service and pass this on to
    browse handlers. This requires a change of the API.

http://git.fawkesrobotics.org/fawkes.git/commit/23df43b
http://trac.fawkesrobotics.org/changeset/23df43b

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

    webview: adapt to browse handler API change

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit a021c3a96854b92a53e1301a7e50676dab9c4082
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:51:08 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:51:08 2016 +0100

    batterymon: adapt to browse handler API change

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

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

    fvnet: adapt to browse handler API change

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit c0078babe157fa105328a0cda3e226c88ead2a0f
Author:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
AuthorDate: Fri Dec 16 18:51:42 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Fri Dec 16 18:51:42 2016 +0100

    gui_utils: adapt AvahiDispatcher to API change

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

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

    gui_utils: adapt to API change, always show interface for IPv6
    
    Show interface name in scope ID notation for IPv6 addresses. Makes it
    easier to understand what's going on.

http://git.fawkesrobotics.org/fawkes.git/commit/993f1e4
http://trac.fawkesrobotics.org/changeset/993f1e4

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


- *Summary* -----------------------------------------------------------
 src/libs/gui_utils/avahi_dispatcher.cpp            |    1 +
 src/libs/gui_utils/avahi_dispatcher.h              |    1 +
 src/libs/gui_utils/service_model.cpp               |   16 +++---
 src/libs/gui_utils/service_model.h                 |    5 ++-
 src/libs/netcomm/dns-sd/avahi_thread.cpp           |   58 ++++++++++----------
 .../netcomm/service_discovery/browse_handler.h     |    2 +
 src/plugins/webview/service_browse_handler.cpp     |    1 +
 src/plugins/webview/service_browse_handler.h       |    1 +
 src/tools/battery_monitor/battery_monitor.cpp      |    1 +
 src/tools/battery_monitor/battery_monitor.h        |    1 +
 src/tools/vision/net.cpp                           |    1 +
 11 files changed, 52 insertions(+), 36 deletions(-)


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

- *commit* 23df43bc2532b5881ea0feebe310c33517001c19 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:49:25 2016 +0100
Subject: netcomm: change service handler signature to include interface

 src/libs/netcomm/dns-sd/avahi_thread.cpp           |   58 ++++++++++----------
 .../netcomm/service_discovery/browse_handler.h     |    2 +
 2 files changed, 32 insertions(+), 28 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 7971fca..cdc9455 100644
--- a/src/libs/netcomm/dns-sd/avahi_thread.cpp
+++ b/src/libs/netcomm/dns-sd/avahi_thread.cpp
@@ -644,7 +644,15 @@ AvahiThread::call_handler_service_added( const char *name,
                                          std::list<std::string> &txt,
                                          AvahiLookupResultFlags flags)
 {
-  struct sockaddr *s = NULL;
+	char ifname[IF_NAMESIZE];
+	ifname[0] = 0;
+	if (if_indextoname(interface, ifname) == NULL) {
+		fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 if_indextoname failed");
+		return;
+	}
+		
+
+	struct sockaddr *s = NULL;
   socklen_t slen;
   if ( address->proto == AVAHI_PROTO_INET ) {
 	  if (! enable_ipv4)  return;
@@ -661,39 +669,33 @@ AvahiThread::call_handler_service_added( const char *name,
     sin->sin6_family = AF_INET6;
     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;
-			    }
+    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);
+			    printf("Scope %u  interface %u\n", sin->sin6_scope_id, interface);
+			    freeaddrinfo(res);
 		    } else {
-			    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 getaddrinfo failed");
-			    return;
+			    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 address lengths different");
+			    freeaddrinfo(res);
+				    return;
 		    }
 	    } else {
-		    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 inet_ntop failed");
+		    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 getaddrinfo failed");
 		    return;
 	    }
     } else {
-	    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 if_indextoname failed");
+	    fprintf(stderr, "AvahiThread::call_handler_service_added: IPv6 inet_ntop failed");
 	    return;
-
     }
     s = (struct sockaddr *)sin;
   } else {
@@ -703,7 +705,7 @@ 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,
+	    (*i)->service_added(name, type, domain, host_name, ifname,
 	                        (struct sockaddr *)s, slen, port, txt, (int)flags);
     }
   }
diff --git a/src/libs/netcomm/service_discovery/browse_handler.h b/src/libs/netcomm/service_discovery/browse_handler.h
index 535ad17..8ff316a 100644
--- a/src/libs/netcomm/service_discovery/browse_handler.h
+++ b/src/libs/netcomm/service_discovery/browse_handler.h
@@ -74,6 +74,7 @@ class ServiceBrowseHandler
    * @param type type of the service
    * @param domain domain of the service
    * @param host_name name of the host that provides the service
+   * @param interface name of network interface to reach service
    * @param addr pointer to sockaddr struct of appropriate type for address
    * @param addr_size size of addr struct
    * @param port port of the service
@@ -84,6 +85,7 @@ class ServiceBrowseHandler
 			     const char *type,
 			     const char *domain,
 			     const char *host_name,
+           const char *interface,
 			     const struct sockaddr *addr,
 			     const socklen_t addr_size,
 			     uint16_t port,

- *commit* ef50309622fdb59ff93e74a3133491e06a9c862f - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:50:15 2016 +0100
Subject: webview: adapt to browse handler API change

 src/plugins/webview/service_browse_handler.cpp |    1 +
 src/plugins/webview/service_browse_handler.h   |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/webview/service_browse_handler.cpp b/src/plugins/webview/service_browse_handler.cpp
index 07b42f6..a56bee6 100644
--- a/src/plugins/webview/service_browse_handler.cpp
+++ b/src/plugins/webview/service_browse_handler.cpp
@@ -83,6 +83,7 @@ WebviewServiceBrowseHandler::service_added(const char *name,
 					   const char *type,
 					   const char *domain,
 					   const char *host_name,
+					   const char *interface,
 					   const struct sockaddr *addr,
 					   const socklen_t addr_size,
 					   uint16_t port,
diff --git a/src/plugins/webview/service_browse_handler.h b/src/plugins/webview/service_browse_handler.h
index 3fb9817..7b13693 100644
--- a/src/plugins/webview/service_browse_handler.h
+++ b/src/plugins/webview/service_browse_handler.h
@@ -48,6 +48,7 @@ class WebviewServiceBrowseHandler : public fawkes::ServiceBrowseHandler
 			     const char *type,
 			     const char *domain,
 			     const char *host_name,
+			     const char *interface,
 			     const struct sockaddr *addr,
 			     const socklen_t addr_size,
 			     uint16_t port,

- *commit* a021c3a96854b92a53e1301a7e50676dab9c4082 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:51:08 2016 +0100
Subject: batterymon: adapt to browse handler API change

 src/tools/battery_monitor/battery_monitor.cpp |    1 +
 src/tools/battery_monitor/battery_monitor.h   |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/battery_monitor/battery_monitor.cpp b/src/tools/battery_monitor/battery_monitor.cpp
index 4f9add0..9e82009 100644
--- a/src/tools/battery_monitor/battery_monitor.cpp
+++ b/src/tools/battery_monitor/battery_monitor.cpp
@@ -88,6 +88,7 @@ BatteryMonitor::service_added( const char* name,
 			       const char* type,
 			       const char* domain,
 			       const char* host_name,
+			       const char* interface,
 			       const struct sockaddr* addr,
 			       const socklen_t addr_size,
 			       uint16_t port,
diff --git a/src/tools/battery_monitor/battery_monitor.h b/src/tools/battery_monitor/battery_monitor.h
index f4481f1..38f22e7 100644
--- a/src/tools/battery_monitor/battery_monitor.h
+++ b/src/tools/battery_monitor/battery_monitor.h
@@ -57,6 +57,7 @@ class BatteryMonitor
 		      const char* type,
 		      const char* domain,
 		      const char* host_name,
+		      const char* interface,
 		      const struct sockaddr* addr,
 		      const socklen_t addr_size,
 		      uint16_t port,

- *commit* be2af409be1f0a093008c9982136078f2ef83e56 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:51:16 2016 +0100
Subject: fvnet: adapt to browse handler API change

 src/tools/vision/net.cpp |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/vision/net.cpp b/src/tools/vision/net.cpp
index aa4f32e..f6f4136 100644
--- a/src/tools/vision/net.cpp
+++ b/src/tools/vision/net.cpp
@@ -250,6 +250,7 @@ class FireVisionNetworkTool
 			     const char *type,
 			     const char *domain,
 			     const char *host_name,
+			     const char *interface,
 			     const struct sockaddr *addr,
 			     const socklen_t addr_size,
 			     uint16_t port,

- *commit* c0078babe157fa105328a0cda3e226c88ead2a0f - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:51:42 2016 +0100
Subject: gui_utils: adapt AvahiDispatcher to API change

 src/libs/gui_utils/avahi_dispatcher.cpp |    1 +
 src/libs/gui_utils/avahi_dispatcher.h   |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/gui_utils/avahi_dispatcher.cpp b/src/libs/gui_utils/avahi_dispatcher.cpp
index 2d9ceda..9ffb382 100644
--- a/src/libs/gui_utils/avahi_dispatcher.cpp
+++ b/src/libs/gui_utils/avahi_dispatcher.cpp
@@ -126,6 +126,7 @@ AvahiDispatcher::service_added(const char *name,
 			       const char *type,
 			       const char *domain,
 			       const char *host_name,
+			       const char *interface,
 			       const struct sockaddr *addr,
 			       const socklen_t addr_size,
 			       uint16_t port,
diff --git a/src/libs/gui_utils/avahi_dispatcher.h b/src/libs/gui_utils/avahi_dispatcher.h
index 493c1d8..d3c9e36 100644
--- a/src/libs/gui_utils/avahi_dispatcher.h
+++ b/src/libs/gui_utils/avahi_dispatcher.h
@@ -59,6 +59,7 @@ class AvahiDispatcher
 			     const char *type,
 			     const char *domain,
 			     const char *host_name,
+			     const char *interface,
 			     const struct sockaddr *addr,
 			     const socklen_t addr_size,
 			     uint16_t port,

- *commit* 993f1e4bc92b6487cde1647b2af9fbab1d6a3c06 - - - - - - - - - -
Author:  Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
Date:    Fri Dec 16 18:52:05 2016 +0100
Subject: gui_utils: adapt to API change, always show interface for IPv6

 src/libs/gui_utils/service_model.cpp |   16 +++++++++-------
 src/libs/gui_utils/service_model.h   |    5 ++++-
 2 files changed, 13 insertions(+), 8 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/gui_utils/service_model.cpp b/src/libs/gui_utils/service_model.cpp
index 3e1f017..b17ed60 100644
--- a/src/libs/gui_utils/service_model.cpp
+++ b/src/libs/gui_utils/service_model.cpp
@@ -158,7 +158,7 @@ ServiceModel::browse_failed( const char* name,
 
 void
 ServiceModel::service_added( const char* name, const char* type,
-                             const char* domain, const char* host_name,
+                             const char* domain, const char* host_name, const char *interface,
                              const struct sockaddr* addr, const socklen_t addr_size,
                              uint16_t port, std::list<std::string>& txt, int flags )
 {
@@ -178,7 +178,7 @@ ServiceModel::service_added( const char* name, const char* type,
 	  struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)addr;
 	  if (inet_ntop(AF_INET6, &(saddr->sin6_addr), ipaddr, sizeof(ipaddr)) != NULL) {
 		  s.ipaddr   = ipaddr;
-		  s.addrport = std::string("[") + ipaddr + "]:" + StringConversions::to_string(port);
+		  s.addrport = std::string("[") + ipaddr + "%" + interface + "]:" + StringConversions::to_string(port);
 	  } else {
 		  s.ipaddr = "";
 		  s.addrport = std::string("Failed to convert IPv6: ") + strerror(errno);
@@ -188,11 +188,12 @@ ServiceModel::service_added( const char* name, const char* type,
 	  s.addrport = "Unknown address family";
   }
 
-  s.name = string(name);
-  s.type = string(type);
-  s.domain = string(domain);
-  s.hostname = string(host_name);
-  s.port = port;
+  s.name      = name;
+  s.type      = type;
+  s.domain    = domain;
+  s.hostname  = host_name;
+  s.interface = interface;
+  s.port      = port;
   memcpy(&s.sockaddr, addr, addr_size);
 
   m_added_services.push_locked(s);
@@ -229,6 +230,7 @@ ServiceModel::on_service_added()
       row[m_service_record.type]     = s.type;
       row[m_service_record.domain]   = s.domain;
       row[m_service_record.hostname] = s.hostname;
+      row[m_service_record.interface] = s.interface;
       row[m_service_record.ipaddr]   = s.ipaddr;
       row[m_service_record.port]     = s.port;
       row[m_service_record.addrport] = s.addrport;
diff --git a/src/libs/gui_utils/service_model.h b/src/libs/gui_utils/service_model.h
index 3e7b46a..376e6cb 100644
--- a/src/libs/gui_utils/service_model.h
+++ b/src/libs/gui_utils/service_model.h
@@ -49,6 +49,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
 	  add(type);
 	  add(domain);
 	  add(hostname);
+	  add(interface);
 	  add(ipaddr);
 	  add(port);
 	  add(addrport);
@@ -59,6 +60,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
       Gtk::TreeModelColumn<Glib::ustring> type;      /**< The type of the service */
       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> interface; /**< Name of network interface to reach service */
       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 */
@@ -75,7 +77,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
                       const char* type,
                       const char* domain );
   void service_added( const char* name, const char* type,
-                      const char* domain, const char* host_name,
+                      const char* domain, const char* host_name, const char *interface,
                       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 );
@@ -86,6 +88,7 @@ class ServiceModel : public fawkes::ServiceBrowseHandler
     std::string type;      /**< the type of the new service */
     std::string domain;    /**< the domain of the new service */
     std::string hostname;  /**< the hostname of the new service */
+    std::string interface; /**< name of network interface to reach 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 */




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


More information about the fawkes-commits mailing list