diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2018-02-09 00:06:52 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2018-02-09 00:06:52 +0000 |
commit | ee02707f510c5b7e607eb906153816a8e465df27 (patch) | |
tree | 3beef4e39a65e09be6e143b6746648efca022e49 | |
parent | e6991d12ff8e52443aeb2bf82f140a27c97d3caa (diff) |
it turns out the wccp header is optional
peek inside the payload to see if the first nibble looks like ipv4.
if it isnt ipv4 assume it is the wccp header.
-rw-r--r-- | usr.sbin/tcpdump/print-gre.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/usr.sbin/tcpdump/print-gre.c b/usr.sbin/tcpdump/print-gre.c index 19be61f5b66..d60877cdc24 100644 --- a/usr.sbin/tcpdump/print-gre.c +++ b/usr.sbin/tcpdump/print-gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-gre.c,v 1.16 2018/02/08 22:56:28 dlg Exp $ */ +/* $OpenBSD: print-gre.c,v 1.17 2018/02/09 00:06:51 dlg Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -219,25 +219,32 @@ gre_print_0(const u_char *p, u_int length) printf("keep-alive"); break; case GRE_WCCP: { - struct wccp_redirect *wccp; - printf("wccp "); - if (l < sizeof(*wccp)) { - printf("[|wccp]"); + + if (l == 0) return; - } - wccp = (struct wccp_redirect *)p; + if (*p >> 4 != 4) { + struct wccp_redirect *wccp; + + if (l < sizeof(*wccp)) { + printf("[|wccp]"); + return; + } - printf("D:%c A:%c SId:%u Alt:%u Pri:%u", - (wccp->flags & WCCP_D) ? '1' : '0', - (wccp->flags & WCCP_A) ? '1' : '0', - wccp->ServiceId, wccp->AltBucket, wccp->PriBucket); + wccp = (struct wccp_redirect *)p; - p += sizeof(*wccp); - l -= sizeof(*wccp); + printf("D:%c A:%c SId:%u Alt:%u Pri:%u", + (wccp->flags & WCCP_D) ? '1' : '0', + (wccp->flags & WCCP_A) ? '1' : '0', + wccp->ServiceId, wccp->AltBucket, wccp->PriBucket); + + p += sizeof(*wccp); + l -= sizeof(*wccp); + + printf(": "); + } - printf(": "); /* FALLTHROUGH */ } case ETHERTYPE_IP: |