Lines Matching defs:ip
119 static struct in_addr calc_network(const struct in_addr *ip,
126 network.s_addr = ip->s_addr & mask->s_addr;
131 const struct in_addr *mask, const struct in_addr *ip)
133 return (ip->s_addr & mask->s_addr) ==
199 static char *get_ipv4_broadcast(struct in_addr ip, unsigned int prefix)
206 broadcast.s_addr = (ip.s_addr & mask.s_addr) | ~mask.s_addr;
217 * {DEFAULT_IPV4_UNUSED_PART1}.XY, when there is a collision with IP.
219 static char *get_ipv4_net16_unused(const struct in_addr *ip,
226 network = calc_network(ip, &mask);
234 if (!is_in_subnet_ipv4(ip, &mask, &network))
241 (rand() % 128) + (((ip->s_addr >> 8) & 0xff) < 128 ? 128 : 0));
246 if (!is_in_subnet_ipv4(ip, &mask, &network))
250 sprintf(net_unused, "%d.%d", (rand() % 128) + (((ip->s_addr) & 0xff)
256 if (!is_in_subnet_ipv4(ip, &mask, &network))
267 * if no collision with existing IP range.
424 * Strip host part from ip address.
426 static char *get_host_from_ip(const char *ip, const char *net)
428 if (ip == NULL || net == NULL)
431 char *result = strstr(ip, net);
433 if (!result || result != ip)
436 char *buf = strdup(ip);
441 if (index == strlen(ip))
445 if (index > 0 && index < strlen(ip)) {
446 len = strlen(ip) - index - 1;
447 assert(ip[index] == ':' || ip[index] == '.');
472 static char *get_ipv4_network(int ip, unsigned int prefix)
490 byte = ip & 0xff;
493 byte = (ip >> i) & 0xff;
591 struct in_addr ip;
611 get_in_addr(lip_str, &ip);
617 get_in_addr(rip_str, &ip);
627 tst_brk_comment("IP addresses cannot be the same ('%s', '%s')",