Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / pick_address.h
1 #ifndef CEPH_PICK_ADDRESS_H
2 #define CEPH_PICK_ADDRESS_H
3
4 #include "common/config.h"
5
6 class CephContext;
7
8
9 #define CEPH_PICK_ADDRESS_PUBLIC     0x01
10 #define CEPH_PICK_ADDRESS_CLUSTER    0x02
11
12 /*
13   Pick addresses based on subnets if needed.
14
15   If an address is not explicitly given, and a list of subnets is
16   given, find an assigned IP address in the subnets and set that.
17
18   cluster_addr is set based on cluster_network, public_addr is set
19   based on public_network.
20
21   cluster_network and public_network are a list of ip/prefix pairs.
22
23   All IP addresses assigned to all local network interfaces are
24   potential matches.
25
26   If multiple IP addresses match the subnet, one of them will be
27   picked, effectively randomly.
28
29   This function will exit on error.
30  */
31 void pick_addresses(CephContext *cct, int needs);
32
33 /**
34  * Find a network interface whose address matches the address/netmask
35  * in `network`.
36  */
37 std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network);
38
39 /**
40  * check for a locally configured address
41  *
42  * check if any of the listed addresses is configured on the local host.
43  *
44  * @param cct context
45  * @param ls list of addresses
46  * @param match [out] pointer to match, if an item in @a ls is found configured locally.
47  */
48 bool have_local_addr(CephContext *cct, const list<entity_addr_t>& ls, entity_addr_t *match);
49
50
51 const struct sockaddr *find_ip_in_subnet_list(
52   CephContext *cct,
53   const struct ifaddrs *ifa,
54   const std::string &networks,
55   const std::string &interfaces);
56
57 #endif