00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef __PANA_MESSAGES_H__
00035 #define __PANA_MESSAGES_H__
00036
00037 #include <list>
00038 #include "ace/Basic_Types.h"
00039 #include "ace/Message_Block.h"
00040 #include "pana_defs.h"
00041 #include "pana_exports.h"
00042 #include "pana_device_id.h"
00043 #include "diameter_parser_api.h"
00044
00045 #if _MSC_VER > 1000
00046 #pragma once
00047 #endif // _MSC_VER > 1000
00048
00049 #define PANA_DICT_PROTOCOL_ID 1
00050
00055 typedef struct {
00056 AAA_UINT8 type;
00057 diameter_octetstring_t value;
00058 } PANA_TVData_t;
00059
00063 #define PANA_MACGEN_HMACSHA1 1
00064 #define PANA_MACGEN_HMACSIZE 20
00065
00066
00067 #define AAA_AVP_DEVICEID_TYPE (AAA_AVP_CUSTOM_TYPE+1)
00068 #define AAA_AVP_MAC_TYPE (AAA_AVP_CUSTOM_TYPE+2)
00069
00070 typedef AAATypeSpecificAvpContainerEntry<PANA_TVData_t> AAATVDataAvpContainerEntry;
00071
00075 class PANA_TVDataParser : public AvpValueParser
00076 {
00077 public:
00081 void parseRawToApp() throw(AAAErrorStatus) {
00082 AAAMessageBlock* aBuffer = (AAAMessageBlock*)getRawData();
00083 AAAAvpContainerEntry* e = (AAAAvpContainerEntry*)getAppData();
00084 PANA_TVData_t &tve = reinterpret_cast<AAATVDataAvpContainerEntry*>(e)->dataRef();
00085 tve.type = *((AAA_UINT8*)aBuffer->base());
00086 tve.value.assign(aBuffer->base() + 1, aBuffer->size() - 1);
00087 }
00088
00092 void parseAppToRaw() throw(AAAErrorStatus) {
00093 AAAMessageBlock* aBuffer = (AAAMessageBlock*)getRawData();
00094 AAAAvpContainerEntry* e = (AAAAvpContainerEntry*)getAppData();
00095 PANA_TVData_t &tve = reinterpret_cast<AAATVDataAvpContainerEntry*>(e)->dataRef();
00096 AAAErrorStatus st;
00097 if (aBuffer->size() - (size_t)aBuffer->wr_ptr() < (tve.value.size() + sizeof(AAA_UINT8))) {
00098 st.set(NORMAL, DIAMETER_OUT_OF_SPACE);
00099 throw st;
00100 }
00101 *((AAA_UINT8*)aBuffer->wr_ptr()) = tve.type;
00102 aBuffer->wr_ptr(sizeof(AAA_UINT8));
00103 aBuffer->copy(tve.value.data(), tve.value.size());
00104 }
00105 };
00106
00110 class PANA_EXPORT PANA_MsgHeader
00111 {
00112 public:
00116 typedef struct {
00117 UCHAR request : 1;
00118 UCHAR reserved1 : 3;
00119 UCHAR separate : 1;
00120 UCHAR reserved2 : 3;
00121 } Flags;
00122
00126 typedef enum {
00127 HeaderLength = 16
00128 };
00129
00130 public:
00134 PANA_MsgHeader();
00135
00139 virtual ~PANA_MsgHeader() { }
00140
00144 inline UCHAR version() { return version_; }
00145
00151 inline void version(UCHAR ver) { version_ = ver; }
00152
00156 inline ACE_UINT32 length() { return length_; }
00157
00163 inline void length(ACE_UINT32 len) { length_ = len; }
00164
00168 inline PANA_MsgHeader::Flags &flags() { return flags_; }
00169
00175 inline void flags(PANA_MsgHeader::Flags flg) { flags_ = flg; }
00176
00180 inline ACE_UINT32 type() { return type_; }
00181
00185 inline void type(ACE_UINT32 typ) { type_ = typ; }
00186
00190 inline ACE_UINT32 tseq() { return tseq_; }
00191
00197 inline void tseq(ACE_UINT32 seq) { tseq_ = seq; }
00198
00202 inline ACE_UINT32 rseq() { return rseq_; }
00203
00209 inline void rseq(ACE_UINT32 seq) { rseq_ = seq; }
00210
00214 inline AAADictionaryHandle *getDictHandle() { return dictHandle_; }
00215
00219 inline void setDictHandle(AAADictionaryHandle *handle) { dictHandle_ = handle; }
00220
00221 protected:
00222
00223 UCHAR version_;
00225 ACE_UINT32 length_:24;
00227 PANA_MsgHeader::Flags flags_;
00229 ACE_UINT32 type_:24;
00231 ACE_UINT32 tseq_;
00233 ACE_UINT32 rseq_;
00235 AAADictionaryHandle* dictHandle_;
00236 };
00237
00238
00239
00240
00241
00242 typedef AAAParser<AAAMessageBlock*,
00243 PANA_MsgHeader*,
00244 AAADictionaryOption*> PANA_HeaderParser;
00245
00246
00247
00248
00249 class PANA_EXPORT PANA_Message : public PANA_MsgHeader
00250 {
00251 public:
00255 PANA_Message();
00256
00260 virtual ~PANA_Message();
00261
00265 AAAAvpContainerList &avpList() { return avpList_; }
00266
00270 PANA_DeviceIdContainer &srcDevices() { return srcDevices_; }
00271
00275 ACE_UINT32 &srcPort() { return srcPort_; }
00276
00280 void srcPort(ACE_UINT32 port) { srcPort_ = port; }
00281
00282 protected:
00283
00284 AAAAvpContainerList avpList_;
00285
00286 PANA_DeviceIdContainer srcDevices_;
00287
00288 ACE_UINT32 srcPort_;
00289 };
00290
00294 typedef PayloadParser PANA_PayloadParser;
00295
00296 #endif