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 #define ASN1TRY try
00060 #define ASN1RTLTHROW(stat) exit (-1)
00061 #define ASN1THROW(ex) exit (-1)
00062 #define ASN1CATCH(exType,ex,body) if (0) { body; }
00063
00093 class EXTRTCLASS ASN1MessageBuffer : public OSRTMessageBuffer
00094 {
00095 protected:
00096
00104 EXTRTMETHOD ASN1MessageBuffer (Type bufferType);
00105
00114 EXTRTMETHOD ASN1MessageBuffer (Type bufferType, OSRTContext* pContext);
00115
00121 virtual int setStatus (int stat) {
00122 getContext()->setStatus (stat);
00123 return stat;
00124 }
00125
00126 public:
00131 virtual ~ASN1MessageBuffer () {}
00132
00141 virtual void addEventHandler (Asn1NamedEventHandler* pEventHandler) {
00142 Asn1NamedEventHandler::addEventHandler
00143 (getCtxtPtr(), pEventHandler);
00144 }
00145
00146 #ifndef __SYMBIAN32__
00147
00158 virtual ASN1BMPString* CStringToBMPString
00159 (const char* cstring, ASN1BMPString* pBMPString,
00160 Asn116BitCharSet* pCharSet = 0);
00161 #endif
00162
00166 virtual void* getAppInfo () { return 0; }
00167
00178 virtual EXTRTMETHOD int initBuffer (OSRTMEMBUF& membuf);
00179
00190 virtual EXTRTMETHOD int initBuffer (OSUNICHAR* unistr);
00191
00202 using OSRTMessageBuffer::initBuffer;
00203 virtual int initBuffer (const OSUTF8CHAR* ) { return RTERR_NOTSUPP; }
00204
00217 virtual OSBOOL isA (Type ) { return FALSE; }
00218
00226 virtual void removeEventHandler (Asn1NamedEventHandler* pEventHandler) {
00227 Asn1NamedEventHandler::removeEventHandler
00228 (getCtxtPtr(), pEventHandler);
00229 }
00230
00235 virtual void resetErrorInfo () {
00236 OSRTMessageBuffer::resetErrorInfo ();
00237 }
00238
00242 virtual void setAppInfo (void* ) { }
00243
00251 virtual void setErrorHandler (Asn1ErrorHandler* pErrorHandler) {
00252 Asn1ErrorHandler::setErrorHandler
00253 (getCtxtPtr(), pErrorHandler);
00254 }
00255
00266 EXTRTMETHOD int setRunTimeKey (const OSOCTET* key, OSSIZE keylen);
00267
00268
00269
00270
00271 inline OSOCTET* GetMsgCopy () { return getMsgCopy(); }
00272 inline const OSOCTET* GetMsgPtr() { return getMsgPtr(); }
00273 inline void PrintErrorInfo() { printErrorInfo(); }
00274
00275 } ;
00291 class EXTRTCLASS ASN1CType {
00292 protected:
00299 OSRTCtxtPtr mpContext;
00300
00305 OSRTMessageBufferIF* mpMsgBuf;
00306
00311 EXTRTMETHOD ASN1CType ();
00312
00319 EXTRTMETHOD ASN1CType (OSRTContext& ctxt);
00320
00321 EXTRTMETHOD int setMsgBuf
00322 (OSRTMessageBufferIF& msgBuf, OSBOOL initBuf=FALSE);
00323
00334 EXTRTMETHOD int setRunTimeKey (const OSOCTET* key, OSSIZE keylen);
00335
00336 public:
00346 EXTRTMETHOD ASN1CType (OSRTMessageBufferIF& msgBuf);
00347
00355 EXTRTMETHOD ASN1CType (const ASN1CType& orig);
00356
00361 virtual ~ASN1CType () {}
00362
00371 inline void append (OSRTDList& llist, void* pdata) {
00372 if (0 == rtxDListAppend (getCtxtPtr(), &llist, pdata))
00373 LOG_RTERR (getCtxtPtr(), RTERR_NOMEM);
00374 }
00375
00382 inline OSRTCtxtPtr getContext () {
00383 return mpContext;
00384 }
00385
00390 inline OSCTXT* getCtxtPtr () {
00391 return (!mpContext.isNull ()) ? mpContext->getPtr() : 0;
00392 }
00393
00410 char* getErrorText (char* textbuf = (char*)0, OSSIZE bufsize = 0);
00411
00425 inline int getStatus () const {
00426 return (!mpContext.isNull()) ? mpContext->getStatus() : 0;
00427 }
00428
00439 inline void* memAlloc (OSSIZE numocts) {
00440 if (mpContext.isNull ()) return 0;
00441 return mpContext->memAlloc (numocts);
00442 }
00443
00450 inline void memFreeAll () {
00451 if (!mpContext.isNull ())
00452 mpContext->memFreeAll ();
00453 }
00454
00464 inline void* memRealloc (void* ptr, OSSIZE numocts) {
00465 if (mpContext.isNull ()) return 0;
00466 return mpContext->memRealloc (ptr, numocts);
00467 }
00468
00474 inline void memReset () {
00475 if (!mpContext.isNull ())
00476 mpContext->memReset ();
00477 }
00478
00487 inline void memFreePtr (void* ptr) {
00488 if (!mpContext.isNull ())
00489 mpContext->memFreePtr (ptr);
00490 }
00491
00496 inline void printErrorInfo () {
00497 if (!mpContext.isNull ())
00498 mpContext->printErrorInfo ();
00499 }
00500
00505 inline void resetError () {
00506 if (!mpContext.isNull ())
00507 mpContext->resetErrorInfo ();
00508 }
00509
00516 inline OSBOOL setDiag (OSBOOL value) {
00517 return getContext()->setDiag (value);
00518 }
00519
00528 virtual EXTRTMETHOD int Encode ();
00529
00538 virtual EXTRTMETHOD int Decode ();
00539
00550 virtual int EncodeTo (OSRTMessageBufferIF& )
00551 { return ASN_E_NOTPDU; }
00552
00563 virtual int DecodeFrom (OSRTMessageBufferIF& )
00564 { return ASN_E_NOTPDU; }
00565 } ;
00579 struct EXTRTCLASS ASN1TDynBitStr : public ASN1DynBitStr {
00583 ASN1TDynBitStr () { data = 0; numbits = 0; }
00584
00592 ASN1TDynBitStr (OSUINT32 _numbits, const OSOCTET* _data) {
00593 numbits = _numbits;
00594 data = _data;
00595 }
00596
00603 ASN1TDynBitStr (ASN1DynBitStr& _bs) {
00604 numbits = _bs.numbits;
00605 data = _bs.data;
00606 }
00607 } ;
00608
00613 struct EXTRTCLASS ASN1TBitStr32 : public ASN1BitStr32 {
00617 ASN1TBitStr32 () { numbits = 0; }
00618
00626 ASN1TBitStr32 (OSUINT32 _numbits, const OSOCTET* _data) {
00627 numbits = _numbits;
00628 OSCRTLMEMCPY (data, _data, sizeof(data));
00629 }
00630
00637 ASN1TBitStr32 (ASN1BitStr32& _bs) {
00638 numbits = _bs.numbits;
00639 OSCRTLMEMCPY (data, _bs.data, sizeof(data));
00640 }
00641 } ;
00642
00643
00644 #include "rtsrc/ASN1TOctStr.h"
00645
00650 struct EXTRTCLASS ASN1TBMPString : public ASN1BMPString {
00654 inline ASN1TBMPString () {
00655 nchars = 0;
00656 data = 0;
00657 }
00658 } ;
00659
00664 struct EXTRTCLASS ASN1TUniversalString : public ASN1UniversalString {
00668 inline ASN1TUniversalString () {
00669 nchars = 0;
00670 data = 0;
00671 }
00672 } ;
00673
00678 struct EXTRTCLASS ASN1TOpenType : public ASN1OpenType {
00682 inline ASN1TOpenType () {
00683 numocts = 0;
00684 data = 0;
00685 }
00686 } ;
00687
00693 struct EXTRTCLASS Asn1TObject : public Asn1Object {
00697 inline Asn1TObject () {
00698 encoded.numocts = 0;
00699 encoded.data = 0;
00700 decoded = 0;
00701 index =0;
00702 }
00703 } ;
00704
00705 typedef Asn1TObject ASN1TObject;
00706
00707
00708 #include "rtsrc/ASN1TObjId.h"
00709
00715 struct EXTRTCLASS ASN1TObjId64 : public ASN1OID64 {
00716 inline ASN1TObjId64 () { numids = 0; }
00717 EXTRTMETHOD ASN1TObjId64 (OSOCTET _numids, const OSINT64* _subids);
00718 EXTRTMETHOD ASN1TObjId64 (const ASN1OID64& oid);
00719 EXTRTMETHOD ASN1TObjId64 (const ASN1TObjId64& oid);
00720 EXTRTMETHOD void operator= (const ASN1OID64& rhs);
00721 EXTRTMETHOD void operator= (const ASN1TObjId64& rhs);
00722 } ;
00723
00728 struct EXTRTCLASS ASN1TSeqExt : public OSRTDList {
00732 inline ASN1TSeqExt () {
00733 rtxDListInit (this);
00734 }
00735 } ;
00736
00742 struct EXTRTCLASS ASN1TPDU {
00743 protected:
00750 OSRTCtxtPtr mpContext;
00751
00752 public:
00770 inline void setContext (OSRTContext* ctxt) {
00771 if (mpContext.isNull()) mpContext = ctxt;
00772 else if (ctxt == 0) mpContext = 0;
00773 }
00774 } ;
00775
00780 struct EXTRTCLASS ASN1TSeqOfList : public OSRTDList {
00784 inline ASN1TSeqOfList () {
00785 rtxDListInit (this);
00786 }
00787 } ;
00788
00794 struct EXTRTCLASS ASN1TPDUSeqOfList : public ASN1TSeqOfList, public ASN1TPDU {
00798 ASN1TPDUSeqOfList () {}
00799 } ;
00800
00805 #endif