+ if (link->network->dhcp_server) {
+ Address *address;
+
+ r = sd_dhcp_server_new(&link->dhcp_server, link->ifindex);
+ if (r < 0)
+ return r;
+
+ r = sd_dhcp_server_attach_event(link->dhcp_server, NULL, 0);
+ if (r < 0)
+ return r;
+
+ LIST_FOREACH(addresses, address,
+ link->network->static_addresses) {
+ struct in_addr pool_start;
+
+ if (address->family != AF_INET)
+ continue;
+
+ /* currently this is picked essentially at random */
+ r = sd_dhcp_server_set_address(link->dhcp_server,
+ &address->in_addr.in);
+ if (r < 0)
+ return r;
+
+ /* offer 32 addresses starting from the address following the server address */
+ pool_start.s_addr = htobe32(be32toh(address->in_addr.in.s_addr) + 1);
+ r = sd_dhcp_server_set_lease_pool(link->dhcp_server,
+ &pool_start, 32);
+ if (r < 0)
+ return r;
+
+ break;
+ }
+
+ /* TODO:
+ r = sd_dhcp_server_set_router(link->dhcp_server,
+ &main_address->in_addr.in);
+ if (r < 0)
+ return r;
+
+ r = sd_dhcp_server_set_prefixlen(link->dhcp_server,
+ main_address->prefixlen);
+ if (r < 0)
+ return r;
+ */
+ }
+
+ if (link_has_carrier(link->flags, link->operstate)) {