plat win add ibterface to sa
authorEmerson Clarke <emerson@openfin.co>
Thu, 6 Nov 2014 15:06:01 +0000 (23:06 +0800)
committerAndy Green <andy.green@linaro.org>
Thu, 6 Nov 2014 15:06:01 +0000 (23:06 +0800)
lib/lws-plat-win.c

index b33f79c..2c9c97f 100644 (file)
@@ -250,7 +250,20 @@ LWS_VISIBLE int
 interface_to_sa(struct libwebsocket_context *context,
                const char *ifname, struct sockaddr_in *addr, size_t addrlen)
 {
-       return -1;
+       long long address = inet_addr(ifname);
+
+       if (address == INADDR_NONE) {
+               struct hostent *entry = gethostbyname(ifname);
+               if (entry)
+                       address = ((struct in_addr *)entry->h_addr_list[0])->s_addr;
+       }
+
+       if (address == INADDR_NONE)
+               return -1;
+
+       addr->sin_addr.s_addr = address;
+
+       return 0;
 }
 
 LWS_VISIBLE void