Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions include/tscore/CryptoHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,9 @@ CryptoContext::finalize(CryptoHash &hash)
return reinterpret_cast<CryptoContextBase *>(_obj)->finalize(hash);
}

} // namespace ats
ts::BufferWriter &bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, ats::CryptoHash const &hash);

namespace ts
{
inline BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, ats::CryptoHash const &hash)
{
BWFSpec local_spec{spec};
if ('X' != local_spec._type)
local_spec._type = 'x';
return bwformat(w, local_spec, std::string_view(reinterpret_cast<const char *>(hash.u8), CRYPTO_HASH_SIZE));
}
} // namespace ts
} // namespace ats

using ats::CryptoHash;
using ats::CryptoContext;
Expand Down
11 changes: 11 additions & 0 deletions proxy/http/HttpConnectionCount.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,17 @@ OutboundConnTrack::TxnState::Warn_Blocked(TxnConfig *config, int64_t sm_id, int

namespace ts
{
BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, OutboundConnTrack::MatchType type)
{
if (spec.has_numeric_type()) {
bwformat(w, spec, static_cast<unsigned int>(type));
} else {
bwformat(w, spec, OutboundConnTrack::MATCH_TYPE_NAME[type]);
}
return w;
}

BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, OutboundConnTrack::Group::Key const &key)
{
Expand Down
12 changes: 1 addition & 11 deletions proxy/http/HttpConnectionCount.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,7 @@ Action *register_ShowConnectionCount(Continuation *, HTTPHdr *);

namespace ts
{
inline BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, OutboundConnTrack::MatchType type)
{
if (spec.has_numeric_type()) {
bwformat(w, spec, static_cast<unsigned int>(type));
} else {
bwformat(w, spec, OutboundConnTrack::MATCH_TYPE_NAME[type]);
}
return w;
}

BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, OutboundConnTrack::MatchType type);
BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, OutboundConnTrack::Group::Key const &key);
BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, OutboundConnTrack::Group const &g);
} // namespace ts
40 changes: 40 additions & 0 deletions proxy/http/HttpDebugNames.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,3 +476,43 @@ HttpDebugNames::get_api_hook_name(TSHttpHookID t)

return "unknown hook";
}

ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::ServerState_t state)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(state));
} else {
return bwformat(w, spec, HttpDebugNames::get_server_state_name(state));
}
}

ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::CacheAction_t state)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(state));
} else {
return bwformat(w, spec, HttpDebugNames::get_cache_action_name(state));
}
}

ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::StateMachineAction_t state)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(state));
} else {
return bwformat(w, spec, HttpDebugNames::get_action_name(state));
}
}

ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, TSHttpHookID id)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(id));
} else {
return bwformat(w, spec, HttpDebugNames::get_api_hook_name(id));
}
}
43 changes: 4 additions & 39 deletions proxy/http/HttpDebugNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,7 @@ class HttpDebugNames
static const char *get_server_state_name(HttpTransact::ServerState_t state);
};

inline ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::ServerState_t state)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(state));
} else {
return bwformat(w, spec, HttpDebugNames::get_server_state_name(state));
}
}

inline ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::CacheAction_t state)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(state));
} else {
return bwformat(w, spec, HttpDebugNames::get_cache_action_name(state));
}
}

inline ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::StateMachineAction_t state)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(state));
} else {
return bwformat(w, spec, HttpDebugNames::get_action_name(state));
}
}

inline ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, TSHttpHookID id)
{
if (spec.has_numeric_type()) {
return bwformat(w, spec, static_cast<uintmax_t>(id));
} else {
return bwformat(w, spec, HttpDebugNames::get_api_hook_name(id));
}
}
ts::BufferWriter &bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::ServerState_t state);
ts::BufferWriter &bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::CacheAction_t state);
ts::BufferWriter &bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, HttpTransact::StateMachineAction_t state);
ts::BufferWriter &bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, TSHttpHookID id);
12 changes: 12 additions & 0 deletions src/tscore/CryptoHash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,15 @@ CryptoHash::toHexStr(char buffer[(CRYPTO_HASH_SIZE * 2) + 1]) const
{
return ink_code_to_hex_str(buffer, u8);
}

namespace ats
{
ts::BufferWriter &
bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, ats::CryptoHash const &hash)
{
ts::BWFSpec local_spec{spec};
if ('X' != local_spec._type)
local_spec._type = 'x';
return bwformat(w, local_spec, std::string_view(reinterpret_cast<const char *>(hash.u8), CRYPTO_HASH_SIZE));
}
} // namespace ats