1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // http://redmine.teslayout.com/projects/anna-suite
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
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
17 // * Neither the name of the copyright holder 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.
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.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_diameter_app_dcca_Message_hpp
38 #define anna_diameter_app_dcca_Message_hpp
42 #include <anna/diameter/app/base/Message.hpp>
45 #include <anna/diameter/helpers/base/defines.hpp>
46 #include <anna/diameter/helpers/tgpp/defines.hpp>
47 #include <anna/diameter/helpers/dcca/defines.hpp>
49 #include <anna/core/RuntimeException.hpp>
55 //------------------------------------------------------------------------------
56 //---------------------------------------------------------------------- #define
57 //------------------------------------------------------------------------------
66 using namespace basetypes;
77 std::string qosProfile;
81 int MaximumBitrateForUplink;
82 int MaximumBitrateForDownlink;
85 void reset() throw() {
87 Release = TrafficClass = HandlingPriority = MaximumBitrateForUplink = MaximumBitrateForDownlink = 0;
96 * Diameter message for DCCA (diameter credit control application)
98 class Message : public anna::diameter::app::base::Message {
100 qosProfile_t a_qosProfile;
105 Avp Subscription-Id-Data data-part pointer reference.
107 @param Subscription-Id-Type value to filter the search. END_USER_E164 by default.
108 @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).
110 const UTF8String * getSubscriptionIdData(int subscriptionIdType = helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_E164, anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
112 const anna::diameter::codec::Avp * sid;
115 while(sid = getAvp(helpers::dcca::AVPID__Subscription_Id, pos++))
116 if(subscriptionIdType == sid->getAvp(helpers::dcca::AVPID__Subscription_Id_Type)->getEnumerated()->getValue())
117 return sid->getAvp(helpers::dcca::AVPID__Subscription_Id_Data)->getUTF8String();
123 Avp Multiple-Services-Credit-Control pointer reference
124 @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).
126 const anna::diameter::codec::Avp * getMultipleServicesCreditControl(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
127 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control));
131 Avp Service-Identifier data-part pointer reference
132 @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).
134 const Unsigned32 * getServiceIdentifier(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
135 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control)->getAvp(helpers::dcca::AVPID__Service_Identifier)->getUnsigned32());
139 Avp Rating-Group data-part pointer reference
140 @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).
142 const Unsigned32 * getRatingGroup(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
143 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control)->getAvp(helpers::dcca::AVPID__Rating_Group)->getUnsigned32());
147 Avp Tariff-Change-Usage data-part pointer reference
148 @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).
150 const Enumerated * getTariffChangeUsage(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
152 return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control)->
153 getAvp(helpers::dcca::AVPID__Used_Service_Unit)->
154 getAvp(helpers::dcca::AVPID__Tariff_Change_Usage)->getEnumerated();
159 Avp Validity-Time data-part pointer reference
160 @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).
162 const Unsigned32 * getValidityTime(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
163 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control)->getAvp(helpers::dcca::AVPID__Validity_Time)->getUnsigned32());
167 Avp Requested-Service-Unit pointer reference
168 @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).
170 const anna::diameter::codec::Avp * getRequestedServiceUnit(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
171 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control)->getAvp(helpers::dcca::AVPID__Requested_Service_Unit));
175 Avp n-th Used-Service-Unit pointer reference
176 @param ocurrence Select the n-th USU within the MSCC. First by default.
177 @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 const anna::diameter::codec::Avp * getUsedServiceUnit(int ocurrence = 1, anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
181 return getAvp(helpers::dcca::AVPID__Multiple_Services_Credit_Control)->
182 getAvp(helpers::dcca::AVPID__Used_Service_Unit, ocurrence);
187 Avp CC_Request_Type data-part pointer reference
188 @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).
190 const Enumerated * getCCRequestType(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
191 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__CC_Request_Type)->getEnumerated());
195 Avp CC_Request_Number data-part pointer reference
196 @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).
198 const Unsigned32 * getCCRequestNumber(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
199 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__CC_Request_Number)->getUnsigned32());
203 Avp Multiple-Services-Indicator data-part pointer reference
204 @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).
206 const Enumerated * getMultipleServicesIndicator(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
207 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Multiple_Services_Indicator)->getEnumerated());
211 Avp Service-Context-Id data-part pointer reference
212 @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).
214 const UTF8String * getServiceContextId(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
215 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__Service_Context_Id)->getUTF8String());
219 Avp 3GPP-NSAPI data-part pointer reference
220 @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).
222 const UTF8String * get3GPPNSAPI(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
223 ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_NSAPI)->getUTF8String());
227 Avp 3GPP-Selection-Mode data-part pointer reference
228 @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).
230 const UTF8String * get3GPPSelectionMode(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
231 ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_Selection_Mode)->getUTF8String());
235 Avp 3GPP-Session-Stop-Indicator data-part pointer reference
236 @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).
238 const OctetString * get3GPPSessionStopIndicator(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
239 ASSERT_APP_GETAVP(return getAvp(helpers::tgpp::AVPID__3GPP_Session_Stop_Indicator)->getOctetString());
243 Avp User-Equipment-Info pointer reference
244 @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).
246 const anna::diameter::codec::Avp * getUserEquipmentInfo(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
247 ASSERT_APP_GETAVP(return getAvp(helpers::dcca::AVPID__User_Equipment_Info));
251 Avp User-Equipment-Info-Value data-part pointer reference.
253 @param User-Equipment-Info-Type value to filter the search. IMEISV by default.
254 @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).
256 const OctetString * getUserEquipmentInfoValue(int userEquipmentInfoType = helpers::dcca::AVPVALUES__User_Equipment_Info_Type::IMEISV, anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
258 const anna::diameter::codec::Avp * uei;
261 while(uei = getAvp(helpers::dcca::AVPID__User_Equipment_Info, pos++))
262 if(userEquipmentInfoType == uei->getAvp(helpers::dcca::AVPID__User_Equipment_Info_Type)->getEnumerated()->getValue())
263 return uei->getAvp(helpers::dcca::AVPID__User_Equipment_Info_Value)->getOctetString();
268 // there has to be at least one out-of-line definition of a non-pure-virtual function (http://www.daniweb.com/software-development/cpp/threads/114299/undefined-reference-to-vtable-for-)
269 // Lo que dice es que las virtuales no puras de una clase deben tener al menos una definicion en el .cc (lo contrario de in-line). Parece una limitaciĆ³n del compilador.
270 // Podemos hacer una definicion por defecto (return NULL), o mejor, hacerla virtual pura (porque se necesitara por parte del decodificador de QoS):
271 virtual const UTF8String * get3GPPGPRSNegQoSProfile(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) = 0;
275 Decodes 3GPP-GPRS-Neg-QoS-Profile (as described in 3GPP TS 24.008)
277 @return 3GPP-GPRS-Neg-QoS-Profile decoded on struct
279 const qosProfile_t & decode3GPPGPRSNegQoSProfile() throw(anna::RuntimeException);
283 // static bool dameTiempoConsumido(const InfoDIAMETER & mensaje,long &tiempoConsumidoAntesConmutacion,long &tiempoConsumidoDespuesConmutacion,long &tiempoConsumidoSinConmutacion);
284 // static bool dameTiempoConsumido(const InfoDIAMETER & mensaje,long &tiempoConsumidoAntesConmutacion,long &tiempoConsumidoDespuesConmutacion,long &tiempoConsumidoSinConmutacion,bool &hayUSUantes, bool &hayUSUdespues);
286 // // nos devuelve el volumen que viene en el mensaje diameter (antes, despues de la conmutacion y el valor cuando no ha habido conmutacion)
287 // // Le pasamos el tipo volumen que queremos ( ambos,downlink,uplink)
288 // // en tipoVol, se indica de que AVP leemos las unidades ( Input_Octets, Output-Octets o TotalOctets )
289 // //static void dameVolumConsumido(const InfoDIAMETER & mensaje,int tipoVol,long &volAntesConmutacion,long &volDespuesConmutacion,long &volConsumidoSinConmutacion);
290 // // Devuelve FALSE si ha habido algun error
291 // static bool dameVolumConsumido(const InfoDIAMETER & mensaje,int tipoVol,long &volUpAntesConmutacion,long &volUpDespuesConmutacion,
292 // long &volDownAntesConmutacion,long &volDownDespuesConmutacion,long &volUp,long &volDown,bool &errorTariffChange);
293 // static bool dameVolumConsumido(const InfoDIAMETER & mensaje,int tipoVol,long &volUpAntesConmutacion,long &volUpDespuesConmutacion,
294 // long &volDownAntesConmutacion,long &volDownDespuesConmutacion,long &volUp,long &volDown,bool &errorTariffChange,
295 // bool &hayUSUantes, bool &hayUSUdespues);
298 // bool getConsumedTime(int &beforeSwitch, int &afterSwitch, int &withoutSwitch) const throw();
299 // bool getConsumedVolume(int volumeType, int &upBeforeSwitch, int &upAfterSwitch, int &downBeforeSwitch, int &downAfterSwitch, int &upWithoutSwitch, int &downWithoutSwitch, bool &tariffChangeError) const throw();