c358446e16d6f3ad6412b19108b39b5711daaa5a
[anna.git] / include / anna / diameter / helpers / base / functions.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_diameter_helpers_base_functions_hpp
10 #define anna_diameter_helpers_base_functions_hpp
11
12
13 // Local
14 #include <anna/diameter/defines.hpp>
15 #include <anna/config/defines.hpp>
16
17 #include <anna/core/RuntimeException.hpp>
18
19 // STL
20 #include <string>
21
22 //------------------------------------------------------------------------------
23 //---------------------------------------------------------------------- #define
24 //------------------------------------------------------------------------------
25
26 namespace anna {
27 class DataBlock;
28 }
29
30
31 namespace anna {
32
33 namespace diameter {
34
35 namespace helpers {
36
37 namespace base {
38
39
40 struct functions {
41
42   // getters & helpers
43
44   /**
45   * Gets the first level command Result-Code from datablock provided
46   *
47   * @param db Provided Message DataBlock
48   *
49   * @return Result-Code value
50   */
51   static U32 getResultCode(const anna::DataBlock &) throw(anna::RuntimeException);
52
53   /**
54   * Gets the tokenized by ';' Session-Id contents defined as '<DiameterIdentity>;<high 32 bits>;<low 32 bits>[;<optional value>]':
55   *
56   * @param sessionId Provided UTF8String Session-Id content
57   * @param diameterIdentity Sender Diameter Identity
58   * @param high High 64-bit-sequence part
59   * @param low Low 64-bit-sequence part
60   * @param optional Empty string when missing
61   */
62   static void decodeSessionId(const std::string &sessionId, std::string &diameterIdentity, U32 &high, U32 &low, std::string &optional) throw(anna::RuntimeException);
63
64   /**
65   * Gets the fixed Session-Id AVP (UTF8String) from datablock provided.
66   * Also gets the tokenized by ';' Session-Id contents defined as '<DiameterIdentity>;<high 32 bits>;<low 32 bits>[;<optional value>]':
67   *
68   * @param db Provided Message DataBlock
69   * @param diameterIdentity Sender Diameter Identity
70   * @param high High 64-bit-sequence part
71   * @param low Low 64-bit-sequence part
72   * @param optional Empty string when missing
73   *
74   * @return Session-Id
75   */
76   static std::string getSessionId(const anna::DataBlock &db, std::string &diameterIdentity, U32 &high, U32 &low, std::string &optional) throw(anna::RuntimeException);
77
78
79   /**
80   * Gets the fixed Session-Id AVP (UTF8String) from datablock provided.
81   *
82   * @param db Provided Message DataBlock
83   *
84   * @return Session-Id
85   */
86   static std::string getSessionId(const anna::DataBlock &db) throw(anna::RuntimeException) {
87     std::string dummy1, dummy4;
88     U32 dummy2, dummy3;
89     return (getSessionId(db, dummy1, dummy2, dummy3, dummy4));
90   }
91 };
92
93
94 }
95 }
96 }
97 }
98
99
100 #endif
101