Home > Support > Documentation

asn1BerCppTypes.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1997-2009 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 
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    // deprecated methods
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 // ASN.1 BER encode message buffer class
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 // ASN.1 BER decode message buffer class
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       // Note: return message buffer pointer from object, not from context, 
00352       // because may not yet be set in context (ED, 9/30/04)..
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    // deprecated methods
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