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 "asn1CppTypes.h"
00043 #include "asn1ber.h"
00044
00055
00056
00066 class EXTERNBER ASN1BERMessageBuffer : public ASN1MessageBuffer {
00067 protected:
00076 ASN1BERMessageBuffer (Type bufferType) : ASN1MessageBuffer(bufferType) {}
00077
00078 public:
00094 inline int calcIndefLen (ASN1OCTET* buf_p, int bufSize = INT_MAX) {
00095 return xd_indeflen_ex (buf_p, bufSize);
00096 }
00097
00108 inline void binDump () {
00109 int stat = xu_dump ((ASN1OCTET*)getMsgPtr(), 0, 0);
00110 if (stat != ASN_OK) setStatus (stat);
00111 }
00112
00123 inline void hexDump (int numocts) {
00124 xu_hex_dump ((ASN1OCTET*)getMsgPtr(), numocts, TRUE);
00125 }
00126
00127
00128 inline int CalcIndefLen (ASN1OCTET* buf_p) { return calcIndefLen(buf_p); }
00129 inline void BinDump () { binDump(); }
00130 inline void HexDump (int numocts) { hexDump (numocts); }
00131 } ;
00132
00133
00140 class EXTERNBER ASN1BEREncodeBuffer : public ASN1BERMessageBuffer {
00141 public:
00149 ASN1BEREncodeBuffer ();
00160 ASN1BEREncodeBuffer (ASN1OCTET* pMsgBuf, size_t msgBufLen);
00161
00177 virtual ASN1OCTET* getMsgCopy ();
00178
00189 virtual const ASN1OCTET* getMsgPtr ();
00190
00208 int init ();
00209
00219 virtual ASN1BOOL isA (Type bufferType) {
00220 return bufferType == BEREncode;
00221 }
00222
00240 int setBuffer (ASN1OCTET* pMsgBuf, size_t msgBufLen);
00241
00247 ASN1BEREncodeBuffer& operator << (ASN1CType& val);
00248 } ;
00249
00250
00251
00259 class EXTERNBER ASN1BERDecodeBuffer : public ASN1BERMessageBuffer {
00260 protected:
00261 const ASN1OCTET* mpMsgBuf;
00262 size_t mMsgBufLen;
00263 ASN1BOOL mBufSetFlag;
00264
00265 public:
00270 ASN1BERDecodeBuffer ();
00271
00288 ASN1BERDecodeBuffer (const ASN1OCTET* pMsgBuf, size_t msgBufLen);
00289
00313 ASN1OCTET* findElement (ASN1TAG tag, int& elemLen, int firstFlag = 1);
00314
00321 virtual const ASN1OCTET* getMsgPtr() {
00322
00323
00324 return mpMsgBuf;
00325 }
00326
00334 int init ();
00335
00345 virtual ASN1BOOL isA (Type bufferType) {
00346 return bufferType == BERDecode;
00347 }
00367 inline int parseTagLen (ASN1TAG& tag, int& msglen) {
00368 mBufSetFlag = TRUE;
00369 return xd_setp (mpContext->getPtr(),
00370 mpMsgBuf, (int)mMsgBufLen, &tag, &msglen);
00371 }
00372
00383 int readBinaryFile (const char* filePath);
00384
00396 int setBuffer (const ASN1OCTET* pMsgBuf, size_t msgBufLen);
00397
00398
00399 inline ASN1OCTET* FindElement (ASN1TAG tag, int& elemLen,
00400 int firstFlag = 1) {
00401 return findElement (tag, elemLen, firstFlag);
00402 }
00403 inline int ParseTagLen (ASN1TAG& tag, int& msglen) {
00404 return parseTagLen (tag, msglen);
00405 }
00406
00412 ASN1BERDecodeBuffer& operator >> (ASN1CType& val);
00413 } ;
00414
00422 #endif