* Parse v3 BMP header * * \details * v3 has a different header structure and changes the peer * header format. * * \param [in] sock Socket to read the message from */
| 286 | * \param [in] sock Socket to read the message from |
| 287 | */ |
| 288 | void parseBMP::parseBMPv3(int sock) { |
| 289 | struct common_hdr_v3 c_hdr = { 0 }; |
| 290 | |
| 291 | SELF_DEBUG("Parsing BMP version 3 (rfc7854)"); |
| 292 | if ((Recv(sock, &c_hdr, BMP_HDRv3_LEN, MSG_WAITALL)) != BMP_HDRv3_LEN) { |
| 293 | throw "ERROR: Cannot read v3 BMP common header."; |
| 294 | } |
| 295 | |
| 296 | // Change to host order |
| 297 | bgp::SWAP_BYTES(&c_hdr.len); |
| 298 | |
| 299 | SELF_DEBUG("BMP v3: type = %x len=%d", c_hdr.type, c_hdr.len); |
| 300 | |
| 301 | // Adjust length to remove common header size |
| 302 | c_hdr.len -= 1 + BMP_HDRv3_LEN; |
| 303 | |
| 304 | if (c_hdr.len > BGP_MAX_MSG_SIZE) |
| 305 | throw "ERROR: BMP length is larger than max possible BGP size"; |
| 306 | |
| 307 | // Parse additional headers based on type |
| 308 | bmp_type = c_hdr.type; |
| 309 | bmp_len = c_hdr.len; |
| 310 | |
| 311 | switch (c_hdr.type) { |
| 312 | case TYPE_ROUTE_MON: // Route monitoring |
| 313 | SELF_DEBUG("BMP MSG : route monitor"); |
| 314 | parsePeerHdr(sock); |
| 315 | break; |
| 316 | |
| 317 | case TYPE_STATS_REPORT: // Statistics Report |
| 318 | SELF_DEBUG("BMP MSG : stats report"); |
| 319 | parsePeerHdr(sock); |
| 320 | break; |
| 321 | |
| 322 | case TYPE_PEER_UP: // Peer Up notification |
| 323 | { |
| 324 | SELF_DEBUG("BMP MSG : peer up"); |
| 325 | parsePeerHdr(sock); |
| 326 | |
| 327 | break; |
| 328 | } |
| 329 | case TYPE_PEER_DOWN: // Peer down notification |
| 330 | SELF_DEBUG("BMP MSG : peer down"); |
| 331 | parsePeerHdr(sock); |
| 332 | break; |
| 333 | |
| 334 | case TYPE_INIT_MSG: |
| 335 | case TYPE_TERM_MSG: |
| 336 | // Allowed |
| 337 | break; |
| 338 | |
| 339 | default: |
| 340 | LOG_ERR("ERROR: Unknown BMP message type of %d", c_hdr.type); |
| 341 | throw "ERROR: BMP message type is not supported"; |
| 342 | break; |
| 343 | } |
| 344 | } |
| 345 |
nothing calls this directly
no test coverage detected