First commit
[anna.git] / include / anna / diameter.comm / OamModule.hpp
1 // ANNA - Anna is Not 'N' Anymore
2 //
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
4 //
5 // https://bitbucket.org/testillano/anna
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 //     * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //     * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
16 // distribution.
17 //     * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 // Authors: eduardo.ramos.testillano@gmail.com
34 //          cisco.tierra@gmail.com
35
36
37 #ifndef anna_diameter_comm_OamModule_hpp
38 #define anna_diameter_comm_OamModule_hpp
39
40
41 #include <anna/core/Singleton.hpp>
42 #include <anna/core/define.autoenum.hpp>
43
44 // HTE
45 #include <anna/core/oam/Module.hpp>
46
47 // STL
48 #include <string>
49
50
51 namespace anna {
52
53 namespace diameter {
54
55 namespace comm {
56
57
58 class OamModule : public anna::oam::Module, public anna::Singleton <OamModule> {
59
60 public:
61
62   struct Alarm {
63
64     //////////////////////////////////////////////////////////////////////////////////////////////////////////////
65     // Transferable Alarms:    preffix = c_                                                                     //
66     // Grouped Alarms:         preffix = g_                                                                     //
67     //                         Be careful: this alarms take more than one place (better define them at the end) //
68     //////////////////////////////////////////////////////////////////////////////////////////////////////////////
69
70     enum _v {
71       // Enumerated labels represent english text and formats. Final order is not restricted to this in any language, but, is useful to
72       //  remember the names at CSL. For example, we should have CSL="primary_address,secondary_address", and then the database text
73       //  could have any composition: "Fail to deliver on secondary address '${secondary_address:%s}' after failing over primary '${primary_address:%s}'"
74
75       None = -1,
76
77       /* Connectivity */
78       // clients
79       UnableToDeliverDiameterMessageToEntityDefinedAs__s__, // 'address1:port1 address2:port2 ...'
80       UnableToDeliverDiameterMessageToEntityDefinedAsPrimary__s__AndSecondary__s__, // 'Primary Server address1:port1 and Secondary Server address2:port2'
81       RequestSentOnClientSessionExpired,
82       RequestSentOnServerSessionExpired,
83       AnswerReceivedOnClientSessionUnknown,
84       AnswerReceivedOnServerSessionUnknown,
85       c_LostAvailabilityOverClientSessionWithServer__s__,
86       c_LostAvailabilityOverClientSessionWithServer__s__ClientSessionId__d__,
87       c_LostAvailabilityOverServerDefinedAs__s__, // 'address:port'
88       c_LostAvailabilityOverEntityDefinedAs__s__, // 'address1:port1 address2:port2 ...'
89       c_LostAvailabilityOverEntityDefinedAsPrimary__s__AndSecondary__s__, // 'Primary Server address1:port1 and Secondary Server address2:port2'
90       c_LostAvailabilityOverEntitiesForEngineWithClassName__s__,
91       // servers
92       UnableToDeliverDiameterMessageToClientFromLocalServer__s__, // 'address:port'
93       LostConnectionForServerSessionAtLocalServer__s__,
94       LostConnectionForServerSessionAtLocalServer__s__ServerSessionId__d__,
95       UnbindConnectionForServerSessionAtLocalServer__s__DueToInactivityTimeAnomaly,
96       UnbindConnectionForServerSessionAtLocalServer__s__ServerSessionId__d__DueToInactivityTimeAnomaly,
97       c_LostAvailabilityOverLocalServerDefinedAs__s__, // 'address:port'
98       c_LostAvailabilityOverLocalServersForEngineWithClassName__s__
99     };
100
101     anna_declare_enum(Alarm);
102   };
103
104   struct Counter {
105     enum _v
106     // In order to simplify, the literals assigned to
107     //  enum-type counters are equivalent to spanich specification ones
108     {
109       None = -1,
110
111       /* Main */
112       // receptions
113       RequestReceived,
114       AnswerReceived,
115       RequestReceivedOnClientSession,
116       AnswerReceivedOnClientSession,
117       RequestReceivedOnServerSession,
118       AnswerReceivedOnServerSession,
119       // sendings
120       RequestSentOK,
121       RequestSentNOK,
122       AnswerSentOK,
123       AnswerSentNOK,
124       RequestSentOnClientSessionOK,
125       RequestSentOnClientSessionNOK,
126       AnswerSentOnClientSessionOK,
127       AnswerSentOnClientSessionNOK,
128       RequestSentOnServerSessionOK,
129       RequestSentOnServerSessionNOK,
130       AnswerSentOnServerSessionOK,
131       AnswerSentOnServerSessionNOK,
132
133       // expirations
134       RequestSentExpired,
135       RequestSentOnClientSessionExpired,
136       RequestSentOnServerSessionExpired,
137
138       // unknown received answers
139       AnswerReceivedUnknown,
140       AnswerReceivedOnClientSessionUnknown,
141       AnswerReceivedOnServerSessionUnknown,
142
143       /* Capabilities Exchange */
144       // clients
145       CERSentOK,
146       CERSentNOK,
147       CEAReceived,
148       // servers
149       CERReceived,
150       CEASentOK,
151       CEASentNOK,
152
153       /* Diameter Keepalive */
154       // clients
155       DWRSentOK,
156       DWRSentNOK,
157       DWAReceived,
158       // servers
159       DWRReceived,
160       DWASentOK,
161       DWASentNOK,
162
163       /* Peer disconnection */
164       // clients
165       DPRSentOK,
166       DPRSentNOK,
167       DPAReceived,
168       // servers
169       DPRReceived,
170       DPASentOK,
171       DPASentNOK,
172
173       /* server socket operations (enable/disable listening port for any local server) */
174       ServerSocketsOpened,
175       ServerSocketsClosed,
176
177       /* Connectivity */
178       // clients
179       UnableToDeliverOverEntity,
180       LostAvailabilityOverClientSession,
181       RecoveredAvailabilityOverClientSession,
182       LostAvailabilityOverServer,
183       RecoveredAvailabilityOverServer,
184       LostAvailabilityOverEntity,
185       RecoveredAvailabilityOverEntity,
186       LostAvailabilityOverEngineForEntities,
187       RecoveredAvailabilityOverEngineForEntities,
188       // servers
189       UnableToDeliverToClient,
190       LostConnectionForServerSession,
191       UnbindConnectionForServerSessionDueToInactivityTimeAnomaly,
192       CreatedConnectionForServerSession,
193       LostAvailabilityOverLocalServer,
194       RecoveredAvailabilityOverLocalServer,
195       LostAvailabilityOverEngineForLocalServers,
196       RecoveredAvailabilityOverEngineForLocalServers
197     };
198
199     anna_declare_enum(Counter);
200   };
201
202   /* virtual */std::string getDefaultInternalAlarmDescription(const int & alarmType) const throw() { return Alarm::asCString((Alarm::_v)alarmType); }
203   /* virtual */std::string getDefaultInternalCounterDescription(const int & counterType) const throw() { return Counter::asCString((Counter::_v)counterType); }
204
205
206 private:
207
208   // private constructor
209   OamModule() : anna::oam::Module("diameter::comm oam module") {};
210
211
212   friend class anna::Singleton <OamModule>;
213 };
214
215 }
216 }
217 }
218
219 #endif
220