Skip to content

Commit 541aff9

Browse files
committed
Report where too small packets are from in radsniff
1 parent 8ec7091 commit 541aff9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/bin/radsniff.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,8 +1330,11 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
13301330
*/
13311331
len = (p - data) + sizeof(udp_header_t) + RADIUS_HEADER_LENGTH; /* length value */
13321332
if ((size_t) len > header->caplen) {
1333-
REDEBUG("Packet too small, we require at least %zu bytes, captured %i bytes",
1334-
(size_t) len, header->caplen);
1333+
char src[INET6_ADDRSTRLEN];
1334+
inet_ntop(version == 4 ? AF_INET : AF_INET6,
1335+
version == 4 ? (void const *)&ip->ip_src.s_addr : (void const *)&ip6->ip_src, src, sizeof(src));
1336+
REDEBUG("Packet from %s too small, we require at least %zu bytes, captured %i bytes",
1337+
src, (size_t) len, header->caplen);
13351338
return;
13361339
}
13371340

@@ -1347,8 +1350,11 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
13471350
actual_len = header->caplen - (p - data);
13481351
/* Truncated data */
13491352
if (udp_len > actual_len) {
1350-
REDEBUG("Packet too small by %zi bytes, UDP header + Payload should be %hu bytes",
1351-
udp_len - actual_len, udp_len);
1353+
char src[INET6_ADDRSTRLEN];
1354+
inet_ntop(version == 4 ? AF_INET : AF_INET6,
1355+
version == 4 ? (void const *)&ip->ip_src.s_addr : (void const *)&ip6->ip_src, src, sizeof(src));
1356+
REDEBUG("Packet from %s too small by %zi bytes, UDP header + Payload should be %hu bytes",
1357+
src, udp_len - actual_len, udp_len);
13521358
return;
13531359
}
13541360

0 commit comments

Comments
 (0)