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

Method parsePeerUpInfo

Server/src/bmp/parseBMP.cpp:591–638  ·  view source on GitHub ↗

* Parse the peer UP informational data * * \details Updates the peer struct info items * * \param [in] data Data pointer to info, should start at start of info TLV * \param [in] len Length of info TLV data to read */

Source from the content-addressed store, hash-verified

589 * \param [in] len Length of info TLV data to read
590 */
591void parseBMP::parsePeerUpInfo(u_char *data, int len) {
592 info_tlv_msg info;
593 char infoBuf[255];
594 int infoLen;
595 u_char *bufPtr = data;
596
597 /*
598 * Loop through the info TLV's (in buffer) and parse each TLV
599 */
600 for (int i = 0; i < len; i += BMP_INFO_TLV_HDR_LEN) {
601
602 memcpy(&info, bufPtr, BMP_INFO_TLV_HDR_LEN);
603 info.info = NULL;
604 bgp::SWAP_BYTES(&info.len);
605 bgp::SWAP_BYTES(&info.type);
606
607 bufPtr += BMP_INFO_TLV_HDR_LEN; // Move pointer past the info header
608
609 SELF_DEBUG("Peer info message type %hu and length %hu parsed", info.type, info.len);
610
611 if (info.len > 0) {
612 infoLen = sizeof(infoBuf) < info.len ? sizeof(infoBuf) : info.len;
613 bzero(infoBuf, sizeof(infoBuf));
614 memcpy(infoBuf, bufPtr, infoLen);
615 bufPtr += infoLen; // Move pointer past the info data
616 i += infoLen; // Update the counter past the info data
617
618 info.info = infoBuf;
619
620 }
621
622 /*
623 * Save the data based on info type
624 */
625 switch (info.type) {
626 case INFO_TLV_PEER_VRF_TABLE :
627 infoLen = sizeof(p_entry->table_name) < (info.len - 1) ? (sizeof(p_entry->table_name) - 1)
628 : info.len;
629 memcpy(p_entry->table_name, info.info, infoLen);
630 LOG_INFO("Peer table/vrf name %hu = %s", info.type, p_entry->table_name);
631
632 break;
633
634 default:
635 LOG_NOTICE("Peer info message type %hu is not implemented", info.type);
636 }
637 }
638}
639
640/**
641 * Parse the v3 peer up BMP header

Callers 1

ReadIncomingMsgMethod · 0.80

Calls 1

SWAP_BYTESFunction · 0.85

Tested by

no test coverage detected