struct sockaddr_storage remote;
char s[NI_MAXHOST];
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving remote hostname and IP address"));
struct sockaddr_in remote;
char *host_ip;
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving remote hostname and IP address"));
return FALSE;
#endif
- /* Get host by address */
- if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
- return FALSE;
+ /* Do reverse lookup if we want hostname too. */
+ if (hostname) {
+ /* Get host by address */
+ if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
+ return FALSE;
- *hostname = silc_memdup(host, strlen(host));
- SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
+ *hostname = silc_memdup(host, strlen(host));
+ SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
- /* Reverse */
- if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
- return FALSE;
+ /* Reverse */
+ if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
+ return FALSE;
- if (strcmp(*ip, host))
- return FALSE;
+ if (strcmp(*ip, host))
+ return FALSE;
+ }
SILC_LOG_DEBUG(("Resolved IP address `%s'", *ip));
return TRUE;
struct sockaddr_storage local;
char s[NI_MAXHOST];
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving local hostname and IP address"));
struct sockaddr_in local;
char *host_ip;
- *hostname = NULL;
+ if (hostname)
+ *hostname = NULL;
*ip = NULL;
SILC_LOG_DEBUG(("Resolving local hostname and IP address"));
return FALSE;
#endif
- /* Get host by address */
- if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
- return FALSE;
+ /* Do reverse lookup if we want hostname too. */
+ if (hostname) {
+ /* Get host by address */
+ if (!silc_net_gethostbyaddr(*ip, host, sizeof(host)))
+ return FALSE;
- *hostname = silc_memdup(host, strlen(host));
- SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
+ *hostname = silc_memdup(host, strlen(host));
+ SILC_LOG_DEBUG(("Resolved hostname `%s'", *hostname));
- /* Reverse */
- if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
- return FALSE;
+ /* Reverse */
+ if (!silc_net_gethostbyname(*hostname, TRUE, host, sizeof(host)))
+ return FALSE;
- if (strcmp(*ip, host))
- return FALSE;
+ if (strcmp(*ip, host))
+ return FALSE;
+ }
SILC_LOG_DEBUG(("Resolved IP address `%s'", *ip));
return TRUE;