summaryrefslogtreecommitdiff
path: root/src/include/ipaddr.h
blob: cac13d62c3e035d43e67bcfbcfa769de8c6182a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef CEPH_IPADDR_H
#define CEPH_IPADDR_H

#include <netinet/in.h>
#include <sys/types.h>
#include <ifaddrs.h>

/*
  Find an IP address that is in the wanted subnet.

  If there are multiple matches, the first one is returned; this order
  is system-dependent and should not be relied on.
 */
const struct sockaddr *find_ip_in_subnet(const struct ifaddrs *addrs,
					 const struct sockaddr *net,
					 unsigned int prefix_len);


bool parse_network(const char *s, struct sockaddr *network, unsigned int *prefix_len);

#endif