1 #ifndef CEPH_PICK_ADDRESS_H
2 #define CEPH_PICK_ADDRESS_H
4 #include "common/config.h"
9 #define CEPH_PICK_ADDRESS_PUBLIC 0x01
10 #define CEPH_PICK_ADDRESS_CLUSTER 0x02
13 Pick addresses based on subnets if needed.
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.
18 cluster_addr is set based on cluster_network, public_addr is set
19 based on public_network.
21 cluster_network and public_network are a list of ip/prefix pairs.
23 All IP addresses assigned to all local network interfaces are
26 If multiple IP addresses match the subnet, one of them will be
27 picked, effectively randomly.
29 This function will exit on error.
31 void pick_addresses(CephContext *cct, int needs);
34 * Find a network interface whose address matches the address/netmask
37 std::string pick_iface(CephContext *cct, const struct sockaddr_storage &network);
40 * check for a locally configured address
42 * check if any of the listed addresses is configured on the local host.
45 * @param ls list of addresses
46 * @param match [out] pointer to match, if an item in @a ls is found configured locally.
48 bool have_local_addr(CephContext *cct, const list<entity_addr_t>& ls, entity_addr_t *match);
51 const struct sockaddr *find_ip_in_subnet_list(
53 const struct ifaddrs *ifa,
54 const std::string &networks,
55 const std::string &interfaces);