chiark / gitweb /
networkd: link - drop assert from _free()
[elogind.git] / src / network / networkd.h
index 3b081d52761a1d400ee6052ea5b615f6d9dc77b0..11268de70d7198e672df3aef00c7c60e40a45655 100644 (file)
@@ -29,6 +29,8 @@
 #include "sd-dhcp-client.h"
 #include "sd-dhcp-server.h"
 #include "sd-ipv4ll.h"
+#include "sd-icmp6-nd.h"
+#include "sd-dhcp6-client.h"
 #include "udev.h"
 
 #include "rtnl-util.h"
 #include "list.h"
 #include "set.h"
 #include "condition-util.h"
+#include "socket-util.h"
 
 #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
 #define VXLAN_VID_MAX (1u << 24) - 1
+#define DHCP_STATIC_ROUTE_METRIC 1024
 
 typedef struct NetDev NetDev;
 typedef struct Network Network;
@@ -46,6 +50,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;
 
@@ -127,6 +132,15 @@ struct NetDev {
         LIST_HEAD(netdev_enslave_callback, callbacks);
 };
 
+typedef enum DHCPSupport {
+        DHCP_SUPPORT_NONE,
+        DHCP_SUPPORT_BOTH,
+        DHCP_SUPPORT_V4,
+        DHCP_SUPPORT_V6,
+        _DHCP_SUPPORT_MAX,
+        _DHCP_SUPPORT_INVALID = -1,
+} DHCPSupport;
+
 struct Network {
         Manager *manager;
 
@@ -149,13 +163,14 @@ struct Network {
         Hashmap *vlans;
         Hashmap *macvlans;
         Hashmap *vxlans;
-        bool dhcp;
+        DHCPSupport dhcp;
         bool dhcp_dns;
         bool dhcp_ntp;
         bool dhcp_mtu;
         bool dhcp_hostname;
         bool dhcp_domainname;
         bool dhcp_critical;
+        bool dhcp_routes;
         bool ipv4ll;
 
         bool dhcp_server;
@@ -184,10 +199,7 @@ struct Address {
         struct in_addr broadcast;
         struct ifa_cacheinfo cinfo;
 
-        union {
-                struct in_addr in;
-                struct in6_addr in6;
-        } in_addr;
+        union in_addr_union in_addr;
 
         LIST_FIELDS(Address, addresses);
 };
@@ -201,15 +213,8 @@ struct Route {
         unsigned char scope;
         uint32_t metrics;
 
-        union {
-                struct in_addr in;
-                struct in6_addr in6;
-        } in_addr;
-
-        union {
-                struct in_addr in;
-                struct in6_addr in6;
-        } dst_addr;
+        union in_addr_union in_addr;
+        union in_addr_union dst_addr;
 
         LIST_FIELDS(Route, routes);
 };
@@ -268,7 +273,23 @@ struct Link {
         uint16_t original_mtu;
         sd_ipv4ll *ipv4ll;
 
+        LIST_HEAD(Address, pool_addresses);
+
         sd_dhcp_server *dhcp_server;
+
+        sd_icmp6_nd *icmp6_router_discovery;
+        sd_dhcp6_client *dhcp6_client;
+};
+
+struct AddressPool {
+        Manager *manager;
+
+        unsigned family;
+        unsigned prefixlen;
+
+        union in_addr_union in_addr;
+
+        LIST_FIELDS(AddressPool, address_pools);
 };
 
 struct Manager {
@@ -286,6 +307,7 @@ struct Manager {
         Hashmap *links;
         Hashmap *netdevs;
         LIST_HEAD(Network, networks);
+        LIST_HEAD(AddressPool, address_pools);
 
         usec_t network_dirs_ts_usec;
 };
@@ -308,6 +330,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)
 
@@ -458,6 +482,23 @@ LinkOperationalState link_operstate_from_string(const char *s) _pure_;
 DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
 #define _cleanup_link_unref_ _cleanup_(link_unrefp)
 
+/* DHCP support */
+
+const char* dhcp_support_to_string(DHCPSupport i) _const_;
+DHCPSupport dhcp_support_from_string(const char *s) _pure_;
+
+int config_parse_dhcp(const char *unit, const char *filename, unsigned line,
+                      const char *section, unsigned section_line, const char *lvalue,
+                      int ltype, const char *rvalue, void *data, void *userdata);
+
+/* 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__)