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:
00113 inline int calcIndefLen (OSOCTET* buf_p, OSSIZE bufSize, OSSIZE* pSize) {
00114 return xd_indeflen64 (buf_p, bufSize, pSize);
00115 }
00116
00134 inline int calcIndefLen (OSOCTET* buf_p, int bufSize = INT_MAX) {
00135 return xd_indeflen_ex (buf_p, bufSize);
00136 }
00137
00148 inline void binDump () {
00149 int stat = xu_dump ((OSOCTET*)getMsgPtr(), 0, 0);
00150 if (stat != 0) setStatus (stat);
00151 }
00152
00163 inline void hexDump (OSSIZE numocts) {
00164 rtxHexDump (getMsgPtr(), numocts);
00165 }
00166
00167
00168 inline int CalcIndefLen (OSOCTET* buf_p) { return calcIndefLen(buf_p); }
00169 inline void BinDump () { binDump(); }
00170 inline void HexDump (OSSIZE numocts) { hexDump (numocts); }
00171 } ;
00172
00173
00180 class EXTERNBER ASN1BEREncodeBuffer : public ASN1BERMessageBuffer {
00181 public:
00187 ASN1BEREncodeBuffer ();
00188
00198 ASN1BEREncodeBuffer (OSOCTET* pMsgBuf, OSSIZE msgBufLen);
00199
00211 ASN1BEREncodeBuffer
00212 (OSOCTET* pMsgBuf, OSSIZE msgBufLen, OSRTContext* pContext);
00213
00218 inline void freeBuffer() { xe_free (getCtxtPtr()); }
00219
00235 virtual OSOCTET* getMsgCopy ();
00236
00247 virtual const OSOCTET* getMsgPtr ();
00248
00266 int init ();
00267
00277 virtual OSBOOL isA (Type bufferType) {
00278 return bufferType == BEREncode;
00279 }
00280
00298 int setBuffer (OSOCTET* pMsgBuf, OSSIZE msgBufLen);
00299
00305 ASN1BEREncodeBuffer& operator << (ASN1CType& val);
00306 } ;
00307
00308
00309
00317 class EXTERNBER ASN1BERDecodeBuffer : public ASN1BERMessageBuffer {
00318 protected:
00319 const OSOCTET* mpMsgBuf;
00320 OSSIZE mMsgBufLen;
00321 OSBOOL mBufSetFlag;
00322
00323 public:
00328 ASN1BERDecodeBuffer ();
00329
00346 ASN1BERDecodeBuffer (const OSOCTET* pMsgBuf, OSSIZE msgBufLen);
00347
00365 ASN1BERDecodeBuffer
00366 (const OSOCTET* pMsgBuf, OSSIZE msgBufLen, OSRTContext* pContext);
00367
00390 OSOCTET* findElement
00391 (ASN1TAG tag, OSINT32& elemLen, OSBOOL firstFlag = TRUE);
00392
00399 virtual const OSOCTET* getMsgPtr() {
00400
00401
00402 return mpMsgBuf;
00403 }
00404
00412 int init ();
00413
00423 virtual OSBOOL isA (Type bufferType) {
00424 return bufferType == BERDecode;
00425 }
00426
00446 inline int parseTagLen (ASN1TAG& tag, int& msglen) {
00447 mBufSetFlag = TRUE;
00448 return xd_setp (getCtxtPtr(),
00449 mpMsgBuf, (int)mMsgBufLen, &tag, &msglen);
00450 }
00451
00477 inline int parseTagLen (ASN1TAG& tag, OSSIZE& msglen, OSBOOL* pIndefLen) {
00478 mBufSetFlag = TRUE;
00479 return xd_setp64
00480 (getCtxtPtr(), mpMsgBuf, mMsgBufLen, &tag, &msglen, pIndefLen);
00481 }
00482
00493 int readBinaryFile (const char* filePath);
00494
00506 int setBuffer (const OSOCTET* pMsgBuf, OSSIZE msgBufLen);
00507
00508
00509 inline OSOCTET* FindElement (ASN1TAG tag, int& elemLen,
00510 int firstFlag = 1) {
00511 return findElement (tag, elemLen, (OSBOOL)firstFlag);
00512 }
00513 inline int ParseTagLen (ASN1TAG& tag, int& msglen) {
00514 return parseTagLen (tag, msglen);
00515 }
00516
00522 ASN1BERDecodeBuffer& operator >> (ASN1CType& val);
00523 } ;
00524
00532 #endif