summaryrefslogtreecommitdiff
path: root/print-juniper.c
diff options
context:
space:
mode:
authorhannes <hannes>2005-08-10 14:23:07 +0000
committerhannes <hannes>2005-08-10 14:23:07 +0000
commit88a7ba9550dcbc8470cb20a9bd31beaa70bd6d11 (patch)
tree6eaae5589809882d5d228ae4e0d65b0213cc5780 /print-juniper.c
parent511fa5aee772c86c48e893e6b7e0cec9233eec5c (diff)
downloadtcpdump-88a7ba9550dcbc8470cb20a9bd31beaa70bd6d11.tar.gz
add support for detection of the extension bit
Diffstat (limited to 'print-juniper.c')
-rw-r--r--print-juniper.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/print-juniper.c b/print-juniper.c
index 24f0c0c8..80136693 100644
--- a/print-juniper.c
+++ b/print-juniper.c
@@ -15,7 +15,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8.2.17 2005-07-29 23:51:37 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8.2.18 2005-08-10 14:23:07 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -40,6 +40,7 @@ static const char rcsid[] _U_ =
#define JUNIPER_BPF_IN 1 /* Incoming packet */
#define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */
#define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */
+#define JUNIPER_BPF_EXT 0x80 /* extensions present */
#define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */
#define JUNIPER_LSQ_COOKIE_RE (1 << 3)
@@ -732,7 +733,7 @@ static int
juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) {
struct juniper_cookie_table_t *lp = juniper_cookie_table;
- u_int idx;
+ u_int idx, offset;
l2info->header_len = 0;
l2info->cookie_len = 0;
@@ -747,12 +748,19 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */
printf("no magic-number found!");
return 0;
- } else
- l2info->header_len = 4;
+ }
if (eflag) /* print direction */
printf("%3s ",tok2str(juniper_direction_values,"---",l2info->direction));
+ /* extensions present ? - calculate how much bytes to skip */
+ if ((p[3] & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) {
+ offset = 6 + EXTRACT_16BITS(p+4);
+ if (eflag>1)
+ printf("ext-len %u, ",EXTRACT_16BITS(p+4));
+ } else
+ offset = 4;
+
if ((p[3] & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) {
if (eflag)
printf("no-L2-hdr, ");
@@ -761,15 +769,15 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
* perform the v4/v6 heuristics
* to figure out what it is
*/
- TCHECK2(p[8],1);
- if(ip_heuristic_guess(p+8,l2info->length-8) == 0)
+ TCHECK2(p[offset+4],1);
+ if(ip_heuristic_guess(p+offset+4,l2info->length-(offset+4)) == 0)
printf("no IP-hdr found!");
- l2info->header_len+=4;
+ l2info->header_len=offset+4;
return 0; /* stop parsing the output further */
}
-
+ l2info->header_len = offset;
p+=l2info->header_len;
l2info->length -= l2info->header_len;
l2info->caplen -= l2info->header_len;