Don't return request socket info if they don't exist, return FALSE.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 20 Nov 2006 14:54:26 +0000 (14:54 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 20 Nov 2006 14:54:26 +0000 (14:54 +0000)
lib/silcutil/silcsocketstream.c
lib/silcutil/silcsocketstream.h

index b599dabf732f46664ab32fae32f67f68a864dff5..86e915b73c58ebfdd4e16ebbda9ccb8ed8b7c17d 100644 (file)
@@ -263,12 +263,21 @@ SilcBool silc_socket_stream_get_info(SilcStream stream,
 
   if (sock)
     *sock = socket_stream->sock;
-  if (hostname)
+  if (hostname) {
+    if (!socket_stream->hostname)
+      return FALSE;
     *hostname = socket_stream->hostname;
-  if (ip)
+  }
+  if (ip) {
+    if (!socket_stream->ip)
+      return FALSE;
     *ip = socket_stream->ip;
-  if (port)
+  }
+  if (port) {
+    if (!socket_stream->port)
+      return FALSE;
     *port = socket_stream->port;
+  }
 
   return TRUE;
 }
@@ -295,6 +304,11 @@ SilcBool silc_socket_stream_set_info(SilcStream stream,
     socket_stream->ip = strdup(ip);
     if (!socket_stream->ip)
       return FALSE;
+    if (!socket_stream->hostname) {
+      socket_stream->hostname = strdup(ip);
+      if (!socket_stream->hostname)
+       return FALSE;
+    }
   }
   if (port)
     socket_stream->port = port;
index 17e64b5a4372da0ad78e25e84f7bef308f8fd118..f135ca54755a618ad9dbab2386ebcfa9f90d0b3b 100644 (file)
@@ -108,7 +108,8 @@ typedef void (*SilcSocketStreamCallback)(SilcSocketStreamStatus status,
  *    have valid hostname and IP address, otherwise the stream creation will
  *    fail.  If it is FALSE then only valid IP address is required.  Note that,
  *    if the `lookup' is FALSE then the hostname, IP and port information
- *    will not be available from the socket stream.
+ *    will not be available from the socket stream.  In that case this will
+ *    also return NULL as the `callback' is called immediately.
  *
  ***/
 SilcAsyncOperation
@@ -180,11 +181,12 @@ SilcBool silc_socket_stream_get_info(SilcStream stream,
  *
  *    Use this function to set the hostname, IP address and remote port
  *    information to the socket stream indicated by `stream' if you did not
- *    perform lookup in the silc_socket_create_stream.  This is not mandatory
- *    but if you would like to associate the information with the stream
- *    use this function.  If the lookup was performed when creating the
- *    stream then calling this function is not necessary.  Use the function
- *    silc_socket_stream_get_info to get the information from the stream.
+ *    perform lookup in the silc_socket_tcp_stream_create.  This is not
+ *    mandatory but if you would like to associate the information with the
+ *    stream use this function.  If the lookup was performed when creating
+ *    the stream then calling this function is not necessary.  Use the
+ *    function silc_socket_stream_get_info to get the information from the
+ *    stream.
  *
  ***/
 SilcBool silc_socket_stream_set_info(SilcStream stream,