From 0b34810726c2a52ea1d093c496aa157ef3a151d0 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Tue, 3 Oct 2023 15:41:53 -0500 Subject: [PATCH 1/2] Fix unused variable warning Commit d6171b8df956fe506044e321ad4de1588f9bd173 switched from using the kernel's `IPV6_CHECKSUM` to calculate the checksum to a manual checksum calculation. Although, it did not remove the reference to the socket leading to an unused variable warning. --- packet/construct_unix.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packet/construct_unix.c b/packet/construct_unix.c index 95fefba..d6c34f9 100644 --- a/packet/construct_unix.c +++ b/packet/construct_unix.c @@ -244,13 +244,11 @@ int construct_udp4_packet( /* Construct a header for UDPv6 probes */ static int construct_udp6_packet( - const struct net_state_t *net_state, struct probe_t *probe, char *packet_buffer, int packet_size, const struct probe_param_t *param) { - int udp_socket = net_state->platform.udp6_send_socket; struct UDPHeader *udp; int udp_size; @@ -782,7 +780,7 @@ int construct_ip6_packet( } if (construct_udp6_packet - (net_state, probe, packet_buffer, packet_size, param)) { + (probe, packet_buffer, packet_size, param)) { return -1; } } else { From 94362ed05f806d26021832f5e98b29597cfd33ce Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Tue, 3 Oct 2023 15:56:44 -0500 Subject: [PATCH 2/2] udp4_checksum -> udp_checksum (also used for ipv6) `udp4_checksum` is also used to checksum udp over ipv6. --- packet/construct_unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packet/construct_unix.c b/packet/construct_unix.c index d6c34f9..97dea1b 100644 --- a/packet/construct_unix.c +++ b/packet/construct_unix.c @@ -175,7 +175,7 @@ void set_udp_ports( /* Prepend pseudoheader to the udp datagram and calculate checksum */ static -int udp4_checksum(void *pheader, void *udata, int psize, int dsize, +int udp_checksum(void *pheader, void *udata, int psize, int dsize, int alt_checksum) { unsigned int totalsize = psize + dsize; @@ -234,7 +234,7 @@ int construct_udp4_packet( udp_size + sizeof(struct UDPHeader)]; } - *checksum_off = htons(udp4_checksum(&udph, udp, + *checksum_off = htons(udp_checksum(&udph, udp, sizeof(struct UDPPseudoHeader), udp_size, udp->checksum != 0)); @@ -276,7 +276,7 @@ int construct_udp6_packet( checksum_off is udp payload */ checksum_off = (uint16_t *)&packet_buffer[sizeof(struct UDPHeader)]; } - *checksum_off = htons(udp4_checksum(&udph, udp, + *checksum_off = htons(udp_checksum(&udph, udp, sizeof(struct IP6PseudoHeader), udp_size, udp->checksum != 0)); return 0;