Set socklen explicitly to make OSX happy when sending data
authorSakari Poussa <sakari.poussa@intel.com>
Mon, 10 Aug 2015 09:48:19 +0000 (12:48 +0300)
committerErich Keane <erich.keane@intel.com>
Mon, 10 Aug 2015 15:13:52 +0000 (15:13 +0000)
Change-Id: I57e6360bcd2fe26ff2b0cc6cce82011519e84485
Signed-off-by: Sakari Poussa <sakari.poussa@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2153
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: John Light <john.j.light@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/ip_adapter/caipserver.c

index 7ee0f4b..3568b65 100644 (file)
@@ -694,6 +694,7 @@ static void sendData(int fd, const CAEndpoint_t *endpoint,
     struct sockaddr_storage sock;
     CAConvertNameToAddr(endpoint->addr, endpoint->port, &sock);
 
+    socklen_t socklen;
     if (sock.ss_family == AF_INET6)
     {
         struct sockaddr_in6 *sock6 = (struct sockaddr_in6 *)&sock;
@@ -701,9 +702,14 @@ static void sendData(int fd, const CAEndpoint_t *endpoint,
         {
             sock6->sin6_scope_id = endpoint->interface;
         }
+        socklen = sizeof(struct sockaddr_in6);
+    }
+    else
+    {
+        socklen = sizeof(struct sockaddr_in);
     }
 
-    ssize_t len = sendto(fd, data, dlen, 0, (struct sockaddr *)&sock, sizeof (sock));
+    ssize_t len = sendto(fd, data, dlen, 0, (struct sockaddr *)&sock, socklen);
     if (-1 == len)
     {
          // If logging is not defined/enabled.