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

ComputeMsg.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: ComputeMsg.cc,v 1.3 2004/05/19 15:56:23 mmarsh Exp $
00008 //
00009 // $Log: ComputeMsg.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 ComputeMsg::ComputeMsg() :
00023    Message( false )
00024 {
00025 }
00026 
00027 ComputeMsg::ComputeMsg( const CODEX_ASN1::Integer& coordinator,
00028                         const SublabelType subshareLabels[ NumShares ] ) :
00029    Message( true ),
00030    m_coordinator( coordinator )
00031 {
00032    for ( unsigned int count = 0 ; count < NumShares ; ++count )
00033    {
00034       m_subshareLabels[count] = subshareLabels[count];
00035    }
00036 }
00037 
00038 ComputeMsg::ComputeMsg( const ComputeMsg& aOther ) :
00039    Message( aOther.m_initialized ),
00040    m_coordinator( aOther.m_coordinator )
00041 {
00042    for ( unsigned int count = 0 ; count < NumShares ; ++count )
00043    {
00044       m_subshareLabels[count] = aOther.m_subshareLabels[count];
00045    }
00046 }
00047 
00048 void
00049 ComputeMsg::operator=( const ComputeMsg& aOther )
00050 {
00051    m_initialized = aOther.m_initialized;
00052    m_coordinator = aOther.m_coordinator;
00053    for ( unsigned int count = 0 ; count < NumShares ; ++count )
00054    {
00055       m_subshareLabels[count] = aOther.m_subshareLabels[count];
00056    }
00057 }
00058 
00059 int
00060 ComputeMsg::marshal( unsigned char ** pp ) const
00061 {
00062    int r=0;
00063    int ret=0;
00064    unsigned char * p;
00065 
00066    ret += m_coordinator.marshal(0);
00067    for ( unsigned int count = 0 ; count < NumShares ; ++count )
00068    {
00069       ret += m_subshareLabels[count].marshal(0);
00070    }
00071    M_ASN1_I2D_seq_total();
00072    m_coordinator.marshal(&p);
00073    for ( unsigned int count = 0 ; count < NumShares ; ++count )
00074    {
00075       m_subshareLabels[count].marshal(&p);
00076    }
00077    M_ASN1_I2D_finish();
00078 }
00079 
00080 void*
00081 ComputeMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00082 {
00083    if ( m_initialized )
00084    {
00085       return NULL;
00086    }
00087    if ( (NULL == pp) || (NULL == *pp) )
00088    {
00089       return NULL;
00090    }
00091    ASN1_CTX c;
00092    c.pp = pp;
00093    c.q = *pp;
00094    c.error = ERR_R_NESTED_ASN1_ERROR;
00095    int i;
00096 
00097    M_ASN1_D2I_Init();
00098    M_ASN1_D2I_start_sequence();
00099    M_ASN1_D2I_get(i, m_coordinator.unmarshal);
00100    for ( unsigned int count = 0 ; count < NumShares ; ++count )
00101    {
00102       M_ASN1_D2I_get(i, m_subshareLabels[count].unmarshal);
00103    }
00104    if ( !asn1_Finish(&c) )
00105    {
00106       return NULL;
00107    }
00108    *pp=c.p;
00109    m_initialized = true;
00110    return this;
00111   err: // needed by ASN.1 macros
00112    return NULL;
00113 }

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