Skip to content

Commit

Permalink
fix relay-reply dhcpv6 packet counter issue (#29)
Browse files Browse the repository at this point in the history
fix Advertise packets counted as Unknown
  • Loading branch information
jcaiMR authored Dec 29, 2022
1 parent 9b30690 commit 4bf1868
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,21 +567,20 @@ void relay_relay_forw(int sock, const uint8_t *msg, int32_t len, const ip6_hdr *
auto dhcp_relay_header = parse_dhcpv6_relay(msg);
current_position += sizeof(struct dhcpv6_relay_msg);

auto position = current_position + sizeof(struct dhcpv6_option);
auto dhcpv6msg = parse_dhcpv6_hdr(position);

while ((current_position - msg) < len) {
auto option = parse_dhcpv6_opt(current_position, &tmp);
current_position = tmp;
if (current_position - msg > len || ntohs(option->option_length) > sizeof(buffer) - (current_buffer_position - buffer)) {
break;
}
switch (ntohs(option->option_code)) {
case OPTION_RELAY_MSG:
memcpy(current_buffer_position, ((uint8_t *)option) + sizeof(struct dhcpv6_option), ntohs(option->option_length));
case OPTION_RELAY_MSG: {
uint8_t *dhcpv6_position = ((uint8_t *)option) + sizeof(struct dhcpv6_option);
type = parse_dhcpv6_hdr(dhcpv6_position)->msg_type;
memcpy(current_buffer_position, dhcpv6_position, ntohs(option->option_length));
current_buffer_position += ntohs(option->option_length);
type = dhcpv6msg->msg_type;
break;
}
default:
break;
}
Expand Down

0 comments on commit 4bf1868

Please sign in to comment.