00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "Message.h"
00019
00020 using namespace CODEX_APSS;
00021
00022 InitMsg::InitMsg() :
00023 Message( false )
00024 {
00025 }
00026
00027 InitMsg::InitMsg( const CODEX_ASN1::Integer& version,
00028 const CODEX_ASN1::Integer& coordinator,
00029 const LabelType& label ) :
00030 Message( true ),
00031 m_version( version ),
00032 m_coordinator( coordinator ),
00033 m_label( label )
00034 {
00035 }
00036
00037 InitMsg::InitMsg( const InitMsg& aOther ) :
00038 Message( aOther.m_initialized ),
00039 m_version( aOther.m_version ),
00040 m_coordinator( aOther.m_coordinator ),
00041 m_label( aOther.m_label )
00042 {
00043 }
00044
00045 void
00046 InitMsg::operator=( const InitMsg& aOther )
00047 {
00048 m_initialized = aOther.m_initialized;
00049 m_version = aOther.m_version;
00050 m_coordinator = aOther.m_coordinator;
00051 m_label = aOther.m_label;
00052 }
00053
00054 int
00055 InitMsg::marshal( unsigned char ** pp ) const
00056 {
00057 int r=0;
00058 int ret=0;
00059 unsigned char * p;
00060
00061 ret += m_version.marshal(0);
00062 ret += m_coordinator.marshal(0);
00063 ret += m_label.marshal(0);
00064 M_ASN1_I2D_seq_total();
00065 m_version.marshal(&p);
00066 m_coordinator.marshal(&p);
00067 m_label.marshal(&p);
00068 M_ASN1_I2D_finish();
00069 }
00070
00071 void*
00072 InitMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00073 {
00074 if ( m_initialized )
00075 {
00076 return NULL;
00077 }
00078 if ( (NULL == pp) || (NULL == *pp) )
00079 {
00080 return NULL;
00081 }
00082 ASN1_CTX c;
00083 c.pp = pp;
00084 c.q = *pp;
00085 c.error = ERR_R_NESTED_ASN1_ERROR;
00086 int i;
00087
00088 M_ASN1_D2I_Init();
00089 M_ASN1_D2I_start_sequence();
00090 M_ASN1_D2I_get(i, m_version.unmarshal);
00091 M_ASN1_D2I_get(i, m_coordinator.unmarshal);
00092 M_ASN1_D2I_get(i, m_label.unmarshal);
00093 if ( !asn1_Finish(&c) )
00094 {
00095 return NULL;
00096 }
00097 *pp=c.p;
00098 m_initialized = true;
00099 return this;
00100 err:
00101 return NULL;
00102 }