⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 en_sock.h

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 H
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** EN_SOCK.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** This module contains the private interfaces for Ethernet Socket
** interface.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major>         Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**
**   en_cd_Class1RecvTask()
**   en_cd_Class1SendTask()
**   en_cd_EncapRecvTask()
**   en_cd_EncapSendTask()
**   en_cd_FormatIOV()
**   en_cd_PassiveWaitTask()
**   en_cd_PostListen()
**   en_cd_TcpConnect()
**   en_cd_TCPSend()
**   en_cd_UDPEncapSendTask()
**   en_cd_UDPRecvTask()
**   en_cd_UDPSend()
**
*****************************************************************************
*****************************************************************************
**                                                                         **
** 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.    **
**                                                                         **
*****************************************************************************
*****************************************************************************
*/


#ifndef EN_SOCK_H
#define EN_SOCK_H


/*
** See if this code is to be included.
*/

#ifdef CD_EN_OBJECTS


/****************************************************************************
**
** Typedefs
**
*****************************************************************************
*/


/*
** jjw 02/23/01 added socket to structure to manage
** multisocket multicast messaging.  BSD limits maximum
** multicasts per socket to IP_MAX_MEMBERSHIPS (20),
we will have more than 20 class 1 message connections.
*/
typedef struct MulticastTblType {
    UINT32      iConnections;       /* Number of open connections to the address */
    UINT32      iMcastAddr;         /* Multicast address */
    UINT32      iSocket;            /* Multicast socket connection is using */
    } MulticastTblType;



/****************************************************************************
**
** Services
**
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** en_cd_Class1SendTask()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_Class1SendTask();
**
**---------------------------------------------------------------------------
*/

EXTFUNC TASKRETURN   en_cd_Class1SendTask( TASKPARAM );



/*---------------------------------------------------------------------------
**
** en_cd_Class1RecvTask()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_Class1RecvTask();
**
**---------------------------------------------------------------------------
*/

EXTFUNC  TASKRETURN  en_cd_Class1RecvTask( TASKPARAM );


/*---------------------------------------------------------------------------
**
** en_cd_UDPRecvTask()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_UDPRecvTask();
**
**---------------------------------------------------------------------------
*/

EXTFUNC  TASKRETURN  en_cd_UDPRecvTask( TASKPARAM );


/*---------------------------------------------------------------------------
**
** en_cd_PostListen()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_PostListen();
**
**---------------------------------------------------------------------------
*/

EXTFUNC   UINT32  en_cd_PostListen( void );


/*---------------------------------------------------------------------------
**
** en_cd_PassiveWaitTask()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_PassiveWaitTask();
**
**---------------------------------------------------------------------------
*/

EXTFUNC TASKRETURN en_cd_PassiveWaitTask( TASKPARAM );


/*---------------------------------------------------------------------------
**
** en_cd_TcpConnect()
**
** This function initiates a connection request to the specified
** foreign host address and port.
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    struct sockaddr_in *psF_Addr	Foreign (remote) host address
**    UINT32 *lSockfd			Pointer to file descriptor
**    UINT32 *nErr        		Pointer to error return value
**
** Outputs:
**    UINT32 *lSockfd			File descriptor returned
**    UINT32 *nErr			Error value returned
**
** Return
**    YES				Socket was opened and connect() successful.
**                                      Parameter 'lSockfd' contains descriptor for socket.
**    NO				Socket could not be created or connect() failed.
**                                      Parameter 'nErr' contains error code.
**
** Usage:
**    en_cd_TcpConnect();
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT32  en_cd_TcpConnect( struct sockaddr_in * psF_Addr,
                                  UINT32 * lSockfd,
                                  UINT32 * nErr );


/*---------------------------------------------------------------------------
**
** en_cd_UDPSend()
**
**  This function is used by the EML to send data on a
**  UDP/IP socket.  The desired I/O is described by an
**  XDESC structure which contains scatter/gather arrays.
**
**  UDP/IP doesn't have the notion of a 'partial' write. There is no need
**  to have the WDESC updated after doing the write.  The 'to' parameter
**  is optional since the caller may have elected to 'connect' the socket to
**  a particular host.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    UINT32 fd                File descriptor for the connection
**    SOCK_WDESC *psWriteDesc  Pointer to write descriptor
**    UINT32 flags             Options flags for socket call
**    struct sockaddr_in *to   Pointer to destination address
**    UINT32 *pnErr            Pointer to error return value
**
** Outputs:
**    UINT32 *pnErr            Error value returned
**
** Return
**    YES     Write completed successfully
**            Parameter 'psWriteDesc' updated
**    NO      Write did not complete
**            Parameter 'pnErr' contains error code.
**
** Usage:
**    en_cd_UDPSend();
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT32 en_cd_UDPSend( UINT32 fd,
                              SOCK_WDESC *psWriteDesc,
                              UINT32 flags,
                              struct sockaddr_in *to,
                              UINT32 *pnErr);


/*---------------------------------------------------------------------------
**
** en_cd_UDPEncapSendTask()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_UDPEncapSendTask();
**
**---------------------------------------------------------------------------
*/

EXTFUNC  TASKRETURN  en_cd_UDPEncapSendTask( TASKPARAM );


/*---------------------------------------------------------------------------
**
** en_cd_TCPSend()
**
**  This function is used by the task to send data on a
**  TCP/IP socket.  The desired I/O is described by an
**  WRITEDESC structure which contains scatter/gather arrays.
**
**  A successful return only means that some, but not all, data
**  was sent.  The lCount in WDESC must be checked.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    UINT32 lSockfd		File descriptor for the connection
**    SOCK_WDESC *psWriteDesc	Pointer to write descriptor
**    UINT32 lFlags       Options lFlags for socket call
**    UINT32 *nErr	Pointer to error return value
**
** Outputs:
**    SOCK_WDESC *psWriteDesc	Updated write descriptor
**    UINT32 *nErr	Error value returned
**
** Return
**    OK      Write completed successfully
**            Parameter 'psWriteDesc' updated
**    ERROR   Write did not complete
**            Parameter 'nErr' contains error code.
**
** Usage:
**    en_cd_TCPSend();
**
**---------------------------------------------------------------------------
*/

EXTFUNC  UINT32 en_cd_TCPSend( UINT32 lSockfd,
                               SOCK_WDESC * psWriteDesc,
                               UINT32 lFlags,
                               UINT32 * nErr );



/*---------------------------------------------------------------------------
**
** en_cd_FormatIOV()
**
**    This function is called to format a message on an ENCAP connection.
**
**    Assumes that the header, object lCount, address tag, and data
**    tag fields in the packet buffer are in HOST byte order and
**    have correct sizes for the message which is to be sent.
**    These fields are converted into ENCAP byte order before
**    transmission.  encap.valid in PKTBUF says which of the fields
**    are part of the message.  The remainder of the message which is
**    present in the DATA area of the PKTBUF must be in the byte order
**    expected by the recipient.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    PKTBUF_P msg	Pointer to PKTBUF used for the error message
**
** Outputs:
**    SOCK_WDESC psWriteDesc	Updated write descriptor
**
** Usage:
**    en_cd_FormatIOV();
**
**---------------------------------------------------------------------------
*/

EXTFUNC  void  en_cd_FormatIOV( PKTBUF_P msg, SOCK_WDESC *psWriteDesc );



/*---------------------------------------------------------------------------
**
** en_cd_EncapSendTask()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_EncapSendTask();
**
**---------------------------------------------------------------------------
*/

EXTFUNC TASKRETURN  en_cd_EncapSendTask( ECE * psEce );


/*---------------------------------------------------------------------------
**
** en_cd_EncapRecvTask()
**
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    None
**
** Usage:
**    en_cd_EncapRecvTask();
**
**---------------------------------------------------------------------------
*/

EXTFUNC TASKRETURN  en_cd_EncapRecvTask( ECE * psOrigEce );


#endif  /* #ifdef CD_EN_OBJECTS */
#endif  /* inclusion lock */

/****************************************************************************
**
** End of EN_SOCK.H
**
*****************************************************************************
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -