mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Retired broken code that checked for NULL ip_address in sockaddr_set_data.
This commit is contained in:
parent
dbe01ae695
commit
83e7fe2ca8
@ -1,3 +1,8 @@
|
||||
2003-10-31 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* connect.c (sockaddr_set_data): Remove the broken code that
|
||||
checked for NULL address.
|
||||
|
||||
2003-10-31 Hrvoje Niksic <hniksic@xemacs.org>
|
||||
|
||||
* host.c (address_list_from_single): Removed.
|
||||
|
@ -66,59 +66,39 @@ extern int errno;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* sockaddr_set_data
|
||||
*
|
||||
* This function takes a sockaddr struct and fills in the protocol
|
||||
* type, the port number and the address. If ENABLE_IPV6 is defined,
|
||||
* SA should really point to struct sockaddr_storage; otherwise, it
|
||||
* should point to struct sockaddr_in.
|
||||
*
|
||||
* Input:
|
||||
* struct sockaddr* The space to be filled
|
||||
* const ip_address The IP address
|
||||
* int The port
|
||||
*
|
||||
* Return:
|
||||
* - Only modifies 1st parameter.
|
||||
*/
|
||||
/* Fill SA as per the data in IP and PORT. SA shoult point to struct
|
||||
sockaddr_storage if ENABLE_IPV6 is defined, to struct sockaddr_in
|
||||
otherwise. */
|
||||
|
||||
static void
|
||||
sockaddr_set_data (struct sockaddr *sa, const ip_address *addr, int port)
|
||||
sockaddr_set_data (struct sockaddr *sa, const ip_address *ip, int port)
|
||||
{
|
||||
if (addr->type == IPV4_ADDRESS)
|
||||
switch (ip->type)
|
||||
{
|
||||
case IPV4_ADDRESS:
|
||||
{
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_port = htons (port);
|
||||
if (addr == NULL)
|
||||
sin->sin_addr.s_addr = INADDR_ANY;
|
||||
else
|
||||
sin->sin_addr = ADDRESS_IPV4_IN_ADDR (addr);
|
||||
sin->sin_addr = ADDRESS_IPV4_IN_ADDR (ip);
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_IPV6
|
||||
else if (addr->type == IPV6_ADDRESS)
|
||||
case IPV6_ADDRESS:
|
||||
{
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
|
||||
sin6->sin6_family = AF_INET6;
|
||||
sin6->sin6_port = htons (port);
|
||||
/* #### How can ADDR be NULL? We have dereferenced it above by
|
||||
accessing addr->type! */
|
||||
if (addr == NULL)
|
||||
{
|
||||
sin6->sin6_addr = in6addr_any;
|
||||
/* #### Should we set the scope_id here? */
|
||||
}
|
||||
else
|
||||
{
|
||||
sin6->sin6_addr = ADDRESS_IPV6_IN6_ADDR (addr);
|
||||
sin6->sin6_addr = ADDRESS_IPV6_IN6_ADDR (ip);
|
||||
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
|
||||
sin6->sin6_scope_id = ADDRESS_IPV6_SCOPE (addr);
|
||||
sin6->sin6_scope_id = ADDRESS_IPV6_SCOPE (ip);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLE_IPV6 */
|
||||
else
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the data of SA, specifically the IP address and the port. If
|
||||
@ -128,7 +108,9 @@ sockaddr_set_data (struct sockaddr *sa, const ip_address *addr, int port)
|
||||
void
|
||||
sockaddr_get_data (const struct sockaddr *sa, ip_address *ip, int *port)
|
||||
{
|
||||
if (sa->sa_family == AF_INET)
|
||||
switch (sa->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
|
||||
if (ip)
|
||||
@ -138,9 +120,10 @@ sockaddr_get_data (const struct sockaddr *sa, ip_address *ip, int *port)
|
||||
}
|
||||
if (port)
|
||||
*port = ntohs (sin->sin_port);
|
||||
break;
|
||||
}
|
||||
#ifdef ENABLE_IPV6
|
||||
else if (sa->sa_family == AF_INET6)
|
||||
case AF_INET6:
|
||||
{
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
|
||||
if (ip)
|
||||
@ -153,10 +136,12 @@ sockaddr_get_data (const struct sockaddr *sa, ip_address *ip, int *port)
|
||||
}
|
||||
if (port)
|
||||
*port = ntohs (sin6->sin6_port);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the size of the sockaddr structure depending on its
|
||||
|
Loading…
Reference in New Issue
Block a user