Skip to content

Commit e23ac83

Browse files
committed
Raw: Avoid printing ambiguous "ip:" with -e option
Print "IP" or "IP6". Also update an error message. Add some LINKTYPE_RAW, LINKTYPE_IPV4, LINKTYPE_IPV6 tests printed with or without '-e'. Update 3 test outputs.
1 parent 41ba27c commit e23ac83

17 files changed

+29
-7
lines changed

print-raw.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ raw_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
3939
{
4040
ndo->ndo_protocol = "raw";
4141
ndo->ndo_ll_hdr_len += 0;
42-
if (ndo->ndo_eflag)
43-
ND_PRINT("ip: ");
4442

4543
if (h->len < 1) {
4644
ND_PRINT("truncated-ip %u", h->len);
@@ -50,13 +48,18 @@ raw_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
5048
u_char ipver = IP_V((const struct ip *)p);
5149
switch (ipver) {
5250
case 4:
51+
if (ndo->ndo_eflag)
52+
ND_PRINT("IP ");
5353
ip_print(ndo, p, h->len);
5454
break;
5555
case 6:
56+
if (ndo->ndo_eflag)
57+
ND_PRINT("IP6 ");
5658
ip6_print(ndo, p, h->len);
5759
break;
5860
default:
59-
ND_PRINT("unknown ip %u", ipver);
61+
ND_PRINT("IP%u", ipver);
62+
nd_print_invalid(ndo);
6063
break;
6164
}
6265
}

tests/LINKTYPE_IPV4-e.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-07-08 17:59:32.592885 IP 192.168.1.100.12345 > 9.9.9.9.53: 4660+ A? example.com. (29)

tests/LINKTYPE_IPV4.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-07-08 17:59:32.592885 IP 192.168.1.100.12345 > 9.9.9.9.53: 4660+ A? example.com. (29)

tests/LINKTYPE_IPV4.pcap

97 Bytes
Binary file not shown.

tests/LINKTYPE_IPV6-e.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-07-08 17:59:26.204450 IP6 2001:db8::1.12345 > 2620:fe::9.53: 4660+ A? example.com. (29)

tests/LINKTYPE_IPV6.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-07-08 17:59:26.204450 IP6 2001:db8::1.12345 > 2620:fe::9.53: 4660+ A? example.com. (29)

tests/LINKTYPE_IPV6.pcap

117 Bytes
Binary file not shown.

tests/LINKTYPE_RAW_ipv4-e.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-07-08 17:59:11.951226 IP 192.168.1.100.12345 > 9.9.9.9.53: 4660+ A? example.com. (29)

tests/LINKTYPE_RAW_ipv4.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 2025-07-08 17:59:11.951226 IP 192.168.1.100.12345 > 9.9.9.9.53: 4660+ A? example.com. (29)

tests/LINKTYPE_RAW_ipv4.pcap

97 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)