Skip to content

Commit

Permalink
Add T1 and T2 timer processing to DHCPv4 replies
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Le Heux authored and GIC-de committed Oct 2, 2024
1 parent 2f0e2e0 commit a69aeeb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
12 changes: 10 additions & 2 deletions code/bngblaster/src/bbl_dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,16 @@ bbl_dhcp_rx(bbl_session_s *session, bbl_ethernet_header_s *eth, bbl_dhcp_s *dhcp
session->dhcp_domain_name = calloc(1, dhcp->domain_name_len +1);
strncpy(session->dhcp_domain_name, dhcp->domain_name, dhcp->domain_name_len);
}
session->dhcp_t1 = 0.5 * session->dhcp_lease_time; if(!session->dhcp_t1) session->dhcp_t1 = 1;
session->dhcp_t2 = 0.875 * session->dhcp_lease_time; if(!session->dhcp_t2) session->dhcp_t2 = 1;
if (dhcp->option_t1) {
session->dhcp_t1 = dhcp->t1;
} else {
session->dhcp_t1 = 0.5 * session->dhcp_lease_time; if(!session->dhcp_t1) session->dhcp_t1 = 1;
}
if (dhcp->option_t2) {
session->dhcp_t2 = dhcp->t2;
} else {
session->dhcp_t2 = 0.875 * session->dhcp_lease_time; if(!session->dhcp_t2) session->dhcp_t2 = 1;
}

session->send_requests &= ~BBL_SEND_DHCP_REQUEST;
if(!session->dhcp_established) {
Expand Down
14 changes: 14 additions & 0 deletions code/bngblaster/src/bbl_protocols.c
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,20 @@ decode_dhcp(uint8_t *buf, uint16_t len,
return DECODE_ERROR;
}
break;
case DHCP_OPTION_RENEWAL_TIME_VALUE:
if(option_len != 4) {
return DECODE_ERROR;
}
dhcp->t1 = be32toh(*(uint32_t*)buf);
dhcp->option_t1 = true;
break;
case DHCP_OPTION_REBINDING_TIME_VALUE:
if(option_len != 4) {
return DECODE_ERROR;
}
dhcp->t2 = be32toh(*(uint32_t*)buf);
dhcp->option_t2 = true;
break;
default:
break;
}
Expand Down
4 changes: 4 additions & 0 deletions code/bngblaster/src/bbl_protocols.h
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,8 @@ typedef struct bbl_dhcp_ {
uint32_t dns2;
uint32_t router;
uint16_t mtu;
uint32_t t1;
uint32_t t2;
char *host_name;
uint8_t host_name_len;
char *domain_name;
Expand All @@ -957,6 +959,8 @@ typedef struct bbl_dhcp_ {
bool option_mtu;
bool option_host_name;
bool option_domain_name;
bool option_t1;
bool option_t2;

access_line_s *access_line;
uint8_t *client_identifier;
Expand Down

0 comments on commit a69aeeb

Please sign in to comment.