diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2024-10-30 10:36:29 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2024-10-30 10:36:29 +0000 |
commit | 9b9cc3a587fda6f7d9516ac213a08c68e9f1813a (patch) | |
tree | 22088e972b2027aa7493700dd57d1bf804c0454b /usr.sbin | |
parent | 2da4331b3e4cce769fe27376ff81cf68fd3b2eb7 (diff) |
print pppoe tags as hex dumps rather than strvis-a-like'd text, unless
they're tags where text is likely. strvis on random cookies is hard to read
and compare, and it's easier to convert 0x05dc than \005\334 to 1500 for
PPP-Max-Payload. ok claudio dlg
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/tcpdump/print-ppp.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.sbin/tcpdump/print-ppp.c b/usr.sbin/tcpdump/print-ppp.c index 15bf91a7a99..2205525050e 100644 --- a/usr.sbin/tcpdump/print-ppp.c +++ b/usr.sbin/tcpdump/print-ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ppp.c,v 1.36 2021/12/01 18:28:46 deraadt Exp $ */ +/* $OpenBSD: print-ppp.c,v 1.37 2024/10/30 10:36:28 sthen Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 @@ -1291,6 +1291,7 @@ pppoe_if_print(u_short ethertype, const u_char *p, u_int length, u_int l) if (ethertype == ETHERTYPE_PPPOEDISC) { while (l > 0) { u_int16_t t_type, t_len; + int text = 0; if (l < 4) goto trunc; @@ -1310,9 +1311,11 @@ pppoe_if_print(u_short ethertype, const u_char *p, u_int length, u_int l) break; case PPPOE_TAG_SERVICE_NAME: printf("Service-Name"); + text = 1; break; case PPPOE_TAG_AC_NAME: printf("AC-Name"); + text = 1; break; case PPPOE_TAG_HOST_UNIQ: printf("Host-Uniq"); @@ -1331,25 +1334,32 @@ pppoe_if_print(u_short ethertype, const u_char *p, u_int length, u_int l) break; case PPPOE_TAG_SERVICE_NAME_ERROR: printf("Service-Name-Error"); + text = 1; break; case PPPOE_TAG_AC_SYSTEM_ERROR: printf("AC-System-Error"); + text = 1; break; case PPPOE_TAG_GENERIC_ERROR: printf("Generic-Error"); + text = 1; break; default: printf("Unknown(0x%04x)", t_type); } printf(", length %u%s", t_len, t_len ? " " : ""); - if (t_len) { + if (t_len && text == 1) { for (t_type = 0; t_type < t_len; t_type++) { if (isprint(p[t_type])) printf("%c", p[t_type]); else printf("\\%03o", p[t_type]); } + } else if (t_len) { + printf("0x"); + for (t_type = 0; t_type < t_len; t_type++) + printf("%02x", p[t_type]); } p += t_len; l -= t_len; |