diff options
Diffstat (limited to 'canohost.c')
-rw-r--r-- | canohost.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/canohost.c b/canohost.c index 54369d49b..057f061b6 100644 --- a/canohost.c +++ b/canohost.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: canohost.c,v 1.39 2004/03/31 21:58:47 djm Exp $"); | 15 | RCSID("$OpenBSD: canohost.c,v 1.40 2004/06/21 17:36:31 avsm Exp $"); |
16 | 16 | ||
17 | #include "packet.h" | 17 | #include "packet.h" |
18 | #include "xmalloc.h" | 18 | #include "xmalloc.h" |
@@ -28,7 +28,7 @@ static void ipv64_normalise_mapped(struct sockaddr_storage *, socklen_t *); | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | static char * | 30 | static char * |
31 | get_remote_hostname(int socket, int use_dns) | 31 | get_remote_hostname(int sock, int use_dns) |
32 | { | 32 | { |
33 | struct sockaddr_storage from; | 33 | struct sockaddr_storage from; |
34 | int i; | 34 | int i; |
@@ -39,13 +39,13 @@ get_remote_hostname(int socket, int use_dns) | |||
39 | /* Get IP address of client. */ | 39 | /* Get IP address of client. */ |
40 | fromlen = sizeof(from); | 40 | fromlen = sizeof(from); |
41 | memset(&from, 0, sizeof(from)); | 41 | memset(&from, 0, sizeof(from)); |
42 | if (getpeername(socket, (struct sockaddr *)&from, &fromlen) < 0) { | 42 | if (getpeername(sock, (struct sockaddr *)&from, &fromlen) < 0) { |
43 | debug("getpeername failed: %.100s", strerror(errno)); | 43 | debug("getpeername failed: %.100s", strerror(errno)); |
44 | cleanup_exit(255); | 44 | cleanup_exit(255); |
45 | } | 45 | } |
46 | 46 | ||
47 | if (from.ss_family == AF_INET) | 47 | if (from.ss_family == AF_INET) |
48 | check_ip_options(socket, ntop); | 48 | check_ip_options(sock, ntop); |
49 | 49 | ||
50 | ipv64_normalise_mapped(&from, &fromlen); | 50 | ipv64_normalise_mapped(&from, &fromlen); |
51 | 51 | ||
@@ -138,7 +138,7 @@ get_remote_hostname(int socket, int use_dns) | |||
138 | */ | 138 | */ |
139 | /* IPv4 only */ | 139 | /* IPv4 only */ |
140 | static void | 140 | static void |
141 | check_ip_options(int socket, char *ipaddr) | 141 | check_ip_options(int sock, char *ipaddr) |
142 | { | 142 | { |
143 | #ifdef IP_OPTIONS | 143 | #ifdef IP_OPTIONS |
144 | u_char options[200]; | 144 | u_char options[200]; |
@@ -152,7 +152,7 @@ check_ip_options(int socket, char *ipaddr) | |||
152 | else | 152 | else |
153 | ipproto = IPPROTO_IP; | 153 | ipproto = IPPROTO_IP; |
154 | option_size = sizeof(options); | 154 | option_size = sizeof(options); |
155 | if (getsockopt(socket, ipproto, IP_OPTIONS, options, | 155 | if (getsockopt(sock, ipproto, IP_OPTIONS, options, |
156 | &option_size) >= 0 && option_size != 0) { | 156 | &option_size) >= 0 && option_size != 0) { |
157 | text[0] = '\0'; | 157 | text[0] = '\0'; |
158 | for (i = 0; i < option_size; i++) | 158 | for (i = 0; i < option_size; i++) |
@@ -227,7 +227,7 @@ get_canonical_hostname(int use_dns) | |||
227 | * The returned string must be freed. | 227 | * The returned string must be freed. |
228 | */ | 228 | */ |
229 | static char * | 229 | static char * |
230 | get_socket_address(int socket, int remote, int flags) | 230 | get_socket_address(int sock, int remote, int flags) |
231 | { | 231 | { |
232 | struct sockaddr_storage addr; | 232 | struct sockaddr_storage addr; |
233 | socklen_t addrlen; | 233 | socklen_t addrlen; |
@@ -238,11 +238,11 @@ get_socket_address(int socket, int remote, int flags) | |||
238 | memset(&addr, 0, sizeof(addr)); | 238 | memset(&addr, 0, sizeof(addr)); |
239 | 239 | ||
240 | if (remote) { | 240 | if (remote) { |
241 | if (getpeername(socket, (struct sockaddr *)&addr, &addrlen) | 241 | if (getpeername(sock, (struct sockaddr *)&addr, &addrlen) |
242 | < 0) | 242 | < 0) |
243 | return NULL; | 243 | return NULL; |
244 | } else { | 244 | } else { |
245 | if (getsockname(socket, (struct sockaddr *)&addr, &addrlen) | 245 | if (getsockname(sock, (struct sockaddr *)&addr, &addrlen) |
246 | < 0) | 246 | < 0) |
247 | return NULL; | 247 | return NULL; |
248 | } | 248 | } |
@@ -261,29 +261,29 @@ get_socket_address(int socket, int remote, int flags) | |||
261 | } | 261 | } |
262 | 262 | ||
263 | char * | 263 | char * |
264 | get_peer_ipaddr(int socket) | 264 | get_peer_ipaddr(int sock) |
265 | { | 265 | { |
266 | char *p; | 266 | char *p; |
267 | 267 | ||
268 | if ((p = get_socket_address(socket, 1, NI_NUMERICHOST)) != NULL) | 268 | if ((p = get_socket_address(sock, 1, NI_NUMERICHOST)) != NULL) |
269 | return p; | 269 | return p; |
270 | return xstrdup("UNKNOWN"); | 270 | return xstrdup("UNKNOWN"); |
271 | } | 271 | } |
272 | 272 | ||
273 | char * | 273 | char * |
274 | get_local_ipaddr(int socket) | 274 | get_local_ipaddr(int sock) |
275 | { | 275 | { |
276 | char *p; | 276 | char *p; |
277 | 277 | ||
278 | if ((p = get_socket_address(socket, 0, NI_NUMERICHOST)) != NULL) | 278 | if ((p = get_socket_address(sock, 0, NI_NUMERICHOST)) != NULL) |
279 | return p; | 279 | return p; |
280 | return xstrdup("UNKNOWN"); | 280 | return xstrdup("UNKNOWN"); |
281 | } | 281 | } |
282 | 282 | ||
283 | char * | 283 | char * |
284 | get_local_name(int socket) | 284 | get_local_name(int sock) |
285 | { | 285 | { |
286 | return get_socket_address(socket, 0, NI_NAMEREQD); | 286 | return get_socket_address(sock, 0, NI_NAMEREQD); |
287 | } | 287 | } |
288 | 288 | ||
289 | /* | 289 | /* |