Updated license
[anna.git] / include / anna / diameter / app / dcca / nokia / Message.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_app_dcca_nokia_Message_hpp
38 #define anna_diameter_app_dcca_nokia_Message_hpp
39
40
41 // Local
42 #include <anna/diameter/app/dcca/Message.hpp>
43
44 // AVPID's
45 #include <anna/diameter/helpers/nokia/defines.hpp>
46
47 #include <anna/core/RuntimeException.hpp>
48
49
50 //------------------------------------------------------------------------------
51 //---------------------------------------------------------------------- #define
52 //------------------------------------------------------------------------------
53
54
55
56 namespace anna {
57
58 namespace diameter {
59
60 namespace codec {
61 using namespace basetypes;
62 }
63
64 namespace app {
65
66 namespace dcca {
67
68 namespace nokia {
69
70
71 /**
72 * Diameter message for Nokia DCCA (diameter credit control application)
73 */
74 class Message : public anna::diameter::app::dcca::Message {
75
76 public:
77
78
79   /**
80      Avp 3GPP-PDP-Type data-part pointer reference
81      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
82   */
83   const Unsigned32 * get3GPPPDPType(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
84     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_PDP_Type)->getUnsigned32());
85   }
86
87
88   /**
89      Avp Framed-IP-Address or Framed-IPv6-Prefix data-part pointer reference, depending on 3GPP-PDP-Type value
90      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
91   */
92   const OctetString * getFramedIP(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
93     ASSERT_APP_GETAVP(
94       int pdpType = get3GPPPDPType()->getValue();
95
96       if(pdpType == helpers::tgpp::AVPVALUES__3GPP_PDP_Type::IPV4)
97       return getAvp(helpers::radius::AVPID__Framed_IP_Address)->getOctetString();
98       if(pdpType == helpers::tgpp::AVPVALUES__3GPP_PDP_Type::IPV6)
99         return getAvp(helpers::radius::AVPID__Framed_IPv6_Prefix)->getOctetString();
100         return NULL;
101       );
102   }
103
104   /**
105      Avp Called-Station-Id data-part pointer reference
106      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
107   */
108   const UTF8String * getCalledStationId(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
109     ASSERT_APP_GETAVP(return getAvp(helpers::radius::AVPID__Called_Station_Id)->getUTF8String());
110   }
111
112   /**
113      Avp 3GPP-SGSN-MCC-MNC data-part pointer reference
114      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
115   */
116   const UTF8String * get3GPPSGSNMCCMNC(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
117     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_SGSN_MCC_MNC)->getUTF8String());
118   }
119
120   /**
121      Avp 3GPP-SGSN-Address data-part pointer reference
122      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
123   */
124   const OctetString * get3GPPSGSNAddress(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
125     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_SGSN_Address)->getOctetString());
126   }
127
128   /**
129      Avp 3GPP-Charging-Characteristics data-part pointer reference
130      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
131   */
132   const UTF8String * get3GPPChargingCharacteristics(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
133     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_Charging_Characteristics)->getUTF8String());
134   }
135
136   /**
137      Avp 3GPP-CG-Address data-part pointer reference
138      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
139   */
140   const OctetString * get3GPPCGAddress(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
141     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_CG_Address)->getOctetString());
142   }
143
144   /**
145      Avp 3GPP-Rat-Type data-part pointer reference
146      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
147   */
148   const OctetString * get3GPPRatType(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
149     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_Rat_Type)->getOctetString());
150   }
151
152   /**
153      Avp Nokia-IMS-Media-Component-Id data-part pointer reference
154      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
155   */
156   const Unsigned32 * getNokiaIMSMediaComponentId(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
157     ASSERT_APP_GETAVP(return getAvp(helpers::nokia::AVPID__Nokia_IMS_Media_Component_Id)->getUnsigned32());
158   }
159
160   /**
161      Avp Time-Of-Last-Usage data-part pointer reference
162      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
163   */
164   const Time * getTimeOfLastUsage(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
165     ASSERT_APP_GETAVP(return getAvp(helpers::nokia::AVPID__Time_Of_Last_Usage)->getTime());
166   }
167
168   /**
169      Avp Time-Of-First-Usage data-part pointer reference
170      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
171   */
172   const Time * getTimeOfFirstUsage(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
173     ASSERT_APP_GETAVP(return getAvp(helpers::nokia::AVPID__Time_Of_First_Usage)->getTime());
174   }
175
176   /**
177      Avp Session-Start-Indicator data-part pointer reference
178      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
179   */
180   const OctetString * getSessionStartIndicator(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
181     ASSERT_APP_GETAVP(return getAvp(helpers::nokia::AVPID__Session_Start_Indicator)->getOctetString());
182   }
183
184   /**
185      Avp Rule-Base-Id data-part pointer reference
186      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
187   */
188   const UTF8String * getRuleBaseId(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
189     ASSERT_APP_GETAVP(return getAvp(helpers::nokia::AVPID__Rule_Base_Id)->getUTF8String());
190   }
191
192   /**
193      Avp 3GPP-GGSN-Address data-part pointer reference
194      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
195   */
196   const OctetString * get3GPPGGSNAddress(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
197     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_GGSN_Address)->getOctetString());
198   }
199
200   /**
201      Avp Nokia-Reporting-Reason data-part pointer reference
202      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
203   */
204   const Enumerated * getNOKIAReportingReason(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
205     ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control)->getAvp(helpers::nokia::AVPID__Nokia_Reporting_Reason)->getEnumerated());
206   }
207
208   /**
209      Avp 3GPP-Charging-Id data-part pointer reference
210      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
211   */
212   const Unsigned32 * get3GPPChargingId(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
213     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_Charging_Id)->getUnsigned32());
214   }
215
216   /**
217      Avp 3GPP_GPRS_Neg_QoS_Profile data-part pointer reference
218      @param emode Excepcion mode handling when avp is not found: Ignore (no action is taken but debug trace), Throw (exception launched, by default), Trace (trace warning).
219   */
220
221   const UTF8String * get3GPPGPRSNegQoSProfile(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
222     ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_GPRS_Neg_QoS_Profile)->getUTF8String());
223   }
224 };
225
226 }
227 }
228 }
229 }
230 }
231
232 #endif