| 246 | } |
| 247 | |
| 248 | std::string |
| 249 | SessionData::get_protocol_stack_helper(const get_protocol_stack_f &get_protocol_stack, const get_tls_description_f &get_tls_node, |
| 250 | const handle_http_version_f &handle_http_version) |
| 251 | { |
| 252 | std::ostringstream protocol_description; |
| 253 | protocol_description << R"("protocol":[)"; |
| 254 | char const *protocol[10]; |
| 255 | int count = -1; |
| 256 | TSAssert(TS_SUCCESS == get_protocol_stack(10, protocol, &count)); |
| 257 | bool is_first_printed_protocol = true; |
| 258 | for (int i = 0; i < count; ++i) { |
| 259 | std::string_view protocol_string(protocol[i]); |
| 260 | if (!is_first_printed_protocol) { |
| 261 | protocol_description << ","; |
| 262 | } |
| 263 | is_first_printed_protocol = false; |
| 264 | if (protocol_string.find("tls") != std::string::npos) { |
| 265 | protocol_description << '{' << get_tls_node() << '}'; |
| 266 | } else { |
| 267 | auto search = tag_to_node.find(std::string(protocol_string)); |
| 268 | if (search == tag_to_node.end()) { |
| 269 | // If the tag from get_protocol_stack is not in our list, then our |
| 270 | // tag_to_node has not been updated with the new tag. Update tag_to_node. |
| 271 | TSError("[%s] Missing tag node description: '%.*s'", traffic_dump::debug_tag, static_cast<int>(protocol_string.length()), |
| 272 | protocol_string.data()); |
| 273 | protocol_description << R"({"name":")" << protocol_string << R"("})"; |
| 274 | } else { |
| 275 | protocol_description << '{' << search->second << '}'; |
| 276 | } |
| 277 | |
| 278 | // See whether an HTTP version is provided. If so, record it. |
| 279 | auto const it = http_tag_to_version.find(std::string(protocol_string)); |
| 280 | if (it != http_tag_to_version.end()) { |
| 281 | handle_http_version(it->second); |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | protocol_description << "]"; // Close the "protocol" sequence. |
| 286 | return protocol_description.str(); |
| 287 | } |
| 288 | |
| 289 | std::string |
| 290 | SessionData::get_client_protocol_description(TSHttpSsn client_ssnp) |