EpcTools
An event based multi-threaded C++ development framework.
|
Go to the documentation of this file.
25 #include <unordered_map>
41 #define GTPV2C_BASE (0xff000000)
42 #define GTPV1U_BASE (0xfe000000)
43 #define PFCP_BASE (0xfd000000)
45 const UInt INTERFACE_S11C = (GTPV2C_BASE + 1);
46 const UInt INTERFACE_S5S8C = (GTPV2C_BASE + 2);
47 const UInt INTERFACE_S4 = (GTPV2C_BASE + 3);
48 const UInt INTERFACE_S2b = (GTPV2C_BASE + 4);
50 const UInt INTERFACE_S1U = (GTPV1U_BASE + 1);
51 const UInt INTERFACE_S11U = (GTPV1U_BASE + 2);
52 const UInt INTERFACE_S5S8U = (GTPV1U_BASE + 3);
53 const UInt INTERFACE_SWu = (GTPV1U_BASE + 4);
55 const UInt INTERFACE_Sxa = (PFCP_BASE + 1);
56 const UInt INTERFACE_Sxb = (PFCP_BASE + 2);
57 const UInt INTERFACE_Sxc = (PFCP_BASE + 3);
58 const UInt INTERFACE_SxaSxb = (PFCP_BASE + 4);
60 const UInt DIAMETER_ANSWER_BIT = 0x80000000;
89 Void
process(
enum fd_hook_type type,
struct msg * msg,
struct peer_hdr * peer,
90 Void * other,
struct fd_hook_permsgdata *pmd);
92 Void setLogger(
ELogger &logger) { m_logger = &logger; }
96 Bool getResult(
struct msg *m);
184 std::atomic<UInt> m_rqst_sent_err;
185 std::atomic<UInt> m_rqst_rcvd_err;
186 std::atomic<UInt> m_rqst_sent_ok;
187 std::atomic<UInt> m_rqst_rcvd_ok;
189 std::atomic<UInt> m_resp_sent_err;
190 std::atomic<UInt> m_resp_rcvd_err;
191 std::atomic<UInt> m_resp_sent_accept;
192 std::atomic<UInt> m_resp_sent_reject;
193 std::atomic<UInt> m_resp_rcvd_accept;
194 std::atomic<UInt> m_resp_rcvd_reject;
197 typedef std::unordered_map<EStatistics::MessageId,EStatistics::MessageStats>
MessageStatsMap;
235 #define INCREMENT_MESSAGE_STAT(__id,__func) \
237 auto srch = m_msgstats.find(__id); \
238 if (srch == m_msgstats.end() ) \
241 return srch->second.__func(); \
288 #undef INCREMENT_MESSAGE_STAT
293 ETime m_lastactivity;
298 typedef std::unordered_map<std::string,EStatistics::Peer>
PeerMap;
350 #define INCREMENT_MESSAGE_STAT(__peer,__id,__func) \
352 EStatistics::Peer &__p( getPeer(__peer) ); \
353 return __p.__func(__id); \
462 #undef INCREMENT_MESSAGE_STAT
477 typedef std::unordered_map<EStatistics::InterfaceId,EStatistics::Interface>
InterfaceMap;
486 auto srch = m_interfaces.find(
id);
487 if (srch == m_interfaces.end())
490 s.
format(
"Unknown interface ID [%u]",
id);
504 auto it = m_interfaces.emplace(
id,
Interface(
id,protocol,intfc));
505 return it.first->second;
513 auto srch = m_interfaces.find(
id);
514 if (srch != m_interfaces.end())
515 m_interfaces.erase( srch );
531 static DiameterHook m_hook_error;
532 static DiameterHook m_hook_success;
538 #endif // #ifndef __ESTATS_H
Peer & addPeer(const EString &peer)
Adds the specified peer.
Definition: estats.cpp:303
UInt incResponseReceivedErrors(const std::string &peer, UInt msgid)
Increments the response receive errors for the specified peer and message.
Definition: estats.h:439
Peer(cpStr name, const EStatistics::MessageStatsMap &tmplt)
Class constructor.
Definition: estats.cpp:220
UInt incRequestReceivedErrors(cpStr peer, UInt msgid)
Increments the request receive errors for the specified peer and message.
Definition: estats.h:366
UInt incRequestSentOk(cpStr peer, UInt msgid)
Increments the request send successes for the specified peer and message.
Definition: estats.h:371
UInt incRequestReceivedOk(cpStr peer, UInt msgid)
Increments the request receive successes for the specified peer and message.
Definition: estats.h:376
UInt getResponseSentErrors()
Retrieves the response send errors for this message.
Definition: estats.h:129
Defines base class for exceptions and declaration helper macros.
UInt incResponseReceivedOkRejected(UInt msgid)
Increments the response received success rejected for the specified message.
Definition: estats.h:285
UInt incResponseReceivedOkAccepted(UInt msgid)
Increments the response received success aceepted for the specified message.
Definition: estats.h:281
UInt incRequestReceivedOk(const std::string &peer, UInt msgid)
Increments the request receive successes for the specified peer and message.
Definition: estats.h:428
EString & getName()
Retrieves the peer name.
Definition: estats.h:221
UInt getResponseSentOkAccepted()
Retrieves the response send successes that were accepted for this message.
Definition: estats.h:135
Class for manipulating date and time of day values.
Definition: etime.h:199
UInt incResponseSentOkAccepted()
Increments the response send successes that were accepted for this message.
Definition: estats.h:167
UInt getRequestSentOk()
Retrieves the request send successes for this message.
Definition: estats.h:122
UInt incResponseSentErrors(UInt msgid)
Increments the response send errors for the specified message.
Definition: estats.h:265
static ETime Now()
Retrieves the current time.
Definition: etime.cpp:1147
UInt incRequestSentErrors(UInt msgid)
Increments the request send errors for the specified message.
Definition: estats.h:248
UInt incRequestSentErrors()
Increments the request send errors for this message.
Definition: estats.h:148
#define True
True.
Definition: ebase.h:25
Hooks into the freeDiameter internals to increment the message statistics.
Definition: estats.h:80
PeerMap & getPeers()
Retrieves the collection of peers for this interface.
Definition: estats.h:329
UInt incResponseSentOkRejected()
Increments the response send successes that were rejected for this message.
Definition: estats.h:170
Void reset()
Resets the message counters to zeroes for all peers.
Definition: estats.cpp:317
UInt getRequestReceivedErrors()
Retrieves the request receive errors for this message.
Definition: estats.h:119
Macros for various standard C library functions and standard includes.
UInt getResponseSentOkRejected()
Retrieves the response send successes that were rejected for this message.
Definition: estats.h:138
virtual Void process(enum fd_hook_type type, struct msg *msg, struct peer_hdr *peer, Void *other, struct fd_hook_permsgdata *pmd)=0
Method that is called to process a freeDiameter hook callback.
UInt incResponseSentErrors(const std::string &peer, UInt msgid)
Increments the response send errors for the specified peer and message.
Definition: estats.h:434
EStatistics::InterfaceId getId()
Retrieves the interface ID.
Definition: estats.h:320
ProtocolType
Definition: estats.h:66
MessageStatsMap & getMessageStatsTemplate()
Retrieves the collection of message statistics.
Definition: estats.h:347
ETime & setLastActivity()
Assigns the time stamp of the last activity.
Definition: estats.h:227
Defines the logging related classes.
UInt incResponseReceivedOkAccepted()
Increments the response receive successes that were accepted for this message.
Definition: estats.h:173
Contains definitions for synchronization objects.
UInt incResponseReceivedOkAccepted(cpStr peer, UInt msgid)
Increments the response receive success accepted for the specified peer and message.
Definition: estats.h:402
static Void init(ELogger &logger)
Initializes the statistics class.
Definition: estats.cpp:24
UInt incRequestReceivedOk()
Increments the request received successes for this message.
Definition: estats.h:157
UInt getResponseReceivedErrors()
Retrieves the response receive errors for this message.
Definition: estats.h:132
EString & getName()
Retrieves the interface name.
Definition: estats.h:323
std::unordered_map< EStatistics::InterfaceId, EStatistics::Interface > InterfaceMap
Definition: estats.h:477
Encapsulates a read-write lock object.
Definition: esynch.h:507
UInt incRequestSentOk(const std::string &peer, UInt msgid)
Increments the request send successes for the specified peer and message.
Definition: estats.h:423
static Interface & addInterface(EStatistics::InterfaceId id, ProtocolType protocol, const EString &intfc)
Adds/updates the interface.
Definition: estats.h:501
UInt incRequestSentErrors(const std::string &peer, UInt msgid)
Increments the request send errors for the specified peer and message.
Definition: estats.h:413
Void removePeer(const EString &peer)
Removes the specified peer.
Definition: estats.cpp:309
Provides class for manipulating time of day values.
Contains the statistics for an individual message.
Definition: estats.h:102
EStatistics::MessageId getId()
Definition: estats.h:111
Defines a logger.
Definition: elogger.h:78
Void reset()
Sets all message statistics counters to zero.
Definition: estats.cpp:251
UInt InterfaceId
Definition: estats.h:75
Registers, unregisters and process freeDiameter hooks. See "MONITORING" in libfdcore....
Definition: efd.h:1792
UInt incResponseSentOkRejected(cpStr peer, UInt msgid)
Increments the response send success rejected for the specified peer and message.
Definition: estats.h:397
UInt incRequestSentOk(UInt msgid)
Increments the request send successes for the specified message.
Definition: estats.h:256
UInt getResponseReceivedOkRejected()
Retrieves the response receive successes that were rejected for this message.
Definition: estats.h:144
UInt incResponseReceivedOkRejected()
Increments the response receive successes that were rejected for this message.
Definition: estats.h:176
UInt incRequestSentOk()
Increments the request send successes for this message.
Definition: estats.h:154
static InterfaceMap & getInterfaces()
Retrieves the interface collection.
Definition: estats.h:520
Request a read lock for the specified read-write lock object.
Definition: esynch.h:535
static Void removeInterface(EStatistics::InterfaceId id)
Removes the specified interface.
Definition: estats.h:510
Void reset()
Definition: estats.cpp:202
UInt incResponseSentOkAccepted(const std::string &peer, UInt msgid)
Increments the response send success accepted for the specified peer and message.
Definition: estats.h:444
UInt incResponseReceivedOkAccepted(const std::string &peer, UInt msgid)
Increments the response receive success accepted for the specified peer and message.
Definition: estats.h:454
UInt incRequestReceivedErrors()
Increments the request receive errors for this message.
Definition: estats.h:151
UInt incResponseReceivedOkRejected(const std::string &peer, UInt msgid)
Increments the response receive rejected accepted for the specified peer and message.
Definition: estats.h:459
std::unordered_map< EStatistics::MessageId, EStatistics::MessageStats > MessageStatsMap
Definition: estats.h:197
std::unordered_map< std::string, EStatistics::Peer > PeerMap
Defines a collection of peers.
Definition: estats.h:298
MessageStats & addMessageStatsTemplate(EStatistics::MessageId msgid, const EString &name)
Adds a message to the statistics message template for this interface.
Definition: estats.cpp:324
static Void reset()
Sets the message counters to zero for all interfaces, peers and messages.
Definition: estats.cpp:42
UInt incResponseSentOkRejected(const std::string &peer, Int msgid)
Increments the response send success rejected for the specified peer and message.
Definition: estats.h:449
UInt getRequestReceivedOk()
Retrieves the request received successes for this message.
Definition: estats.h:125
ProtocolType getProtocol()
Retrieves the interface protocol.
Definition: estats.h:326
UInt incResponseSentErrors(cpStr peer, UInt msgid)
Increments the response send errors for the specified peer and message.
Definition: estats.h:382
Request a write lock for the specified read-write lock object.
Definition: esynch.h:574
Represents an interface to track peer and message statistics for.
Definition: estats.h:301
static Void uninit()
Uninitializes teh statistics class.
Definition: estats.cpp:36
ETime & getLastActivity()
Retrieves the time stamp of the last activity.
Definition: estats.h:224
UInt incResponseReceivedOkRejected(cpStr peer, UInt msgid)
Increments the response receive rejected accepted for the specified peer and message.
Definition: estats.h:407
UInt incResponseReceivedErrors()
Increments the response receive errors for this message.
Definition: estats.h:164
EString & format(cpChar pszFormat,...)
Sets the value to the string using a "printf" style format string and arguments.
Definition: estring.cpp:38
UInt incResponseReceivedErrors(cpStr peer, UInt msgid)
Increments the response receive errors for the specified peer and message.
Definition: estats.h:387
UInt incRequestReceivedErrors(UInt msgid)
Increments the request receive errors for the specified message.
Definition: estats.h:252
UInt incResponseReceivedErrors(UInt msgid)
Increments the response receive errors for the specified message.
Definition: estats.h:269
String class.
Definition: estring.h:30
UInt incResponseSentErrors()
Increments the response send errors for this message.
Definition: estats.h:161
static Interface & getInterface(EStatistics::InterfaceId id)
Retrieves the requested interface object.
Definition: estats.h:483
UInt incRequestReceivedErrors(const std::string &peer, UInt msgid)
Increments the request receive errors for the specified peer and message.
Definition: estats.h:418
UInt getResponseReceivedOkAccepted()
Retrieves the response receive successes that were accepted for this message.
Definition: estats.h:141
The base class for exceptions derived from std::exception.
Definition: eerror.h:92
Warning.
Definition: eerror.h:101
UInt incResponseSentOkRejected(UInt msgid)
Increments the response send success rejected for the specified message.
Definition: estats.h:277
const EString & getName()
Definition: estats.h:112
EStatistics::MessageStatsMap & getMessageStats()
Retrieves the message statistics collection for this peer.
Definition: estats.h:230
Encapsulates and extends a std::string object.
UInt incRequestReceivedOk(UInt msgid)
Increments the request receive successes for the specified message.
Definition: estats.h:260
UInt incRequestSentErrors(cpStr peer, UInt msgid)
Increments the request send errors for the specified peer and message.
Definition: estats.h:361
freeDiameter wrapper classes.
UInt incResponseSentOkAccepted(UInt msgid)
Increments the response send success aceepted for the specified message.
Definition: estats.h:273
UInt getRequestSentErrors()
Retrieves the request send errors for this message.
Definition: estats.h:116
Contains the peer information including the statistics for the individual messages.
Definition: estats.h:200
UInt incResponseSentOkAccepted(cpStr peer, UInt msgid)
Increments the response send success accepted for the specified peer and message.
Definition: estats.h:392
Peer & getPeer(const EString &peer, Bool addFlag=True)
Retrieves the specified peer with option to add if it does not exist.
Definition: estats.cpp:283
UInt MessageId
Definition: estats.h:76