aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2010-03-24 11:22:54 +0100
committerMartin Willi <martin@revosec.ch>2010-03-25 14:28:29 +0100
commite06a6154e21c22e5fa44339a60b69a6b6e0602c0 (patch)
treeee8ed21b579b141c8bb8c6905958155d0e765160 /src
parent4f0932ecfeb7400e39b990ac2a7716657d4bbe09 (diff)
downloadstrongswan-e06a6154e21c22e5fa44339a60b69a6b6e0602c0.tar.bz2
strongswan-e06a6154e21c22e5fa44339a60b69a6b6e0602c0.tar.xz
Added identity_lease option to create random or identity based DHCP leases
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/plugins/dhcp/dhcp_socket.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libcharon/plugins/dhcp/dhcp_socket.c b/src/libcharon/plugins/dhcp/dhcp_socket.c
index 2d0e63c59..8921228fc 100644
--- a/src/libcharon/plugins/dhcp/dhcp_socket.c
+++ b/src/libcharon/plugins/dhcp/dhcp_socket.c
@@ -96,6 +96,11 @@ struct private_dhcp_socket_t {
int receive;
/**
+ * Do we use per-identity or random leases (and MAC addresses)
+ */
+ bool identity_lease;
+
+ /**
* DHCP server address, or broadcast
*/
host_t *dst;
@@ -192,7 +197,7 @@ static int prepare_dhcp(private_dhcp_socket_t *this,
dhcp_option_t *option;
int optlen = 0;
host_t *src;
- u_int hash;
+ u_int32_t id;
memset(dhcp, 0, sizeof(*dhcp));
dhcp->opcode = BOOTREQUEST;
@@ -222,8 +227,15 @@ static int prepare_dhcp(private_dhcp_socket_t *this,
dhcp->client_hw_addr[0] = 0x7A;
dhcp->client_hw_addr[1] = 0xA7;
/* with ID specific postfix */
- hash = htonl(chunk_hash(chunk));
- memcpy(&dhcp->client_hw_addr[2], &hash, 4);
+ if (this->identity_lease)
+ {
+ id = htonl(chunk_hash(chunk));
+ }
+ else
+ {
+ id = transaction->get_id(transaction);
+ }
+ memcpy(&dhcp->client_hw_addr[2], &id, sizeof(id));
dhcp->magic_cookie = htonl(0x63825363);
@@ -600,6 +612,8 @@ dhcp_socket_t *dhcp_socket_create()
destroy(this);
return NULL;
}
+ this->identity_lease = lib->settings->get_bool(lib->settings,
+ "charon.plugins.dhcp.identity_lease", FALSE);
this->dst = host_create_from_string(lib->settings->get_str(lib->settings,
"charon.plugins.dhcp.server", "255.255.255.255"),
DHCP_SERVER_PORT);