Author: tjansen Date: Wed Nov 25 12:28:37 2009 New Revision: 1768 Log: Replaced pisa_convert_string_to_address in pairing and removed the now unused function. The two calls in management.c want to convert a HIT. The complexity of pisa_convert_string_to_address is not needed for that, because a HIT is always IPv6. Thus we can simply replace it with inet_pton(AF_INET6, ...). This renders pisa_convert_string_to_address unused (and in consequence pisa_convert_string_to_address_v4 as well). Both are removed along with the IPV4_TO_IPV6_MAP() macro. Modified: trunk/libpisa/util.c trunk/libpisa/util.h trunk/pairing/management.c Modified: trunk/libpisa/util.c ============================================================================== --- trunk/libpisa/util.c Wed Nov 25 11:29:53 2009 (r1767) +++ trunk/libpisa/util.c Wed Nov 25 12:28:37 2009 (r1768) @@ -244,59 +244,6 @@ return err; } -#ifndef __KERNEL__ -static int pisa_convert_string_to_address_v4(const char *str, struct in_addr *ip){ - int ret = 0, err = 0; - - ret = inet_pton(AF_INET, str, ip); - PISA_IFEL((ret < 0 && errno == EAFNOSUPPORT), -1, - "inet_pton: not a valid address family\n"); - PISA_IFEL((ret == 0), -1, - "inet_pton: %s: not a valid network address\n", str); - out_err: - return err; -} - -int pisa_convert_string_to_address(const char *str, - struct in6_addr *ip6){ - int ret = 0, err = 0; - struct in_addr ip4; - - ret = inet_pton(AF_INET6, str, ip6); - PISA_IFEL((ret < 0 && errno == EAFNOSUPPORT), -1, - "\"%s\" is not of valid address family.\n", str); - if (ret > 0) { - /* IPv6 address conversion was ok */ -/* _PISA_DEBUG_IN6ADDR("Converted IPv6", ip6);*/ - goto out_err; - } - - /* Might be an ipv4 address (ret == 0). Lets catch it here. */ - err = pisa_convert_string_to_address_v4(str, &ip4); - if (err) - goto out_err; - -/* FIXME: This is an ugly hack to map between different struct in6_addr - * member names on Linux/glibc and Mac OS X. */ -#ifndef s6_addr32 -#define s6_addr32 __u6_addr.__u6_addr32 -#endif - -#define IPV4_TO_IPV6_MAP(in_addr_from, in6_addr_to) \ - {(in6_addr_to)->s6_addr32[0] = 0; \ - (in6_addr_to)->s6_addr32[1] = 0; \ - (in6_addr_to)->s6_addr32[2] = htonl(0xffff); \ - (in6_addr_to)->s6_addr32[3] = (uint32_t) ((in_addr_from)->s_addr);} - - IPV4_TO_IPV6_MAP(&ip4, ip6); - PISA_DEBUG("Mapped v4 to v6.\n"); -/* PISA_DEBUG_IN6ADDR("mapped v6", ip6);*/ - - out_err: - return err; -} -#endif /* __KERNEL__ */ - int pisa_remove_lock_file(const char *filename){ return unlink(filename); } Modified: trunk/libpisa/util.h ============================================================================== --- trunk/libpisa/util.h Wed Nov 25 11:29:53 2009 (r1767) +++ trunk/libpisa/util.h Wed Nov 25 12:28:37 2009 (r1768) @@ -79,8 +79,6 @@ int pisa_check_and_create_dir(const char *dirname, const mode_t mode); -int pisa_convert_string_to_address(const char *str, struct in6_addr *ip6); - void pisa_daemonize(void); int pisa_time_before(struct timeval *t1, struct timeval *t2); Modified: trunk/pairing/management.c ============================================================================== --- trunk/pairing/management.c Wed Nov 25 11:29:53 2009 (r1767) +++ trunk/pairing/management.c Wed Nov 25 12:28:37 2009 (r1768) @@ -156,7 +156,7 @@ struct in6_addr addr; - if (pisa_convert_string_to_address(buffer, &addr) != 0) + if (inet_pton(AF_INET6, buffer, &addr) != 1) { PISA_ERROR("Invalid network address string:<%s>\n", buffer); } @@ -714,7 +714,7 @@ case 'h': - if (pisa_convert_string_to_address(optarg, &addr) != 0) + if (inet_pton(AF_INET6, optarg, &addr) != 1) { return 0; }