|
Lines 321-326
clear_cached_addr(void)
Link Here
|
| 321 |
cached_port = -1; |
321 |
cached_port = -1; |
| 322 |
} |
322 |
} |
| 323 |
|
323 |
|
|
|
324 |
void set_remote_ipaddr(void) { |
| 325 |
if (canonical_host_ip != NULL) |
| 326 |
free(canonical_host_ip); |
| 327 |
|
| 328 |
if (packet_connection_is_on_socket()) { |
| 329 |
canonical_host_ip = |
| 330 |
get_peer_ipaddr(packet_get_connection_in()); |
| 331 |
if (canonical_host_ip == NULL) |
| 332 |
cleanup_exit(255); |
| 333 |
} else { |
| 334 |
/* If not on socket, return UNKNOWN. */ |
| 335 |
canonical_host_ip = xstrdup("UNKNOWN"); |
| 336 |
} |
| 337 |
} |
| 338 |
|
| 324 |
/* |
339 |
/* |
| 325 |
* Returns the IP-address of the remote host as a string. The returned |
340 |
* Returns the IP-address of the remote host as a string. The returned |
| 326 |
* string must not be freed. |
341 |
* string must not be freed. |
|
Lines 330-346
const char *
Link Here
|
| 330 |
get_remote_ipaddr(void) |
345 |
get_remote_ipaddr(void) |
| 331 |
{ |
346 |
{ |
| 332 |
/* Check whether we have cached the ipaddr. */ |
347 |
/* Check whether we have cached the ipaddr. */ |
| 333 |
if (canonical_host_ip == NULL) { |
348 |
if (canonical_host_ip == NULL) |
| 334 |
if (packet_connection_is_on_socket()) { |
349 |
set_remote_ipaddr(); |
| 335 |
canonical_host_ip = |
350 |
|
| 336 |
get_peer_ipaddr(packet_get_connection_in()); |
|
|
| 337 |
if (canonical_host_ip == NULL) |
| 338 |
cleanup_exit(255); |
| 339 |
} else { |
| 340 |
/* If not on socket, return UNKNOWN. */ |
| 341 |
canonical_host_ip = xstrdup("UNKNOWN"); |
| 342 |
} |
| 343 |
} |
| 344 |
return canonical_host_ip; |
351 |
return canonical_host_ip; |
| 345 |
} |
352 |
} |
| 346 |
|
353 |
|