📄 elu_obj.c
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** ELU_OBJ.C
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** User provided routines for the Ethernet Link Object.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>----4<major> Customization: <none>----4<major>
**
*****************************************************************************
*****************************************************************************
** **
** ETHERNET/IP EXAMPLE CODE **
** COPYRIGHT (c) 2000-2005 ODVA (Open DeviceNet Vendor Association) **
** & ControlNet International Ltd. **
** **
** All rights reserved, except as specifically licensed in writing. **
** Use of the Ethernet/IP Example Protocol Software is subject to **
** ODVA's and ControlNet International's Terms of Use Agreement. **
** The following work constitutes example program code and is intended **
** merely to illustrate useful programming techniques. The user is **
** responsible for applying the code correctly. The code is provided **
** AS IS without warranty and is in no way guaranteed to be error-free. **
** **
*****************************************************************************
*****************************************************************************
*/
/****************************************************************************
*****************************************************************************
**
** Change Log
** ----------
**
**
*****************************************************************************
*****************************************************************************
*/
/*
** See if this object is to be included.
*/
#include "ab.h"
#ifdef ETHERNET_LINK_OBJECT
#include "cd.h" /* Communications Device public interfaces */
#include "mr.h" /* Message Router public interfaces */
#include "el.h" /* Ethernet Link Object public interfaces */
#include "el_obj.h" /* Ethernet Link Object private interfaces */
/****************************************************************************
**
** Externals
**
*****************************************************************************
*/
/****************************************************************************
**
** Public Globals
**
*****************************************************************************
*/
/****************************************************************************
**
** Private Services
**
*****************************************************************************
*/
typedef struct _ASTAT_ {
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
}ASTAT, * PASTAT;
ASTAT Adapter;
void eiu_GetMacAddr( UINT8 *pabDest )
{
NCB Ncb;
UCHAR uRetCode;
LANA_ENUM lenum;
int i;
/*
** Init to 0's, in case we fail
*/
memset( pabDest, 0, EL_MAC_ADDR_LENGTH );
/*
** Use the netbios interface to get the mac address
** See microsoft's knowledge base article ID: Q118623
*/
memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBENUM;
Ncb.ncb_buffer = (UCHAR *)&lenum;
Ncb.ncb_length = sizeof(lenum);
uRetCode = Netbios( &Ncb );
if( uRetCode == NRC_GOODRET )
{
for( i=0; i < lenum.length ;i++ )
{
memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBRESET;
Ncb.ncb_lana_num = lenum.lana[i];
uRetCode = Netbios( &Ncb );
if( uRetCode != NRC_GOODRET )
{
continue;
}
memset( &Ncb, 0, sizeof (Ncb) );
Ncb.ncb_command = NCBASTAT;
Ncb.ncb_lana_num = lenum.lana[i];
strcpy( Ncb.ncb_callname, "* " );
Ncb.ncb_buffer = (char *) &Adapter;
Ncb.ncb_length = sizeof(Adapter);
uRetCode = Netbios( &Ncb );
if( uRetCode == NRC_GOODRET )
{
memcpy( pabDest, Adapter.adapt.adapter_address, EL_MAC_ADDR_LENGTH );
break;
}
}
}
}
/*---------------------------------------------------------------------------
** eiu_GetEthernetLinkData()
**---------------------------------------------------------------------------
*/
UINT16 eiu_GetEthernetLinkData( void )
{
UINT16 iStatus;
/*
** Update the el_s.lInterfaceSpeed, el_s.lInterfaceFlags, and
** el_s.achEnetAddr fields
*/
/*********************************************************/
/*** PORTING ALERT! ***/
/*** ADD APPLICATION SPECIFIC CODE HERE ***/
/*********************************************************/
iStatus = CI_GRC_SUCCESS;
/*
** If product can be accessed via a CIP port other than TCP/IP, then
** the link active bit must be determined. If product only responds
** to one source of CIP requests (Ethernet port e.g.), then we can
** assume that it is active, since we got this request.
*/
el_s.lInterfaceFlags |= EL_FLAG_LINK_ACTIVE;
/*
** The interface flags and interface speed must be determined
** from your hardware interface.
*/
el_s.lInterfaceFlags &= ~EL_FLAG_DUPLEX_MODE;
el_s.lInterfaceSpeed = 10;
/*
** Get the Physical Ethernet address
*/
eiu_GetMacAddr( &el_s.achEnetAddr[0] );
return( iStatus );
} /* end of eiu_GetEthernetLinkData() */
#endif /* #ifdef ETHERNET_LINK_OBJECT */
/****************************************************************************
**
** End of ELU_OBJ.C
**
*****************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -