asn1BerCppTypes.h
Go to the documentation of this file.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 (OSOCTET* pMsgBuf, size_t msgBufLen,
00188 OSRTContext *pContext);
00189
00205 virtual OSOCTET* getMsgCopy ();
00206
00217 virtual const OSOCTET* getMsgPtr ();
00218
00236 int init ();
00237
00247 virtual OSBOOL isA (int bufferType) {
00248 return bufferType == BEREncode;
00249 }
00250
00268 int setBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00269
00275 ASN1BEREncodeBuffer& operator << (ASN1CType& val);
00276 } ;
00277
00278
00279
00287 class EXTERNBER ASN1BERDecodeBuffer : public ASN1BERMessageBuffer {
00288 protected:
00289 const OSOCTET* mpMsgBuf;
00290 size_t mMsgBufLen;
00291 OSBOOL mBufSetFlag;
00292
00293 public:
00298 ASN1BERDecodeBuffer ();
00299
00316 ASN1BERDecodeBuffer (const OSOCTET* pMsgBuf, size_t msgBufLen);
00317
00341 OSOCTET* findElement
00342 (ASN1TAG tag, OSINT32& elemLen, OSBOOL firstFlag = TRUE);
00343
00350 virtual const OSOCTET* getMsgPtr() {
00351
00352
00353 return mpMsgBuf;
00354 }
00355
00363 int init ();
00364
00374 virtual OSBOOL isA (int bufferType) {
00375 return bufferType == BERDecode;
00376 }
00396 inline int parseTagLen (ASN1TAG& tag, int& msglen) {
00397 mBufSetFlag = TRUE;
00398 return xd_setp (mpContext->getPtr(),
00399 mpMsgBuf, (int)mMsgBufLen, &tag, &msglen);
00400 }
00401
00412 int readBinaryFile (const char* filePath);
00413
00425 int setBuffer (const OSOCTET* pMsgBuf, size_t msgBufLen);
00426
00427
00428 inline OSOCTET* FindElement (ASN1TAG tag, int& elemLen,
00429 int firstFlag = 1) {
00430 return findElement (tag, elemLen, firstFlag);
00431 }
00432 inline int ParseTagLen (ASN1TAG& tag, int& msglen) {
00433 return parseTagLen (tag, msglen);
00434 }
00435
00441 ASN1BERDecodeBuffer& operator >> (ASN1CType& val);
00442 } ;
00443
00451 #endif