2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that: (1) source code
4 * distributions retain the above copyright notice and this paragraph
5 * in its entirety, and (2) distributions including binary code include
6 * the above copyright notice and this paragraph in its entirety in
7 * the documentation or other materials provided with the distribution.
8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE.
13 * Original code by Hannes Gredler (hannes@juniper.net)
17 static const char rcsid
[] _U_
=
18 "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.21 2005-06-20 07:37:02 hannes Exp $ (LBL)";
25 #include <tcpdump-stdinc.h>
30 #include "interface.h"
31 #include "addrtoname.h"
36 #include "ethertype.h"
39 #define JUNIPER_BPF_OUT 0 /* Outgoing packet */
40 #define JUNIPER_BPF_IN 1 /* Incoming packet */
41 #define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */
42 #define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */
43 #define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */
45 #define JUNIPER_LSQ_L3_PROTO_SHIFT 4
46 #define JUNIPER_LSQ_L3_PROTO_MASK (0x17 << JUNIPER_LSQ_L3_PROTO_SHIFT)
47 #define JUNIPER_LSQ_L3_PROTO_IPV4 (0 << JUNIPER_LSQ_L3_PROTO_SHIFT)
48 #define JUNIPER_LSQ_L3_PROTO_IPV6 (1 << JUNIPER_LSQ_L3_PROTO_SHIFT)
49 #define JUNIPER_LSQ_L3_PROTO_MPLS (2 << JUNIPER_LSQ_L3_PROTO_SHIFT)
50 #define JUNIPER_LSQ_L3_PROTO_ISO (3 << JUNIPER_LSQ_L3_PROTO_SHIFT)
52 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE 1
53 #define JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE 2
54 #define JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE 3
55 #define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4
56 #define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5
58 static struct tok juniper_ipsec_type_values
[] = {
59 { JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE
, "ESP ENCR-AUTH" },
60 { JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE
, "ESP ENCR-AH AUTH" },
61 { JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE
, "ESP AUTH" },
62 { JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE
, "AH AUTH" },
63 { JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE
, "ESP ENCR" },
67 static struct tok juniper_direction_values
[] = {
68 { JUNIPER_BPF_IN
, "In"},
69 { JUNIPER_BPF_OUT
, "Out"},
73 struct juniper_cookie_table_t
{
74 u_int32_t pictype
; /* pic type */
75 u_int8_t cookie_len
; /* cookie len */
76 const char *s
; /* pic name */
79 static struct juniper_cookie_table_t juniper_cookie_table
[] = {
80 #ifdef DLT_JUNIPER_ATM1
81 { DLT_JUNIPER_ATM1
, 4, "ATM1"},
83 #ifdef DLT_JUNIPER_ATM2
84 { DLT_JUNIPER_ATM2
, 8, "ATM2"},
86 #ifdef DLT_JUNIPER_MLPPP
87 { DLT_JUNIPER_MLPPP
, 2, "MLPPP"},
89 #ifdef DLT_JUNIPER_MLFR
90 { DLT_JUNIPER_MLFR
, 2, "MLFR"},
92 #ifdef DLT_JUNIPER_MFR
93 { DLT_JUNIPER_MFR
, 4, "MFR"},
95 #ifdef DLT_JUNIPER_PPPOE
96 { DLT_JUNIPER_PPPOE
, 0, "PPPoE"},
98 #ifdef DLT_JUNIPER_PPPOE_ATM
99 { DLT_JUNIPER_PPPOE_ATM
, 0, "PPPoE ATM"},
101 #ifdef DLT_JUNIPER_GGSN
102 { DLT_JUNIPER_GGSN
, 8, "GGSN"},
104 #ifdef DLT_JUNIPER_MONITOR
105 { DLT_JUNIPER_MONITOR
, 8, "MONITOR"},
107 #ifdef DLT_JUNIPER_SERVICES
108 { DLT_JUNIPER_SERVICES
, 8, "AS"},
110 #ifdef DLT_JUNIPER_ES
111 { DLT_JUNIPER_ES
, 0, "ES"},
116 struct juniper_l2info_t
{
123 u_int8_t cookie_type
;
129 #define LS_COOKIE_ID 0x54
130 #define AS_COOKIE_ID 0x47
131 #define LS_MLFR_COOKIE_LEN 4
132 #define ML_MLFR_COOKIE_LEN 2
133 #define LS_MFR_COOKIE_LEN 6
134 #define ATM1_COOKIE_LEN 4
135 #define ATM2_COOKIE_LEN 8
137 #define ATM2_PKT_TYPE_MASK 0x70
138 #define ATM2_GAP_COUNT_MASK 0x3F
140 #define JUNIPER_PROTO_NULL 1
141 #define JUNIPER_PROTO_IPV4 2
142 #define JUNIPER_PROTO_IPV6 6
144 static struct tok juniper_protocol_values
[] = {
145 { JUNIPER_PROTO_NULL
, "Null" },
146 { JUNIPER_PROTO_IPV4
, "IPv4" },
147 { JUNIPER_PROTO_IPV6
, "IPv6" },
151 int ip_heuristic_guess(register const u_char
*, u_int
);
152 int juniper_ppp_heuristic_guess(register const u_char
*, u_int
);
153 static int juniper_parse_header (const u_char
*, const struct pcap_pkthdr
*, struct juniper_l2info_t
*);
155 #ifdef DLT_JUNIPER_GGSN
157 juniper_ggsn_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
159 struct juniper_l2info_t l2info
;
160 struct juniper_ggsn_header
{
168 const struct juniper_ggsn_header
*gh
;
170 l2info
.pictype
= DLT_JUNIPER_GGSN
;
171 if(juniper_parse_header(p
, h
, &l2info
) == 0)
172 return l2info
.header_len
;
174 p
+=l2info
.header_len
;
175 gh
= (struct juniper_ggsn_header
*)p
;
178 printf("proto %s (%u), vlan %u: ",
179 tok2str(juniper_protocol_values
,"Unknown",gh
->proto
),
181 EXTRACT_16BITS(&gh
->vlan_id
[0]));
184 case JUNIPER_PROTO_IPV4
:
185 ip_print(gndo
, p
, l2info
.length
);
188 case JUNIPER_PROTO_IPV6
:
189 ip6_print(p
, l2info
.length
);
194 printf("unknown GGSN proto (%u)", gh
->proto
);
197 return l2info
.header_len
;
201 #ifdef DLT_JUNIPER_ES
203 juniper_es_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
205 struct juniper_l2info_t l2info
;
206 struct juniper_ipsec_header
{
207 u_int8_t sa_index
[2];
214 u_int rewrite_len
,es_type_bundle
;
215 const struct juniper_ipsec_header
*ih
;
217 l2info
.pictype
= DLT_JUNIPER_ES
;
218 if(juniper_parse_header(p
, h
, &l2info
) == 0)
219 return l2info
.header_len
;
221 p
+=l2info
.header_len
;
222 ih
= (struct juniper_ipsec_header
*)p
;
225 case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE
:
226 case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE
:
230 case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE
:
231 case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE
:
232 case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE
:
236 printf("ES Invalid type %u, length %u",
239 return l2info
.header_len
;
242 l2info
.length
-=rewrite_len
;
246 if (!es_type_bundle
) {
247 printf("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
248 EXTRACT_16BITS(&ih
->sa_index
),
250 tok2str(juniper_ipsec_type_values
,"Unknown",ih
->type
),
252 EXTRACT_32BITS(&ih
->spi
),
253 ipaddr_string(EXTRACT_32BITS(&ih
->src_ip
)),
254 ipaddr_string(EXTRACT_32BITS(&ih
->dst_ip
)),
257 printf("ES SA, index %u, ttl %u type %s (%u), length %u\n",
258 EXTRACT_16BITS(&ih
->sa_index
),
260 tok2str(juniper_ipsec_type_values
,"Unknown",ih
->type
),
266 ip_print(gndo
, p
, l2info
.length
);
267 return l2info
.header_len
;
271 #ifdef DLT_JUNIPER_MONITOR
273 juniper_monitor_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
275 struct juniper_l2info_t l2info
;
276 struct juniper_monitor_header
{
280 u_int8_t service_id
[4];
282 const struct juniper_monitor_header
*mh
;
284 l2info
.pictype
= DLT_JUNIPER_MONITOR
;
285 if(juniper_parse_header(p
, h
, &l2info
) == 0)
286 return l2info
.header_len
;
288 p
+=l2info
.header_len
;
289 mh
= (struct juniper_monitor_header
*)p
;
292 printf("service-id %u, iif %u, pkt-type %u: ",
293 EXTRACT_32BITS(&mh
->service_id
),
294 EXTRACT_16BITS(&mh
->iif
),
297 /* no proto field - lets guess by first byte of IP header*/
298 ip_heuristic_guess(p
, l2info
.length
);
300 return l2info
.header_len
;
304 #ifdef DLT_JUNIPER_SERVICES
306 juniper_services_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
308 struct juniper_l2info_t l2info
;
309 struct juniper_services_header
{
312 u_int8_t svc_set_id
[2];
315 const struct juniper_services_header
*sh
;
317 l2info
.pictype
= DLT_JUNIPER_SERVICES
;
318 if(juniper_parse_header(p
, h
, &l2info
) == 0)
319 return l2info
.header_len
;
321 p
+=l2info
.header_len
;
322 sh
= (struct juniper_services_header
*)p
;
325 printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
328 EXTRACT_16BITS(&sh
->svc_set_id
),
329 EXTRACT_24BITS(&sh
->dir_iif
[1]));
331 /* no proto field - lets guess by first byte of IP header*/
332 ip_heuristic_guess(p
, l2info
.length
);
334 return l2info
.header_len
;
338 #ifdef DLT_JUNIPER_PPPOE
340 juniper_pppoe_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
342 struct juniper_l2info_t l2info
;
344 l2info
.pictype
= DLT_JUNIPER_PPPOE
;
345 if(juniper_parse_header(p
, h
, &l2info
) == 0)
346 return l2info
.header_len
;
348 p
+=l2info
.header_len
;
349 /* this DLT contains nothing but raw ethernet frames */
350 ether_print(p
, l2info
.length
, l2info
.caplen
);
351 return l2info
.header_len
;
355 #ifdef DLT_JUNIPER_PPPOE_ATM
357 juniper_pppoe_atm_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
359 struct juniper_l2info_t l2info
;
360 u_int16_t extracted_ethertype
;
362 l2info
.pictype
= DLT_JUNIPER_PPPOE_ATM
;
363 if(juniper_parse_header(p
, h
, &l2info
) == 0)
364 return l2info
.header_len
;
366 p
+=l2info
.header_len
;
368 extracted_ethertype
= EXTRACT_16BITS(p
);
369 /* this DLT contains nothing but raw PPPoE frames,
370 * prepended with a type field*/
371 if (ether_encap_print(extracted_ethertype
,
373 l2info
.length
-ETHERTYPE_LEN
,
374 l2info
.caplen
-ETHERTYPE_LEN
,
375 &extracted_ethertype
) == 0)
376 /* ether_type not known, probably it wasn't one */
377 printf("unknown ethertype 0x%04x", extracted_ethertype
);
379 return l2info
.header_len
;
383 #ifdef DLT_JUNIPER_MLPPP
385 juniper_mlppp_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
387 struct juniper_l2info_t l2info
;
389 l2info
.pictype
= DLT_JUNIPER_MLPPP
;
390 if(juniper_parse_header(p
, h
, &l2info
) == 0)
391 return l2info
.header_len
;
393 /* suppress Bundle-ID if frame was captured on a child-link
394 * best indicator if the cookie looks like a proto */
396 EXTRACT_16BITS(&l2info
.cookie
) != PPP_OSI
&&
397 EXTRACT_16BITS(&l2info
.cookie
) != (PPP_ADDRESS
<< 8 | PPP_CONTROL
))
398 printf("Bundle-ID %u: ",l2info
.bundle
);
400 p
+=l2info
.header_len
;
402 /* first try the LSQ protos */
403 switch(l2info
.proto
) {
404 case JUNIPER_LSQ_L3_PROTO_IPV4
:
405 ip_print(gndo
, p
, l2info
.length
);
406 return l2info
.header_len
;
408 case JUNIPER_LSQ_L3_PROTO_IPV6
:
409 ip6_print(p
,l2info
.length
);
410 return l2info
.header_len
;
412 case JUNIPER_LSQ_L3_PROTO_MPLS
:
413 mpls_print(p
,l2info
.length
);
414 return l2info
.header_len
;
415 case JUNIPER_LSQ_L3_PROTO_ISO
:
416 isoclns_print(p
,l2info
.length
,l2info
.caplen
);
417 return l2info
.header_len
;
422 /* zero length cookie ? */
423 switch (EXTRACT_16BITS(&l2info
.cookie
)) {
425 ppp_print(p
-2,l2info
.length
+2);
427 case (PPP_ADDRESS
<< 8 | PPP_CONTROL
): /* fall through */
429 ppp_print(p
,l2info
.length
);
433 return l2info
.header_len
;
438 #ifdef DLT_JUNIPER_MFR
440 juniper_mfr_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
442 struct juniper_l2info_t l2info
;
444 l2info
.pictype
= DLT_JUNIPER_MFR
;
445 if(juniper_parse_header(p
, h
, &l2info
) == 0)
446 return l2info
.header_len
;
448 p
+=l2info
.header_len
;
449 /* suppress Bundle-ID if frame was captured on a child-link */
450 if (eflag
&& EXTRACT_32BITS(l2info
.cookie
) != 1) printf("Bundle-ID %u, ",l2info
.bundle
);
451 switch (l2info
.proto
) {
452 case (LLCSAP_ISONS
<<8 | LLCSAP_ISONS
):
453 isoclns_print(p
+1, l2info
.length
-1, l2info
.caplen
-1);
455 case (LLC_UI
<<8 | NLPID_Q933
):
456 case (LLC_UI
<<8 | NLPID_IP
):
457 case (LLC_UI
<<8 | NLPID_IP6
):
458 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
459 isoclns_print(p
-1, l2info
.length
+1, l2info
.caplen
+1);
462 printf("unknown protocol 0x%04x, length %u",l2info
.proto
, l2info
.length
);
465 return l2info
.header_len
;
469 #ifdef DLT_JUNIPER_MLFR
471 juniper_mlfr_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
473 struct juniper_l2info_t l2info
;
475 l2info
.pictype
= DLT_JUNIPER_MLFR
;
476 if(juniper_parse_header(p
, h
, &l2info
) == 0)
477 return l2info
.header_len
;
479 p
+=l2info
.header_len
;
481 /* suppress Bundle-ID if frame was captured on a child-link */
482 if (eflag
&& EXTRACT_32BITS(l2info
.cookie
) != 1) printf("Bundle-ID %u, ",l2info
.bundle
);
483 switch (l2info
.proto
) {
486 isoclns_print(p
, l2info
.length
, l2info
.caplen
);
488 case (LLC_UI
<<8 | NLPID_Q933
):
489 case (LLC_UI
<<8 | NLPID_IP
):
490 case (LLC_UI
<<8 | NLPID_IP6
):
491 /* pass IP{4,6} to the OSI layer for proper link-layer printing */
492 isoclns_print(p
-1, l2info
.length
+1, l2info
.caplen
+1);
495 printf("unknown protocol 0x%04x, length %u",l2info
.proto
, l2info
.length
);
498 return l2info
.header_len
;
503 * ATM1 PIC cookie format
505 * +-----+-------------------------+-------------------------------+
506 * |fmtid| vc index | channel ID |
507 * +-----+-------------------------+-------------------------------+
510 #ifdef DLT_JUNIPER_ATM1
512 juniper_atm1_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
514 u_int16_t extracted_ethertype
;
516 struct juniper_l2info_t l2info
;
518 l2info
.pictype
= DLT_JUNIPER_ATM1
;
519 if(juniper_parse_header(p
, h
, &l2info
) == 0)
520 return l2info
.header_len
;
522 p
+=l2info
.header_len
;
524 if (l2info
.cookie
[0] == 0x80) { /* OAM cell ? */
525 oam_print(p
,l2info
.length
,ATM_OAM_NOHEC
);
526 return l2info
.header_len
;
529 if (EXTRACT_24BITS(p
) == 0xfefe03 || /* NLPID encaps ? */
530 EXTRACT_24BITS(p
) == 0xaaaa03) { /* SNAP encaps ? */
532 if (llc_print(p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
,
533 &extracted_ethertype
) != 0)
534 return l2info
.header_len
;
537 if (p
[0] == 0x03) { /* Cisco style NLPID encaps ? */
538 isoclns_print(p
+ 1, l2info
.length
- 1, l2info
.caplen
- 1);
539 /* FIXME check if frame was recognized */
540 return l2info
.header_len
;
543 if(ip_heuristic_guess(p
, l2info
.length
) != 0) /* last try - vcmux encaps ? */
544 return l2info
.header_len
;
546 return l2info
.header_len
;
551 * ATM2 PIC cookie format
553 * +-------------------------------+---------+---+-----+-----------+
554 * | channel ID | reserv |AAL| CCRQ| gap cnt |
555 * +-------------------------------+---------+---+-----+-----------+
558 #ifdef DLT_JUNIPER_ATM2
560 juniper_atm2_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
562 u_int16_t extracted_ethertype
;
563 u_int32_t control_word
;
565 struct juniper_l2info_t l2info
;
567 l2info
.pictype
= DLT_JUNIPER_ATM2
;
568 if(juniper_parse_header(p
, h
, &l2info
) == 0)
569 return l2info
.header_len
;
571 p
+=l2info
.header_len
;
573 if (l2info
.cookie
[7] & ATM2_PKT_TYPE_MASK
) { /* OAM cell ? */
574 control_word
= EXTRACT_32BITS(p
);
575 if(control_word
== 0 || control_word
== 0x08000000) {
576 l2info
.header_len
+= 4;
580 oam_print(p
,l2info
.length
,ATM_OAM_NOHEC
);
581 return l2info
.header_len
;
584 if (EXTRACT_24BITS(p
) == 0xfefe03 || /* NLPID encaps ? */
585 EXTRACT_24BITS(p
) == 0xaaaa03) { /* SNAP encaps ? */
587 if (llc_print(p
, l2info
.length
, l2info
.caplen
, NULL
, NULL
,
588 &extracted_ethertype
) != 0)
589 return l2info
.header_len
;
592 if (l2info
.direction
!= JUNIPER_BPF_PKT_IN
&& /* ether-over-1483 encaps ? */
593 (EXTRACT_32BITS(l2info
.cookie
) & ATM2_GAP_COUNT_MASK
)) {
594 ether_print(p
, l2info
.length
, l2info
.caplen
);
595 return l2info
.header_len
;
598 if (p
[0] == 0x03) { /* Cisco style NLPID encaps ? */
599 isoclns_print(p
+ 1, l2info
.length
- 1, l2info
.caplen
- 1);
600 /* FIXME check if frame was recognized */
601 return l2info
.header_len
;
604 if(juniper_ppp_heuristic_guess(p
, l2info
.length
) != 0) /* PPPoA vcmux encaps ? */
605 return l2info
.header_len
;
607 if(ip_heuristic_guess(p
, l2info
.length
) != 0) /* last try - vcmux encaps ? */
608 return l2info
.header_len
;
610 return l2info
.header_len
;
615 /* try to guess, based on all PPP protos that are supported in
616 * a juniper router if the payload data is encapsulated using PPP */
618 juniper_ppp_heuristic_guess(register const u_char
*p
, u_int length
) {
620 switch(EXTRACT_16BITS(p
)) {
623 case PPP_MPLS_UCAST
:
624 case PPP_MPLS_MCAST
:
636 ppp_print(p
, length
);
640 return 0; /* did not find a ppp header */
643 return 1; /* we printed a ppp packet */
647 ip_heuristic_guess(register const u_char
*p
, u_int length
) {
661 ip_print(gndo
, p
, length
);
680 ip6_print(p
, length
);
684 return 0; /* did not find a ip header */
687 return 1; /* we printed an v4/v6 packet */
691 juniper_parse_header (const u_char
*p
, const struct pcap_pkthdr
*h
, struct juniper_l2info_t
*l2info
) {
693 struct juniper_cookie_table_t
*lp
= juniper_cookie_table
;
696 l2info
->header_len
= 0;
697 l2info
->cookie_len
= 0;
701 l2info
->length
= h
->len
;
702 l2info
->caplen
= h
->caplen
;
703 l2info
->direction
= p
[3]&JUNIPER_BPF_PKT_IN
;
706 if (EXTRACT_24BITS(p
) != JUNIPER_MGC_NUMBER
) /* magic number found ? */
709 l2info
->header_len
= 4;
711 if (eflag
) /* print direction */
712 printf("%3s ",tok2str(juniper_direction_values
,"---",l2info
->direction
));
714 if ((p
[3] & JUNIPER_BPF_NO_L2
) == JUNIPER_BPF_NO_L2
) {
716 printf("no-L2-hdr, ");
718 /* there is no link-layer present -
719 * perform the v4/v6 heuristics
720 * to figure out what it is
723 if(ip_heuristic_guess(p
+8,l2info
->length
-8) == 0)
724 printf("no IP-hdr found!");
726 l2info
->header_len
+=4;
727 return 0; /* stop parsing the output further */
731 p
+=l2info
->header_len
;
732 l2info
->length
-= l2info
->header_len
;
733 l2info
->caplen
-= l2info
->header_len
;
735 /* search through the cookie table and copy values matching for our PIC type */
736 while (lp
->s
!= NULL
) {
737 if (lp
->pictype
== l2info
->pictype
) {
739 l2info
->cookie_len
= lp
->cookie_len
;
740 l2info
->header_len
+= lp
->cookie_len
;
744 l2info
->cookie_type
= LS_COOKIE_ID
;
745 l2info
->cookie_len
+= 2;
746 l2info
->header_len
+= 2;
749 l2info
->cookie_type
= AS_COOKIE_ID
;
750 l2info
->cookie_len
+= 6;
751 l2info
->header_len
+= 6;
755 l2info
->bundle
= l2info
->cookie
[0];
760 printf("%s-PIC, cookie-len %u",
764 if (l2info
->cookie_len
> 0) {
765 TCHECK2(p
[0],l2info
->cookie_len
);
767 printf(", cookie 0x");
768 for (idx
= 0; idx
< l2info
->cookie_len
; idx
++) {
769 l2info
->cookie
[idx
] = p
[idx
]; /* copy cookie data */
770 if (eflag
) printf("%02x",p
[idx
]);
774 if (eflag
) printf(": "); /* print demarc b/w L2/L3*/
777 l2info
->proto
= EXTRACT_16BITS(p
+l2info
->cookie_len
);
782 p
+=l2info
->cookie_len
;
784 /* DLT_ specific parsing */
785 switch(l2info
->pictype
) {
786 case DLT_JUNIPER_MLPPP
:
787 switch (l2info
->cookie_type
) {
789 l2info
->bundle
= l2info
->cookie
[1];
792 l2info
->bundle
= (EXTRACT_16BITS(&l2info
->cookie
[6])>>3)&0xfff;
793 l2info
->proto
= (l2info
->cookie
[5])&JUNIPER_LSQ_L3_PROTO_MASK
;
796 l2info
->bundle
= l2info
->cookie
[0];
800 case DLT_JUNIPER_MLFR
: /* fall through */
801 case DLT_JUNIPER_MFR
:
802 switch (l2info
->cookie_type
) {
804 l2info
->bundle
= l2info
->cookie
[1];
807 l2info
->bundle
= (EXTRACT_16BITS(&l2info
->cookie
[6])>>3)&0xfff;
810 l2info
->bundle
= l2info
->cookie
[0];
813 l2info
->proto
= EXTRACT_16BITS(p
);
814 l2info
->header_len
+= 2;
818 case DLT_JUNIPER_ATM2
:
820 /* ATM cell relay control word present ? */
821 if (l2info
->cookie
[7] & ATM2_PKT_TYPE_MASK
&& *p
& 0x08) {
822 l2info
->header_len
+= 4;
824 printf("control-word 0x%08x ",EXTRACT_32BITS(p
));
827 case DLT_JUNIPER_ATM1
:
833 printf("hlen %u, proto 0x%04x, ",l2info
->header_len
,l2info
->proto
);
835 return 1; /* everything went ok so far. continue parsing */
837 printf("[|juniper_hdr], length %u",h
->len
);
844 * c-style: whitesmith