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
00033
00034
00035
00036
00038
00043 #ifndef _ASN1CPPTYPES_H_
00044 #define _ASN1CPPTYPES_H_
00045
00046 #ifndef __SYMBIAN32__
00047 #include <new>
00048 #endif
00049
00050 #include "rtxsrc/rtxMemory.h"
00051 #include "rtxsrc/rtxDiag.h"
00052 #include "rtxsrc/rtxError.h"
00053 #include "rtxsrc/rtxMemBuf.h"
00054 #include "rtsrc/asn1CppEvtHndlr.h"
00055 #include "rtsrc/ASN1Context.h"
00056 #include "rtxsrc/OSRTMsgBuf.h"
00057
00058
00059
00061 #define ASN1TRY try
00062
00068 #define ASN1RTLTHROW(stat) exit (-1)
00069
00075 #define ASN1THROW(ex) exit (-1)
00076
00085 #define ASN1CATCH(exType,ex,body) if (0) { body; }
00086
00116 class EXTRTCLASS ASN1MessageBuffer : public OSRTMessageBuffer
00117 {
00118 protected:
00119
00127 EXTRTMETHOD ASN1MessageBuffer (Type bufferType);
00128
00137 EXTRTMETHOD ASN1MessageBuffer (Type bufferType, OSRTContext* pContext);
00138
00144 virtual int setStatus (int stat) {
00145 getContext()->setStatus (stat);
00146 return stat;
00147 }
00148
00149 public:
00154 virtual ~ASN1MessageBuffer () {}
00155
00164 virtual void addEventHandler (Asn1NamedEventHandler* pEventHandler) {
00165 Asn1NamedEventHandler::addEventHandler
00166 (getCtxtPtr(), pEventHandler);
00167 }
00168
00169 #ifndef __SYMBIAN32__
00170
00181 virtual ASN1BMPString* CStringToBMPString
00182 (const char* cstring, ASN1BMPString* pBMPString,
00183 Asn116BitCharSet* pCharSet = 0);
00184 #endif
00185
00189 virtual void* getAppInfo () { return 0; }
00190
00201 virtual EXTRTMETHOD int initBuffer (OSRTMEMBUF& membuf);
00202
00213 virtual EXTRTMETHOD int initBuffer (OSUNICHAR* unistr);
00214
00225 using OSRTMessageBuffer::initBuffer;
00226 virtual int initBuffer (const OSUTF8CHAR* ) { return RTERR_NOTSUPP; }
00227
00240 virtual OSBOOL isA (Type ) { return FALSE; }
00241
00249 virtual void removeEventHandler (Asn1NamedEventHandler* pEventHandler) {
00250 Asn1NamedEventHandler::removeEventHandler
00251 (getCtxtPtr(), pEventHandler);
00252 }
00253
00258 virtual void resetErrorInfo () {
00259 OSRTMessageBuffer::resetErrorInfo ();
00260 }
00261
00265 virtual void setAppInfo (void* ) { }
00266
00274 virtual void setErrorHandler (Asn1ErrorHandler* pErrorHandler) {
00275 Asn1ErrorHandler::setErrorHandler
00276 (getCtxtPtr(), pErrorHandler);
00277 }
00278
00289 EXTRTMETHOD int setRunTimeKey (const OSOCTET* key, OSSIZE keylen);
00290
00291
00292
00293
00294 inline OSOCTET* GetMsgCopy () { return getMsgCopy(); }
00295 inline const OSOCTET* GetMsgPtr() { return getMsgPtr(); }
00296 inline void PrintErrorInfo() { printErrorInfo(); }
00297
00298 } ;
00314 class EXTRTCLASS ASN1CType {
00315 protected:
00322 OSRTCtxtPtr mpContext;
00323
00328 OSRTMessageBufferIF* mpMsgBuf;
00329
00334 EXTRTMETHOD ASN1CType ();
00335
00342 EXTRTMETHOD ASN1CType (OSRTContext& ctxt);
00343
00344 EXTRTMETHOD int setMsgBuf
00345 (OSRTMessageBufferIF& msgBuf, OSBOOL initBuf=FALSE);
00346
00357 EXTRTMETHOD int setRunTimeKey (const OSOCTET* key, OSSIZE keylen);
00358
00359 public:
00369 EXTRTMETHOD ASN1CType (OSRTMessageBufferIF& msgBuf);
00370
00378 EXTRTMETHOD ASN1CType (const ASN1CType& orig);
00379
00384 virtual ~ASN1CType () {}
00385
00394 inline void append (OSRTDList& llist, void* pdata) {
00395 if (0 == rtxDListAppend (getCtxtPtr(), &llist, pdata))
00396 LOG_RTERR (getCtxtPtr(), RTERR_NOMEM);
00397 }
00398
00405 inline OSRTCtxtPtr getContext () {
00406 return mpContext;
00407 }
00408
00413 inline OSCTXT* getCtxtPtr () {
00414 return (!mpContext.isNull ()) ? mpContext->getPtr() : 0;
00415 }
00416
00433 char* getErrorText (char* textbuf = (char*)0, OSSIZE bufsize = 0);
00434
00448 inline int getStatus () const {
00449 return (!mpContext.isNull()) ? mpContext->getStatus() : 0;
00450 }
00451
00462 inline void* memAlloc (OSSIZE numocts) {
00463 if (mpContext.isNull ()) return 0;
00464 return mpContext->memAlloc (numocts);
00465 }
00466
00478 inline void* memAllocZ (OSSIZE numocts) {
00479 if (mpContext.isNull ()) return 0;
00480 return mpContext->memAllocZ (numocts);
00481 }
00482
00489 inline void memFreeAll () {
00490 if (!mpContext.isNull ())
00491 mpContext->memFreeAll ();
00492 }
00493
00503 inline void* memRealloc (void* ptr, OSSIZE numocts) {
00504 if (mpContext.isNull ()) return 0;
00505 return mpContext->memRealloc (ptr, numocts);
00506 }
00507
00513 inline void memReset () {
00514 if (!mpContext.isNull ())
00515 mpContext->memReset ();
00516 }
00517
00526 inline void memFreePtr (void* ptr) {
00527 if (!mpContext.isNull ())
00528 mpContext->memFreePtr (ptr);
00529 }
00530
00535 inline void printErrorInfo () {
00536 if (!mpContext.isNull ())
00537 mpContext->printErrorInfo ();
00538 }
00539
00544 inline void resetError () {
00545 if (!mpContext.isNull ())
00546 mpContext->resetErrorInfo ();
00547 }
00548
00555 inline OSBOOL setDiag (OSBOOL value) {
00556 return getContext()->setDiag (value);
00557 }
00558
00567 virtual EXTRTMETHOD int Encode ();
00568
00580 virtual EXTRTMETHOD int Decode (OSBOOL free = FALSE);
00581
00592 virtual int EncodeTo (OSRTMessageBufferIF& )
00593 { return ASN_E_NOTPDU; }
00594
00608 virtual int DecodeFrom (OSRTMessageBufferIF& , OSBOOL free = TRUE)
00609 { return ASN_E_NOTPDU; }
00610 } ;
00624 struct EXTRTCLASS ASN1TDynBitStr : public ASN1DynBitStr {
00628 ASN1TDynBitStr () { data = 0; numbits = 0; }
00629
00637 ASN1TDynBitStr (OSUINT32 _numbits, const OSOCTET* _data) {
00638 numbits = _numbits;
00639 data = _data;
00640 }
00641
00648 ASN1TDynBitStr (ASN1DynBitStr& _bs) {
00649 numbits = _bs.numbits;
00650 data = _bs.data;
00651 }
00652 } ;
00653
00658 struct EXTRTCLASS ASN1TBitStr32 : public ASN1BitStr32 {
00662 ASN1TBitStr32 () { numbits = 0; }
00663
00671 ASN1TBitStr32 (OSUINT32 _numbits, const OSOCTET* _data) {
00672 numbits = _numbits;
00673 OSCRTLMEMCPY (data, _data, sizeof(data));
00674 }
00675
00682 ASN1TBitStr32 (ASN1BitStr32& _bs) {
00683 numbits = _bs.numbits;
00684 OSCRTLMEMCPY (data, _bs.data, sizeof(data));
00685 }
00686 } ;
00687
00688
00689 #include "rtsrc/ASN1TOctStr.h"
00690
00695 struct EXTRTCLASS ASN1TBMPString : public ASN1BMPString {
00699 inline ASN1TBMPString () {
00700 nchars = 0;
00701 data = 0;
00702 }
00703 } ;
00704
00709 struct EXTRTCLASS ASN1TUniversalString : public ASN1UniversalString {
00713 inline ASN1TUniversalString () {
00714 nchars = 0;
00715 data = 0;
00716 }
00717 } ;
00718
00723 struct EXTRTCLASS ASN1TOpenType : public ASN1OpenType {
00727 inline ASN1TOpenType () {
00728 numocts = 0;
00729 data = 0;
00730 }
00731 } ;
00732
00738 struct EXTRTCLASS Asn1TObject : public Asn1Object {
00742 inline Asn1TObject () {
00743 encoded.numocts = 0;
00744 encoded.data = 0;
00745 decoded = 0;
00746 index =0;
00747 }
00748 } ;
00749
00750 typedef Asn1TObject ASN1TObject;
00751
00752
00753 #include "rtsrc/ASN1TObjId.h"
00754
00760 struct EXTRTCLASS ASN1TObjId64 : public ASN1OID64 {
00764 inline ASN1TObjId64 () { numids = 0; }
00765
00773 EXTRTMETHOD ASN1TObjId64 (OSOCTET _numids, const OSINT64* _subids);
00774
00780 EXTRTMETHOD ASN1TObjId64 (const ASN1OID64& oid);
00781
00787 EXTRTMETHOD ASN1TObjId64 (const ASN1TObjId64& oid);
00788
00794 EXTRTMETHOD void operator= (const ASN1OID64& rhs);
00795
00801 EXTRTMETHOD void operator= (const ASN1TObjId64& rhs);
00802 } ;
00803
00808 struct EXTRTCLASS ASN1TSeqExt : public OSRTDList {
00812 inline ASN1TSeqExt () {
00813 rtxDListInit (this);
00814 }
00815 } ;
00816
00822 struct EXTRTCLASS ASN1TPDU {
00823 protected:
00830 OSRTCtxtPtr mpContext;
00831
00832 public:
00850 inline void setContext (OSRTContext* ctxt) {
00851 if (mpContext.isNull()) mpContext = ctxt;
00852 else if (ctxt == 0) mpContext = 0;
00853 }
00854 } ;
00855
00860 struct EXTRTCLASS ASN1TSeqOfList : public OSRTDList {
00864 inline ASN1TSeqOfList () {
00865 rtxDListInit (this);
00866 }
00867 } ;
00868
00874 struct EXTRTCLASS ASN1TPDUSeqOfList : public ASN1TSeqOfList, public ASN1TPDU {
00878 ASN1TPDUSeqOfList () {}
00879 } ;
00880
00885 #endif