canohost.c (147005) | canohost.c (149753) |
---|---|
1/* 2 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * All rights reserved 5 * Functions for returning the canonical host name of the remote site. 6 * 7 * As far as I am concerned, the code I have written for this software 8 * can be used freely for any purpose. Any derived versions of this 9 * software must be clearly marked as such, and if the derived work is 10 * incompatible with the protocol description in the RFC file, it must be 11 * called by a name other than "ssh" or "Secure Shell". 12 */ 13 14#include "includes.h" | 1/* 2 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * All rights reserved 5 * Functions for returning the canonical host name of the remote site. 6 * 7 * As far as I am concerned, the code I have written for this software 8 * can be used freely for any purpose. Any derived versions of this 9 * software must be clearly marked as such, and if the derived work is 10 * incompatible with the protocol description in the RFC file, it must be 11 * called by a name other than "ssh" or "Secure Shell". 12 */ 13 14#include "includes.h" |
15RCSID("$OpenBSD: canohost.c,v 1.42 2005/02/18 03:05:53 djm Exp $"); | 15RCSID("$OpenBSD: canohost.c,v 1.44 2005/06/17 02:44:32 djm Exp $"); |
16 17#include "packet.h" 18#include "xmalloc.h" 19#include "log.h" 20#include "canohost.h" 21 22static void check_ip_options(int, char *); 23 --- 114 unchanged lines hidden (view full) --- 138/* IPv4 only */ 139static void 140check_ip_options(int sock, char *ipaddr) 141{ 142#ifdef IP_OPTIONS 143 u_char options[200]; 144 char text[sizeof(options) * 3 + 1]; 145 socklen_t option_size; | 16 17#include "packet.h" 18#include "xmalloc.h" 19#include "log.h" 20#include "canohost.h" 21 22static void check_ip_options(int, char *); 23 --- 114 unchanged lines hidden (view full) --- 138/* IPv4 only */ 139static void 140check_ip_options(int sock, char *ipaddr) 141{ 142#ifdef IP_OPTIONS 143 u_char options[200]; 144 char text[sizeof(options) * 3 + 1]; 145 socklen_t option_size; |
146 int i, ipproto; | 146 u_int i; 147 int ipproto; |
147 struct protoent *ip; 148 149 if ((ip = getprotobyname("ip")) != NULL) 150 ipproto = ip->p_proto; 151 else 152 ipproto = IPPROTO_IP; 153 option_size = sizeof(options); 154 if (getsockopt(sock, ipproto, IP_OPTIONS, options, --- 13 unchanged lines hidden (view full) --- 168void 169ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len) 170{ 171 struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)addr; 172 struct sockaddr_in *a4 = (struct sockaddr_in *)addr; 173 struct in_addr inaddr; 174 u_int16_t port; 175 | 148 struct protoent *ip; 149 150 if ((ip = getprotobyname("ip")) != NULL) 151 ipproto = ip->p_proto; 152 else 153 ipproto = IPPROTO_IP; 154 option_size = sizeof(options); 155 if (getsockopt(sock, ipproto, IP_OPTIONS, options, --- 13 unchanged lines hidden (view full) --- 169void 170ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len) 171{ 172 struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)addr; 173 struct sockaddr_in *a4 = (struct sockaddr_in *)addr; 174 struct in_addr inaddr; 175 u_int16_t port; 176 |
176 if (addr->ss_family != AF_INET6 || | 177 if (addr->ss_family != AF_INET6 || |
177 !IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) 178 return; 179 180 debug3("Normalising mapped IPv4 in IPv6 address"); 181 182 memcpy(&inaddr, ((char *)&a6->sin6_addr) + 12, sizeof(inaddr)); 183 port = a6->sin6_port; 184 --- 156 unchanged lines hidden (view full) --- 341 if (local) { 342 if (getsockname(sock, (struct sockaddr *)&from, &fromlen) < 0) { 343 error("getsockname failed: %.100s", strerror(errno)); 344 return 0; 345 } 346 } else { 347 if (getpeername(sock, (struct sockaddr *)&from, &fromlen) < 0) { 348 debug("getpeername failed: %.100s", strerror(errno)); | 178 !IN6_IS_ADDR_V4MAPPED(&a6->sin6_addr)) 179 return; 180 181 debug3("Normalising mapped IPv4 in IPv6 address"); 182 183 memcpy(&inaddr, ((char *)&a6->sin6_addr) + 12, sizeof(inaddr)); 184 port = a6->sin6_port; 185 --- 156 unchanged lines hidden (view full) --- 342 if (local) { 343 if (getsockname(sock, (struct sockaddr *)&from, &fromlen) < 0) { 344 error("getsockname failed: %.100s", strerror(errno)); 345 return 0; 346 } 347 } else { 348 if (getpeername(sock, (struct sockaddr *)&from, &fromlen) < 0) { 349 debug("getpeername failed: %.100s", strerror(errno)); |
349 cleanup_exit(255); | 350 return -1; |
350 } 351 } 352 353 /* Work around Linux IPv6 weirdness */ 354 if (from.ss_family == AF_INET6) 355 fromlen = sizeof(struct sockaddr_in6); 356 357 /* Return port number. */ --- 46 unchanged lines hidden --- | 351 } 352 } 353 354 /* Work around Linux IPv6 weirdness */ 355 if (from.ss_family == AF_INET6) 356 fromlen = sizeof(struct sockaddr_in6); 357 358 /* Return port number. */ --- 46 unchanged lines hidden --- |