|
32 | 32 | namespace chops {
|
33 | 33 | namespace test {
|
34 | 34 |
|
35 |
| -enum msg_direction { incoming, outgoing }; |
| 35 | +template <typename AsioIpProtocol> |
| 36 | +std::string format_addr (const asio::ip::basic_endpoint<AsioIpProtocol>& endpoint) { |
| 37 | + return endpoint.address().to_string() + ":" + std::to_string(endpoint.port()); |
| 38 | +} |
36 | 39 |
|
37 | 40 | struct monitor_msg_data {
|
38 | 41 |
|
39 |
| - static constexpr max_msg_data_to_capture = 15; |
| 42 | + static constexpr std::size_t max_msg_data_to_capture = 15; |
| 43 | + enum msg_direction { incoming, outgoing }; |
40 | 44 |
|
41 | 45 | std::string m_dsr_name;
|
42 | 46 | std::string m_protocol; // "tcp" or "udp"
|
43 |
| - std::string m_remote_host; |
44 |
| - std::string m_remote_port; |
| 47 | + std::string m_remote_addr; // in "host:port" format, see format_addr above |
45 | 48 | msg_direction m_direction;
|
46 | 49 | std::size_t m_curr_msg_num;
|
47 | 50 | std::size_t m_curr_msg_size;
|
48 | 51 | std::string m_curr_msg_beginning; // up to max_msg_data_to_capture chars
|
49 | 52 | std::size_t m_total_msgs_to_send; // 0 if direction is incoming, since total not known in advance
|
50 | 53 | std::size_t m_outgoing_queue_size;
|
51 | 54 |
|
52 |
| - template <typename AsioIpProtocol> |
53 |
| - monitor_msg_data (const asio::ip::basic_endpoint<AsioIpProtocol>& remote_endpoint, |
54 |
| - const std::string& dsr_name, |
55 |
| - msg_direction direction, |
56 |
| - std::size_t curr_msg_num, |
57 |
| - std::size_t curr_msg_size, |
58 |
| - const std::string& curr_msg_beginning, |
59 |
| - std::size_t total_msgs_to_send, |
60 |
| - std::size_t outgoing_queue_size) : |
61 |
| - m_dsr_name(dsr_name), |
62 |
| - m_protocol("tcp"), |
63 |
| - m_remote_host(), |
64 |
| - m_remote_port(), |
65 |
| - m_direction(direction), |
66 |
| - m_curr_msg_num(curr_msg_num), |
67 |
| - m_curr_msg_size(curr_msg_size), |
68 |
| - m_curr_msg_beginning(curr_msg_beginning), |
69 |
| - m_total_msgs_to_send(total_msgs_to_send), |
70 |
| - m_outgoing_queue_size(outgoing_queue_size) |
71 |
| - { |
72 |
| - m_remote_host = remote_endpoint.address().to_string(); |
73 |
| - m_remote_port = std::to_string(remote_endpoint.port()); |
74 |
| - if constexpr (std::is_same_v<asio::ip::udp, AsioIpProtocol>) { |
75 |
| - m_protocol = "udp"; |
76 |
| - } |
77 |
| - } |
78 | 55 | };
|
79 | 56 |
|
80 | 57 | struct shutdown_msg {
|
|
0 commit comments