20#include <xrpld/overlay/detail/TrafficCount.h>
26 ::google::protobuf::Message
const& message,
30 if ((type == protocol::mtPING) || (type == protocol::mtSTATUS_CHANGE))
33 if (type == protocol::mtCLUSTER)
36 if (type == protocol::mtMANIFESTS)
39 if (type == protocol::mtENDPOINTS)
42 if (type == protocol::mtTRANSACTION)
45 if (type == protocol::mtVALIDATORLIST ||
46 type == protocol::mtVALIDATORLISTCOLLECTION)
49 if (type == protocol::mtVALIDATION)
52 if (type == protocol::mtPROPOSE_LEDGER)
55 if (type == protocol::mtHAVE_SET)
59 if (
auto msg =
dynamic_cast<protocol::TMLedgerData const*
>(&message))
61 if (msg->type() == protocol::liTS_CANDIDATE)
62 return (inbound && !msg->has_requestcookie())
66 if (msg->type() == protocol::liTX_NODE)
67 return (inbound && !msg->has_requestcookie())
71 if (msg->type() == protocol::liAS_NODE)
72 return (inbound && !msg->has_requestcookie())
76 return (inbound && !msg->has_requestcookie())
81 if (
auto msg =
dynamic_cast<protocol::TMGetLedger const*
>(&message))
83 if (msg->itype() == protocol::liTS_CANDIDATE)
84 return (inbound || msg->has_requestcookie())
88 if (msg->itype() == protocol::liTX_NODE)
89 return (inbound || msg->has_requestcookie())
93 if (msg->itype() == protocol::liAS_NODE)
94 return (inbound || msg->has_requestcookie())
98 return (inbound || msg->has_requestcookie())
103 if (
auto msg =
dynamic_cast<protocol::TMGetObjectByHash const*
>(&message))
105 if (msg->type() == protocol::TMGetObjectByHash::otLEDGER)
106 return (msg->query() == inbound)
110 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION)
111 return (msg->query() == inbound)
115 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTION_NODE)
116 return (msg->query() == inbound)
120 if (msg->type() == protocol::TMGetObjectByHash::otSTATE_NODE)
121 return (msg->query() == inbound)
125 if (msg->type() == protocol::TMGetObjectByHash::otCAS_OBJECT)
126 return (msg->query() == inbound)
130 if (msg->type() == protocol::TMGetObjectByHash::otFETCH_PACK)
131 return (msg->query() == inbound)
135 if (msg->type() == protocol::TMGetObjectByHash::otTRANSACTIONS)
142 if (type == protocol::mtPROOF_PATH_REQ)
145 if (type == protocol::mtPROOF_PATH_RESPONSE)
148 if (type == protocol::mtREPLAY_DELTA_REQ)
151 if (type == protocol::mtREPLAY_DELTA_RESPONSE)
154 if (type == protocol::mtHAVE_TRANSACTIONS)
157 if (type == protocol::mtTRANSACTIONS)
static category categorize(::google::protobuf::Message const &message, int type, bool inbound)
Given a protocol message, determine which traffic category it belongs to.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.