Skip to content

Commit

Permalink
fixed RENEW with relay agent
Browse files Browse the repository at this point in the history
  • Loading branch information
gnocuil committed Oct 11, 2012
1 parent 31b2ae2 commit 4658272
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 56 deletions.
69 changes: 29 additions & 40 deletions dhcp-4.2.3-P2/server/dhcp.c
Expand Up @@ -167,45 +167,37 @@ dhcp (struct packet *packet) {
(packet->options->universe_count <= agent_universe.index ||
packet->options->universes[agent_universe.index] == NULL))
{
struct iaddr cip;
struct iaddr_pset ipset;//get pset-option from request packet. sunqi
printf("*************************dhcp.c,line 151***************\n");
/********if pset option exists, get it; else use original method. sunqi*******/

ipset.ip_addr.len = sizeof packet -> raw -> ciaddr;
memcpy (ipset.ip_addr.iabuf, &packet -> raw -> ciaddr,
sizeof packet -> raw -> ciaddr);
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)){
if (data.len == 4) {
u_int32_t tmp = getULong (data.data);
ipset.pset_index = tmp >> 16;
ipset.pset_mask = tmp;
} else {
printf("no port-set option found.");

}

data_string_forget (&data, MDL);


if (!find_lease_by_ip_pset (&lease, ipset, MDL))
goto nolease;

} else {/******************/
struct iaddr_pset cip_pset;
if ((oc = lookup_option (&dhcp_universe, packet -> options,
DHO_PORT_SET))) {//[pset]
struct data_string d2;
memset(&d2, 0, sizeof d2);
evaluate_option_cache (&d2, packet, (struct lease *)0,
(struct client_state *)0,
packet -> options,
(struct option_state *)0,
&global_scope, oc, MDL);
memcpy(&cip_pset.pset_index, d2.data, 2);
memcpy(&cip_pset.pset_mask, (void*)d2.data + 2, 2);
cip_pset.pset_index = ntohs(cip_pset.pset_index);
cip_pset.pset_mask = ntohs(cip_pset.pset_mask);
cip_pset.ip_addr.len = sizeof packet -> raw -> ciaddr;
memcpy (cip_pset.ip_addr.iabuf, &packet -> raw -> ciaddr,
sizeof packet -> raw -> ciaddr);
if (!find_lease_by_ip_pset (&lease, cip_pset, MDL))
goto nolease;
} else {
struct iaddr cip;

cip.len = sizeof packet -> raw -> ciaddr;
memcpy (cip.iabuf, &packet -> raw -> ciaddr,
sizeof packet -> raw -> ciaddr);
if (!find_lease_by_ip_addr (&lease, cip, MDL))
goto nolease;
cip.len = sizeof packet -> raw -> ciaddr;
memcpy (cip.iabuf, &packet -> raw -> ciaddr,
sizeof packet -> raw -> ciaddr);
if (!find_lease_by_ip_addr (&lease, cip, MDL))
goto nolease;
}
if (!lease)
goto nolease;

/* If there are no agent options on the lease, it's not
interesting. */
if (!lease -> agent_options)
Expand Down Expand Up @@ -273,9 +265,6 @@ dhcp (struct packet *packet) {
/* Classify the client. */
classify_client (packet);

/* [pset] check whether option 55 contains port set option */
//findPsetInOption55(packet);

switch (packet -> packet_type) {
case DHCPDISCOVER:
dhcpdiscover (packet, ms_nulltp);
Expand Down
22 changes: 21 additions & 1 deletion dhcp-4.2.3-P2/server/dhcpd.leases
@@ -1,5 +1,25 @@
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.2.3-P2

server-duid "\000\001\000\001\030\010\370\365\010\000'\366\002\307";
server-duid "\000\001\000\001\030\011 \213\010\000'\366\002\307";

lease 192.168.1.10 {
starts 4 2012/10/11 06:15:45;
ends 4 2012/10/11 06:16:57;
cltt 4 2012/10/11 06:15:45;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 08:00:27:f3:0f:45;
port-set 0x0800 0xf800;
}
lease 192.168.1.10 {
starts 4 2012/10/11 06:16:27;
ends 4 2012/10/11 06:17:39;
cltt 4 2012/10/11 06:16:27;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 08:00:27:f3:0f:45;
port-set 0x0800 0xf800;
}
15 changes: 0 additions & 15 deletions dhcp-4.2.3-P2/server/dhcpd.leases~
@@ -1,15 +0,0 @@
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.2.3-P2

server-duid "\000\001\000\001\030\010\370\365\010\000'\366\002\307";

lease 192.168.1.10 {
starts 4 2012/10/11 03:26:49;
ends 4 2012/10/11 03:36:49;
cltt 4 2012/10/11 03:26:49;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 08:00:27:f3:0f:45;
port-set 0x0800 0xf800;
}

0 comments on commit 4658272

Please sign in to comment.