mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +00:00
udhcpsnoop: look at more options for the cache expiry
make the code look for leasetime, rebind and renew options to determine the cache expiry time. Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -6,10 +6,11 @@
|
|||||||
#include "dhcpsnoop.h"
|
#include "dhcpsnoop.h"
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
|
|
||||||
const char *dhcpsnoop_parse_ipv4(const void *buf, size_t len, uint16_t port, uint32_t *rebind)
|
const char *dhcpsnoop_parse_ipv4(const void *buf, size_t len, uint16_t port, uint32_t *expire)
|
||||||
{
|
{
|
||||||
const struct dhcpv4_message *msg = buf;
|
const struct dhcpv4_message *msg = buf;
|
||||||
const uint8_t *pos, *end;
|
const uint8_t *pos, *end;
|
||||||
|
uint32_t leasetime = 0, rebind = 0, renew = 0;
|
||||||
char type = 0;
|
char type = 0;
|
||||||
|
|
||||||
if (port != 67 && port != 68)
|
if (port != 67 && port != 68)
|
||||||
@@ -46,14 +47,32 @@ const char *dhcpsnoop_parse_ipv4(const void *buf, size_t len, uint16_t port, uin
|
|||||||
continue;
|
continue;
|
||||||
type = opt[2];
|
type = opt[2];
|
||||||
break;
|
break;
|
||||||
|
case DHCPV4_OPT_LEASETIME:
|
||||||
|
if (opt[1] != 4)
|
||||||
|
leasetime = *((uint32_t *) &opt[2]);
|
||||||
|
break;
|
||||||
case DHCPV4_OPT_REBIND:
|
case DHCPV4_OPT_REBIND:
|
||||||
if (!rebind || opt[1] != 4)
|
if (opt[1] != 4)
|
||||||
continue;
|
continue;
|
||||||
*rebind = *((uint32_t *) &opt[2]);
|
rebind = *((uint32_t *) &opt[2]);
|
||||||
|
break;
|
||||||
|
case DHCPV4_OPT_RENEW:
|
||||||
|
if (opt[1] != 4)
|
||||||
|
continue;
|
||||||
|
renew = *((uint32_t *) &opt[2]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (renew)
|
||||||
|
*expire = renew;
|
||||||
|
else if (rebind)
|
||||||
|
*expire = rebind;
|
||||||
|
else if (leasetime)
|
||||||
|
*expire = leasetime;
|
||||||
|
else
|
||||||
|
*expire = 24 * 60;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case DHCPV4_MSG_ACK:
|
case DHCPV4_MSG_ACK:
|
||||||
return "ack";
|
return "ack";
|
||||||
|
|||||||
Reference in New Issue
Block a user