- 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 (%u), length: %u",
- tok2strbuf(bgp_capcode_values, "Unknown",
- cap_type, tokbuf, sizeof(tokbuf)),
- cap_type,
- cap_len);
- switch(cap_type) {
- case BGP_CAPCODE_MP:
- printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
- tok2strbuf(af_values, "Unknown",
- EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2),
- tokbuf, sizeof(tokbuf)),
- EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2),
- tok2strbuf(bgp_safi_values, "Unknown",
- opt[i+BGP_OPT_SIZE+5],
- tokbuf, sizeof(tokbuf)),
- 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",
- tok2strbuf(af_values,"Unknown",
- EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset),
- tokbuf, sizeof(tokbuf)),
- EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset),
- tok2strbuf(bgp_safi_values,"Unknown",
- opt[i+BGP_OPT_SIZE+cap_offset+2],
- tokbuf2, sizeof(tokbuf2)),
- 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;
- case BGP_CAPCODE_AS_NEW:
-
- /*
- * Extract the 4 byte AS number encoded.
- */
- TCHECK2(opt[i + BGP_OPT_SIZE + 2], cap_len);
- if (cap_len == 4) {
- printf("\n\t\t 4 Byte AS %s",
- as_printf(astostr, sizeof(astostr),
- EXTRACT_32BITS(opt + i + BGP_OPT_SIZE + 2)));
- }
- break;
- default:
- TCHECK2(opt[i+BGP_OPT_SIZE+2],cap_len);
- 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) {
- TCHECK2(opt[i+BGP_OPT_SIZE+2],cap_len);
- 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;
- }