Пример #1
0
static void
copy_i1( u_i1 *src, u_i1 *dst )
{
    STATUS status;
    CV2L_I1_MACRO( src, dst, &status );
    return;
}
Пример #2
0
static STATUS
read_cr_parms( GCD_RCB *rcb, u_i1 *size, u_i1 **msg_parms, u_i2 *msg_len )
{
    GCD_CCB		*ccb = rcb->ccb;
    DAM_TL_PARAM	param;
    STATUS		status;

    while( rcb->buf_len >= (CV_N_I1_SZ * 2) )
    {
	CV2L_I1_MACRO( rcb->buf_ptr, &param.param_id, &status );
	rcb->buf_ptr += CV_N_I1_SZ;
	rcb->buf_len -= CV_N_I1_SZ;

	CV2L_I1_MACRO( rcb->buf_ptr, &param.pl1, &status );
	rcb->buf_ptr += CV_N_I1_SZ;
	rcb->buf_len -= CV_N_I1_SZ;

	if ( param.pl1 < 255 )
	    param.pl2 = param.pl1;
	else  if ( rcb->buf_len >= CV_N_I2_SZ )
	{
	    CV2L_I2_MACRO( rcb->buf_ptr, &param.pl2, &status );
	    rcb->buf_ptr += CV_N_I2_SZ;
	    rcb->buf_len -= CV_N_I2_SZ;
	}
	else
	{
	    if ( GCD_global.gcd_trace_level >= 1 )
		TRdisplay( "%4d    GCD no CR param length: need %d, have %d\n",
			   ccb->id, CV_N_I2_SZ, rcb->buf_len );
			
	    return( E_GC480A_PROTOCOL_ERROR );
	}

	if ( param.pl2 > rcb->buf_len )
	{
	    if ( GCD_global.gcd_trace_level >= 1 )
		TRdisplay( "%4d    GCD no CR parameter: need %d, have %d\n",
			   ccb->id, param.pl2, rcb->buf_len );
	    return( E_GC480A_PROTOCOL_ERROR );
	}

	switch( param.param_id )
	{
	case DAM_TL_CP_PROTO :
	    if ( param.pl2 == CV_N_I1_SZ )
		CV2L_I1_MACRO( rcb->buf_ptr, &ccb->tl.proto_lvl, &status );
	    else
	    {
		if ( GCD_global.gcd_trace_level >= 1 )
		    TRdisplay( "%4d    GCD CR PROTO param length: %d\n",
			       ccb->id, param.pl2 );
		return( E_GC480A_PROTOCOL_ERROR );
	    }
	    break;

	case DAM_TL_CP_SIZE :
	    if ( param.pl2 == CV_N_I1_SZ )
		CV2L_I1_MACRO( rcb->buf_ptr, size, &status );
	    else
	    {
		if ( GCD_global.gcd_trace_level >= 1 )
		    TRdisplay( "%4d    GCD CR SIZE param length: %d\n",
			       ccb->id, param.pl2 );
		return( E_GC480A_PROTOCOL_ERROR );
	    }
	    break;

	case DAM_TL_CP_MSG_ID :
	    if ( param.pl2 != CV_N_I4_SZ )
	    {
		if ( GCD_global.gcd_trace_level >= 1 )
		    TRdisplay( "%4d    GCD CR MSG ID param length: %d\n",
			       ccb->id, param.pl2 );
		return( E_GC480A_PROTOCOL_ERROR );
	    }
	    else
	    {
		u_i4 tl_id;
		CV2L_I4_MACRO( rcb->buf_ptr, &tl_id, &status );

		if ( tl_id != DAM_TL_DMML_ID )
		{
		    if ( GCD_global.gcd_trace_level >= 1 )
			TRdisplay( "%4d    GCD CR invalid MSG ID : 0x%x\n",
				   ccb->id, tl_id );
		    return( E_GC480A_PROTOCOL_ERROR );
		}
	    }
	    break;

	case DAM_TL_CP_MSG :
	    *msg_parms = rcb->buf_ptr;
	    *msg_len = param.pl2;
	    break;

	default :
	    /*
	    ** We don't service this protocol above level 1,
	    ** so only trace this warning when appropriate.
	    */
	    if ( GCD_global.gcd_trace_level >= 1 )
		TRdisplay( "%4d    GCD unknown DMTL CR param ID: %d\n",
			   ccb->id, param.param_id );
	    break;
	}

	rcb->buf_ptr += param.pl2;
	rcb->buf_len -= param.pl2;
    }

    if ( rcb->buf_len > 0 )
    {
	if ( GCD_global.gcd_trace_level >= 1 )
	    TRdisplay( "%4d    GCD extra data with CR request: %d\n",
		       ccb->id, rcb->buf_len );
	return( E_GC480A_PROTOCOL_ERROR );
    }

    return( OK );
}