📄 cm.h
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** CM.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** Public interface definitions for the Connection Manager.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major> Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**
** CM_DecodeTimePerTickAndTicks() - Converts ticks & time/tic to time in ms
** CM_EncodeTimePerTickAndTicks() - Converts time in ms to ticks & time/tic
** CM_IsConnectionTypeNull() - Test for NULL type connection
** CM_Init() - Data/task creation/allocation/initialization
**
*****************************************************************************
*****************************************************************************
** **
** 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
** ----------
**
**
*****************************************************************************
*****************************************************************************
*/
#ifndef CM_H
#define CM_H
/*
** See if this code is to be included.
*/
#ifdef CORE_OBJECTS
#ifdef CD_EN_OBJECTS
#include "en_encap.h"
#endif
/****************************************************************************
**
** Constants
**
*****************************************************************************
*/
/*---------------------------------------------------------------------------
**
** Class and revision numbers
**
**---------------------------------------------------------------------------
*/
#define CM_CLASS_NUMBER 0x06
#define CM_REVISION 1
/*---------------------------------------------------------------------------
**
** Connection Manager specific service codes
**
**---------------------------------------------------------------------------
*/
#define CM_SC_FWD_CLOSE 0x4E
#define CM_SC_UNCONNECTED_SEND 0x52
#define CM_SC_FWD_OPEN 0x54
/*---------------------------------------------------------------------------
**
** Extended Response Codes
**
**---------------------------------------------------------------------------
*/
#define CM_ERC_ALREADY_USED 0x100 /* Connection already in use */
#define CM_ERC_BAD_TRANSPORT 0x103 /* Transport type not supported */
#define CM_ERC_OWNER_CONFLICT 0x106 /* More than one guy configuring */
#define CM_ERC_BAD_CONNECTION 0x107 /* Trying to close inactive conn */
#define CM_ERC_BAD_CONN_TYPE 0x108 /* Unsupported connection type */
#define CM_ERC_BAD_CONN_SIZE 0x109 /* Connection size mismatch */
#define CM_ERC_CONN_UNCONFIGURED 0x110 /* Connection unconfigured */
#define CM_ERC_BAD_RPI 0x111 /* Unsupportable RPI */
#define CM_ERC_NO_CM_RESOURCES 0x113 /* Conn Mgr out of connections */
#define CM_ERC_BAD_VENDOR_PRODUCT 0x114 /* Mismatch in electronic key */
#define CM_ERC_BAD_DEVICE_TYPE 0x115 /* Mismatch in electronic key */
#define CM_ERC_BAD_REVISION 0x116 /* Mismatch in electronic key */
#define CM_ERC_BAD_CONN_POINT 0x117 /* Nonexistant instance number */
#define CM_ERC_BAD_CONFIGURATION 0x118 /* Bad config instance number */
#define CM_ERC_CONN_REQ_FAILS 0x119 /* No controlling connection opn */
#define CM_ERC_NO_APP_RESOURCES 0x11A /* App out of connections */
#define CM_ERC_CONN_TIMED_OUT 0x203 /* Using a timed out connection */
#define CM_ERC_UCSEND_TIMED_OUT 0x204 /* Unconnected Send timed out */
#define CM_ERC_UCSEND_PARAM_ERR 0x205 /* Unconnected Send parameter error */
#define CM_ERC_NO_BUFFER 0x301 /* No buffer memory available */
#define CM_ERC_NO_BANDWIDTH 0x302 /* Insufficient bandwidth left */
#define CM_ERC_NO_SCREENER 0x303 /* Out of gen screeners */
#define CM_ERC_NOT_CONF_FOR_RT 0x304 /* Not configured to send RT data*/
#define CM_ERC_SIGNATURE_MISMATCH 0x305 /* sig does not match sig store in CCM */
#define CM_ERC_CCM_NOT_AVAIL 0x306 /* ccm is not responding to requests */
#define CM_ERC_BAD_PORT 0x311 /* Nonexistant port */
#define CM_ERC_BAD_LINK_ADDRESS 0x312 /* Invalid link address in path */
#define CM_ERC_BAD_SEGMENT 0x315 /* Invalid segment in path */
#define CM_ERC_BAD_CLOSE 0x316 /* Path & conn not equal in close*/
#define CM_ERC_BAD_NET_SEGMENT 0x317 /* Net seg not present or bad */
#define CM_ERC_BAD_LINK_AD_TO_SELF 0x318 /* Link address to self invalid */
#define CM_ERC_NO_SEC_RESOURCE 0x319 /* Resources in secondary unavail*/
#define CM_ERC_REDUND_CONN_MISMATCH 0x31D /* Redundant connection mismatch */
/*---------------------------------------------------------------------------
**
** CM_TRAN_ID_*
**
** Special transport ID markers. Some are compared for equality, others
** are limits and are compared for relative value.
**
** CM_TRAN_ID_UNSTARTED == Used in this connection, unstarted, ready to start.
** CM_TRAN_ID_STARTING == In the process of starting.
** CM_TRAN_ID_STOPPING == In the process of stopping.
** CM_TRAN_ID_POSTPONED <= Used in this connection, but start is postponed
** until forward open reply is received from target.
** CM_TRAN_ID_OK <= OK (Running or unused in this connection).
** CM_TRAN_ID_UNUSED == Unused in this connection (or shut down).
** CM_TRAN_ID_REAL <= Limit for real transports.
**
**---------------------------------------------------------------------------
*/
#define CM_TRAN_ID_UNSTARTED 0xFFFF
#define CM_TRAN_ID_STARTING 0xFFFC
#define CM_TRAN_ID_STOPPING 0xFFF0
#define CM_TRAN_ID_POSTPONED 0xFF00
#define CM_TRAN_ID_OK 0xF000
#define CM_TRAN_ID_UNUSED 0x8000
#define CM_TRAN_ID_REAL 0x7FFF
/*---------------------------------------------------------------------------
**
** Forward open packet details
**
** Defined in the order they appear in a forward open packet.
**
**---------------------------------------------------------------------------
*/
/*
** Priority/Tick Time masks & values.
** (bPriorityTickTime)
**
** Priority is for traffic related to connection opening (ignored).
** Time tick is for connection opening as well.
** Tick time duration is ( 1 << TICKTIME ) ms.
*/
#define CM_PTT_PRIORITY_MASK 0x10
#define CM_PTT_TICKTIME_MASK 0x0f
#define CM_PTT_HIGH_PRIORITY 0x10
/*
** Connection ID type mask.
** (bConnType in sLeOTConnID & sLeTOConnID)
** These are redundant and should not be used to determine connection type.
** Use the type bits in the connection parameters fields instead.
**
**
** #define CM_CID_TYPE_MASK 0x80
**
** #define CM_CID_TYPE_MULTICAST 0x00
** #define CM_CID_TYPE_POINT 0x80
*/
/*
** Timeout multiplier mask.
** (bTimeoutMultiplier)
**
** Timeout multiplier is ( 4 << bTimeoutMultiplier ).
*/
#define CM_TM_MASK 0x07
/*
** Connection parameters masks and values.
** (iOTConnParams & iTOConnParams)
*/
#define CM_CP_REDUNDANT_MASK 0x8000
#define CM_CP_EXCLUSIVE_OWNER 0x0000
#define CM_CP_REDUNDANT_OWNER 0x8000
#define CM_CP_TYPE_MASK 0x6000
#define CM_CP_TYPE_NULL 0x0000
#define CM_CP_TYPE_MULTICAST 0x2000
#define CM_CP_TYPE_POINT 0x4000
#define CM_CP_PRIORITY_MASK 0x0C00
#define CM_CP_PRIORITY_LOW 0x0000
#define CM_CP_PRIORITY_HIGH 0x0400
#define CM_CP_PRIORITY_SCHEDULED 0x0800
#define CM_CP_FIXED_VAR_MASK 0x0200
#define CM_CP_VARIABLE_SIZE 0x0200
#define CM_CP_FIXED_SIZE 0x0000
#define CM_CP_SIZE_MASK 0x01FF
/*
** Transport class & trigger.
** (bClassTrigger)
*/
#define CM_TCT_CLIENTSERVER_MASK 0x80
#define CM_TCT_CLIENT 0x00
#define CM_TCT_SERVER 0x80
#define CM_TCT_TRIGGER_MASK 0x70
#define CM_TCT_TRIGGER_CYCLIC 0x00
#define CM_TCT_TRIGGER_CHANGE 0x10
#define CM_TCT_TRIGGER_APP 0x20
#define CM_TCT_CLASS_MASK 0x0F
#define CM_TCT_CLASS_0 0x00
#define CM_TCT_CLASS_1 0x01
#define CM_TCT_CLASS_2 0x02
#define CM_TCT_CLASS_3 0x03
#define CM_TCT_CLASS_4 0x04
#define CM_TCT_CLASS_5 0x05
#define CM_TCT_CLASS_TUI 0x0F
/*
** Electronic key segment. Revision bit masks.
** If the updates OK bit is cleared, an exact revision munber match is required.
** A zero for the revision number means any number is acceptable.
*/
#define CM_KEY_UPDATES_OK_MASK 0x80
#define CM_KEY_MAJOR_REV_MASK 0x7F
/****************************************************************************
**
** Typedefs
**
*****************************************************************************
*/
/*---------------------------------------------------------------------------
**
** CM_LeConnIdType
** CM_ConnIdType
**
** Connection ID (within forward open and other packets) structure.
** Little-endian and native versions.
**
** Note that the connection type identifier in this structure is
** historical and is no longer used. The connection type identifier in
** the connection parameters field now contain this information.
**
**---------------------------------------------------------------------------
*/
typedef packet_struct CM_LeConnIdType
{
LeUINT16 iLeConnNumber; /* Second and third gen tag bytes */
UINT8 bMacId; /* First gen tag byte */
UINT8 bAbandoned; /* Connection Type Identifier */
}
GNU_PACKED CM_LeConnIdType;
typedef packet_struct CM_ConnIdType
{
UINT16 iConnNumber; /* Second and third gen tag bytes */
UINT8 bMacId; /* First gen tag byte */
UINT8 bAbandoned; /* Connection Type Identifier */
}
GNU_PACKED CM_ConnIdType;
/*---------------------------------------------------------------------------
**
** CM_LeFwdCloseType
**
** Forward close packet. (The portion between the IOI and the path).
**
**---------------------------------------------------------------------------
*/
typedef packet_struct CM_LeFwdCloseType
{
UINT8 bOpenPriorityTickTime;
UINT8 bOpenTimeoutTicks;
LeUINT16 iLeOrigConnectionSn;
LeUINT16 iLeOrigVendorId;
LeUINT32 lLeOrigDeviceSn;
UINT8 bClosePathSize;
UINT8 bReserved;
}
GNU_PACKED CM_LeFwdCloseType;
/*---------------------------------------------------------------------------
**
** CM_LeFwdCloseReplyType
** CM_LeFwdOpenErrorReplyType
**
** Forward open reply error packet
** Forward close reply and reply error packet.
** (the portion between the reply header and the reply data).
**
**---------------------------------------------------------------------------
*/
typedef packet_struct CM_LeFwdCloseReplyType
{
LeUINT16 iLeOrigConnectionSn;
LeUINT16 iLeOrigVendorId;
LeUINT32 lLeOrigDeviceSn;
UINT8 bPathSize; /* Received Message Path size in words */
UINT8 bReserved;
}
GNU_PACKED CM_LeFwdCloseReplyType;
#define CM_LeFwdOpenErrorReplyType CM_LeFwdCloseReplyType
/*---------------------------------------------------------------------------
**
** CM_LeFwdOpenType
**
** Forward open packet (the portion up to the connection path).
**
**---------------------------------------------------------------------------
*/
typedef packet_struct CM_LeFwdOpenType
{
UINT8 bOpenPriorityTickTime;
UINT8 bOpenTimeoutTicks;
LeUINT32 lLeOTConnId;
LeUINT32 lLeTOConnId;
LeUINT16 iLeOrigConnectionSn;
LeUINT16 iLeOrigVendorId;
LeUINT32 lLeOrigDeviceSn;
UINT8 bTimeoutMult;
UINT8 bReserved; /* Must be 0 */
UINT16 iReserved; /* Must be 0 */
LeUINT32 lLeOTRpi;
LeUINT16 iLeOTConnParams;
LeUINT32 lLeTORpi;
LeUINT16 iLeTOConnParams;
UINT8 bClassTrigger;
UINT8 bConnPathSize;
/* Connection Path... */
}
GNU_PACKED CM_LeFwdOpenType;
/*---------------------------------------------------------------------------
**
** CM_LeFwdOpenReplyType
**
** Forward open reply packet.
** (The portion between the reply header and the reply data.)
** (Reply data portion shown here only for reference.)
**
**---------------------------------------------------------------------------
*/
typedef packet_struct CM_LeFwdOpenReplyType
{
LeUINT32 lLeOTConnId;
LeUINT32 lLeTOConnId;
LeUINT16 iLeOrigConnectionSn;
LeUINT16 iLeOrigVendorId;
LeUINT32 lLeOrigDeviceSn;
LeUINT32 lLeOTApi;
LeUINT32 lLeTOApi;
/* UINT8 bReplyDataSize; */
/* UINT8 bReserved; */
/* UINT16 aiReplyData[]; */
}
GNU_PACKED CM_LeFwdOpenReplyType;
/*---------------------------------------------------------------------------
**
** CM_AppOpenCloseTrrblType
**
** Tribble used for the app open, app open complete, and app close
** notifications between the CM and the app.
** The forward open & close combufs are cleared when sent to the app.
** They are only used if the app needs to send app specific data with
** the fwd open or close replies.
**
** Note that in the case of an app close initiated by a transport timeout,
** there will not be a forward close combuf (pointer will be NULL).
**
** The first block of parameters make up the minimum routable tribble.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -