📄 el_obj.c
字号:
EL_LeClassAttributeType *pLeCAttrib;
/*
** Valid tribble/combuf. Pull out the essential information.
*/
pIOI = CB_GetDataPtrComBuf( pTrrbl->pComBuf );
bIOIsize = pIOI->bIoiSize;
/*
** If there is anything remaining in the IOI, we have a problem.
*/
if ( bIOIsize != 0 )
{
return( CI_GRC_BAD_PATH );
}
/*
** Attempt to get a combuf big enough for the attribute data.
** Reply with an error if we fail.
** Connect the new combuf to the request tribble if we succeed.
*/
pComBuf = CB_TradeForBiggerClear( pTrrbl->pComBuf,
sizeof( CI_GoodReplyHeaderType ) +
sizeof( EL_LeClassAttributeType ) );
if ( pComBuf == NULL )
{
return( CI_GRC_NO_RESOURCE );
}
pTrrbl->pComBuf = pComBuf;
/*
** Fill in the class attribute data and prepend a reply header.
*/
CB_ExpandComBuf( pComBuf, sizeof( EL_LeClassAttributeType ) );
pLeCAttrib = CB_GetDataPtrComBuf( pComBuf );
pLeCAttrib->iLeRevision = UC_iTOiLeConst( EL_REVISION );
pLeCAttrib->iLeMaxInstance = UC_iTOiLeConst( 1 );
pLeCAttrib->iLeNumInstance = UC_iTOiLeConst( 1 );
return( CI_GRC_SUCCESS );
} /* end of el_ProcessGetAttrAllClass() */
/*---------------------------------------------------------------------------
** el_ProcessGetAttrAllInstance()
**---------------------------------------------------------------------------
*/
UINT16 el_ProcessGetAttrAllInstance( CD_PacketTrrblType *pTrrbl )
{
CB_ComBufType *pComBuf;
CI_IoiType *pIOI;
UINT8 bIOIsize;
EL_LeInstanceAttributeType *psLeInstaceAttr;
/*
** Valid tribble/combuf. Pull out the essential information.
*/
pIOI = CB_GetDataPtrComBuf( pTrrbl->pComBuf );
bIOIsize = pIOI->bIoiSize;
/*
** If there is anything remaining in the IOI, we have a problem.
*/
if ( bIOIsize != 0 )
{
return ( CI_GRC_BAD_PATH );
}
/*
** Attempt to get a combuf big enough for the attribute data.
*/
pComBuf = CB_TradeForBiggerClear( pTrrbl->pComBuf,
sizeof( CI_GoodReplyHeaderType ) +
sizeof( EL_LeInstanceAttributeType ) );
/*
** Reply with an error if we fail.
** Connect the new combuf to the request tribble if we succeed.
*/
if ( pComBuf == NULL )
{
return ( CI_GRC_NO_RESOURCE );
}
pTrrbl->pComBuf = pComBuf;
/*
** Make enough room in the combuf for the attributes.
*/
CB_ExpandComBuf( pComBuf, ( sizeof( EL_LeInstanceAttributeType ) ) );
psLeInstaceAttr = CB_GetDataPtrComBuf( pComBuf );
psLeInstaceAttr->lLeInterfaceSpeed = UC_lTOlLe( el_s.lInterfaceSpeed );
psLeInstaceAttr->lLeInterfaceFlags = UC_lTOlLe( el_s.lInterfaceFlags );
UC_CopyMem( &psLeInstaceAttr->achEnetAddr[0], &el_s.achEnetAddr[0], EL_MAC_ADDR_LENGTH );
return( CI_GRC_SUCCESS );
} /* end of el_ProcessGetAttrAllInstance() */
/*---------------------------------------------------------------------------
** el_ProcessGetAttrSingleClass()
**---------------------------------------------------------------------------
*/
UINT16 el_ProcessGetAttrSingleClass( CD_PacketTrrblType *pTrrbl )
{
CB_ComBufType *pComBuf;
UINT8 bSegType;
UINT16 iAttribute;
UINT16 iStatus;
LeUINT16 *piLeAttribute;
/*
** Find which attribute to get.
*/
iStatus = CI_ParseIoiSegment( pTrrbl->pComBuf, &bSegType, &iAttribute, TRUE );
if( iStatus != CI_GRC_SUCCESS )
{
return( iStatus );
}
if( bSegType != CI_LOGICAL_SEG_ATTRIBUTE )
{
return( CI_GRC_BAD_PATH );
}
/*
** Make sure we have enough room for the reply in the combuf.
** Reply with an error if we fail.
** Connect the new combuf to the request tribble if we succeed.
*/
pComBuf = CB_TradeForBiggerClear( pTrrbl->pComBuf,
sizeof( CI_GoodReplyHeaderType ) + sizeof( LeUINT16 ) );
if( pComBuf == NULL )
{
return( CI_GRC_NO_RESOURCE );
}
pTrrbl->pComBuf = pComBuf;
/*
** Copy the attribute into the combuf.
*/
switch( iAttribute )
{
case EL_CA_REVISION:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT16 ) );
piLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*piLeAttribute = UC_iTOiLeConst( EL_REVISION );
break;
case EL_CA_MAX_INSTANCE:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT16 ) );
piLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*piLeAttribute = UC_iTOiLeConst( 1 );
break;
case EL_CA_NUM_INSTANCES:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT16 ) );
piLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*piLeAttribute = UC_iTOiLeConst( 1 );
break;
default:
iStatus = CI_GRC_UNDEFINED_ATTR;
break;
}
return( iStatus );
} /* end of el_ProcessGetAttrSingleClass() */
/*---------------------------------------------------------------------------
** el_ProcessGetAttrSingleInstance()
**---------------------------------------------------------------------------
*/
UINT16 el_ProcessGetAttrSingleInstance( CD_PacketTrrblType *pTrrbl, UINT8 bService )
{
CB_ComBufType *pComBuf;
UINT8 bSegType;
UINT16 iAttribute;
UINT16 iStatus;
LeUINT32 *plLeAttribute;
UINT8 *pData;
/*
** Find which attribute to get.
*/
iStatus = CI_ParseIoiSegment( pTrrbl->pComBuf, &bSegType, &iAttribute, TRUE );
if( iStatus != CI_GRC_SUCCESS )
{
return( iStatus );
}
if( bSegType != CI_LOGICAL_SEG_ATTRIBUTE )
{
return( CI_GRC_BAD_PATH );
}
/*
** Only able to get-and-clear Interface and Media Counters
*/
if( ( bService == EL_SC_GET_AND_CLEAR ) &&
( ( iAttribute != EL_IA_INTERFACE_COUNTERS ) &&
( iAttribute != EL_IA_MEDIA_COUNTERS ) ) )
{
return( CI_GRC_ATTR_NOT_SETTABLE );
}
/*
** Make sure we have enough room for the reply in the combuf.
** Connect the new combuf to the request tribble if we succeed.
*/
pComBuf = CB_TradeForBiggerClear( pTrrbl->pComBuf,
sizeof( EL_LeInstanceAttributeType ) );
if( pComBuf == NULL )
{
return( CI_GRC_NO_RESOURCE );
}
pTrrbl->pComBuf = pComBuf;
/*
** Copy the attribute into the combuf.
*/
switch( iAttribute )
{
case EL_IA_INTERFACE_SPEED:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT32 ) );
plLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*plLeAttribute = UC_lTOlLe( el_s.lInterfaceSpeed );
break;
case EL_IA_INTERFACE_FLAGS:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT32 ) );
plLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*plLeAttribute = UC_lTOlLe( el_s.lInterfaceFlags );
break;
case EL_IA_PHYSICAL_ADDRESS:
CB_ExpandComBuf( pComBuf, EL_MAC_ADDR_LENGTH );
pData = CB_GetDataPtrComBuf( pComBuf );
UC_CopyMem( pData, &el_s.achEnetAddr[0], EL_MAC_ADDR_LENGTH );
break;
default:
iStatus = CI_GRC_UNDEFINED_ATTR;
break;
}
return( iStatus );
} /* end of el_ProcessGetAttrSingleInstance() */
/*---------------------------------------------------------------------------
** el_ProcessInstanceRequest()
**---------------------------------------------------------------------------
*/
void el_ProcessInstanceRequest( CD_PacketTrrblType *pTrrbl )
{
CI_IoiType *pIOI;
UINT8 bService;
UINT16 iStatus;
pIOI = CB_GetDataPtrComBuf( pTrrbl->pComBuf );
bService = pIOI->bService;
/*
** Obtain the current Ethernet Link data
*/
iStatus = eiu_GetEthernetLinkData();
/*
** Process per the service code.
*/
if( iStatus == CI_GRC_SUCCESS )
{
switch ( bService )
{
case CI_SC_GET_ATTR_ALL:
iStatus = el_ProcessGetAttrAllInstance( pTrrbl );
break;
case CI_SC_GET_ATTR_SINGLE:
case EL_SC_GET_AND_CLEAR:
iStatus = el_ProcessGetAttrSingleInstance( pTrrbl, bService );
break;
case CI_SC_SET_ATTR_SINGLE:
case CI_SC_SET_ATTR_ALL:
iStatus = CI_GRC_ATTR_NOT_SETTABLE;
break;
default:
/*
** Unsupported request code. Return a bad reply header only.
*/
iStatus = CI_GRC_BAD_SERVICE;
break;
}
}
/*
** For errors, clear the ComBuf. Always preprend the Header
*/
if( iStatus != CI_GRC_SUCCESS )
{
CB_ClearComBuf( pTrrbl->pComBuf );
}
CI_PrependReplyHeader( pTrrbl->pComBuf, bService, (UINT8)iStatus, 0 );
} /* end of el_ProcessInstanceRequest() */
#endif /* #ifdef ETHERNET_LINK_OBJECT */
/****************************************************************************
**
** End of EL_OBJ.C
**
*****************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -