summaryrefslogtreecommitdiff
path: root/src/network/networkd.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-06-18 18:22:14 +0200
committerLennart Poettering <lennart@poettering.net>2014-06-18 18:28:29 +0200
commit11bf3cced13c885ca215c108cb0bdb7a148520d6 (patch)
treea4b0af55dee44c786b80bcfab13e3eb0f3f84a4e /src/network/networkd.h
parent059f6c42b744a18d0deec0c79a9e0730ec6c1c76 (diff)
networkd: add address pool support
When an address is configured to be all zeroes, networkd will now automatically find a locally unused network of the right size from a list of pre-configured pools. Currently those pools are 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and fc00::/7, i.e. the network ranges for private networks. They are compiled in, but should be configurable eventually. This allows applying the same configuration to a large number of interfaces with each time a different IP range block, and management of these IP ranges is fully automatic. When allocating an address range from the pool it is made sure the range is not used otherwise.
Diffstat (limited to 'src/network/networkd.h')
-rw-r--r--src/network/networkd.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 308be832e1..7069a11d4c 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -47,6 +47,7 @@ typedef struct Link Link;
typedef struct Address Address;
typedef struct Route Route;
typedef struct Manager Manager;
+typedef struct AddressPool AddressPool;
typedef struct netdev_enslave_callback netdev_enslave_callback;
@@ -259,9 +260,22 @@ struct Link {
uint16_t original_mtu;
sd_ipv4ll *ipv4ll;
+ LIST_HEAD(Address, pool_addresses);
+
sd_dhcp_server *dhcp_server;
};
+struct AddressPool {
+ Manager *manager;
+
+ unsigned family;
+ unsigned prefixlen;
+
+ union in_addr_union in_addr;
+
+ LIST_FIELDS(AddressPool, address_pools);
+};
+
struct Manager {
sd_rtnl *rtnl;
sd_event *event;
@@ -277,6 +291,7 @@ struct Manager {
Hashmap *links;
Hashmap *netdevs;
LIST_HEAD(Network, networks);
+ LIST_HEAD(AddressPool, address_pools);
usec_t network_dirs_ts_usec;
};
@@ -299,6 +314,8 @@ int manager_bus_listen(Manager *m);
int manager_save(Manager *m);
+int manager_address_pool_acquire(Manager *m, unsigned family, unsigned prefixlen, union in_addr_union *found);
+
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
#define _cleanup_manager_free_ _cleanup_(manager_freep)
@@ -449,6 +466,14 @@ LinkOperationalState link_operstate_from_string(const char *s) _pure_;
DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
#define _cleanup_link_unref_ _cleanup_(link_unrefp)
+/* Address Pool */
+
+int address_pool_new(Manager *m, AddressPool **ret, unsigned family, const union in_addr_union *u, unsigned prefixlen);
+int address_pool_new_from_string(Manager *m, AddressPool **ret, unsigned family, const char *p, unsigned prefixlen);
+void address_pool_free(AddressPool *p);
+
+int address_pool_acquire(AddressPool *p, unsigned prefixlen, union in_addr_union *found);
+
/* Macros which append INTERFACE= to the message */
#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)