| 353 | } |
| 354 | |
| 355 | void entity_addrvec_t::decode(ceph::buffer::list::const_iterator& bl) |
| 356 | { |
| 357 | using ceph::decode; |
| 358 | __u8 marker; |
| 359 | decode(marker, bl); |
| 360 | if (marker == 0) { |
| 361 | // legacy! |
| 362 | entity_addr_t addr; |
| 363 | addr.decode_legacy_addr_after_marker(bl); |
| 364 | v.clear(); |
| 365 | v.push_back(addr); |
| 366 | return; |
| 367 | } |
| 368 | if (marker == 1) { |
| 369 | entity_addr_t addr; |
| 370 | DECODE_START(1, bl); |
| 371 | decode(addr.type, bl); |
| 372 | decode(addr.nonce, bl); |
| 373 | __u32 elen; |
| 374 | decode(elen, bl); |
| 375 | if (elen) { |
| 376 | struct sockaddr *sa = (struct sockaddr *)addr.get_sockaddr(); |
| 377 | #if defined(__FreeBSD__) || defined(__APPLE__) |
| 378 | sa->sa_len = 0; |
| 379 | #endif |
| 380 | uint16_t ss_family; |
| 381 | if (elen < sizeof(ss_family)) { |
| 382 | throw ceph::buffer::malformed_input("elen smaller than family len"); |
| 383 | } |
| 384 | decode(ss_family, bl); |
| 385 | sa->sa_family = ss_family; |
| 386 | elen -= sizeof(ss_family); |
| 387 | if (elen > addr.get_sockaddr_len() - sizeof(sa->sa_family)) { |
| 388 | throw ceph::buffer::malformed_input("elen exceeds sockaddr len"); |
| 389 | } |
| 390 | bl.copy(elen, sa->sa_data); |
| 391 | } |
| 392 | DECODE_FINISH(bl); |
| 393 | v.clear(); |
| 394 | v.push_back(addr); |
| 395 | return; |
| 396 | } |
| 397 | if (marker > 2) |
| 398 | throw ceph::buffer::malformed_input("entity_addrvec_marker > 2"); |
| 399 | decode(v, bl); |
| 400 | } |
| 401 | |
| 402 | void entity_addrvec_t::dump(ceph::Formatter *f) const |
| 403 | { |
nothing calls this directly
no test coverage detected