| 578 | } |
| 579 | |
| 580 | int |
| 581 | HttpProxyPort::print(char *out, size_t n) |
| 582 | { |
| 583 | size_t zret = 0; // # of chars printed so far. |
| 584 | ip_text_buffer ipb; |
| 585 | bool need_colon_p = false; |
| 586 | |
| 587 | if (m_inbound_ip.isValid()) { |
| 588 | zret += snprintf(out + zret, n - zret, "%s=[%s]", OPT_INBOUND_IP_PREFIX, m_inbound_ip.toString(ipb, sizeof(ipb))); |
| 589 | need_colon_p = true; |
| 590 | } |
| 591 | if (zret >= n) { |
| 592 | return n; |
| 593 | } |
| 594 | |
| 595 | if (m_outbound.has_ip4()) { |
| 596 | if (need_colon_p) { |
| 597 | out[zret++] = ':'; |
| 598 | } |
| 599 | zret += snprintf(out + zret, n - zret, "%s=[%s]", OPT_OUTBOUND_IP_PREFIX, |
| 600 | swoc::FixedBufferWriter(ipb, sizeof(ipb)).print("{}", m_outbound.ip4()).data()); |
| 601 | need_colon_p = true; |
| 602 | } |
| 603 | if (zret >= n) { |
| 604 | return n; |
| 605 | } |
| 606 | |
| 607 | if (m_outbound.has_ip6()) { |
| 608 | if (need_colon_p) { |
| 609 | out[zret++] = ':'; |
| 610 | } |
| 611 | zret += snprintf(out + zret, n - zret, "%s=[%s]", OPT_OUTBOUND_IP_PREFIX, |
| 612 | swoc::FixedBufferWriter(ipb, sizeof(ipb)).print("{}", m_outbound.ip6()).data()); |
| 613 | need_colon_p = true; |
| 614 | } |
| 615 | if (zret >= n) { |
| 616 | return n; |
| 617 | } |
| 618 | |
| 619 | if (0 != m_port) { |
| 620 | if (need_colon_p) { |
| 621 | out[zret++] = ':'; |
| 622 | } |
| 623 | zret += snprintf(out + zret, n - zret, "%d", m_port); |
| 624 | need_colon_p = true; |
| 625 | } |
| 626 | if (zret >= n) { |
| 627 | return n; |
| 628 | } |
| 629 | |
| 630 | if (ts::NO_FD != m_fd) { |
| 631 | if (need_colon_p) { |
| 632 | out[zret++] = ':'; |
| 633 | } |
| 634 | zret += snprintf(out + zret, n - zret, "fd=%d", m_fd); |
| 635 | } |
| 636 | if (zret >= n) { |
| 637 | return n; |