+ printf("\n\t Version %d, ", bgpo.bgpo_version);
+ printf("my AS %u, ", ntohs(bgpo.bgpo_myas));
+ printf("Holdtime %us, ", ntohs(bgpo.bgpo_holdtime));
+ printf("ID %s", getname((u_char *)&bgpo.bgpo_id));
+ printf("\n\t Optional parameters, length: %u", bgpo.bgpo_optlen);
+
+ /* some little sanity checking */
+ if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE)
+ return;
+
+ /* ugly! */
+ opt = &((const struct bgp_open *)dat)->bgpo_optlen;
+ opt++;
+
+ i = 0;
+ while (i < bgpo.bgpo_optlen) {
+ TCHECK2(opt[i], BGP_OPT_SIZE);
+ memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE);
+ if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
+ printf("\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len);
+ break;
+ }
+
+ printf("\n\t Option %s (%u), length: %u",
+ tok2str(bgp_opt_values,"Unknown", bgpopt.bgpopt_type),
+ bgpopt.bgpopt_type,
+ bgpopt.bgpopt_len);
+
+ /* now lets decode the options we know*/
+ switch(bgpopt.bgpopt_type) {
+ case BGP_OPT_CAP:
+ cap_type=opt[i+BGP_OPT_SIZE];
+ cap_len=opt[i+BGP_OPT_SIZE+1];
+ tcap_len=cap_len;
+ printf("\n\t %s, length: %u",
+ tok2str(bgp_capcode_values,"Unknown", cap_type),
+ cap_len);
+ switch(cap_type) {
+ case BGP_CAPCODE_MP:
+ printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
+ tok2str(bgp_afi_values,"Unknown", EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2)),
+ EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2),
+ tok2str(bgp_safi_values,"Unknown", opt[i+BGP_OPT_SIZE+5]),
+ opt[i+BGP_OPT_SIZE+5]);
+ break;
+ case BGP_CAPCODE_RESTART:
+ printf("\n\t\tRestart Flags: [%s], Restart Time %us",
+ ((opt[i+BGP_OPT_SIZE+2])&0x80) ? "R" : "none",
+ EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2)&0xfff);
+ tcap_len-=2;
+ cap_offset=4;
+ while(tcap_len>=4) {
+ printf("\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
+ tok2str(bgp_afi_values,"Unknown", EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset)),
+ EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset),
+ tok2str(bgp_safi_values,"Unknown", opt[i+BGP_OPT_SIZE+cap_offset+2]),
+ opt[i+BGP_OPT_SIZE+cap_offset+2],
+ ((opt[i+BGP_OPT_SIZE+cap_offset+3])&0x80) ? "yes" : "no" );
+ tcap_len-=4;
+ cap_offset+=4;
+ }
+ break;
+ case BGP_CAPCODE_RR:
+ case BGP_CAPCODE_RR_CISCO:
+ break;
+ default:
+ printf("\n\t\tno decoder for Capability %u",
+ cap_type);
+ if (vflag <= 1)
+ print_unknown_data(&opt[i+BGP_OPT_SIZE+2],"\n\t\t",cap_len);
+ break;
+ }
+ if (vflag > 1)
+ print_unknown_data(&opt[i+BGP_OPT_SIZE+2],"\n\t\t",cap_len);
+ break;
+ case BGP_OPT_AUTH:
+ default:
+ printf("\n\t no decoder for option %u",
+ bgpopt.bgpopt_type);
+ break;
+ }
+
+ i += BGP_OPT_SIZE + bgpopt.bgpopt_len;
+ }
+ return;
+trunc:
+ printf("[|BGP]");