--------------------- PatchSet 1308 Date: 2005/04/25 08:06:26 Author: rmartinez Branch: squid3-ipv6 Tag: (none) Log: Some additional routines on IPv6 Members: include/util.h:1.10.8.4->1.10.8.5 Index: squid3/include/util.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/util.h,v retrieving revision 1.10.8.4 retrieving revision 1.10.8.5 diff -u -r1.10.8.4 -r1.10.8.5 --- squid3/include/util.h 19 Apr 2005 10:57:54 -0000 1.10.8.4 +++ squid3/include/util.h 25 Apr 2005 08:06:26 -0000 1.10.8.5 @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.10.8.4 2005/04/19 10:57:54 rmartinez Exp $ + * $Id: util.h,v 1.10.8.5 2005/04/25 08:06:26 rmartinez Exp $ * * AUTHOR: Harvest Derived * @@ -65,50 +65,6 @@ #define _etext etext #endif -#if ENABLE_IPV6 -/* - This structs is an abstract IPv4 or IPv6 address. - - It is currently implemented by using a full struct sockaddr_storage. - - It might also be implemented by struct in6_addr (which is shorter), but - the IPv6-compatible name lookup functions require - struct sockaddr_storage anyway for specifying just an IPv6 address. - So if this struct was implemented by struct in6_addr, one should - have to dynamically allocate a struct sockaddr_storage for these cases. - -*/ -struct inaddr_storage -{ - struct sockaddr_storage embedded; -}; - -#define HAVE_SOCKADDR_STORAGE_LEN 0 - -#define sockaddr_storage_is_ipv4(x) ((x)->ss_family==AF_INET) -#define sockaddr_storage_to_in4_addr(x) (((struct sockaddr_in *) (x))->sin_addr) -#if HAVE_SOCKADDR_STORAGE_LEN // Note that for certain platforms, struct sockaddr_storage.ss_len does not exist. -#define sockaddr_storage_len(x) ((x)->ss_len) -#else -#define sockaddr_storage_len(x) (sizeof(struct sockaddr_storage)) -#endif -#define sockaddr_storage_ipv4_port(x) (((struct sockaddr_in *) (x))->sin_port) -#define sockaddr_storage_ipv6_port(x) (((struct sockaddr_in6 *) (x))->sin6_port) -#define sockaddr_storage_port(x) (sockaddr_storage_is_ipv4(x)?sockaddr_storage_ipv4_port(x):sockaddr_storage_ipv6_port(x)) // in practise, these fields are exaclty the same (for IPv4 and IPv6), we do not consider any other address families) -#define inaddr_storage_is_ipv4(x) ((x)->embedded.ss_family==AF_INET) -#define inaddr_storage_to_in4_addr(x) (((struct sockaddr_in *) (x))->sin_addr) -#define inaddr_storage_to_sockaddr(x) ((struct sockaddr *) (x)) -#define inaddr_storage_to_sockaddr_len(x) (sizeof(struct sockaddr)) -/* - - @return - 0 if both adresses match - !=0 if they do not match -*/ -#define sockaddr_storage_to_inaddr_storage_simple_compare(ss,is) sockaddr_host_simple_compare(ss,&((is)->embedded)) - -#endif - SQUIDCEXTERN const char *getfullhostname(void); SQUIDCEXTERN const char *mkhttpdlogtime(const time_t *); SQUIDCEXTERN const char *mkrfc1123(time_t); @@ -170,27 +126,12 @@ extern void xmalloc_find_leaks(void); #endif -<<<<<<< util.h -typedef struct in_addr SIA; - -SQUIDCEXTERN int safe_inet4_addr(const char *, SIA *); -#if ENABLE_IPV6 -SQUIDCEXTERN int safe_inet_addr(const char *, SIA *); -#else -======= typedef struct IN_ADDR SIA; ->>>>>>> 1.13 -SQUIDCEXTERN int safe_inet_addr(const char *, SIA *); -#endif -SQUIDCEXTERN int is_numeric_ip_address(const char *hostname); -#if ENABLE_IPV6 -SQUIDCEXTERN char * sockaddr_host_address_to_address_string( struct sockaddr_storage * sockaddr); -SQUIDCEXTERN char * sockaddr_host_address_to_address_string_force( struct sockaddr_storage * sockaddr); -SQUIDCEXTERN char * inet6_network_byte_order_to_address_string( struct inaddr_storage * addr6); -SQUIDCEXTERN char * inet6_network_byte_order_to_address_string_force( struct inaddr_storage * addr6); -SQUIDCEXTERN int sockaddr_host_simple_compare( struct sockaddr_storage * ss0, struct sockaddr_storage * ss1); -SQUIDCEXTERN void copy_sockaddr_host( struct sockaddr_storage * from, struct sockaddr_storage * to); -SQUIDCEXTERN void sockaddr_storage_to_inaddr_storage( struct sockaddr_storage * from, struct inaddr_storage * to); +SQUIDCEXTERN int safe_inet_addr(const char *, struct in_addr *); +#ifdef INET6 +SQUIDCEXTERN const char * inet6_ntoa(const struct in6_addr in); +SQUIDCEXTERN int safe_inet_sockaddr(const char *, struct sockaddr_storage *); +SQUIDCEXTERN int safe_inet6_addr(const char *, struct in6_addr *); #endif SQUIDCEXTERN time_t parse_iso3307_time(const char *buf); SQUIDCEXTERN char *base64_decode(const char *coded);