Home > Support > Documentation

asn1BerCppTypes.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1997-2007 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00024 //
00025 // CHANGE LOG
00026 // Date         Init    Description
00027 // 07/14/02     ED      Changed all methods to being with lowercase 
00028 //                      char for consistency.  Added deprecated inline 
00029 //                      methods for those that did not to maintain 
00030 //                      backward compatibility.
00031 // 10/30/03     CZ      Added Doxygen code.
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 // ASN.1 BER message buffer class
00058 
00068 class EXTERNBER ASN1BERMessageBuffer : public ASN1MessageBuffer {
00069  protected:
00078    ASN1BERMessageBuffer (Type bufferType) : ASN1MessageBuffer(bufferType) {}
00079 
00080  public:
00096    inline int calcIndefLen (OSOCTET* buf_p, int bufSize = INT_MAX) {
00097       return xd_indeflen_ex (buf_p, bufSize);
00098    }
00099 
00110    inline void binDump () { 
00111       int stat = xu_dump ((OSOCTET*)getMsgPtr(), 0, 0); 
00112       if (stat != 0) setStatus (stat);
00113    }
00114 
00125    inline void hexDump (int numocts) { 
00126       rtxHexDump (getMsgPtr(), numocts); 
00127    }
00128 
00129    // deprecated methods
00130    inline int  CalcIndefLen (OSOCTET* buf_p) { return calcIndefLen(buf_p); }
00131    inline void BinDump () { binDump(); }
00132    inline void HexDump (int numocts) { hexDump (numocts); }
00133 } ;
00134 
00135 // ASN.1 BER encode message buffer class
00142 class EXTERNBER ASN1BEREncodeBuffer : public ASN1BERMessageBuffer {
00143  public:
00149    ASN1BEREncodeBuffer ();
00150 
00160    ASN1BEREncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00161 
00177    virtual OSOCTET* getMsgCopy ();
00178 
00189    virtual const OSOCTET* getMsgPtr ();
00190 
00208    int init ();
00209 
00219    virtual OSBOOL isA (int bufferType) {
00220       return bufferType == BEREncode;
00221    }
00222 
00240    int setBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00241 
00247    ASN1BEREncodeBuffer& operator << (ASN1CType& val); 
00248 } ;
00249 
00250 
00251 // ASN.1 BER decode message buffer class
00259 class EXTERNBER ASN1BERDecodeBuffer : public ASN1BERMessageBuffer {
00260  protected:
00261    const OSOCTET* mpMsgBuf;
00262    size_t mMsgBufLen;
00263    OSBOOL mBufSetFlag;
00264 
00265  public:
00270    ASN1BERDecodeBuffer ();
00271 
00288    ASN1BERDecodeBuffer (const OSOCTET* pMsgBuf, size_t msgBufLen);
00289 
00313    OSOCTET* findElement 
00314       (ASN1TAG tag, OSINT32& elemLen, OSBOOL firstFlag = TRUE);
00315 
00322    virtual const OSOCTET* getMsgPtr() {
00323       // Note: return message buffer pointer from object, not from context, 
00324       // because may not yet be set in context (ED, 9/30/04)..
00325       return mpMsgBuf;
00326    }
00327 
00335    int init ();
00336 
00346    virtual OSBOOL isA (int bufferType) {
00347       return bufferType == BERDecode;
00348    }
00368    inline int parseTagLen (ASN1TAG& tag, int& msglen) {
00369       mBufSetFlag = TRUE;
00370       return xd_setp (mpContext->getPtr(), 
00371                       mpMsgBuf, (int)mMsgBufLen, &tag, &msglen);
00372    }
00373 
00384    int readBinaryFile (const char* filePath);
00385 
00397    int setBuffer (const OSOCTET* pMsgBuf, size_t msgBufLen);
00398 
00399    // deprecated methods
00400    inline OSOCTET* FindElement (ASN1TAG tag, int& elemLen, 
00401                                   int firstFlag = 1) {
00402       return findElement (tag, elemLen, firstFlag);
00403    }
00404    inline int ParseTagLen (ASN1TAG& tag, int& msglen) {
00405       return parseTagLen (tag, msglen);
00406    }
00407 
00413    ASN1BERDecodeBuffer& operator >> (ASN1CType& val); 
00414 } ;
00415 
00423 #endif