* MP Reach Link State NLRI parse * * \details Will handle parsing the link state NLRI * * \param [in] nlri Reference to parsed NLRI struct */
| 41 | * \param [in] nlri Reference to parsed NLRI struct |
| 42 | */ |
| 43 | void MPLinkState::parseReachLinkState(MPReachAttr::mp_reach_nlri &nlri) { |
| 44 | ls_data = &parsed_data->ls; |
| 45 | |
| 46 | // Process the next hop |
| 47 | // Next-hop is an IPv6 address - Change/set the next-hop attribute in parsed data to use this next-hop |
| 48 | u_char ip_raw[16]; |
| 49 | char ip_char[40]; |
| 50 | |
| 51 | if (nlri.nh_len == 4) { |
| 52 | memcpy(ip_raw, nlri.next_hop, nlri.nh_len); |
| 53 | inet_ntop(AF_INET, ip_raw, ip_char, sizeof(ip_char)); |
| 54 | } else if (nlri.nh_len > 4) { |
| 55 | memcpy(ip_raw, nlri.next_hop, nlri.nh_len); |
| 56 | inet_ntop(AF_INET6, ip_raw, ip_char, sizeof(ip_char)); |
| 57 | } |
| 58 | |
| 59 | parsed_data->attrs[ATTR_TYPE_NEXT_HOP] = std::string(ip_char); |
| 60 | |
| 61 | /* |
| 62 | * Decode based on SAFI |
| 63 | */ |
| 64 | switch (nlri.safi) { |
| 65 | case bgp::BGP_SAFI_BGPLS: // Unicast BGP-LS |
| 66 | SELF_DEBUG("REACH: bgp-ls: len=%d", nlri.nlri_len); |
| 67 | parseLinkStateNlriData(nlri.nlri_data, nlri.nlri_len); |
| 68 | break; |
| 69 | |
| 70 | default : |
| 71 | LOG_INFO("%s: MP_UNREACH AFI=bgp-ls SAFI=%d is not implemented yet, skipping for now", |
| 72 | peer_addr.c_str(), nlri.afi, nlri.safi); |
| 73 | return; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | |
| 78 | /** |