Skip to content

Commit 07c3190

Browse files
committed
Merge ipN_print() into raw_if_print().
Reuse the existing IP_V() while at it.
1 parent 79e2df7 commit 07c3190

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

netdissect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,6 @@ extern u_int ieee802_15_4_print(netdissect_options *, const u_char *, u_int);
682682
extern void igmp_print(netdissect_options *, const u_char *, u_int);
683683
extern void igrp_print(netdissect_options *, const u_char *, u_int);
684684
extern void ip6_print(netdissect_options *, const u_char *, u_int);
685-
extern void ipN_print(netdissect_options *, const u_char *, u_int);
686685
extern void ip_print(netdissect_options *, const u_char *, const u_int);
687686
extern void ipcomp_print(netdissect_options *, const u_char *);
688687
extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);

print-ip.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -506,25 +506,3 @@ ip_print(netdissect_options *ndo,
506506
invalid:
507507
nd_print_invalid(ndo);
508508
}
509-
510-
void
511-
ipN_print(netdissect_options *ndo, const u_char *bp, u_int length)
512-
{
513-
ndo->ndo_protocol = "ipn";
514-
if (length < 1) {
515-
ND_PRINT("truncated-ip %u", length);
516-
return;
517-
}
518-
519-
switch (GET_U_1(bp) & 0xF0) {
520-
case 0x40:
521-
ip_print(ndo, bp, length);
522-
break;
523-
case 0x60:
524-
ip6_print(ndo, bp, length);
525-
break;
526-
default:
527-
ND_PRINT("unknown ip %u", (GET_U_1(bp) & 0xF0) >> 4);
528-
break;
529-
}
530-
}

print-raw.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include "netdissect-stdinc.h"
2727

2828
#include "netdissect.h"
29+
#include "extract.h"
30+
31+
#include "ip.h"
2932

3033
/*
3134
* The DLT_RAW packet has no header. It contains a raw IP packet.
@@ -39,5 +42,21 @@ raw_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
3942
if (ndo->ndo_eflag)
4043
ND_PRINT("ip: ");
4144

42-
ipN_print(ndo, p, h->len);
45+
if (h->len < 1) {
46+
ND_PRINT("truncated-ip %u", h->len);
47+
return;
48+
}
49+
50+
u_char ipver = IP_V((const struct ip *)p);
51+
switch (ipver) {
52+
case 4:
53+
ip_print(ndo, p, h->len);
54+
break;
55+
case 6:
56+
ip6_print(ndo, p, h->len);
57+
break;
58+
default:
59+
ND_PRINT("unknown ip %u", ipver);
60+
break;
61+
}
4362
}

0 commit comments

Comments
 (0)