Skip to content

Commit 4e7524b

Browse files
committed
EGP: Fix the -v flag usage
When -v flag is set print more fields, not less. Print the protocol name before any check. Use ND_ICHECK_U to check the version. s/packet length/length/ in an error message as in other prints.
1 parent 3989102 commit 4e7524b

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

CHANGES

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
5252
Use %zu when printing a sizeof to squelch compiler warnings
5353
Remove unused missing/strdup.c.
5454
(FIXME: somebody please wrap the line below just before the release)
55-
AODV, AppleTalk, BOOTP, CHDLC, DCCP, EAP, EGP, EIGRP, ForCES, Geneve, GRE, ICMP, Juniper, L2TP, LISP, mobile, MSDP, NetFlow, NFLOG, NTP, OLSR, pflog, PGM, RADIUS, RIP, RSVP, SCTP, SNMP, TCP, UDP, vsock: Modernize packet parsing style
56-
DCCP, EGP: Replace custom code with tok2str()
55+
AODV, AppleTalk, BOOTP, CHDLC, DCCP, EAP, EIGRP, ForCES, Geneve, GRE, ICMP, Juniper, L2TP, LISP, mobile, MSDP, NetFlow, NFLOG, NTP, OLSR, pflog, PGM, RADIUS, RIP, RSVP, SCTP, SNMP, TCP, UDP, vsock: Modernize packet parsing style
56+
DCCP: Replace custom code with tok2str().
5757
UDP: Clean up address and port printing.
5858
AppleTalk: Declutter appletalk.h.
5959
IEEE 802.11: Simplify handle_action().
@@ -108,6 +108,8 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
108108
IPv6 mobility: Modernize packet parsing and make fixes.
109109
IP6OPTS: Modernize packet parsing and make fixes.
110110
VXLAN: Add UDP port 8472 used by Linux as the default port.
111+
EGP: Replace custom code with tok2str(); Modernize packet parsing and
112+
fix the -v flag usage.
111113
User interface:
112114
Add optional unit suffix on -C file size.
113115
Improve the handling of size suffixes for -C.

print-egp.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,28 +256,27 @@ egp_print(netdissect_options *ndo,
256256
u_int status;
257257

258258
ndo->ndo_protocol = "egp";
259+
nd_print_protocol_caps(ndo);
260+
259261
egp = (const struct egp_packet *)bp;
260-
ND_ICHECKMSG_ZU("packet length", length, <, sizeof(*egp));
261-
ND_TCHECK_SIZE(egp);
262+
ND_ICHECK_ZU(length, <, sizeof(*egp));
262263

263264
version = GET_U_1(egp->egp_version);
264-
if (!ndo->ndo_vflag) {
265-
ND_PRINT("EGPv%u, AS %u, seq %u, length %u",
265+
ND_ICHECK_U(version, !=, EGP_VERSION);
266+
ND_TCHECK_SIZE(egp);
267+
268+
if (ndo->ndo_vflag) {
269+
ND_PRINT("v%u, AS %u, seq %u, length %u",
266270
version,
267271
GET_BE_U_2(egp->egp_as),
268272
GET_BE_U_2(egp->egp_sequence),
269273
length);
270274
return;
271275
} else
272-
ND_PRINT("EGPv%u, length %u",
276+
ND_PRINT("v%u, length %u",
273277
version,
274278
length);
275279

276-
if (version != EGP_VERSION) {
277-
ND_PRINT("[version %u]", version);
278-
return;
279-
}
280-
281280
type = GET_U_1(egp->egp_type);
282281
ND_PRINT(" %s", tok2str(egp_type_str, "[type %u]", type));
283282
code = GET_U_1(egp->egp_code);

0 commit comments

Comments
 (0)