Updated license
[anna.git] / include / anna / diameter / app / base / 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_base_Message_hpp
38 #define anna_diameter_app_base_Message_hpp
39
40
41 // Local
42 #include <anna/diameter/codec/Message.hpp>
43 #include <anna/diameter/app/defines.hpp>
44
45 // AVPID's
46 #include <anna/diameter/helpers/base/defines.hpp>
47 #include <anna/diameter/helpers/radius/defines.hpp>
48
49 #include <anna/core/RuntimeException.hpp>
50
51
52
53 //------------------------------------------------------------------------------
54 //---------------------------------------------------------------------- #define
55 //------------------------------------------------------------------------------
56
57
58
59 namespace anna {
60
61 namespace diameter {
62
63 namespace codec {
64 using namespace basetypes;
65 }
66
67 namespace app {
68
69 namespace base {
70
71
72 /**
73 * Diameter base message
74 */
75 class Message : public anna::diameter::codec::Message {
76
77 public:
78
79   /**
80      Avp Session-Id 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 UTF8String * getSessionId(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
84     ASSERT_APP_GETAVP(return getAvp(helpers::base::AVPID__Session_Id)->getUTF8String());
85   }
86
87   /**
88      Avp Destination-Host data-part pointer reference
89      @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).
90   */
91   const DiameterIdentity * getDestinationHost(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
92     ASSERT_APP_GETAVP(return getAvp(helpers::base::AVPID__Destination_Host)->getDiameterIdentity());
93   }
94
95   /**
96      Avp Destination-Realm data-part pointer reference
97      @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).
98   */
99   const DiameterIdentity * getDestinationRealm(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
100     ASSERT_APP_GETAVP(return getAvp(helpers::base::AVPID__Destination_Realm)->getDiameterIdentity());
101   }
102
103   /**
104      Avp User-Name data-part pointer reference
105      @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).
106   */
107   const UTF8String * getUserName(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
108     ASSERT_APP_GETAVP(return getAvp(helpers::radius::AVPID__User_Name)->getUTF8String());
109   }
110
111   /**
112      Avp Termination-Cause data-part pointer reference
113      @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).
114   */
115   const Enumerated * getTerminationCause(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
116     ASSERT_APP_GETAVP(return getAvp(helpers::base::AVPID__Termination_Cause)->getEnumerated());
117   }
118
119   /**
120      Avp Auth-Application-Id data-part pointer reference
121      @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).
122   */
123   const Unsigned32 * getAuthApplicationId(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
124     ASSERT_APP_GETAVP(return getAvp(helpers::base::AVPID__Auth_Application_Id)->getUnsigned32());
125   }
126
127   /**
128      Avp Event-Timestamp data-part pointer reference
129      @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).
130   */
131   const Time * getEventTimestamp(anna::Exception::Mode::_v emode = anna::Exception::Mode::Throw) throw(anna::RuntimeException) {
132     ASSERT_APP_GETAVP(return getAvp(helpers::radius::AVPID__Event_Timestamp)->getTime());
133   }
134 };
135
136 }
137 }
138 }
139 }
140
141 #endif