2 * Copyright (C) 1999 WIDE Project.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
30 * complete BGP support.
38 static const char rcsid
[] =
39 "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.61 2003-02-11 06:28:39 guy Exp $";
42 #include <tcpdump-stdinc.h>
47 #include "interface.h"
48 #include "addrtoname.h"
52 u_int8_t bgp_marker
[16];
56 #define BGP_SIZE 19 /* unaligned */
60 #define BGP_NOTIFICATION 3
61 #define BGP_KEEPALIVE 4
62 #define BGP_ROUTE_REFRESH 5
64 static struct tok bgp_msg_values
[] = {
66 { BGP_UPDATE
, "Update"},
67 { BGP_NOTIFICATION
, "Notification"},
68 { BGP_KEEPALIVE
, "Keepalive"},
69 { BGP_ROUTE_REFRESH
, "Route Refresh"},
74 u_int8_t bgpo_marker
[16];
77 u_int8_t bgpo_version
;
79 u_int16_t bgpo_holdtime
;
82 /* options should follow */
84 #define BGP_OPEN_SIZE 29 /* unaligned */
91 #define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
93 struct bgp_notification
{
94 u_int8_t bgpn_marker
[16];
99 /* data should follow */
101 #define BGP_NOTIFICATION_SIZE 21 /* unaligned */
103 struct bgp_route_refresh
{
104 u_int8_t bgp_marker
[16];
107 u_int8_t afi
[2]; /* the compiler messes this structure up */
108 u_int8_t res
; /* when doing misaligned sequences of int8 and int16 */
109 u_int8_t safi
; /* afi should be int16 - so we have to access it using */
110 }; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
111 #define BGP_ROUTE_REFRESH_SIZE 23
120 #define bgp_attr_len(p) \
121 (((p)->bgpa_flags & 0x10) ? \
122 EXTRACT_16BITS(&(p)->bgpa_len.elen) : (p)->bgpa_len.len)
123 #define bgp_attr_off(p) \
124 (((p)->bgpa_flags & 0x10) ? 4 : 3)
127 #define BGPTYPE_ORIGIN 1
128 #define BGPTYPE_AS_PATH 2
129 #define BGPTYPE_NEXT_HOP 3
130 #define BGPTYPE_MULTI_EXIT_DISC 4
131 #define BGPTYPE_LOCAL_PREF 5
132 #define BGPTYPE_ATOMIC_AGGREGATE 6
133 #define BGPTYPE_AGGREGATOR 7
134 #define BGPTYPE_COMMUNITIES 8 /* RFC1997 */
135 #define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */
136 #define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */
137 #define BGPTYPE_DPA 11 /* draft-ietf-idr-bgp-dpa */
138 #define BGPTYPE_ADVERTISERS 12 /* RFC1863 */
139 #define BGPTYPE_RCID_PATH 13 /* RFC1863 */
140 #define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */
141 #define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */
142 #define BGPTYPE_EXTD_COMMUNITIES 16 /* draft-ietf-idr-bgp-ext-communities */
144 static struct tok bgp_attr_values
[] = {
145 { BGPTYPE_ORIGIN
, "Origin"},
146 { BGPTYPE_AS_PATH
, "AS Path"},
147 { BGPTYPE_NEXT_HOP
, "Next Hop"},
148 { BGPTYPE_MULTI_EXIT_DISC
, "Multi Exit Discriminator"},
149 { BGPTYPE_LOCAL_PREF
, "Local Preference"},
150 { BGPTYPE_ATOMIC_AGGREGATE
, "Atomic Aggregate"},
151 { BGPTYPE_AGGREGATOR
, "Aggregator"},
152 { BGPTYPE_COMMUNITIES
, "Community"},
153 { BGPTYPE_ORIGINATOR_ID
, "Originator ID"},
154 { BGPTYPE_CLUSTER_LIST
, "Cluster List"},
155 { BGPTYPE_DPA
, "DPA"},
156 { BGPTYPE_ADVERTISERS
, "Advertisers"},
157 { BGPTYPE_RCID_PATH
, "RCID Path / Cluster ID"},
158 { BGPTYPE_MP_REACH_NLRI
, "Multi-Protocol Reach NLRI"},
159 { BGPTYPE_MP_UNREACH_NLRI
, "Multi-Protocol Unreach NLRI"},
160 { BGPTYPE_EXTD_COMMUNITIES
, "Extended Community"},
161 { 255, "Reserved for development"},
165 #define BGP_OPT_AUTH 1
166 #define BGP_OPT_CAP 2
169 static struct tok bgp_opt_values
[] = {
170 { BGP_OPT_AUTH
, "Authentication Information"},
171 { BGP_OPT_CAP
, "Capabilities Advertisement"},
175 #define BGP_CAPCODE_MP 1
176 #define BGP_CAPCODE_RR 2
177 #define BGP_CAPCODE_RESTART 64 /* draft-ietf-idr-restart-05 */
178 #define BGP_CAPCODE_RR_CISCO 128
180 static struct tok bgp_capcode_values
[] = {
181 { BGP_CAPCODE_MP
, "Multiprotocol Extensions"},
182 { BGP_CAPCODE_RR
, "Route Refresh"},
183 { BGP_CAPCODE_RESTART
, "Graceful Restart"},
184 { BGP_CAPCODE_RR_CISCO
, "Route Refresh (Cisco)"},
188 #define BGP_NOTIFY_MAJOR_MSG 1
189 #define BGP_NOTIFY_MAJOR_OPEN 2
190 #define BGP_NOTIFY_MAJOR_UPDATE 3
191 #define BGP_NOTIFY_MAJOR_HOLDTIME 4
192 #define BGP_NOTIFY_MAJOR_FSM 5
193 #define BGP_NOTIFY_MAJOR_CEASE 6
195 static struct tok bgp_notify_major_values
[] = {
196 { BGP_NOTIFY_MAJOR_MSG
, "Message Header Error"},
197 { BGP_NOTIFY_MAJOR_OPEN
, "OPEN Message Error"},
198 { BGP_NOTIFY_MAJOR_UPDATE
, "UPDATE Message Error"},
199 { BGP_NOTIFY_MAJOR_HOLDTIME
,"Hold Timer Expired"},
200 { BGP_NOTIFY_MAJOR_FSM
, "Finite State Machine Error"},
201 { BGP_NOTIFY_MAJOR_CEASE
, "Cease"},
205 static struct tok bgp_notify_minor_msg_values
[] = {
206 { 1, "Connection Not Synchronized"},
207 { 2, "Bad Message Length"},
208 { 3, "Bad Message Type"},
212 static struct tok bgp_notify_minor_open_values
[] = {
213 { 1, "Unsupported Version Number"},
215 { 3, "Bad BGP Identifier"},
216 { 4, "Unsupported Optional Parameter"},
217 { 5, "Authentication Failure"},
218 { 6, "Unacceptable Hold Time"},
222 static struct tok bgp_notify_minor_update_values
[] = {
223 { 1, "Malformed Attribute List"},
224 { 2, "Unrecognized Well-known Attribute"},
225 { 3, "Missing Well-known Attribute"},
226 { 4, "Attribute Flags Error"},
227 { 5, "Attribute Length Error"},
228 { 6, "Invalid ORIGIN Attribute"},
229 { 7, "AS Routing Loop"},
230 { 8, "Invalid NEXT_HOP Attribute"},
231 { 9, "Optional Attribute Error"},
232 { 10, "Invalid Network Field"},
233 { 11, "Malformed AS_PATH"},
237 static struct tok bgp_origin_values
[] = {
244 /* Subsequent address family identifier, RFC2283 section 7 */
246 #define SAFNUM_UNICAST 1
247 #define SAFNUM_MULTICAST 2
248 #define SAFNUM_UNIMULTICAST 3
249 /* labeled BGP RFC3107 */
250 #define SAFNUM_LABUNICAST 4
251 /* Section 4.3.4 of draft-rosen-rfc2547bis-03.txt */
252 #define SAFNUM_VPNUNICAST 128
253 #define SAFNUM_VPNMULTICAST 129
254 #define SAFNUM_VPNUNIMULTICAST 130
256 #define BGP_VPN_RD_LEN 8
258 static struct tok bgp_safi_values
[] = {
259 { SAFNUM_RES
, "Reserved"},
260 { SAFNUM_UNICAST
, "Unicast"},
261 { SAFNUM_MULTICAST
, "Multicast"},
262 { SAFNUM_UNIMULTICAST
, "Unicast+Multicast"},
263 { SAFNUM_LABUNICAST
, "labeled Unicast"},
264 { SAFNUM_VPNUNICAST
, "labeled VPN Unicast"},
265 { SAFNUM_VPNMULTICAST
, "labeled VPN Multicast"},
266 { SAFNUM_VPNUNIMULTICAST
, "labeled VPN Unicast+Multicast"},
270 /* well-known community */
271 #define BGP_COMMUNITY_NO_EXPORT 0xffffff01
272 #define BGP_COMMUNITY_NO_ADVERT 0xffffff02
273 #define BGP_COMMUNITY_NO_EXPORT_SUBCONFED 0xffffff03
275 /* RFC1700 address family numbers */
277 #define AFNUM_INET6 2
280 #define AFNUM_BBN1822 5
285 #define AFNUM_X121 10
287 #define AFNUM_ATALK 12
288 #define AFNUM_DECNET 13
289 #define AFNUM_BANYAN 14
290 #define AFNUM_E164NSAP 15
291 /* draft-kompella-ppvpn-l2vpn */
292 #define AFNUM_L2VPN 196 /* still to be approved by IANA */
294 static struct tok bgp_afi_values
[] = {
296 { AFNUM_INET
, "IPv4"},
297 { AFNUM_INET6
, "IPv6"},
298 { AFNUM_NSAP
, "NSAP"},
299 { AFNUM_HDLC
, "HDLC"},
300 { AFNUM_BBN1822
, "BBN 1822"},
302 { AFNUM_E163
, "E.163"},
303 { AFNUM_E164
, "E.164"},
304 { AFNUM_F69
, "F.69"},
305 { AFNUM_X121
, "X.121"},
306 { AFNUM_IPX
, "Novell IPX"},
307 { AFNUM_ATALK
, "Appletalk"},
308 { AFNUM_DECNET
, "Decnet IV"},
309 { AFNUM_BANYAN
, "Banyan Vines"},
310 { AFNUM_E164NSAP
, "E.164 with NSAP subaddress"},
311 { AFNUM_L2VPN
, "Layer-2 VPN"},
315 /* Extended community type - draft-ramachandra-bgp-ext-communities */
316 #define BGP_EXT_COM_RT_0 0x0002 /* Route Target,Format AS(2bytes):AN(4bytes) */
317 #define BGP_EXT_COM_RT_1 0x0102 /* Route Target,Format IP address:AN(2bytes) */
318 #define BGP_EXT_COM_RO_0 0x0003 /* Route Origin,Format AS(2bytes):AN(4bytes) */
319 #define BGP_EXT_COM_RO_1 0x0103 /* Route Origin,Format IP address:AN(2bytes) */
320 #define BGP_EXT_COM_LINKBAND 0x4004 /* Link Bandwidth,Format AS(2B):Bandwidth(4B) */
321 /* rfc2547 bgp-mpls-vpns */
323 #define BGP_EXT_COM_VPN_ORIGIN 0x0005 /* OSPF Domain ID / VPN of Origin - draft-rosen-vpns-ospf-bgp-mpls */
324 #define BGP_EXT_COM_VPN_ORIGIN2 0x0105 /* duplicate - keep for backwards compatability */
325 #define BGP_EXT_COM_VPN_ORIGIN3 0x0205 /* duplicate - keep for backwards compatability */
326 #define BGP_EXT_COM_VPN_ORIGIN4 0x8005 /* duplicate - keep for backwards compatability */
328 #define BGP_EXT_COM_OSPF_RTYPE 0x0306 /* OSPF Route Type,Format Area(4B):RouteType(1B):Options(1B) */
329 #define BGP_EXT_COM_OSPF_RTYPE2 0x8000 /* duplicate - keep for backwards compatability */
331 #define BGP_EXT_COM_OSPF_RID 0x0107 /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
332 #define BGP_EXT_COM_OSPF_RID2 0x8001 /* duplicate - keep for backwards compatability */
334 #define BGP_EXT_COM_L2INFO 0x800a /* draft-kompella-ppvpn-l2vpn */
336 static struct tok bgp_extd_comm_subtype_values
[] = {
337 { BGP_EXT_COM_RT_0
, "target"},
338 { BGP_EXT_COM_RT_1
, "target"},
339 { BGP_EXT_COM_RO_0
, "origin"},
340 { BGP_EXT_COM_RO_1
, "origin"},
341 { BGP_EXT_COM_LINKBAND
, "link-BW"},
342 { BGP_EXT_COM_VPN_ORIGIN
, "ospf-domain"},
343 { BGP_EXT_COM_VPN_ORIGIN2
, "ospf-domain"},
344 { BGP_EXT_COM_VPN_ORIGIN3
, "ospf-domain"},
345 { BGP_EXT_COM_VPN_ORIGIN4
, "ospf-domain"},
346 { BGP_EXT_COM_OSPF_RTYPE
, "ospf-route-type"},
347 { BGP_EXT_COM_OSPF_RTYPE2
, "ospf-route-type"},
348 { BGP_EXT_COM_OSPF_RID
, "ospf-router-id"},
349 { BGP_EXT_COM_OSPF_RID2
, "ospf-router-id"},
350 { BGP_EXT_COM_L2INFO
, "layer2-info"},
354 /* OSPF codes for BGP_EXT_COM_OSPF_RTYPE draft-rosen-vpns-ospf-bgp-mpls */
355 #define BGP_OSPF_RTYPE_RTR 1 /* OSPF Router LSA */
356 #define BGP_OSPF_RTYPE_NET 2 /* OSPF Network LSA */
357 #define BGP_OSPF_RTYPE_SUM 3 /* OSPF Summary LSA */
358 #define BGP_OSPF_RTYPE_EXT 5 /* OSPF External LSA, note that ASBR doesn't apply to MPLS-VPN */
359 #define BGP_OSPF_RTYPE_NSSA 7 /* OSPF NSSA External*/
360 #define BGP_OSPF_RTYPE_SHAM 129 /* OSPF-MPLS-VPN Sham link */
361 #define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */
363 static struct tok bgp_extd_comm_ospf_rtype_values
[] = {
364 { BGP_OSPF_RTYPE_RTR
, "Router" },
365 { BGP_OSPF_RTYPE_NET
, "Network" },
366 { BGP_OSPF_RTYPE_SUM
, "Summary" },
367 { BGP_OSPF_RTYPE_EXT
, "External" },
368 { BGP_OSPF_RTYPE_NSSA
,"NSSA External" },
369 { BGP_OSPF_RTYPE_SHAM
,"MPLS-VPN Sham" },
373 static struct tok bgp_l2vpn_encaps_values
[] = {
376 { 2, "ATM AAL5 VCC transport"},
377 { 3, "ATM transparent cell transport"},
378 { 4, "Ethernet VLAN"},
383 { 9, "ATM VCC cell transport"},
384 { 10, "ATM VPC cell transport"},
387 { 64, "IP-interworking"},
392 decode_prefix4(const u_char
*pptr
, char *buf
, u_int buflen
)
401 memset(&addr
, 0, sizeof(addr
));
402 memcpy(&addr
, &pptr
[1], (plen
+ 7) / 8);
404 ((u_char
*)&addr
)[(plen
+ 7) / 8 - 1] &=
405 ((0xff00 >> (plen
% 8)) & 0xff);
407 snprintf(buf
, buflen
, "%s/%d", getname((u_char
*)&addr
), plen
);
408 return 1 + (plen
+ 7) / 8;
412 decode_labeled_prefix4(const u_char
*pptr
, char *buf
, u_int buflen
)
417 plen
= pptr
[0]; /* get prefix length */
419 /* this is one of the weirdnesses of rfc3107
420 the label length (actually the label + COS bits)
421 is added to the prefix length;
422 we also do only read out just one label -
423 there is no real application for advertisement of
424 stacked labels in a a single BGP message
427 plen
-=24; /* adjust prefixlen - labellength */
432 memset(&addr
, 0, sizeof(addr
));
433 memcpy(&addr
, &pptr
[4], (plen
+ 7) / 8);
435 ((u_char
*)&addr
)[(plen
+ 7) / 8 - 1] &=
436 ((0xff00 >> (plen
% 8)) & 0xff);
438 /* the label may get offsetted by 4 bits so lets shift it right */
439 snprintf(buf
, buflen
, "%s/%d, label:%u %s",
440 getname((u_char
*)&addr
),
442 EXTRACT_24BITS(pptr
+1)>>4,
443 ((pptr
[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
445 return 4 + (plen
+ 7) / 8;
449 bgp_vpn_rd_print (const u_char
*pptr
) {
451 /* allocate space for the following string
452 * xxx.xxx.xxx.xxx:xxxxx
453 * 21 bytes plus one termination byte */
457 /* ok lets load the RD format */
458 switch (EXTRACT_16BITS(pptr
)) {
459 /* AS:IP-address fmt*/
461 sprintf(pos
, "%u:%u.%u.%u.%u",
462 EXTRACT_16BITS(pptr
+2),
468 /* IP-address:AS fmt*/
470 sprintf(pos
, "%u.%u.%u.%u:%u",
475 EXTRACT_16BITS(pptr
+6));
478 sprintf(pos
, "unknown RD format");
487 decode_labeled_vpn_prefix4(const u_char
*pptr
, char *buf
, u_int buflen
)
492 plen
= pptr
[0]; /* get prefix length */
494 plen
-=(24+64); /* adjust prefixlen - labellength - RD len*/
499 memset(&addr
, 0, sizeof(addr
));
500 memcpy(&addr
, &pptr
[12], (plen
+ 7) / 8);
502 ((u_char
*)&addr
)[(plen
+ 7) / 8 - 1] &=
503 ((0xff00 >> (plen
% 8)) & 0xff);
505 /* the label may get offsetted by 4 bits so lets shift it right */
506 snprintf(buf
, buflen
, "RD: %s, %s/%d, label:%u %s",
507 bgp_vpn_rd_print(pptr
+4),
508 getname((u_char
*)&addr
),
510 EXTRACT_24BITS(pptr
+1)>>4,
511 ((pptr
[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
513 return 12 + (plen
+ 7) / 8;
517 decode_labeled_vpn_l2(const u_char
*pptr
, char *buf
, u_int buflen
)
519 int plen
,tlen
,strlen
,tlv_type
,tlv_len
,ttlv_len
;
520 plen
=EXTRACT_16BITS(pptr
);
523 strlen
=snprintf(buf
, buflen
, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
524 bgp_vpn_rd_print(pptr
),
525 EXTRACT_16BITS(pptr
+8),
526 EXTRACT_16BITS(pptr
+10),
527 EXTRACT_24BITS(pptr
+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
531 /* ok now the variable part - lets read out TLVs*/
534 tlv_len
=EXTRACT_16BITS(pptr
);
540 strlen
+=snprintf(buf
+strlen
,buflen
-strlen
, "\n\t\tcircuit status vector (%u) length: %u: 0x",
543 ttlv_len
=ttlv_len
/8+1; /* how many bytes do we need to read ? */
545 strlen
+=snprintf(buf
+strlen
,buflen
-strlen
, "%02x",*pptr
++);
550 snprintf(buf
+strlen
,buflen
-strlen
, "\n\t\tunknown TLV #%u, length: %u",
555 tlen
-=(tlv_len
<<3); /* the tlv-length is expressed in bits so lets shift it tright */
562 decode_prefix6(const u_char
*pd
, char *buf
, u_int buflen
)
564 struct in6_addr addr
;
571 memset(&addr
, 0, sizeof(addr
));
572 memcpy(&addr
, &pd
[1], (plen
+ 7) / 8);
574 addr
.s6_addr
[(plen
+ 7) / 8 - 1] &=
575 ((0xff00 >> (plen
% 8)) & 0xff);
577 snprintf(buf
, buflen
, "%s/%d", getname6((u_char
*)&addr
), plen
);
578 return 1 + (plen
+ 7) / 8;
582 decode_labeled_prefix6(const u_char
*pptr
, char *buf
, u_int buflen
)
584 struct in6_addr addr
;
587 plen
= pptr
[0]; /* get prefix length */
588 plen
-=24; /* adjust prefixlen - labellength */
593 memset(&addr
, 0, sizeof(addr
));
594 memcpy(&addr
, &pptr
[4], (plen
+ 7) / 8);
596 addr
.s6_addr
[(plen
+ 7) / 8 - 1] &=
597 ((0xff00 >> (plen
% 8)) & 0xff);
599 /* the label may get offsetted by 4 bits so lets shift it right */
600 snprintf(buf
, buflen
, "%s/%d, label:%u %s",
601 getname6((u_char
*)&addr
),
603 EXTRACT_24BITS(pptr
+1)>>4,
604 ((pptr
[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
606 return 4 + (plen
+ 7) / 8;
610 decode_labeled_vpn_prefix6(const u_char
*pptr
, char *buf
, u_int buflen
)
612 struct in6_addr addr
;
615 plen
= pptr
[0]; /* get prefix length */
617 plen
-=(24+64); /* adjust prefixlen - labellength - RD len*/
622 memset(&addr
, 0, sizeof(addr
));
623 memcpy(&addr
, &pptr
[12], (plen
+ 7) / 8);
625 addr
.s6_addr
[(plen
+ 7) / 8 - 1] &=
626 ((0xff00 >> (plen
% 8)) & 0xff);
628 /* the label may get offsetted by 4 bits so lets shift it right */
629 snprintf(buf
, buflen
, "RD: %s, %s/%d, label:%u %s",
630 bgp_vpn_rd_print(pptr
+4),
631 getname6((u_char
*)&addr
),
633 EXTRACT_24BITS(pptr
+1)>>4,
634 ((pptr
[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
636 return 12 + (plen
+ 7) / 8;
641 bgp_attr_print(const struct bgp_attr
*attr
, const u_char
*pptr
, int len
)
646 float bw
; /* copy buffer for bandwidth values */
650 char buf
[MAXHOSTNAMELEN
+ 100];
655 switch (attr
->bgpa_type
) {
658 printf("invalid len");
660 printf("%s", tok2str(bgp_origin_values
, "Unknown Origin Typecode", tptr
[0]));
662 case BGPTYPE_AS_PATH
:
664 printf("invalid len");
671 while (tptr
< pptr
+ len
) {
673 * under RFC1965, p[0] means:
674 * 1: AS_SET 2: AS_SEQUENCE
675 * 3: AS_CONFED_SET 4: AS_CONFED_SEQUENCE
677 if (tptr
[0] == 3 || tptr
[0] == 4)
679 printf("%s", (tptr
[0] & 1) ? "{" : "");
680 for (i
= 0; i
< tptr
[1] * 2; i
+= 2) {
681 printf("%s%u", i
== 0 ? "" : " ",
682 EXTRACT_16BITS(&tptr
[2 + i
]));
684 printf("%s", (tptr
[0] & 1) ? "}" : "");
685 tptr
+= 2 + tptr
[1] * 2;
688 case BGPTYPE_NEXT_HOP
:
690 printf("invalid len");
692 printf("%s", getname(tptr
));
694 case BGPTYPE_MULTI_EXIT_DISC
:
695 case BGPTYPE_LOCAL_PREF
:
697 printf("invalid len");
699 printf("%u", EXTRACT_32BITS(tptr
));
701 case BGPTYPE_ATOMIC_AGGREGATE
:
703 printf("invalid len");
705 case BGPTYPE_AGGREGATOR
:
707 printf("invalid len");
710 printf(" AS #%u, origin %s", EXTRACT_16BITS(tptr
),
713 case BGPTYPE_COMMUNITIES
:
715 printf("invalid len");
720 comm
= EXTRACT_32BITS(tptr
);
722 case BGP_COMMUNITY_NO_EXPORT
:
723 printf(" NO_EXPORT");
725 case BGP_COMMUNITY_NO_ADVERT
:
726 printf(" NO_ADVERTISE");
728 case BGP_COMMUNITY_NO_EXPORT_SUBCONFED
:
729 printf(" NO_EXPORT_SUBCONFED");
733 (comm
>> 16) & 0xffff,
735 (tlen
>4) ? ", " : "");
742 case BGPTYPE_ORIGINATOR_ID
:
744 printf("invalid len");
747 printf("%s",getname(tptr
));
749 case BGPTYPE_CLUSTER_LIST
:
753 (tlen
>4) ? ", " : "");
758 case BGPTYPE_MP_REACH_NLRI
:
759 af
= EXTRACT_16BITS(tptr
);
762 printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)",
763 tok2str(bgp_afi_values
, "Unknown AFI", af
),
765 (safi
>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
766 tok2str(bgp_safi_values
, "Unknown SAFI", safi
),
769 if (af
== AFNUM_INET
|| af
==AFNUM_L2VPN
)
772 else if (af
== AFNUM_INET6
)
776 printf("\n\t no AFI %u decoder",af
);
778 print_unknown_data(tptr
,"\n\t ",tlen
);
788 printf("\n\t nexthop: ");
794 case SAFNUM_MULTICAST
:
795 case SAFNUM_UNIMULTICAST
:
796 case SAFNUM_LABUNICAST
:
797 printf("%s",getname(tptr
));
798 tlen
-= sizeof(struct in_addr
);
799 tptr
+= sizeof(struct in_addr
);
801 case SAFNUM_VPNUNICAST
:
802 case SAFNUM_VPNMULTICAST
:
803 case SAFNUM_VPNUNIMULTICAST
:
805 bgp_vpn_rd_print(tptr
),
806 getname(tptr
+BGP_VPN_RD_LEN
));
807 tlen
-= (sizeof(struct in_addr
)+BGP_VPN_RD_LEN
);
808 tptr
+= (sizeof(struct in_addr
)+BGP_VPN_RD_LEN
);
811 printf("no SAFI %u decoder",safi
);
813 print_unknown_data(tptr
,"\n\t ",tlen
);
821 case SAFNUM_MULTICAST
:
822 case SAFNUM_UNIMULTICAST
:
823 case SAFNUM_LABUNICAST
:
824 printf("%s", getname6(tptr
));
825 tlen
-= sizeof(struct in6_addr
);
826 tptr
+= sizeof(struct in6_addr
);
828 case SAFNUM_VPNUNICAST
:
829 case SAFNUM_VPNMULTICAST
:
830 case SAFNUM_VPNUNIMULTICAST
:
832 bgp_vpn_rd_print(tptr
),
833 getname6(tptr
+BGP_VPN_RD_LEN
));
834 tlen
-= (sizeof(struct in6_addr
)+BGP_VPN_RD_LEN
);
835 tptr
+= (sizeof(struct in6_addr
)+BGP_VPN_RD_LEN
);
838 printf("no SAFI %u decoder",safi
);
840 print_unknown_data(tptr
,"\n\t ",tlen
);
847 case SAFNUM_VPNUNICAST
:
848 case SAFNUM_VPNMULTICAST
:
849 case SAFNUM_VPNUNIMULTICAST
:
850 printf("%s", getname(tptr
));
851 tlen
-= (sizeof(struct in_addr
));
852 tptr
+= (sizeof(struct in_addr
));
855 printf("no SAFI %u decoder",safi
);
857 print_unknown_data(tptr
,"\n\t ",tlen
);
863 printf("no AFI %u decoder",af
);
865 print_unknown_data(tptr
,"\n\t ",tlen
);
876 printf("\n\t %u SNPA", snpa
);
877 for (/*nothing*/; snpa
> 0; snpa
--) {
878 printf("\n\t %d bytes", tptr
[0]);
885 while (len
- (tptr
- pptr
) > 0) {
890 case SAFNUM_MULTICAST
:
891 case SAFNUM_UNIMULTICAST
:
892 advance
= decode_prefix4(tptr
, buf
, sizeof(buf
));
894 printf("\n\t %s", buf
);
896 printf("\n\t (illegal prefix length)");
898 case SAFNUM_LABUNICAST
:
899 advance
= decode_labeled_prefix4(tptr
, buf
, sizeof(buf
));
900 printf("\n\t %s", buf
);
902 case SAFNUM_VPNUNICAST
:
903 case SAFNUM_VPNMULTICAST
:
904 case SAFNUM_VPNUNIMULTICAST
:
905 advance
= decode_labeled_vpn_prefix4(tptr
, buf
, sizeof(buf
));
906 printf("\n\t %s", buf
);
909 printf("\n\t no SAFI %u decoder",safi
);
911 print_unknown_data(tptr
-3,"\n\t ",tlen
);
921 case SAFNUM_MULTICAST
:
922 case SAFNUM_UNIMULTICAST
:
923 advance
= decode_prefix6(tptr
, buf
, sizeof(buf
));
924 printf("\n\t %s", buf
);
926 case SAFNUM_LABUNICAST
:
927 advance
= decode_labeled_prefix6(tptr
, buf
, sizeof(buf
));
928 printf("\n\t %s", buf
);
930 case SAFNUM_VPNUNICAST
:
931 case SAFNUM_VPNMULTICAST
:
932 case SAFNUM_VPNUNIMULTICAST
:
933 advance
= decode_labeled_vpn_prefix6(tptr
, buf
, sizeof(buf
));
934 printf("\n\t %s", buf
);
937 printf("\n\t no SAFI %u decoder ",safi
);
939 print_unknown_data(tptr
-3,"\n\t ",tlen
);
948 case SAFNUM_VPNUNICAST
:
949 case SAFNUM_VPNMULTICAST
:
950 case SAFNUM_VPNUNIMULTICAST
:
951 advance
= decode_labeled_vpn_l2(tptr
, buf
, sizeof(buf
));
952 printf("\n\t %s", buf
);
955 printf("no SAFI %u decoder",safi
);
957 print_unknown_data(tptr
,"\n\t ",tlen
);
966 printf("\n\t no AFI %u decoder ",af
);
968 print_unknown_data(tptr
-3,"\n\t ",tlen
);
977 case BGPTYPE_MP_UNREACH_NLRI
:
978 af
= EXTRACT_16BITS(tptr
);
981 printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)",
982 tok2str(bgp_afi_values
, "Unknown AFI", af
),
984 (safi
>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
985 tok2str(bgp_safi_values
, "Unknown SAFI", safi
),
990 while (len
- (tptr
- pptr
) > 0) {
995 case SAFNUM_MULTICAST
:
996 case SAFNUM_UNIMULTICAST
:
997 advance
= decode_prefix4(tptr
, buf
, sizeof(buf
));
999 printf("\n\t %s", buf
);
1001 printf("\n\t (illegal prefix length)");
1003 case SAFNUM_LABUNICAST
:
1004 advance
= decode_labeled_prefix4(tptr
, buf
, sizeof(buf
));
1005 printf("\n\t %s", buf
);
1007 case SAFNUM_VPNUNICAST
:
1008 case SAFNUM_VPNMULTICAST
:
1009 case SAFNUM_VPNUNIMULTICAST
:
1010 advance
= decode_labeled_vpn_prefix4(tptr
, buf
, sizeof(buf
));
1011 printf("\n\t %s", buf
);
1014 printf("\n\t no SAFI %u decoder",safi
);
1016 print_unknown_data(tptr
-3,"\n\t ",tlen
);
1026 case SAFNUM_UNICAST
:
1027 case SAFNUM_MULTICAST
:
1028 case SAFNUM_UNIMULTICAST
:
1029 advance
= decode_prefix6(tptr
, buf
, sizeof(buf
));
1030 printf("\n\t %s", buf
);
1032 case SAFNUM_LABUNICAST
:
1033 advance
= decode_labeled_prefix6(tptr
, buf
, sizeof(buf
));
1034 printf("\n\t %s", buf
);
1036 case SAFNUM_VPNUNICAST
:
1037 case SAFNUM_VPNMULTICAST
:
1038 case SAFNUM_VPNUNIMULTICAST
:
1039 advance
= decode_labeled_vpn_prefix6(tptr
, buf
, sizeof(buf
));
1040 printf("\n\t %s", buf
);
1043 printf("\n\t no SAFI %u decoder",safi
);
1045 print_unknown_data(tptr
-3,"\n\t ",tlen
);
1055 case SAFNUM_VPNUNICAST
:
1056 case SAFNUM_VPNMULTICAST
:
1057 case SAFNUM_VPNUNIMULTICAST
:
1058 advance
= decode_labeled_vpn_l2(tptr
, buf
, sizeof(buf
));
1059 printf("\n\t %s", buf
);
1062 printf("no SAFI %u decoder",safi
);
1064 print_unknown_data(tptr
-3,"\n\t ",tlen
);
1072 printf("\n\t no AFI %u decoder",af
);
1074 print_unknown_data(tptr
-3,"\n\t ",tlen
);
1083 case BGPTYPE_EXTD_COMMUNITIES
:
1085 printf("invalid len");
1089 u_int16_t extd_comm
;
1090 extd_comm
=EXTRACT_16BITS(tptr
);
1092 case BGP_EXT_COM_RT_0
:
1093 case BGP_EXT_COM_RO_0
:
1094 printf("\n\t %s%s%s(0x%04x):%u:%s",
1095 (extd_comm
&0x8000) ? "vendor-specific: " : "",
1096 (extd_comm
&0x4000) ? "non-transitive: " : "",
1097 tok2str(bgp_extd_comm_subtype_values
,
1101 EXTRACT_16BITS(tptr
+2),
1104 case BGP_EXT_COM_RT_1
:
1105 case BGP_EXT_COM_RO_1
:
1106 printf("\n\t %s%s%s(0x%04x):%s:%u",
1107 (extd_comm
&0x8000) ? "vendor-specific: " : "",
1108 (extd_comm
&0x4000) ? "non-transitive: " : "",
1109 tok2str(bgp_extd_comm_subtype_values
,
1114 EXTRACT_16BITS(tptr
+6));
1116 case BGP_EXT_COM_LINKBAND
:
1117 memcpy (&bw
, tptr
+2, 4);
1118 printf("\n\t %s%s%s(0x%04x):bandwidth: %.3f Mbps",
1119 (extd_comm
&0x8000) ? "vendor-specific: " : "",
1120 (extd_comm
&0x4000) ? "non-transitive: " : "",
1121 tok2str(bgp_extd_comm_subtype_values
,
1127 case BGP_EXT_COM_VPN_ORIGIN
:
1128 case BGP_EXT_COM_VPN_ORIGIN2
:
1129 case BGP_EXT_COM_VPN_ORIGIN3
:
1130 case BGP_EXT_COM_VPN_ORIGIN4
:
1131 case BGP_EXT_COM_OSPF_RID
:
1132 case BGP_EXT_COM_OSPF_RID2
:
1133 printf("\n\t %s%s%s(0x%04x):%s",
1134 (extd_comm
&0x8000) ? "vendor-specific: " : "",
1135 (extd_comm
&0x4000) ? "non-transitive: " : "",
1136 tok2str(bgp_extd_comm_subtype_values
,
1142 case BGP_EXT_COM_OSPF_RTYPE
:
1143 case BGP_EXT_COM_OSPF_RTYPE2
:
1144 printf("\n\t %s%s%s(0x%04x), area:%s, router-type:%s, metric-type:%s%s",
1145 (extd_comm
&0x8000) ? "vendor-specific: " : "",
1146 (extd_comm
&0x4000) ? "non-transitive: " : "",
1147 tok2str(bgp_extd_comm_subtype_values
,
1152 tok2str(bgp_extd_comm_ospf_rtype_values
,
1155 (*(tptr
+7) & BGP_OSPF_RTYPE_METRIC_TYPE
) ? "E2" : "",
1156 (*(tptr
+6) == (BGP_OSPF_RTYPE_EXT
||BGP_OSPF_RTYPE_NSSA
)) ? "E1" : "");
1158 case BGP_EXT_COM_L2INFO
:
1159 printf("\n\t %s%s(0x%04x):%s Control Flags [0x%02x]:MTU %u",
1160 (extd_comm
&0x4000) ? "non-transitive: " : "",
1161 tok2str(bgp_extd_comm_subtype_values
,
1165 tok2str(bgp_l2vpn_encaps_values
,
1169 EXTRACT_16BITS(tptr
+4));
1172 printf("\n\t unknown extd community typecode (0x%04x)",
1174 print_unknown_data(tptr
,"\n\t ",8);
1183 printf("\n\t no Attribute %u decoder",attr
->bgpa_type
); /* we have no decoder for the attribute */
1185 print_unknown_data(pptr
,"\n\t ",len
);
1188 if (vflag
> 1 && len
) /* omit zero length attributes*/
1189 print_unknown_data(pptr
,"\n\t ",len
);
1193 bgp_open_print(const u_char
*dat
, int length
)
1195 struct bgp_open bgpo
;
1196 struct bgp_opt bgpopt
;
1199 int i
,cap_type
,cap_len
,tcap_len
,cap_offset
;
1201 TCHECK2(dat
[0], BGP_OPEN_SIZE
);
1202 memcpy(&bgpo
, dat
, BGP_OPEN_SIZE
);
1203 hlen
= ntohs(bgpo
.bgpo_len
);
1205 printf("\n\t Version %d, ", bgpo
.bgpo_version
);
1206 printf("my AS %u, ", ntohs(bgpo
.bgpo_myas
));
1207 printf("Holdtime %us, ", ntohs(bgpo
.bgpo_holdtime
));
1208 printf("ID %s", getname((u_char
*)&bgpo
.bgpo_id
));
1209 printf("\n\t Optional parameters, length: %u", bgpo
.bgpo_optlen
);
1211 /* some little sanity checking */
1212 if (length
< bgpo
.bgpo_optlen
+BGP_OPEN_SIZE
)
1216 opt
= &((const struct bgp_open
*)dat
)->bgpo_optlen
;
1220 while (i
< bgpo
.bgpo_optlen
) {
1221 TCHECK2(opt
[i
], BGP_OPT_SIZE
);
1222 memcpy(&bgpopt
, &opt
[i
], BGP_OPT_SIZE
);
1223 if (i
+ 2 + bgpopt
.bgpopt_len
> bgpo
.bgpo_optlen
) {
1224 printf("\n\t Option %d, length: %u", bgpopt
.bgpopt_type
, bgpopt
.bgpopt_len
);
1228 printf("\n\t Option %s (%u), length: %u",
1229 tok2str(bgp_opt_values
,"Unknown", bgpopt
.bgpopt_type
),
1233 /* now lets decode the options we know*/
1234 switch(bgpopt
.bgpopt_type
) {
1236 cap_type
=opt
[i
+BGP_OPT_SIZE
];
1237 cap_len
=opt
[i
+BGP_OPT_SIZE
+1];
1239 printf("\n\t %s, length: %u",
1240 tok2str(bgp_capcode_values
,"Unknown", cap_type
),
1243 case BGP_CAPCODE_MP
:
1244 printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
1245 tok2str(bgp_afi_values
,"Unknown", EXTRACT_16BITS(opt
+i
+BGP_OPT_SIZE
+2)),
1246 EXTRACT_16BITS(opt
+i
+BGP_OPT_SIZE
+2),
1247 tok2str(bgp_safi_values
,"Unknown", opt
[i
+BGP_OPT_SIZE
+5]),
1248 opt
[i
+BGP_OPT_SIZE
+5]);
1250 case BGP_CAPCODE_RESTART
:
1251 printf("\n\t\tRestart Flags: [%s], Restart Time %us",
1252 ((opt
[i
+BGP_OPT_SIZE
+2])&0x80) ? "R" : "none",
1253 EXTRACT_16BITS(opt
+i
+BGP_OPT_SIZE
+2)&0xfff);
1256 while(tcap_len
>=4) {
1257 printf("\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
1258 tok2str(bgp_afi_values
,"Unknown", EXTRACT_16BITS(opt
+i
+BGP_OPT_SIZE
+cap_offset
)),
1259 EXTRACT_16BITS(opt
+i
+BGP_OPT_SIZE
+cap_offset
),
1260 tok2str(bgp_safi_values
,"Unknown", opt
[i
+BGP_OPT_SIZE
+cap_offset
+2]),
1261 opt
[i
+BGP_OPT_SIZE
+cap_offset
+2],
1262 ((opt
[i
+BGP_OPT_SIZE
+cap_offset
+3])&0x80) ? "yes" : "no" );
1267 case BGP_CAPCODE_RR
:
1268 case BGP_CAPCODE_RR_CISCO
:
1271 printf("\n\t\tno decoder for Capability %u",
1274 print_unknown_data(&opt
[i
+BGP_OPT_SIZE
+2],"\n\t\t",cap_len
);
1278 print_unknown_data(&opt
[i
+BGP_OPT_SIZE
+2],"\n\t\t",cap_len
);
1282 printf("\n\t no decoder for option %u",
1283 bgpopt
.bgpopt_type
);
1287 i
+= BGP_OPT_SIZE
+ bgpopt
.bgpopt_len
;
1295 bgp_update_print(const u_char
*dat
, int length
)
1298 struct bgp_attr bgpa
;
1304 TCHECK2(dat
[0], BGP_SIZE
);
1305 memcpy(&bgp
, dat
, BGP_SIZE
);
1306 hlen
= ntohs(bgp
.bgp_len
);
1307 p
= dat
+ BGP_SIZE
; /*XXX*/
1309 /* Unfeasible routes */
1310 len
= EXTRACT_16BITS(p
);
1313 * Without keeping state from the original NLRI message,
1314 * it's not possible to tell if this a v4 or v6 route,
1315 * so only try to decode it if we're not v6 enabled.
1318 printf("\n\t Withdrawn routes: %d bytes", len
);
1320 char buf
[MAXHOSTNAMELEN
+ 100];
1326 printf("\n\t Withdrawn routes:");
1328 while(i
< 2 + len
) {
1329 wpfx
= decode_prefix4(&p
[i
], buf
, sizeof(buf
));
1332 printf("\n\t %s", buf
);
1334 printf("\n\t (illegal prefix length)");
1343 len
= EXTRACT_16BITS(p
);
1345 /* do something more useful!*/
1347 while (i
< 2 + len
) {
1350 TCHECK2(p
[i
], sizeof(bgpa
));
1351 memcpy(&bgpa
, &p
[i
], sizeof(bgpa
));
1352 alen
= bgp_attr_len(&bgpa
);
1353 aoff
= bgp_attr_off(&bgpa
);
1355 printf("\n\t %s (%u), length: %u",
1356 tok2str(bgp_attr_values
, "Unknown Attribute", bgpa
.bgpa_type
),
1360 if (bgpa
.bgpa_flags
) {
1361 printf(", flags [%s%s%s%s",
1362 bgpa
.bgpa_flags
& 0x80 ? "O" : "",
1363 bgpa
.bgpa_flags
& 0x40 ? "T" : "",
1364 bgpa
.bgpa_flags
& 0x20 ? "P" : "",
1365 bgpa
.bgpa_flags
& 0x10 ? "E" : "");
1366 if (bgpa
.bgpa_flags
& 0xf)
1367 printf("+%x", bgpa
.bgpa_flags
& 0xf);
1370 bgp_attr_print(&bgpa
, &p
[i
+ aoff
], alen
);
1376 if (dat
+ length
> p
) {
1377 printf("\n\t Updated routes:");
1378 while (dat
+ length
> p
) {
1379 char buf
[MAXHOSTNAMELEN
+ 100];
1380 i
= decode_prefix4(p
, buf
, sizeof(buf
));
1382 printf("\n\t %s", buf
);
1385 printf("\n\t (illegal prefix length)");
1396 bgp_notification_print(const u_char
*dat
, int length
)
1398 struct bgp_notification bgpn
;
1401 TCHECK2(dat
[0], BGP_NOTIFICATION_SIZE
);
1402 memcpy(&bgpn
, dat
, BGP_NOTIFICATION_SIZE
);
1403 hlen
= ntohs(bgpn
.bgpn_len
);
1405 /* some little sanity checking */
1406 if (length
<BGP_NOTIFICATION_SIZE
)
1409 printf(", Error - %s", tok2str(bgp_notify_major_values
, "Unknown", bgpn
.bgpn_major
));
1411 switch (bgpn
.bgpn_major
) {
1413 case BGP_NOTIFY_MAJOR_MSG
:
1414 printf(" subcode %s", tok2str(bgp_notify_minor_msg_values
, "Unknown", bgpn
.bgpn_minor
));
1416 case BGP_NOTIFY_MAJOR_OPEN
:
1417 printf(" subcode %s", tok2str(bgp_notify_minor_open_values
, "Unknown", bgpn
.bgpn_minor
));
1419 case BGP_NOTIFY_MAJOR_UPDATE
:
1420 printf(" subcode %s", tok2str(bgp_notify_minor_update_values
, "Unknown", bgpn
.bgpn_minor
));
1432 bgp_route_refresh_print(const u_char
*pptr
, int len
) {
1434 const struct bgp_route_refresh
*bgp_route_refresh_header
;
1435 bgp_route_refresh_header
= (const struct bgp_route_refresh
*)pptr
;
1437 printf("\n\t AFI %s (%u), SAFI %s (%u)",
1438 tok2str(bgp_afi_values
,"Unknown",
1439 EXTRACT_16BITS(&bgp_route_refresh_header
->afi
)), /* this stinks but the compiler pads the structure weird */
1440 EXTRACT_16BITS(&bgp_route_refresh_header
->afi
),
1441 tok2str(bgp_safi_values
,"Unknown",
1442 bgp_route_refresh_header
->safi
),
1443 bgp_route_refresh_header
->safi
);
1446 print_unknown_data(pptr
,"\n\t ", len
);
1452 bgp_header_print(const u_char
*dat
, int length
)
1456 TCHECK2(dat
[0], BGP_SIZE
);
1457 memcpy(&bgp
, dat
, BGP_SIZE
);
1458 printf("\n\t%s Message (%u), length: %u",
1459 tok2str(bgp_msg_values
, "Unknown", bgp
.bgp_type
),
1463 switch (bgp
.bgp_type
) {
1465 bgp_open_print(dat
, length
);
1468 bgp_update_print(dat
, length
);
1470 case BGP_NOTIFICATION
:
1471 bgp_notification_print(dat
, length
);
1475 case BGP_ROUTE_REFRESH
:
1476 bgp_route_refresh_print(dat
, length
);
1479 /* we have no decoder for the BGP message */
1480 printf("\n\t no Message %u decoder",bgp
.bgp_type
);
1481 print_unknown_data(dat
,"\n\t ",length
);
1490 bgp_print(const u_char
*dat
, int length
)
1494 const u_char
*start
;
1495 const u_char marker
[] = {
1496 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1497 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1503 if (snapend
< dat
+ length
)
1506 printf(": BGP, length: %u",length
);
1508 if (vflag
< 1) /* lets be less chatty */
1513 while (p
< snapend
) {
1514 if (!TTEST2(p
[0], 1))
1521 if (!TTEST2(p
[0], sizeof(marker
)))
1523 if (memcmp(p
, marker
, sizeof(marker
)) != 0) {
1528 /* found BGP header */
1529 TCHECK2(p
[0], BGP_SIZE
); /*XXX*/
1530 memcpy(&bgp
, p
, BGP_SIZE
);
1535 hlen
= ntohs(bgp
.bgp_len
);
1537 if (TTEST2(p
[0], hlen
)) {
1538 bgp_header_print(p
, hlen
);
1542 printf("\n[|BGP %s]", tok2str(bgp_msg_values
, "Unknown Message Type",bgp
.bgp_type
));