Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

EstablishMsg.cc

00001 /*
00002  * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved.
00003  * This software is released under the modified BSD license.
00004  * See the file LICENSE in the top-level directory for details.
00005  */
00006 //
00007 // $Id: EstablishMsg.cc,v 1.3 2004/05/19 15:56:23 mmarsh Exp $
00008 //
00009 // $Log: EstablishMsg.cc,v $
00010 // Revision 1.3  2004/05/19 15:56:23  mmarsh
00011 // Added copyright and license statements.
00012 //
00013 // Revision 1.2  2003/11/04 22:31:45  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #include "Message.h"
00019 
00020 using namespace CODEX_APSS;
00021 
00022 EstablishMsg::EstablishMsg() :
00023    Message( false )
00024 {
00025 }
00026 
00027 EstablishMsg::EstablishMsg( const CODEX_ASN1::Integer& version,
00028                             const SublabelType& sublabel,
00029                             const CODEX_ASN1::Integer& establisher,
00030                             const CODEX_ASN1::Integer& recipient,
00031                             const ShareType& shares ) :
00032    Message( true ),
00033    m_version( version ),
00034    m_sublabel( sublabel ),
00035    m_establisher( establisher ),
00036    m_recipient( recipient ),
00037    m_shares( shares )
00038 {
00039 }
00040 
00041 EstablishMsg::EstablishMsg( const EstablishMsg& aOther ) :
00042    Message( aOther.m_initialized ),
00043    m_version( aOther.m_version ),
00044    m_sublabel( aOther.m_sublabel ),
00045    m_establisher( aOther.m_establisher ),
00046    m_recipient( aOther.m_recipient ),
00047    m_shares( aOther.m_shares )
00048 {
00049 }
00050 
00051 void
00052 EstablishMsg::operator=( const EstablishMsg& aOther )
00053 {
00054    m_initialized = aOther.m_initialized;
00055    m_version = aOther.m_version;
00056    m_sublabel = aOther.m_sublabel;
00057    m_establisher = aOther.m_establisher;
00058    m_recipient = aOther.m_recipient;
00059    m_shares = aOther.m_shares;
00060 }
00061 
00062 int
00063 EstablishMsg::marshal( unsigned char ** pp ) const
00064 {
00065    int r=0;
00066    int ret=0;
00067    unsigned char * p;
00068 
00069    ret += m_version.marshal(0);
00070    ret += m_sublabel.marshal(0);
00071    ret += m_establisher.marshal(0);
00072    ret += m_recipient.marshal(0);
00073    ret += m_shares.marshal(0);
00074    M_ASN1_I2D_seq_total();
00075    m_version.marshal(&p);
00076    m_sublabel.marshal(&p);
00077    m_establisher.marshal(&p);
00078    m_recipient.marshal(&p);
00079    m_shares.marshal(&p);
00080    M_ASN1_I2D_finish();
00081 }
00082 
00083 void*
00084 EstablishMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00085 {
00086    if ( m_initialized )
00087    {
00088       return NULL;
00089    }
00090    if ( (NULL == pp) || (NULL == *pp) )
00091    {
00092       return NULL;
00093    }
00094    ASN1_CTX c;
00095    c.pp = pp;
00096    c.q = *pp;
00097    c.error = ERR_R_NESTED_ASN1_ERROR;
00098    int i;
00099 
00100    M_ASN1_D2I_Init();
00101    M_ASN1_D2I_start_sequence();
00102    M_ASN1_D2I_get(i, m_version.unmarshal);
00103    M_ASN1_D2I_get(i, m_sublabel.unmarshal);
00104    M_ASN1_D2I_get(i, m_establisher.unmarshal);
00105    M_ASN1_D2I_get(i, m_recipient.unmarshal);
00106    M_ASN1_D2I_get(i, m_shares.unmarshal);
00107    if ( !asn1_Finish(&c) )
00108    {
00109       return NULL;
00110    }
00111    *pp=c.p;
00112    m_initialized = true;
00113    return this;
00114   err: // needed by ASN.1 macros
00115    return NULL;
00116 }

Generated on Fri May 6 17:39:12 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1