📄 ei_obj.c
字号:
case CI_SC_GET_ATTR_SINGLE:
iStatus = ei_ProcessGetAttrSingleClass( pTrrbl );
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 ei_ProcessClassRequest() */
/*---------------------------------------------------------------------------
** ei_ProcessGetAttrAllClass()
**---------------------------------------------------------------------------
*/
UINT16 ei_ProcessGetAttrAllClass( CD_PacketTrrblType *pTrrbl )
{
CB_ComBufType *pComBuf;
CI_IoiType *pIOI;
UINT8 bIOIsize;
EI_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( EI_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( EI_LeClassAttributeType ) );
pLeCAttrib = CB_GetDataPtrComBuf( pComBuf );
pLeCAttrib->iLeRevision = UC_iTOiLeConst( EI_REVISION );
pLeCAttrib->iLeMaxInstance = UC_iTOiLeConst( 1 );
pLeCAttrib->iLeNumInstance = UC_iTOiLeConst( 1 );
return( CI_GRC_SUCCESS );
} /* end of ei_ProcessGetAttrAllClass() */
/*---------------------------------------------------------------------------
** ei_ProcessGetAttrAllInstance()
**---------------------------------------------------------------------------
*/
UINT16 ei_ProcessGetAttrAllInstance( CD_PacketTrrblType *pTrrbl )
{
CB_ComBufType *pComBuf;
CI_IoiType *pIOI;
UINT8 bIOIsize;
EI_LeInstanceAttributeType *psLeInstaceAttr;
UINT16 iVariableLength;
LeUINT16 iLeNameSize;
UINT8 bPad = 0;
/*
** 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.
** Include the size of the variable portion, and the size of
** the "fixed" portion of the structure. Include the pad bytes
** for odd name sizes as needed.
*/
iVariableLength = ei_s.sInterfaceConfig.iDomainNameSize +
ei_s.iHostNameSize +
sizeof(ei_s.iHostNameSize);
iVariableLength += ( ei_s.sInterfaceConfig.iDomainNameSize & 1 ) ? 1 : 0;
iVariableLength += ( ei_s.iHostNameSize & 1 ) ? 1 : 0;
pComBuf = CB_TradeForBiggerClear( pTrrbl->pComBuf,
sizeof( CI_GoodReplyHeaderType ) +
sizeof( EI_LeInstanceAttributeType ) +
iVariableLength );
/*
** 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;
/*
** Since variable length strings are at the end of this data, first need to
** prepend this data (Host Size & Host Name). Pad w/ zero to even number
** of characters, but don't include the pad in the size field.
*/
if( ei_s.iHostNameSize & 1 )
{
CB_PrependComBuf( pComBuf, &bPad, 1 );
}
CB_PrependComBuf( pComBuf, &ei_s.achHostName[0], ei_s.iHostNameSize );
iLeNameSize = UC_iTOiLe( ei_s.iHostNameSize );
CB_PrependComBuf( pComBuf, &iLeNameSize, sizeof( iLeNameSize ) );
/*
** Now prepend the rest of the interface config attributes including the variable length
** domain name.
*/
ei_GetInterfaceConfigAttribute( pComBuf );
/*
** Make enough room in the combuf for the "fixed" length Status, Capability,
** Control, and Link path attributes. Get these four attributes.
*/
CB_ExpandComBuf( pComBuf, ( sizeof( EI_LeInstanceAttributeType ) -
sizeof( EI_LeInterfaceConfig ) ) );
psLeInstaceAttr = CB_GetDataPtrComBuf( pComBuf );
psLeInstaceAttr->lLeInterfaceStatus = UC_lTOlLe( ei_s.lInterfaceStatus );
psLeInstaceAttr->lLeConfigCapability = UC_lTOlLe( ei_s.lConfigCapability );
psLeInstaceAttr->lLeConfigControl = UC_lTOlLe( ei_s.lConfigControl );
psLeInstaceAttr->iLeLinkObjPathSize = UC_iTOiLe( ei_s.iLinkObjPathSize );
UC_CopyMem( &psLeInstaceAttr->achLinkObjPath[0],
&ei_s.achLinkObjPath[0],
EIU_LINK_PATH_LENGTH );
return( CI_GRC_SUCCESS );
} /* end of ei_ProcessGetAttrAllInstance() */
/*---------------------------------------------------------------------------
** ei_ProcessGetAttrSingleClass()
**---------------------------------------------------------------------------
*/
UINT16 ei_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 EI_CA_REVISION:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT16 ) );
piLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*piLeAttribute = UC_iTOiLeConst( EI_REVISION );
break;
case EI_CA_MAX_INSTANCE:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT16 ) );
piLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*piLeAttribute = UC_iTOiLeConst( 1 );
break;
case EI_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 ei_ProcessGetAttrSingleClass() */
/*---------------------------------------------------------------------------
** ei_ProcessGetAttrSingleInstance()
**---------------------------------------------------------------------------
*/
UINT16 ei_ProcessGetAttrSingleInstance( CD_PacketTrrblType *pTrrbl )
{
CB_ComBufType *pComBuf;
UINT8 bSegType;
UINT16 iAttribute;
UINT16 iStatus;
UINT16 iPadByte;
LeUINT32 *plLeAttribute;
LeUINT16 *piLeAttribute;
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 );
}
/*
** Make sure we have enough room for the reply in the combuf.
** Rather than check for each individual attribute,
** just figure a worst case of the entire record.
** 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( EI_LeInstanceAttributeType ) +
EI_MAX_DOMAIN_LENGTH +
EI_MAX_HOST_LENGTH );
if( pComBuf == NULL )
{
return( CI_GRC_NO_RESOURCE );
}
pTrrbl->pComBuf = pComBuf;
/*
** Copy the attribute into the combuf.
*/
switch( iAttribute )
{
case EI_IA_INTERFACE_STATUS:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT32 ) );
plLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*plLeAttribute = UC_lTOlLe( ei_s.lInterfaceStatus );
break;
case EI_IA_CONFIG_CAPABILITY:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT32 ) );
plLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*plLeAttribute = UC_lTOlLe( ei_s.lConfigCapability );
break;
case EI_IA_CONFIG_CONTROL:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT32 ) );
plLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*plLeAttribute = UC_lTOlLe( ei_s.lConfigControl );
break;
case EI_IA_LINK_PATH:
CB_ExpandComBuf( pComBuf, sizeof( LeUINT16 ) + EIU_LINK_PATH_LENGTH );
piLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*piLeAttribute++ = UC_iTOiLe( ei_s.iLinkObjPathSize );
UC_CopyMem( piLeAttribute, &ei_s.achLinkObjPath[0], EIU_LINK_PATH_LENGTH );
break;
case EI_IA_INTERFACE_CONFIG:
ei_GetInterfaceConfigAttribute( pComBuf );
break;
case EI_IA_HOST_NAME:
/*
** Need to pad w/ a zero byte for odd Host name sizes.
** The pad byte is NOT included in the size field.
*/
iPadByte = ( ei_s.iHostNameSize & 1 ) ? 1 : 0;
CB_ExpandComBuf( pComBuf, sizeof( LeUINT16 ) + ei_s.iHostNameSize + iPadByte );
piLeAttribute = CB_GetDataPtrComBuf( pComBuf );
*piLeAttribute++ = UC_iTOiLe( ei_s.iHostNameSize );
pData = (UINT8 *)piLeAttribute;
UC_CopyMem( pData, &ei_s.achHostName[0], ei_s.iHostNameSize );
if( iPadByte )
{
pData += ei_s.iHostNameSize;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -