Lines Matching refs:ip
108 static struct in_addr calc_network(const struct in_addr *ip,
115 network.s_addr = ip->s_addr & mask->s_addr;
120 const struct in_addr *mask, const struct in_addr *ip)
122 return (ip->s_addr & mask->s_addr) ==
188 static char *get_ipv4_broadcast(struct in_addr ip, unsigned int prefix)
195 broadcast.s_addr = (ip.s_addr & mask.s_addr) | ~mask.s_addr;
208 static char *get_ipv4_net16_unused(const struct in_addr *ip,
215 network = calc_network(ip, &mask);
223 if (!is_in_subnet_ipv4(ip, &mask, &network))
230 (rand() % 128) + (((ip->s_addr >> 8) & 0xff) < 128 ? 128 : 0));
235 if (!is_in_subnet_ipv4(ip, &mask, &network))
239 sprintf(net_unused, "%d.%d", (rand() % 128) + (((ip->s_addr) & 0xff)
245 if (!is_in_subnet_ipv4(ip, &mask, &network))
413 * Strip host part from ip address.
415 static char *get_host_from_ip(const char *ip, const char *net)
417 if (ip == NULL || net == NULL)
420 char *result = strstr(ip, net);
422 if (!result || result != ip)
425 char *buf = strdup(ip);
430 if (index == strlen(ip))
434 if (index > 0 && index < strlen(ip)) {
435 len = strlen(ip) - index - 1;
436 assert(ip[index] == ':' || ip[index] == '.');
461 static char *get_ipv4_network(int ip, unsigned int prefix)
468 ip = htonl(ip);
479 byte = (ip >> i) & 0xff;
576 struct in_addr ip;
596 tst_get_in_addr(lip_str, &ip);
602 tst_get_in_addr(rip_str, &ip);