MCPcopy Create free account
hub / github.com/SNAS/openbmp / decodeType_Opaque

Method decodeType_Opaque

Server/src/bgp/ExtCommunity.cpp:362–451  ·  view source on GitHub ↗

* Decode Opaque subtypes * * \details * Converts to human readable form. * * \param [in] ec_hdr Reference to the extended community header * * \return Decoded string value */

Source from the content-addressed store, hash-verified

360 * \return Decoded string value
361 */
362 std::string ExtCommunity::decodeType_Opaque(const extcomm_hdr &ec_hdr) {
363 std::stringstream val_ss;
364 uint32_t val_32b;
365
366 switch(ec_hdr.low_type) {
367 case EXT_OPAQUE_COST_COMMUNITY: {
368 u_char poi = ec_hdr.value[0]; // Point of Insertion
369 u_char cid = ec_hdr.value[1]; // Community-ID
370 memcpy(&val_32b, ec_hdr.value + 2, 4);
371 bgp::SWAP_BYTES(&val_32b);
372
373 val_ss << "cost=";
374
375 switch (poi) {
376 case 128 : // Absolute_value
377 val_ss << "abs:";
378 break;
379 case 129 : // IGP Cost
380 val_ss << "igp:";
381 break;
382 case 130: // External_Internal
383 val_ss << "ext:";
384 break;
385 case 131: // BGP_ID
386 val_ss << "bgp_id:";
387 break;
388 default:
389 val_ss << "unkn";
390 break;
391 }
392
393 val_ss << (int)cid << ":" << val_32b;
394
395 break;
396 }
397
398 case EXT_OPAQUE_CP_ORF:
399 val_ss << "cp-orf";
400 break;
401
402 case EXT_OPAQUE_OSPF_ROUTE_TYPE: {
403 memcpy(&val_32b, ec_hdr.value, 4);
404 bgp::SWAP_BYTES(&val_32b);
405
406 val_ss << "ospf-rt=area-" << val_32b << ":";
407
408 // Get the route type
409 switch (ec_hdr.value[4]) {
410 case 1: // intra-area routes
411 case 2: // intra-area routes
412 val_ss << "O:";
413 break;
414 case 3: // Inter-area routes
415 val_ss << "IA:";
416 break;
417 case 5: // External routes
418 val_ss << "E:";
419 break;

Callers

nothing calls this directly

Calls 1

SWAP_BYTESFunction · 0.85

Tested by

no test coverage detected