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
00034
00039 #ifndef _ASN1BERCPPTYPES_H_
00040 #define _ASN1BERCPPTYPES_H_
00041
00042 #include "rtsrc/asn1CppTypes.h"
00043 #include "rtbersrc/asn1ber.h"
00044 #include "rtxsrc/rtxPrint.h"
00045
00057
00058
00068 class EXTERNBER ASN1BERMessageBuffer : public ASN1MessageBuffer {
00069 protected:
00078 ASN1BERMessageBuffer (Type bufferType) : ASN1MessageBuffer(bufferType) {}
00079
00091 ASN1BERMessageBuffer (Type bufferType, OSRTContext *pContext) :
00092 ASN1MessageBuffer (bufferType, pContext) { }
00093
00094 public:
00110 inline int calcIndefLen (OSOCTET* buf_p, int bufSize = INT_MAX) {
00111 return xd_indeflen_ex (buf_p, bufSize);
00112 }
00113
00124 inline void binDump () {
00125 int stat = xu_dump ((OSOCTET*)getMsgPtr(), 0, 0);
00126 if (stat != 0) setStatus (stat);
00127 }
00128
00139 inline void hexDump (int numocts) {
00140 rtxHexDump (getMsgPtr(), numocts);
00141 }
00142
00143
00144 inline int CalcIndefLen (OSOCTET* buf_p) { return calcIndefLen(buf_p); }
00145 inline void BinDump () { binDump(); }
00146 inline void HexDump (int numocts) { hexDump (numocts); }
00147 } ;
00148
00149
00156 class EXTERNBER ASN1BEREncodeBuffer : public ASN1BERMessageBuffer {
00157 public:
00163 ASN1BEREncodeBuffer ();
00164
00174 ASN1BEREncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00175
00187 ASN1BEREncodeBuffer
00188 (OSOCTET* pMsgBuf, size_t msgBufLen, OSRTContext* pContext);
00189
00194 inline void freeBuffer() { xe_free (getCtxtPtr()); }
00195
00211 virtual OSOCTET* getMsgCopy ();
00212
00223 virtual const OSOCTET* getMsgPtr ();
00224
00242 int init ();
00243
00253 virtual OSBOOL isA (Type bufferType) {
00254 return bufferType == BEREncode;
00255 }
00256
00274 int setBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00275
00281 ASN1BEREncodeBuffer& operator << (ASN1CType& val);
00282 } ;
00283
00284
00285
00293 class EXTERNBER ASN1BERDecodeBuffer : public ASN1BERMessageBuffer {
00294 protected:
00295 const OSOCTET* mpMsgBuf;
00296 size_t mMsgBufLen;
00297 OSBOOL mBufSetFlag;
00298
00299 public:
00304 ASN1BERDecodeBuffer ();
00305
00322 ASN1BERDecodeBuffer (const OSOCTET* pMsgBuf, size_t msgBufLen);
00323
00341 ASN1BERDecodeBuffer
00342 (const OSOCTET* pMsgBuf, size_t msgBufLen, OSRTContext* pContext);
00343
00366 OSOCTET* findElement
00367 (ASN1TAG tag, OSINT32& elemLen, OSBOOL firstFlag = TRUE);
00368
00375 virtual const OSOCTET* getMsgPtr() {
00376
00377
00378 return mpMsgBuf;
00379 }
00380
00388 int init ();
00389
00399 virtual OSBOOL isA (Type bufferType) {
00400 return bufferType == BERDecode;
00401 }
00421 inline int parseTagLen (ASN1TAG& tag, int& msglen) {
00422 mBufSetFlag = TRUE;
00423 return xd_setp (getCtxtPtr(),
00424 mpMsgBuf, (int)mMsgBufLen, &tag, &msglen);
00425 }
00426
00437 int readBinaryFile (const char* filePath);
00438
00450 int setBuffer (const OSOCTET* pMsgBuf, size_t msgBufLen);
00451
00452
00453 inline OSOCTET* FindElement (ASN1TAG tag, int& elemLen,
00454 int firstFlag = 1) {
00455 return findElement (tag, elemLen, (OSBOOL)firstFlag);
00456 }
00457 inline int ParseTagLen (ASN1TAG& tag, int& msglen) {
00458 return parseTagLen (tag, msglen);
00459 }
00460
00466 ASN1BERDecodeBuffer& operator >> (ASN1CType& val);
00467 } ;
00468
00476 #endif