updates.
[silc.git] / lib / silcutil / win32 / silcwin32net.c
index 2e1338a1f7ecfbeaa9cdaffc0ead483d1597dd72..e8fcc26a2195ae834fb08658c390468e094f31b1 100644 (file)
@@ -99,7 +99,8 @@ void silc_net_close_server(int sock)
    socket or -1 on error. This blocks the process while trying to create
    the connection. */
 
-int silc_net_create_connection(int port, char *host)
+int silc_net_create_connection(const char *local_ip, int port, 
+                              const char *host)
 {
   SOCKET sock;
   int rval, err;
@@ -111,7 +112,8 @@ int silc_net_create_connection(int port, char *host)
   /* Do host lookup */
   dest = gethostbyname(host);
   if (!dest) {
-    SILC_LOG_ERROR(("Network (%s) unreachable", host));
+    SILC_LOG_ERROR(("Network (%s) unreachable: could not resolve the "
+                   "IP address", host));
     return -1;
   }
 
@@ -154,7 +156,8 @@ int silc_net_create_connection(int port, char *host)
    connection returns directly. To get the result of the connect() one
    must select() the socket and read the result after it's ready. */
 
-int silc_net_create_connection_async(int port, char *host)
+int silc_net_create_connection_async(const char *local_ip, int port, 
+                                    const char *host)
 {
   SOCKET sock;
   int rval, err;
@@ -167,7 +170,8 @@ int silc_net_create_connection_async(int port, char *host)
   /* Do host lookup */
   dest = gethostbyname(host);
   if (!dest) {
-    SILC_LOG_ERROR(("Network (%s) unreachable", host));
+    SILC_LOG_ERROR(("Network (%s) unreachable: could not resolve the "
+                   "IP address", host));
     return -1;
   }
 
@@ -218,8 +222,7 @@ void silc_net_close_connection(int sock)
 /* Converts the IP number string from numbers-and-dots notation to
    binary form. */
 
-bool silc_net_addr2bin(const char *addr, unsigned char *bin,
-                      uint32 bin_len)
+bool silc_net_addr2bin(const char *addr, void *bin, uint32 bin_len);
 {
   unsigned long ret;
 
@@ -228,7 +231,24 @@ bool silc_net_addr2bin(const char *addr, unsigned char *bin,
   if (bin_len < 4)
     return FALSE;
 
-  SILC_PUT32_LSB(ret, bin);
+  memcpy(bin, (unsigned char *)&tmp.s_addr, 4);
+  return ret != INADDR_NONE;
+}
+
+/* Converts the IP number string from numbers-and-dots notation to
+   binary form in network byte order. */
+
+bool silc_net_addr2bin_ne(const char *addr, unsigned char *bin,
+                         uint32 bin_len)
+{
+  unsigned long ret;
+
+  ret = inet_addr(addr);
+
+  if (bin_len < 4)
+    return FALSE;
+
+  SILC_PUT32_MSB(ret, bin);
 
   return ret != INADDR_NONE;
 }