Permalink
Browse files

Merge branch 'master' of ssh://github.com/gnocuil/DHCPv4-over-v6

  • Loading branch information...
2 parents b06911a + a350b9e commit 996ad6abc9d718d9a3c6def0356c6f4f3f133796 @gnocuil committed Oct 9, 2012
Showing with 754 additions and 447 deletions.
  1. +32 −5 dhcp-4.2.3-P2/server/dhcp.c
  2. +722 −442 dhcp-4.2.3-P2/server/tags
@@ -750,7 +750,8 @@ void dhcprelease (packet, ms_nulltp)
int ms_nulltp;
{
struct lease *lease = (struct lease *)0, *next = (struct lease *)0;
- struct iaddr cip;
+ //struct iaddr cip;
+ struct iaddr_pset cipset;//pset for client
struct option_cache *oc;
struct data_string data;
const char *s;
@@ -781,12 +782,37 @@ void dhcprelease (packet, ms_nulltp)
/* See if we can find a lease that matches the IP address
the client is claiming. */
+ cipset.ip_addr.len = 4;
+ memcpy(cipset.ip_addr.iabuf, &packet -> raw -> ciaddr, 4);
+
+ oc = lookup_option (&dhcp_universe, packet -> options,
+ DHO_PORT_SET);
+ memset (&data, 0, sizeof data);
+ if (oc &&
+ evaluate_option_cache (&data, packet, (struct lease *)0,
+ (struct client_state *)0,
+ packet -> options, (struct option_state *)0,
+ &global_scope, oc, MDL)) {
+ memcpy(&cipset.index, data.data, 2);
+ cipset.index = ntohs(cipset.index);
+ memcpy(&cipset,mask, data.data + 2, 2);
+ cipset.mask = ntohs(cipset.mask);
+ data_string_forget (&data, MDL);
+ }else{
+ log_info ("there is no information about pset in the packet!!\n");
+ return;
+ }
+
while (lease) {
if (lease -> n_uid)
lease_reference (&next, lease -> n_uid, MDL);
- if (!memcmp (&packet -> raw -> ciaddr,
+ /*if (!memcmp (&packet -> raw -> ciaddr,
lease -> ip_addr.iabuf, 4)) {
break;
+ }*/
+ if(!memcmp (&cipset, &lease -> ip_pset,
+ sizeof(struct iaddr_pset))){ //cmp pset
+ break;
}
lease_dereference (&lease, MDL);
if (next) {
@@ -802,9 +828,10 @@ void dhcprelease (packet, ms_nulltp)
but the spec on this has changed historically, so try the
IP address in ciaddr if the client-identifier fails. */
if (!lease) {
- cip.len = 4;
- memcpy (cip.iabuf, &packet -> raw -> ciaddr, 4);
- find_lease_by_ip_addr (&lease, cip, MDL);
+ //cip.len = 4;
+ //memcpy (cip.iabuf, &packet -> raw -> ciaddr, 4);
+ //find_lease_by_ip_addr (&lease, cip, MDL);
+ find_lease_by_ip_pset(&lease, cipset, MDL);
}
Oops, something went wrong.

0 comments on commit 996ad6a

Please sign in to comment.