Updated license
[anna.git] / include / anna / diameter / codec / OamModule.hpp
1 // ANNA - Anna is Not Nothingness 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_codec_OamModule_hpp
38 #define anna_diameter_codec_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 codec {
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
72       None = -1,
73
74       /////////////////////////////////////////////
75       // All defined alarms are not transferable //
76       /////////////////////////////////////////////
77
78       /* Avp decoding */
79
80       AvpDecode__NotEnoughBytesToCoverAvpHeaderLength,
81       // El buffer pasado no es suficiente para construir un AVP
82       // Not enough buffer to build AVP
83
84       AvpDecode__IncoherenceBetweenActivatedVBitAndZeroedVendorIDValueReceived,
85       // Los Flags indican que el AVP es vendor-specific (bit V) y sin embargo el campo vendor-ID tiene un valor 0 (IETF)
86       // AVP Flags are vendor-specific (V bit) but vendor-ID octets value is 0 (IETF)
87
88       AvpDecode__IncorrectLength,
89       // Existe un error de formato en el AVP, la longitud es incorrecta
90       // There is an error inside the AVP, the length is not correct
91
92       AvpDecode__DataPartInconsistence,
93       // Existe un error de inconsistencia en la parte de datos
94       // There is an inconsistence error inside the AVP data part
95
96       AvpDecode__UnknownAvp__s__WithMandatoryBit,
97       // Formato desconocido del AVP %s con bit M activo
98       // Unknown format for AVP %s with activated M bit
99
100       /* Message decoding */
101
102       MessageDecode__NotEnoughBytesToCoverMessageHeaderLength,
103       // El buffer pasado no es suficiente para construir la cabecera de un mensaje DIAMETER
104       // Not enough buffer to build the DIAMETER message header
105
106       MessageDecode__NotEnoughBytesToCoverMessageLength,
107       // No se han proporcionado octetos suficientes para cubrir la longitud del mensaje DIAMETER
108       // Not enough bytes to fit DIAMETER message length
109
110
111       /* Avp validation */
112
113       AvpValidation__EnumeratedAvp__s__WithValue__d__DoesNotComplyRestriction__s__,
114       // El AVP enumerado %s con valor %d, no cumple la restriccion: %s
115       // Enumerated AVP %s with value %d does not comply to restriction: %s
116
117       AvpValidation__Avp__s__Flags__d__DoesNotFulfillTheDefinedFlagRules__s__,
118       // El AVP %s tiene flags (%d) incoherentes con las reglas de flags definidas: %s
119       // AVP %s flags (%d) does not fulfill the defined flag rules: %s
120
121
122       /* Message validation */
123
124       MessageValidation__UnknownOperation__s__UnableToValidate,
125       // Operacion %s desconocida, imposible validar
126       // Unknown operation %s, unable to validate
127
128       MessageValidation__Operation__s__HaveIncoherentFlags__d__,
129       // La operacion %s tiene flags (%d) incoherentes
130       // Operation %s have incoherent flags (%d)
131
132
133       /* Level validation */
134
135       LevelValidation__MissingFixedRule__s__Inside__s__,
136       // Falta un AVP fijo %s dentro de %s
137       // Missing fixed rule %s inside %s
138
139       LevelValidation__FailedRule__s__ForCardinality_Found__d__ItemsInside__s__,
140       // Ha fallado la regla %s de cardinalidad (encontrados %s items dentro de %s)
141       // Failed rule %s for cardinality (found %d items inside %s)
142
143       LevelValidation__FailedGenericAvpRule__s__ForCardinality_Found__d__DisregardedItemsInside__s__,
144       // Ha fallado la regla del AVP Generico %s para la cardinalidad (encontrados %d items no contemplados dentro de %s)
145       // Failed Generic AVP rule %s for cardinality (found %d disregarded items inside %s)
146
147       LevelValidation__FoundDisregardedItemsInside__s__AndGenericAVPWasNotSpecified__s__
148       // Encontrados items no contemplados dentro de %s y el AVP Generico no se especifico: %s
149       // Found disregarded items inside %s and Generic AVP was not specified: %s
150     };
151
152     anna_declare_enum(Alarm);
153   };
154
155   struct Counter {
156     enum _v
157     // In order to simplify, the literals assigned to
158     //  enum-type counters are equal to specification ones (in spanish)
159     {
160       None = -1,
161
162       /* Avp decoding */
163       AvpDecode__NotEnoughBytesToCoverAvpHeaderLength,
164       AvpDecode__IncoherenceBetweenActivatedVBitAndZeroedVendorIDValueReceived,
165       AvpDecode__IncorrectLength,
166       AvpDecode__DataPartInconsistence,
167       AvpDecode__UnknownAvpWithMandatoryBit,
168
169       /* Message decoding */
170       MessageDecode__NotEnoughBytesToCoverMessageHeaderLength,
171       MessageDecode__NotEnoughBytesToCoverMessageLength,
172
173       /* Avp validation */
174       AvpValidation__EnumeratedAvpWithValueDoesNotComplyRestriction,
175       AvpValidation__AvpFlagsDoesNotFulfillTheDefinedFlagRules,
176
177       /* Message validation */
178       MessageValidation__UnknownOperationUnableToValidate,
179       MessageValidation__OperationHaveIncoherentFlags,
180
181       /* Level validation */
182       LevelValidation__MissingFixedRule,
183       LevelValidation__FailedRuleForCardinality,
184       LevelValidation__FailedRuleForCardinalityLessThanNeeded,
185       LevelValidation__FailedRuleForCardinalityMoreThanNeeded,
186       LevelValidation__FailedGenericAvpRuleForCardinalityFoundDisregardedItem,
187       LevelValidation__FoundDisregardedItemsAndGenericAVPWasNotSpecified
188     };
189
190     anna_declare_enum(Counter);
191   };
192
193   /* virtual */std::string getDefaultInternalAlarmDescription(const int & alarmType) const throw() { return Alarm::asCString((Alarm::_v)alarmType); }
194   /* virtual */std::string getDefaultInternalCounterDescription(const int & counterType) const throw() { return Counter::asCString((Counter::_v)counterType); }
195
196
197 private:
198
199   // private constructor
200   OamModule() : anna::oam::Module("diameter::codec oam module") {};
201
202
203   friend class anna::Singleton <OamModule>;
204 };
205
206 }
207 }
208 }
209
210 #endif
211