Пример #1
0
int simple_pton(const char* addr, void* result){
	if(STRING_IS_IPV6(addr)){
		return ipv6_pton(addr, result);
	}else{
		return ipv4_pton(addr, result);
	}
}
Пример #2
0
/**
 * Initialize and read the ipv6 presentation, returning in pbits the number of masked (on) bits
 * 
 * @return AM_FALSE iff the presentation form cannot be parsed as an ipv6 address in CIDR notation
 */
static am_bool_t read_ip6(const char * p, struct in6_addr * n, int * pbits) {
    *pbits = ipv6_pton(p, n);
    if (*pbits == -1) {
        return AM_FALSE;
    }
    return AM_TRUE;
}
Пример #3
0
int ipv6_addrinit(struct sockaddr* addr, const char* address, int port){
	struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr;
	simple_bzero(addr6, sizeof(*addr6));
	addr6->sin6_family = AF_INET6;
	addr6->sin6_port = htons(port);
	if(ipv6_pton(address, &addr6->sin6_addr) <= 0){
		return -1;
	}
	return 0;
}