summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-05-26 15:18:47 +0200
committerTom Gundersen <teg@jklm.no>2014-06-13 17:07:20 +0200
commit500792d8180c9a11d65f107cdc79dea21b2964c4 (patch)
treeed8be90a8c1a54981e112c257bf1bd6d03eeac14 /src/libsystemd-network
parent5b34277c2015e32e51d10cfa076df2c7106b4537 (diff)
sd-dhcp-server: add RELEASE support
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index cb014e2dfc..4ce10549d6 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -544,7 +544,7 @@ static int get_pool_offset(sd_dhcp_server *server, be32_t requested_ip) {
if (be32toh(requested_ip) < be32toh(server->pool_start) ||
be32toh(requested_ip) >= be32toh(server->pool_start) +
- + server->pool_size)
+ + server->pool_size)
return -EINVAL;
return be32toh(requested_ip) - be32toh(server->pool_start);
@@ -743,6 +743,31 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
break;
}
+ case DHCP_RELEASE: {
+ int pool_offset;
+
+ log_dhcp_server(server, "RELEASE (0x%x)",
+ be32toh(req->message->xid));
+
+ if (!existing_lease)
+ return 0;
+
+ if (existing_lease->address != req->message->ciaddr)
+ return 0;
+
+ pool_offset = get_pool_offset(server, req->message->ciaddr);
+ if (pool_offset < 0)
+ return 0;
+
+ if (server->bound_leases[pool_offset] == existing_lease) {
+ server->bound_leases[pool_offset] = NULL;
+ hashmap_remove(server->leases_by_client_id, existing_lease);
+ dhcp_lease_free(existing_lease);
+
+ return 1;
+ } else
+ return 0;
+ }
}
return 0;