* Parse Ethernet Segment Identifier * * \details * Will parse the Segment Identifier. Based on https://tools.ietf.org/html/rfc7432#section-5 * * \param [in/out] data_pointer Pointer to the beginning of Route Distinguisher * \param [out] rd_type Reference to RD type. * \param [out] rd_assigned_number Reference to Assigned
| 38 | * \param [out] rd_administrator_subfield Reference to Administrator subfield |
| 39 | */ |
| 40 | void EVPN::parseEthernetSegmentIdentifier(u_char *data_pointer, std::string *parsed_data) { |
| 41 | std::stringstream result; |
| 42 | uint8_t type = *data_pointer; |
| 43 | |
| 44 | data_pointer++; |
| 45 | |
| 46 | result << (int) type << " "; |
| 47 | |
| 48 | switch (type) { |
| 49 | case 0: { |
| 50 | for (int i = 0; i < 9; i++) { |
| 51 | result << std::hex << setfill('0') << setw(2) << (int) data_pointer[i]; |
| 52 | } |
| 53 | break; |
| 54 | } |
| 55 | case 1: { |
| 56 | for (int i = 0; i < 6; ++i) { |
| 57 | if (i != 0) result << ':'; |
| 58 | result.width(2); //< Use two chars for each byte |
| 59 | result.fill('0'); //< Fill up with '0' if the number is only one hexadecimal digit |
| 60 | result << std::hex << (int) (data_pointer[i]); |
| 61 | } |
| 62 | data_pointer += 6; |
| 63 | |
| 64 | result << " "; |
| 65 | |
| 66 | uint16_t CE_LACP_port_key; |
| 67 | memcpy(&CE_LACP_port_key, data_pointer, 2); |
| 68 | bgp::SWAP_BYTES(&CE_LACP_port_key, 2); |
| 69 | |
| 70 | result << std::dec << (int) CE_LACP_port_key; |
| 71 | |
| 72 | break; |
| 73 | } |
| 74 | case 2: { |
| 75 | for (int i = 0; i < 6; ++i) { |
| 76 | if (i != 0) result << ':'; |
| 77 | result.width(2); //< Use two chars for each byte |
| 78 | result.fill('0'); //< Fill up with '0' if the number is only one hexadecimal digit |
| 79 | result << std::hex << (int) (data_pointer[i]); |
| 80 | } |
| 81 | data_pointer += 6; |
| 82 | |
| 83 | result << " "; |
| 84 | |
| 85 | uint16_t root_bridge_priority; |
| 86 | memcpy(&root_bridge_priority, data_pointer, 2); |
| 87 | bgp::SWAP_BYTES(&root_bridge_priority, 2); |
| 88 | |
| 89 | result << std::dec << (int) root_bridge_priority; |
| 90 | |
| 91 | break; |
| 92 | } |
| 93 | case 3: { |
| 94 | for (int i = 0; i < 6; ++i) { |
| 95 | if (i != 0) result << ':'; |
| 96 | result.width(2); //< Use two chars for each byte |
| 97 | result.fill('0'); //< Fill up with '0' if the number is only one hexadecimal digit |
nothing calls this directly
no test coverage detected