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;
338 Void removePeer(
const EString &peer);
350 #define INCREMENT_MESSAGE_STAT(__peer,__id,__func) \ 352 EStatistics::Peer &__p( getPeer(__peer) ); \ 353 return __p.__func(__id); \ 413 UInt
incRequestSentErrors(
const std::string &peer, UInt msgid) { INCREMENT_MESSAGE_STAT(peer, msgid, incRequestSentErrors); }
418 UInt
incRequestReceivedErrors(
const std::string &peer, UInt msgid) { INCREMENT_MESSAGE_STAT(peer, msgid, incRequestReceivedErrors); }
423 UInt
incRequestSentOk(
const std::string &peer, UInt msgid) { INCREMENT_MESSAGE_STAT(peer, msgid, incRequestSentOk); }
428 UInt
incRequestReceivedOk(
const std::string &peer, UInt msgid) { INCREMENT_MESSAGE_STAT(peer, msgid, incRequestReceivedOk); }
434 UInt
incResponseSentErrors(
const std::string &peer, UInt msgid) { INCREMENT_MESSAGE_STAT(peer, msgid, incResponseSentErrors); }
462 #undef INCREMENT_MESSAGE_STAT 475 MessageStatsMap m_msgstats_template;
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 );
538 #endif // #ifndef __ESTATS_H
freeDiameter wrapper classes.
UInt incResponseSentErrors(UInt msgid)
Increments the response send errors for the specified message.
Definition: estats.h:265
Encapsulates and extends a std::string object.
#define True
True.
Definition: ebase.h:25
Request a read lock for the specified read-write lock object.
Definition: esynch.h:535
UInt getRequestReceivedErrors()
Retrieves the request receive errors for this message.
Definition: estats.h:119
UInt incResponseReceivedOkRejected()
Increments the response receive successes that were rejected for this message.
Definition: estats.h:176
UInt getResponseReceivedOkRejected()
Retrieves the response receive successes that were rejected for this message.
Definition: estats.h:144
static ETime Now()
Retrieves the current time.
Definition: etime.cpp:1147
UInt incResponseReceivedOkAccepted(cpStr peer, UInt msgid)
Increments the response receive success accepted for the specified peer and message.
Definition: estats.h:402
Macros for various standard C library functions and standard includes.
UInt incRequestSentErrors(cpStr peer, UInt msgid)
Increments the request send errors for the specified peer and message.
Definition: estats.h:361
UInt incResponseReceivedErrors(const std::string &peer, UInt msgid)
Increments the response receive errors for the specified peer and message.
Definition: estats.h:439
UInt incResponseSentOkRejected()
Increments the response send successes that were rejected for this message.
Definition: estats.h:170
Hooks into the freeDiameter internals to increment the message statistics.
Definition: estats.h:80
UInt incRequestReceivedOk(const std::string &peer, UInt msgid)
Increments the request receive successes for the specified peer and message.
Definition: estats.h:428
static Void init(ELogger &logger)
Initializes the statistics class.
Definition: estats.cpp:24
Warning.
Definition: eerror.h:103
UInt incRequestSentOk(const std::string &peer, UInt msgid)
Increments the request send successes for the specified peer and message.
Definition: estats.h:423
UInt incResponseSentOkRejected(UInt msgid)
Increments the response send success rejected for the specified message.
Definition: estats.h:277
Request a write lock for the specified read-write lock object.
Definition: esynch.h:574
UInt incRequestReceivedOk(UInt msgid)
Increments the request receive successes for the specified message.
Definition: estats.h:260
ProtocolType
Definition: estats.h:66
UInt incResponseSentOkRejected(cpStr peer, UInt msgid)
Increments the response send success rejected for the specified peer and message. ...
Definition: estats.h:397
UInt incRequestSentOk(cpStr peer, UInt msgid)
Increments the request send successes for the specified peer and message.
Definition: estats.h:371
UInt incResponseSentOkAccepted(UInt msgid)
Increments the response send success aceepted for the specified message.
Definition: estats.h:273
UInt incRequestReceivedErrors()
Increments the request receive errors for this message.
Definition: estats.h:151
UInt incRequestReceivedErrors(UInt msgid)
Increments the request receive errors for the specified message.
Definition: estats.h:252
const EString & getName()
Definition: estats.h:112
UInt getRequestReceivedOk()
Retrieves the request received successes for this message.
Definition: estats.h:125
Provides class for manipulating time of day values.
UInt incResponseReceivedErrors(UInt msgid)
Increments the response receive errors for the specified message.
Definition: estats.h:269
UInt incRequestSentOk()
Increments the request send successes for this message.
Definition: estats.h:154
UInt incResponseReceivedOkAccepted(UInt msgid)
Increments the response received success aceepted for the specified message.
Definition: estats.h:281
static InterfaceMap & getInterfaces()
Retrieves the interface collection.
Definition: estats.h:520
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 incResponseSentErrors()
Increments the response send errors for this message.
Definition: estats.h:161
UInt getRequestSentErrors()
Retrieves the request send errors for this message.
Definition: estats.h:116
Defines the logging related classes.
Class for manipulating date and time of day values.
Definition: etime.h:199
UInt incResponseReceivedOkAccepted()
Increments the response receive successes that were accepted for this message.
Definition: estats.h:173
PeerMap & getPeers()
Retrieves the collection of peers for this interface.
Definition: estats.h:329
UInt getResponseSentErrors()
Retrieves the response send errors for this message.
Definition: estats.h:129
UInt getResponseReceivedOkAccepted()
Retrieves the response receive successes that were accepted for this message.
Definition: estats.h:141
UInt incResponseSentOkRejected(const std::string &peer, Int msgid)
Increments the response send success rejected for the specified peer and message. ...
Definition: estats.h:449
Contains the peer information including the statistics for the individual messages.
Definition: estats.h:200
UInt incRequestSentErrors(UInt msgid)
Increments the request send errors for the specified message.
Definition: estats.h:248
static Interface & addInterface(EStatistics::InterfaceId id, ProtocolType protocol, const EString &intfc)
Adds/updates the interface.
Definition: estats.h:501
UInt incResponseSentErrors(const std::string &peer, UInt msgid)
Increments the response send errors for the specified peer and message.
Definition: estats.h:434
UInt getResponseSentOkAccepted()
Retrieves the response send successes that were accepted for this message.
Definition: estats.h:135
std::unordered_map< EStatistics::MessageId, EStatistics::MessageStats > MessageStatsMap
Definition: estats.h:197
ProtocolType getProtocol()
Retrieves the interface protocol.
Definition: estats.h:326
MessageStatsMap & getMessageStatsTemplate()
Retrieves the collection of message statistics.
Definition: estats.h:347
UInt getRequestSentOk()
Retrieves the request send successes for this message.
Definition: estats.h:122
Defines base class for exceptions and declaration helper macros.
EStatistics::InterfaceId getId()
Retrieves the interface ID.
Definition: estats.h:320
UInt InterfaceId
Definition: estats.h:75
UInt incRequestReceivedOk()
Increments the request received successes for this message.
Definition: estats.h:157
std::unordered_map< EStatistics::InterfaceId, EStatistics::Interface > InterfaceMap
Definition: estats.h:477
UInt incRequestReceivedErrors(const std::string &peer, UInt msgid)
Increments the request receive errors for the specified peer and message.
Definition: estats.h:418
UInt incResponseReceivedOkRejected(UInt msgid)
Increments the response received success rejected for the specified message.
Definition: estats.h:285
The base class for exceptions derived from std::exception.
Definition: eerror.h:94
EStatistics::MessageStatsMap & getMessageStats()
Retrieves the message statistics collection for this peer.
Definition: estats.h:230
EString & getName()
Retrieves the interface name.
Definition: estats.h:323
Contains the statistics for an individual message.
Definition: estats.h:102
UInt incRequestSentErrors(const std::string &peer, UInt msgid)
Increments the request send errors for the specified peer and message.
Definition: estats.h:413
Represents an interface to track peer and message statistics for.
Definition: estats.h:301
std::unordered_map< std::string, EStatistics::Peer > PeerMap
Defines a collection of peers.
Definition: estats.h:298
UInt getResponseSentOkRejected()
Retrieves the response send successes that were rejected for this message.
Definition: estats.h:138
UInt incResponseSentOkAccepted(cpStr peer, UInt msgid)
Increments the response send success accepted for the specified peer and message. ...
Definition: estats.h:392
static Void removeInterface(EStatistics::InterfaceId id)
Removes the specified interface.
Definition: estats.h:510
Defines a logger.
Definition: elogger.h:76
static Interface & getInterface(EStatistics::InterfaceId id)
Retrieves the requested interface object.
Definition: estats.h:483
Registers, unregisters and process freeDiameter hooks. See "MONITORING" in libfdcore.h in the freeDiameter library.
Definition: efd.h:1792
EString & getName()
Retrieves the peer name.
Definition: estats.h:221
UInt incResponseSentOkAccepted()
Increments the response send successes that were accepted for this message.
Definition: estats.h:167
UInt incResponseReceivedOkAccepted(const std::string &peer, UInt msgid)
Increments the response receive success accepted for the specified peer and message.
Definition: estats.h:454
static Void uninit()
Uninitializes teh statistics class.
Definition: estats.cpp:36
ETime & setLastActivity()
Assigns the time stamp of the last activity.
Definition: estats.h:227
static Void reset()
Sets the message counters to zero for all interfaces, peers and messages.
Definition: estats.cpp:42
UInt incRequestSentErrors()
Increments the request send errors for this message.
Definition: estats.h:148
UInt incRequestSentOk(UInt msgid)
Increments the request send successes for the specified message.
Definition: estats.h:256
UInt getResponseReceivedErrors()
Retrieves the response receive errors for this message.
Definition: estats.h:132
UInt incRequestReceivedErrors(cpStr peer, UInt msgid)
Increments the request receive errors for the specified peer and message.
Definition: estats.h:366
UInt MessageId
Definition: estats.h:76
UInt incRequestReceivedOk(cpStr peer, UInt msgid)
Increments the request receive successes for the specified peer and message.
Definition: estats.h:376
UInt incResponseReceivedOkRejected(const std::string &peer, UInt msgid)
Increments the response receive rejected accepted for the specified peer and message.
Definition: estats.h:459
ETime & getLastActivity()
Retrieves the time stamp of the last activity.
Definition: estats.h:224
UInt incResponseReceivedErrors(cpStr peer, UInt msgid)
Increments the response receive errors for the specified peer and message.
Definition: estats.h:387
EString & format(cpChar pszFormat,...)
Sets the value to the string using a "printf" style format string and arguments.
Definition: estring.cpp:38
EStatistics::MessageId getId()
Definition: estats.h:111
UInt incResponseReceivedOkRejected(cpStr peer, UInt msgid)
Increments the response receive rejected accepted for the specified peer and message.
Definition: estats.h:407
String class.
Definition: estring.h:31
Contains definitions for synchronization objects.
Encapsulates a read-write lock object.
Definition: esynch.h:507
UInt incResponseReceivedErrors()
Increments the response receive errors for this message.
Definition: estats.h:164
UInt incResponseSentErrors(cpStr peer, UInt msgid)
Increments the response send errors for the specified peer and message.
Definition: estats.h:382