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 #include "rtxsrc/rtxMemory.h"
00047 #include "rtxsrc/rtxDiag.h"
00048 #include "rtxsrc/rtxError.h"
00049 #include "rtxsrc/rtxMemBuf.h"
00050 #include "rtsrc/asn1CppEvtHndlr.h"
00051 #include "rtsrc/ASN1Context.h"
00052 #include "rtxsrc/OSRTMsgBuf.h"
00053
00054
00055 #define ASN1TRY try
00056 #define ASN1RTLTHROW(stat) exit (-1)
00057 #define ASN1THROW(ex) exit (-1)
00058 #define ASN1CATCH(exType,ex,body) if (0) { body; }
00059
00089 class EXTRTCLASS ASN1MessageBuffer : public OSRTMessageBuffer
00090 {
00091 protected:
00092
00100 EXTRTMETHOD ASN1MessageBuffer (Type bufferType);
00101
00110 EXTRTMETHOD ASN1MessageBuffer (Type bufferType, OSRTContext* pContext);
00111
00117 virtual int setStatus (int stat) {
00118 mpContext->setStatus (stat);
00119 return stat;
00120 }
00121
00122 public:
00127 virtual ~ASN1MessageBuffer () {}
00128
00137 virtual void addEventHandler (Asn1NamedEventHandler* pEventHandler) {
00138 Asn1NamedEventHandler::addEventHandler
00139 (getCtxtPtr(), pEventHandler);
00140 }
00141
00142 #ifndef __SYMBIAN32__
00143
00154 virtual ASN1BMPString* CStringToBMPString
00155 (const char* cstring, ASN1BMPString* pBMPString,
00156 Asn116BitCharSet* pCharSet = 0);
00157 #endif
00158
00162 virtual void* getAppInfo () { return 0; }
00163
00174 virtual EXTRTMETHOD int initBuffer (OSRTMEMBUF& membuf);
00175
00186 virtual EXTRTMETHOD int initBuffer (OSUNICHAR* unistr);
00187
00198 virtual int initBuffer (const OSUTF8CHAR* ) { return RTERR_NOTSUPP; }
00199
00212 virtual OSBOOL isA (Type ) { return FALSE; }
00213
00221 virtual void removeEventHandler (Asn1NamedEventHandler* pEventHandler) {
00222 Asn1NamedEventHandler::removeEventHandler
00223 (getCtxtPtr(), pEventHandler);
00224 }
00225
00230 virtual void resetErrorInfo () {
00231 OSRTMessageBuffer::resetErrorInfo ();
00232 }
00233
00237 virtual void setAppInfo (void* ) { }
00238
00246 virtual void setErrorHandler (Asn1ErrorHandler* pErrorHandler) {
00247 Asn1ErrorHandler::setErrorHandler
00248 (getCtxtPtr(), pErrorHandler);
00249 }
00250
00261 EXTRTMETHOD int setRunTimeKey (const OSOCTET* key, size_t keylen);
00262
00263
00264
00265
00266 inline OSOCTET* GetMsgCopy () { return getMsgCopy(); }
00267 inline const OSOCTET* GetMsgPtr() { return getMsgPtr(); }
00268 inline void PrintErrorInfo() { printErrorInfo(); }
00269
00270 } ;
00286 class EXTRTCLASS ASN1CType {
00287 protected:
00294 OSRTCtxtPtr mpContext;
00295
00300 OSRTMessageBufferIF* mpMsgBuf;
00301
00306 EXTRTMETHOD ASN1CType ();
00307
00314 EXTRTMETHOD ASN1CType (OSRTContext& ctxt);
00315
00316 EXTRTMETHOD int setMsgBuf (OSRTMessageBufferIF& msgBuf, OSBOOL initBuf=FALSE);
00317
00328 EXTRTMETHOD int setRunTimeKey (const OSOCTET* key, size_t keylen);
00329
00330 public:
00340 EXTRTMETHOD ASN1CType (OSRTMessageBufferIF& msgBuf);
00341
00349 EXTRTMETHOD ASN1CType (const ASN1CType& orig);
00350
00355 virtual ~ASN1CType () {}
00356
00365 inline void append (OSRTDList& llist, void* pdata) {
00366 if (0 == rtxDListAppend (getCtxtPtr(), &llist, pdata))
00367 LOG_RTERR (getCtxtPtr(), RTERR_NOMEM);
00368 }
00369
00376 inline OSRTCtxtPtr getContext () {
00377 return mpContext;
00378 }
00379
00384 inline OSCTXT* getCtxtPtr () {
00385 return (!mpContext.isNull ()) ? mpContext->getPtr() : 0;
00386 }
00387
00401 inline int getStatus () const {
00402 return (!mpContext.isNull()) ? mpContext->getStatus() : 0;
00403 }
00404
00415 inline void* memAlloc (size_t numocts) {
00416 if (mpContext.isNull ()) return 0;
00417 return mpContext->memAlloc (numocts);
00418 }
00419
00426 inline void memFreeAll () {
00427 if (!mpContext.isNull ())
00428 mpContext->memFreeAll ();
00429 }
00430
00440 inline void* memRealloc (void* ptr, size_t numocts) {
00441 if (mpContext.isNull ()) return 0;
00442 return mpContext->memRealloc (ptr, numocts);
00443 }
00444
00450 inline void memReset () {
00451 if (!mpContext.isNull ())
00452 mpContext->memReset ();
00453 }
00454
00463 inline void memFreePtr (void* ptr) {
00464 if (!mpContext.isNull ())
00465 mpContext->memFreePtr (ptr);
00466 }
00467
00472 inline void printErrorInfo () {
00473 if (!mpContext.isNull ())
00474 mpContext->printErrorInfo ();
00475 }
00476
00481 inline void resetError () {
00482 if (!mpContext.isNull ())
00483 mpContext->resetErrorInfo ();
00484 }
00485
00492 inline OSBOOL setDiag (OSBOOL value) {
00493 return getContext()->setDiag (value);
00494 }
00495
00504 virtual EXTRTMETHOD int Encode ();
00505
00514 virtual EXTRTMETHOD int Decode ();
00515
00526 virtual int EncodeTo (OSRTMessageBufferIF& )
00527 { return ASN_E_NOTPDU; }
00528
00539 virtual int DecodeFrom (OSRTMessageBufferIF& )
00540 { return ASN_E_NOTPDU; }
00541 } ;
00555 struct EXTRTCLASS ASN1TDynBitStr : public ASN1DynBitStr {
00559 ASN1TDynBitStr () { numbits = 0; }
00560
00568 ASN1TDynBitStr (OSUINT32 _numbits, const OSOCTET* _data) {
00569 numbits = _numbits;
00570 data = _data;
00571 }
00572
00579 ASN1TDynBitStr (ASN1DynBitStr& _bs) {
00580 numbits = _bs.numbits;
00581 data = _bs.data;
00582 }
00583 } ;
00584
00589 struct EXTRTCLASS ASN1TBitStr32 : public ASN1BitStr32 {
00593 ASN1TBitStr32 () { numbits = 0; }
00594
00602 ASN1TBitStr32 (OSUINT32 _numbits, const OSOCTET* _data) {
00603 numbits = _numbits;
00604 OSCRTLMEMCPY (data, _data, sizeof(data));
00605 }
00606
00613 ASN1TBitStr32 (ASN1BitStr32& _bs) {
00614 numbits = _bs.numbits;
00615 OSCRTLMEMCPY (data, _bs.data, sizeof(data));
00616 }
00617 } ;
00618
00619
00620 #include "rtsrc/ASN1TOctStr.h"
00621
00626 struct EXTRTCLASS ASN1TBMPString : public ASN1BMPString {
00630 inline ASN1TBMPString () {
00631 nchars = 0;
00632 data = 0;
00633 }
00634 } ;
00635
00640 struct EXTRTCLASS ASN1TUniversalString : public ASN1UniversalString {
00644 inline ASN1TUniversalString () {
00645 nchars = 0;
00646 data = 0;
00647 }
00648 } ;
00649
00654 struct EXTRTCLASS ASN1TOpenType : public ASN1OpenType {
00658 inline ASN1TOpenType () {
00659 numocts = 0;
00660 data = 0;
00661 }
00662 } ;
00663
00669 struct EXTRTCLASS Asn1TObject : public Asn1Object {
00673 inline Asn1TObject () {
00674 encoded.numocts = 0;
00675 encoded.data = 0;
00676 decoded = 0;
00677 index =0;
00678 }
00679 } ;
00680
00681 typedef Asn1TObject ASN1TObject;
00682
00683
00684 #include "rtsrc/ASN1TObjId.h"
00685
00691 struct EXTRTCLASS ASN1TObjId64 : public ASN1OID64 {
00692 inline ASN1TObjId64 () { numids = 0; }
00693 EXTRTMETHOD ASN1TObjId64 (OSOCTET _numids, const OSINT64* _subids);
00694 EXTRTMETHOD ASN1TObjId64 (const ASN1OID64& oid);
00695 EXTRTMETHOD ASN1TObjId64 (const ASN1TObjId64& oid);
00696 EXTRTMETHOD void operator= (const ASN1OID64& rhs);
00697 EXTRTMETHOD void operator= (const ASN1TObjId64& rhs);
00698 } ;
00699
00704 struct EXTRTCLASS ASN1TSeqExt : public OSRTDList {
00708 inline ASN1TSeqExt () {
00709 rtxDListInit (this);
00710 }
00711 } ;
00712
00718 struct EXTRTCLASS ASN1TPDU {
00719 protected:
00726 OSRTCtxtPtr mpContext;
00727
00728 public:
00746 inline void setContext (OSRTContext* ctxt) {
00747 if (mpContext.isNull()) mpContext = ctxt;
00748 else if (ctxt == 0) mpContext = 0;
00749 }
00750 } ;
00751
00756 struct EXTRTCLASS ASN1TSeqOfList : public OSRTDList {
00760 inline ASN1TSeqOfList () {
00761 rtxDListInit (this);
00762 }
00763 } ;
00764
00770 struct EXTRTCLASS ASN1TPDUSeqOfList : public ASN1TSeqOfList, public ASN1TPDU {
00774 ASN1TPDUSeqOfList () {}
00775 } ;
00776
00781 #endif