TCP IP - Packet Interface API 14 EN
TCP IP - Packet Interface API 14 EN
TCP/IP
Packet Interface
V2.4
Table of contents
1 Introduction............................................................................................................................................. 4
1.1 About this document ...................................................................................................................... 4
1.2 List of revisions............................................................................................................................... 4
1.3 Functional overview ....................................................................................................................... 5
1.4 System requirements ..................................................................................................................... 5
1.5 Intended audience .......................................................................................................................... 5
1.6 Specifications ................................................................................................................................. 6
1.6.1 Supported protocols .......................................................................................................................... 6
1.6.2 Technical data ................................................................................................................................... 6
1.6.3 Limitations ......................................................................................................................................... 6
1.7 Terms, abbreviations and definitions ............................................................................................. 7
1.8 References to documents .............................................................................................................. 7
1.9 Legal notes ..................................................................................................................................... 8
1.9.1 Copyright ........................................................................................................................................... 8
1.9.2 Important notes ................................................................................................................................. 8
1.9.3 Exclusion of liability ........................................................................................................................... 9
1.9.4 Export ................................................................................................................................................ 9
2 Getting started ...................................................................................................................................... 10
2.1 Sockets-based programming model ............................................................................................ 10
2.1.1 TCP client example ......................................................................................................................... 10
2.1.2 TCP server example ........................................................................................................................ 13
2.1.3 UDP communication example ......................................................................................................... 16
2.2 Configuration ................................................................................................................................ 18
2.3 Start-up of the TCP/IP stack ........................................................................................................ 18
3 Application implementation requirements ........................................................................................ 19
3.1 UDP sockets................................................................................................................................. 19
3.2 TCP sockets ................................................................................................................................. 21
4 The application interface ..................................................................................................................... 24
4.1 Configuration ................................................................................................................................ 24
4.1.1 Protocol parameters ........................................................................................................................ 24
4.1.2 TCPIP_IP_CMD_SET_CONFIG_REQ/CNF - Providing configuration data ...................................... 26
4.1.3 TCPIP_IP_CMD_GET_CONFIG_REQ/CNF - Obtaining configuration data ...................................... 30
4.1.4 TCPIP_IP_CMD_SET_PARAM_REQ/CNF - Setting IP parameters .................................................. 33
4.1.5 TCPIP_IP_CMD_GET_PARAM_REQ/CNF - Obtaining IP parameters .............................................. 45
4.2 TCP and UDP socket and communication services .................................................................... 52
4.2.1 TCPIP_TCP_UDP_CMD_OPEN_REQ/CNF - Opening a socket ......................................................... 52
4.2.2 TCPIP_TCP_UDP_CMD_CLOSE_REQ/CNF - Closing a socket ........................................................ 57
4.2.3 TCPIP_TCP_UDP_CMD_CLOSE_ALL_REQ/CNF - Closing all sockets............................................. 61
4.2.4 TCPIP_TCP_CMD_WAIT_CONNECT_REQ/CNF - Waiting for an Incoming TCP connection ............ 65
4.2.5 TCPIP_TCP_CMD_CONNECT_REQ/CNF - Establishing a TCP connection ...................................... 69
4.2.6 TCPIP_TCP_CMD_SEND_REQ/CNF - Sending TCP data ................................................................ 73
4.2.7 TCPIP_UDP_CMD_SEND_REQ/CNF - Sending UDP data ................................................................ 77
4.2.8 TCPIP_TCP_UDP_CMD_SET_SOCK_OPTION_REQ/CNF - Setting socket options .......................... 81
4.2.9 TCPIP_TCP_UDP_CMD_GET_SOCK_OPTION_REQ/CNF - Obtaining socket options ...................... 87
4.2.10 TCPIP_TCP_UDP_CMD_RECEIVE_IND - Receiving TCP data and UDP data ................................ 91
4.2.11 TCPIP_TCP_UDP_CMD_SHUTDOWN_IND/RES - Shutdown of the stack ......................................... 94
4.2.12 TCPIP_TCP_UDP_CMD_RECEIVE_STOP_IND - Stop receiving of TCP data and UDP data .......... 96
4.3 ICMP services .............................................................................................................................. 99
4.3.1 TCPIP_IP_CMD_PING_REQ/CNF - Sending a ping ........................................................................ 99
4.3.2 TCPIP_IP_CMD_ICMP_IND – ICMP indication has been received ............................................. 102
4.4 Information services ................................................................................................................... 104
4.4.1 TCPIP_TCP_UDP_CMD_ACD_CONFLICT_IND – Address conflict occurred ................................. 104
4.4.2 TCPIP_IP_CMD_GET_OPTIONS_REQ/CNF - Obtaining TCP/IP stack capabilities ....................... 107
5 Special topics ..................................................................................................................................... 111
5.1 TCP_UDP task ........................................................................................................................... 111
5.2 TCP/IP startup parameters ........................................................................................................ 112
6 Status/error codes .............................................................................................................................. 117
6.1 Status/error codes (general) ...................................................................................................... 117
TCP/IP | Packet Interface
DOC050201API14EN | Revision 14 | English | 2017-01 | Released | Public © Hilscher, 2005-2017
Introduction 3/127
6.2 Status/error codes of TCP/IP (IP task) ....................................................................................... 117
6.3 Status/error codes of TCP/IP (TCP task) ................................................................................... 119
7 Appendix ............................................................................................................................................. 124
7.1 List of tables ............................................................................................................................... 124
7.2 List of figures .............................................................................................................................. 126
7.3 Contacts ..................................................................................................................................... 127
1 Introduction
1.1 About this document
This manual describes the application interface of the TCP/IP and UDP/IP protocol stack. Use this
manual to support and guide you through the integration process of the given stack into your own
application.
This stack was developed based upon Hilscher’s Task Layer Reference Programming Model. This
programming model is a description of how to develop a task in general, which is a convention
defining a combination of appropriate functions belonging to the same task. Furthermore, it defines
how different tasks have to communicate with each other in order to exchange their data. The
Reference Model is commonly used by all developers at Hilscher and shall be used by you as well
when writing your application task on top of the stack.
1.6 Specifications
The data below applies to TCP/IP stack version V2.4.
1.6.3 Limitations
IP fragmentation not supported
TCP urgent data not supported
TCP port 0 not supported
UDP port 67 reserved for BOOTP and DHCP
UDP port 25383 reserved for Hilscher NetIdent Protocol
IP multicast receive always enabled from Ethernet Device Driver (EDD)
All variables, parameters, and data used in this manual have the LSB/MSB (“Intel”) data format.
This corresponds to the convention of the Microsoft C Compiler.
All IP addresses in this document have host byte order.
1.9.4 Export
The delivered product (including the technical data) is subject to export or import laws as well as
the associated regulations of different counters, in particular those of Germany and the USA. The
software may not be exported to countries where this is prohibited by the United States Export
Administration Act and its additional provisions. You are obligated to comply with the regulations at
your personal responsibility. We wish to inform you that you may require permission from state
authorities to export, re-export or import the product.
2 Getting started
2.1 Sockets-based programming model
The TCP_UDP-task utilizes a sockets-based handling of TCP and UDP communication. The
socket model implemented in the stack is loosely related to the well-known BSD sockets or
Winsock programming model. However, only the basic features known from these models are
implemented in order to simplify the communication and to adapt to the restrictions of an
embedded device. The main difference is the command-based communication provided by the
TCP/IP stack as opposed to the function calls implemented by BSD sockets or Winsock libraries.
The function calls are represented by request command and confirmation command pairs in the
TCP_UDP-task.
The following sections describe how to make use of the socket communication and how to handle
the commands involved. Chapter The application (page 24) describe all commands in detail.
Socket
The first step of any socket-based communication is to open a socket of the desired protocol type.
Therefor a TCPIP_TCP_UDP_CMD_OPEN request command should be sent to the stack. The stack
will return a confirmation command containing the handle of the socket just opened.
When the confirmation command is returned the TCP client application can proceed to the next
step which establishes a connection to the TCP server. This will be accomplished by sending a
TCPIP_TCP_CMD_CONNECT command to the stack.
Socket
Device
The device then contacts the server owning the IP address given in the
TCPIP_TCP_CMD_CONNECT request command. If the connection could be established a
confirmation command reporting success will be returned to the application. In case the IP address
cannot be found or the server refuses the connection the confirmation command will contain an
error code indicating the reason of failure.
Data
Acknowledge
Socket
Once the connection is established the application can then start sending its request data using a
TCPIP_TCP_CMD_SEND request command. The TCP/IP stack forwards the data to the server,
and waits for the server’s TCP/IP stack to acknowledge it. When the acknowledgement arrives the
stack returns a TCPIP_TCP_CMD_SEND confirmation command to the application.
Remark: The application must not wait for the TCPIP_TCP_CMD_SEND confirmation command to
send the next TCPIP_TCP_CMD_SEND request command.
Data
Acknowledge
Socket
TCP_UDP_CMD_RECEI VE Request Command
...
Device
TCP_UDP_CMD_RECEI VE Request Command
When the server has finished processing, it sends its response data through the TCP connection.
The stack receives the data from the network, and sends it to the application using
TCPIP_TCP_UDP_CMD_RECEIVE indication commands. There will be as many
TCPIP_TCP_UDP_CMD_RECEIVE indication commands as required to transport the server’s data.
Please note, that the stack sends TCPIP_TCP_UDP_CMD_RECEIVE indication commands
automatically, whenever data is received from the network. There is no explicit receive request
command, because the application is assumed to be ready to handle received data once it has
established a connection. Thus, the application should check for available indication commands
from the stack on a regular basis.
Once the application has received all response data from the server it terminates the TCP
connection by sending a TCPIP_TCP_UDP_CMD_CLOSE request command.
Socket
When the connection is terminated the stack closes the socket, and a
TCPIP_TCP_UDP_CMD_CLOSE confirmation command is returned to the application.
Socket
A socket must be opened before any TCP communication on the network can start. The server
application sends a TCPIP_TCP_UDP_CMD_OPEN request command to the stack, and waits for the
corresponding confirmation command which returns a socket handle.
Socket
Device
When a socket handle can be obtained, the server application puts this socket into listening state
by sending a TCPIP_TCP_CMD_WAIT_CONNECT request command. The stack defers the
confirmation command to this request command as long as the socket is waiting for an incoming
connection.
TCP Connection
Establishment
Socket
Device
Once a connection request is detected, it is processed, and the socket is no longer listening. The
result of the connection establishment is returned in the TCPIP_TCP_CMD_WAIT_CONNECT
confirmation command then. If successful, the socket will be connected to the client that initiated
the connection.
Data
Acknowledge
Socket
TCP_UDP_CMD_RECEI VE Request Command
Device
TCP_UDP_CMD_RECEI VE Request Command
The server then awaits the client’s request data, which is transferred to the server application using
TCPIP_TCP_UDP_CMD_RECEIVE indication commands.
Data
Acknowledge
Socket
After processing the request the server sends response data back to the client by means of
TCPIP_TCP_CMD_SEND commands.
Socket
Once the data is transferred the server sends a TCPIP_TCP_UDP_CMD_CLOSE request command
to the stack in order to terminate the TCP connection and to close the socket.
Socket
Most simply, only a UDP socket needs to be opened in order to enable an application to receive
UDP data. The application sends a TCPIP_TCP_UDP_CMD_OPEN request command to the stack,
and waits for the corresponding confirmation command to be returned.
Data
Socket
TCP_UDP_CMD_RECEI VE Request Command
Device
TCP_UDP_CMD_RECEI VE Request Command
Once the socket is opened all incoming UDP data for this socket will be sent to the application by
means of TCPIP_TCP_UDP_CMD_RECEIVE commands.
Data
Socket
The application processes the data, and sends its response data using TCPIP_UDP_CMD_SEND
commands.
Socket
2.2 Configuration
The TCP/IP stack needs basic configuration data to be able to start. Normally, this configuration
data will be read from a database (DBM file) residing in the device’s flash memory.
Alternatively, it is possible to provide the configuration data dynamically by the AP-task.
Configuration data sent to the TCP/IP stack this way will have precedence over the data read from
flash, but will not be stored in flash memory. Hence, the dynamic configuration procedure must be
executed again after each reset or power cycle of the stack.
It is possible to send configuration command to the TCP/IP stack (TCP_UDP task). The commands
are explained in detail in section The application starting at page 24.
The following actions are used in the statemachines and are to be implemented in the application:
Name Description
send_TCP_UDP_OPEN_REQ The application sends a TCPIP_TCP_UDP_CMD_OPEN_REQ packet to the
TCP/IP protocol.
send_TCP_UDP_CLOSE_REQ The application sends a TCPIP_TCP_UDP_CMD_CLOSE_REQ packet to the
TCP/IP protocol.
send_TCP_WAIT_CONNECT_REQ The application sends a TCPIP_TCP_CMD_WAIT_CONNECT_REQ packet to
the TCP/IP protocol (Listen socket only).
send_TCP_CONNECT_REQ The application sends a TCPIP_TCP_CMD_CONNECT_REQ packet to the
TCP/IP protocol (Connection socket only).
startTimer() The application starts an internal timer associated with the socket. Timeout hast
to be greater than 10 ms.
stopTimer() The application stops the internal timer associated with the socket.
newClient() The application creates a new connection socket using the initial event
CREATE_CLIENT.
Table 9 Actions used in TCP socket statemachines
4.1 Configuration
Normally the configuration is stored into the non-volatile flash memory. The TCP/IP stack reads
this data block during its start-up initialization and performs consistency checks.
The application can add, change or delete parameters during run-time. These parameters will be
kept in the RAM area of the device. For this purpose, the command
TCPIP_IP_CMD_SET_CONFIG_REQ has to be used.
Note: Parameter sets stored in the RAM area will get lost if the device is powered down or if
a restart is performed.
Parameter ulFlags
The ulFlags parameter holds bit-oriented flags according to the following table:
Bits Bit mask / Description
31 ... 15 Reserved for future use
14 IP_CFG_FLAG_NO_GRATUITOUS_ARP
Enable/Disable sending of gratuitous ARP frames. If set, sending is disabled.
13 … 6 Reserved for future use
5 IP_CFG_FLAG_ETHERNET_ADDR
Set Ethernet address (MAC address): If set, the abEthernetAddr area will be evaluated.
4 IP_CFG_FLAG_DHCP
Enable DHCP: If set, the stack obtains its configuration from a DHCP server.
3 IP_CFG_FLAG_BOOTP
Enable BOOTP: If set, the stack obtains its configuration from a BOOTP server.
2 IP_CFG_FLAG_GATEWAY
Gateway available: If set, the content of the ulGateway parameter will be evaluated. If the flag is not set the
stack will assume that there exists no gateway.
1 IP_CFG_FLAG_NET_MASK
Netmask available: If set, the content of the ulNetMask parameter will be evaluated. If the flag is not set the
stack will assume to be an isolated host which is not connected to any network. The ulGateway parameter
will be ignored in this case.
0 IP_CFG_FLAG_IP_ADDR
IP address available: If set, the content of the ulIpAddr parameter will be evaluated.
Table 10: Parameter ulFlags
Parameter ulIpAddr
The stacks IP address can be configured using the ulIpAddr parameter. Additionally, the
IP_CFG_FLAG_IP_ADDR flag must be set in ulFlags.
Parameter ulNetMask
The ulNetMask parameter holds the Netmask for the subnet the device is connected to.
Additionally, the IP_CFG_FLAG_NET_MASK flag must be set in ulFlags.
Parameter ulGateway
The ulGateway parameter stores the IP address of the default gateway. Additionally, the
IP_CFG_FLAG_GATEWAY flag must be set in ulFlags.
Parameter abEthernetAddr
The abEthernetAddr area can be used to overwrite the device’s default Ethernet address (MAC
address). Additionally, the IP_CFG_FLAG_ETHERNET_ADDR flag must be set in ulFlags.
Packet structure
typedef struct TCPIP_DATA_IP_CMD_SET_CONFIG_REQ_Ttag
{
TLR_UINT32 ulFlags;
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulNetMask;
TLR_UINT32 ulGateway;
TLR_UINT8 abEthernetAddr[6];
} TCPIP_DATA_IP_CMD_SET_CONFIG_REQ_T;
#define TCPIP_DATA_IP_CMD_SET_CONFIG_REQ_SIZE \
(sizeof(TCPIP_DATA_IP_CMD_SET_CONFIG_REQ_T))
} TCPIP_PACKET_IP_CMD_SET_CONFIG_REQ_T;
Packet description
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for TCPIP_IP_xx
packets.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 22 TCPIP_DATA_IP_CMD_SET_CONFIG_REQ_SIZE - Packet data
length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLR_RESULT
ApIpCmdSetConfigReq( TCPIP_AP_TASK_RSC_T FAR* ptRsc )
{
TCPIP_PACKET_IP_CMD_SET_CONFIG_REQ_T* ptPck;
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
ptPck->tHead.ulLen = TCPIP_DATA_IP_CMD_SET_CONFIG_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_IP_CMD_SET_CONFIG_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulFlags = IP_CFG_FLAG_IP_ADDR | \
IP_CFG_FLAG_NET_MASK | IP_CFG_FLAG_GATEWAY;
ptPck->tData.ulIpAddr = LOCAL_IP_ADDR;
ptPck->tData.ulNetMask = LOCAL_NET_MASK;
ptPck->tData.ulGateway = LOCAL_GATEWAY;
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_PACKET_IP_CMD_SET_CONFIG_CNF_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_IP_CMD_SET_CONFIG_CNF_T;
Packet description
structure TLR_PACKET_HEADER_T
ulDest UINT32 Destination queue handle, untouched
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
typedef struct TCPIP_PACKET_IP_CMD_GET_CONFIG_REQ_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_IP_CMD_GET_CONFIG_REQ_T;
Packet description
structure TCPIP_PACKET_IP_CMD_GET_CONFIG_REQ_T Type: Request
Variable Type Value / Range Description
structure TLR_PACKET_HEADER_T
ulDest UINT32 Destination queue handle of TCP_UDP-task process queue
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for TCPIP_IP_xx
packets.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 0 Packet data length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_IP_CMD_GET_CONFIG_CNF_Ttag
{
TLR_UINT32 ulFlags;
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulNetMask;
TLR_UINT32 ulGateway;
TLR_UINT8 abEthernetAddr[6];
} TCPIP_DATA_IP_CMD_GET_CONFIG_CNF_T;
#define TCPIP_DATA_IP_CMD_GET_CONFIG_CNF_SIZE \
(sizeof(TCPIP_DATA_IP_CMD_GET_CONFIG_CNF_T))
} TCPIP_PACKET_IP_CMD_GET_CONFIG_CNF_T;
Packet description
LIB_MEMCPY( &ptRsc->tLoc.abEthernetAddr[0],
&ptPck->tData.abEthernetAddr[0],
sizeof( ptPck->tData.abEthernetAddr ) );
}
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
/* Valid modes of packet ulMode variable */
#define IP_PRM_ADD_ARP_ENTRY (1)
#define IP_PRM_DEL_ARP_ENTRY (2)
#define IP_PRM_DEL_ARP_ENTRY_IP (3)
#define IP_PRM_DEL_ARP_ENTRY_MAC (4)
#define IP_PRM_SEND_ARP_REQ (5)
#define IP_PRM_SEND_ARP_TMT_REQ (6)
#define IP_PRM_SET_ARP_REQ_TMT (7)
#define IP_PRM_REGISTER_ACD_APP (8)
#define IP_PRM_REGISTER_ICMP_APP (9)
union
{
struct
{
TLR_UINT32 ulIpAddr;
TLR_UINT8 abEthernetAddr[6];
} tAddDelArpEntry;
struct
{
TLR_UINT32 ulIpAddr;
} tDelArpEntryIp;
struct
{
TLR_UINT8 abEthernetAddr[6];
} tDelArpEntryMac;
struct
{
TLR_UINT32 ulServices;
} tRegisterIcmpService;
struct
{
TLR_UINT32 ulIpAddr;
TLR_UINT8 abEthernetAddr[6];
} tSendArpReq;
struct
{
TLR_UINT32 ulIpAddr;
TLR_UINT8 abEthernetAddr[6];
TLR_UINT32 ulStationCntAbort; /* Abort command, if this count of */
} tSendArpTmtReq; /* stations has reached (e.g. 2) */
struct
{
TLR_UINT32 ulTimeout;
} tSetArpReqTmt;
} unParam;
} TCPIP_DATA_IP_CMD_SET_PARAM_REQ_T;
#define TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_ADD_ARP_ENTRY \
(sizeof(TLR_UINT32) + 10 /*sizeof(tAddDelArpEntry)*/)
#define TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_DEL_ARP_ENTRY \
(sizeof(TLR_UINT32) + 10 /*sizeof(tAddDelArpEntry)*/)
#define TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_DEL_ARP_ENTRY_IP \
(sizeof(TLR_UINT32) + 4 /*sizeof(tDelArpEntryIp )*/)
#define TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_DEL_ARP_ENTRY_MAC \
(sizeof(TLR_UINT32) + 6 /*sizeof(tDelArpEntryMac)*/)
#define TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_SEND_ARP_REQ \
(sizeof(TLR_UINT32) + 10 /*sizeof(tSendArpReq )*/)
#define TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_SEND_ARP_TMT_REQ \
(sizeof(TLR_UINT32) + 14 /*sizeof(tSendArpTmtReq )*/)
#define TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_SET_ARP_REQ_TMT \
(sizeof(TLR_UINT32) + 4 /*sizeof(tSetArpReqTmt )*/)
Packet description
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for TCPIP_IP_xx
packets.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 Packet data length in bytes: See Table 16:
TCPIP_IP_CMD_SET_PARAM_REQ – Mode description for
parameter data unParam
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
* The allocated packet size must consider the maximum used packet data length ulLen by
memory allocation! This must be considered also for the confirmation packet, see Table 26 on
43.
The following table describes the union unParam in structure
TCPIP_DATA_IP_CMD_SET_PARAM_REQ_T. The union elements are described in the following
tables.
Union unParam
Structure tAddDelArpEntry
Structure tDelArpEntryIp
Structure tDelArpEntryMac
Structure tSendArpReq
Structure tSendArpTmtReq
ulStationCntAbort UINT32 0 … 0xFFFF0000 Count of received stations, when the command aborts
0 = No station limit
Table 22: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tSendArpTmtReq of union unParam
Structure tSetArpReqTmt
Structure tRegisterIcmpService
TLR_RESULT
ApIpCmdSetParamReq( TCPIP_AP_TASK_RSC_T FAR* ptRsc )
{
TCPIP_PACKET_IP_CMD_SET_PARAM_REQ_T* ptPck;
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
ptPck->tHead.ulLen = TCPIP_DATA_IP_CMD_SET_PARAM_REQ_SIZE_ADD_ARP_ENTRY;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_IP_CMD_SET_PARAM_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulMode = IP_PRM_ADD_ARP_ENTRY;
ptPck->tData.unParam.tAddDelArpEntry.ulIpAddr = REMOTE_IP_ADDR;
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_IP_CMD_SET_PARAM_CNF_Ttag
{
TLR_UINT32 ulMode;
union
{
struct
{
TLR_UINT32 ulIpAddr;
TLR_UINT8 abEthernetAddr[6];
} tSendArpCnf;
struct
{
TLR_UINT32 ulIpAddr; /* Struct of Request */
TLR_UINT8 abEthernetAddr[6]; /* */
TLR_UINT32 ulStationCntAbort; /* */
} unParam;
} TCPIP_DATA_IP_CMD_SET_PARAM_CNF_T;
#define TCPIP_DATA_IP_CMD_SET_PARAM_CNF_SIZE \
(sizeof(TLR_UINT32))
#define TCPIP_DATA_IP_CMD_SET_PARAM_CNF_SIZE_SEND_ARP_REQ \
(sizeof(TLR_UINT32) + 10 /*sizeof(tSendArpCnf )*/)
#define TCPIP_DATA_IP_CMD_SET_PARAM_CNF_SIZE_SEND_ARP_TMT_REQ_MIN \
(sizeof(TLR_UINT32) + 18 /*sizeof(tSendArpTmtCnf )*/)
} TCPIP_PACKET_IP_CMD_SET_PARAM_CNF_T;
Packet description
Structure tSendArpCnf
Structure tSendArpTmtCnf
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
/* Valid modes of packet ulMode variable */
#define IP_PRM_GET_ARP_ENTRY_INDEX (1)
#define IP_PRM_GET_ARP_ENTRY_IP (2)
#define IP_PRM_GET_ARP_ENTRY_MAC (3)
union
{
struct
{
TLR_UINT32 ulIndex;
} tArpEntryIndex;
struct
{
TLR_UINT32 ulIpAddr;
} tArpEntryIp;
struct
{
TLR_UINT8 abEthernetAddr[6];
} tArpEntryMac;
} unParam;
} TCPIP_DATA_IP_CMD_GET_PARAM_REQ_T;
#define TCPIP_DATA_IP_CMD_GET_PARAM_REQ_SIZE_GET_ARP_ENTRY_INDEX \
(sizeof(TLR_UINT32) + 4 /*sizeof(tArpEntryIndex)*/)
#define TCPIP_DATA_IP_CMD_GET_PARAM_REQ_SIZE_GET_ARP_ENTRY_IP \
(sizeof(TLR_UINT32) + 4 /*sizeof(tArpEntryIp) */)
#define TCPIP_DATA_IP_CMD_GET_PARAM_REQ_SIZE_GET_ARP_ENTRY_MAC \
(sizeof(TLR_UINT32) + 6 /*sizeof(tArpEntryMac) */)
} TCPIP_PACKET_IP_CMD_GET_PARAM_REQ_T;
Packet description
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for TCPIP_IP_xx
packets.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 Packet data length in bytes: See Table 31:
TCPIP_IP_CMD_GET_PARAM_REQ – Mode description for parameter
data unParam
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
* The allocated packet size must consider the maximum used packet data length ulLen by
memory allocation!
The following table describes the union unParam in structure
TCPIP_DATA_IP_CMD_GET_PARAM_REQ_T. The union elements are described in the following
tables.
Union unParam
Structure tArpEntryIndex
Structure tArpEntryIp
Structure tArpEntryMac
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
ptPck->tHead.ulLen = \
TCPIP_DATA_IP_CMD_GET_PARAM_REQ_SIZE_GET_ARP_ENTRY_INDEX;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_IP_CMD_GET_PARAM_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulMode = IP_PRM_GET_ARP_ENTRY_INDEX;
ptPck->tData.unParam.tArpEntryIndex.ulIndex = 0; /* First ARP cache entry */
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_IP_CMD_GET_PARAM_CNF_Ttag
{
TLR_UINT32 ulMode;
union
{
struct
{
TLR_UINT32 ulIpAddr;
TLR_UINT8 abEthernetAddr[6];
} tArpEntry;
TLR_CHAR szDomainName[TCP_MAX_DOMAIN_NAME];
TLR_CHAR szHostName[TCP_MAX_HOST_NAME];
} unParam;
} TCPIP_DATA_IP_CMD_GET_PARAM_CNF_T;
#define TCPIP_DATA_IP_CMD_GET_PARAM_CNF_SIZE_GET_ARP_ENTRY_INDEX \
(sizeof(TLR_UINT32) + 10 /*sizeof(tArpEntry)*/)
#define TCPIP_DATA_IP_CMD_GET_PARAM_CNF_SIZE_GET_ARP_ENTRY_IP \
(sizeof(TLR_UINT32) + 10 /*sizeof(tArpEntry)*/)
#define TCPIP_DATA_IP_CMD_GET_PARAM_CNF_SIZE_GET_ARP_ENTRY_MAC \
(sizeof(TLR_UINT32) + 10 /*sizeof(tArpEntry)*/)
} TCPIP_PACKET_IP_CMD_GET_PARAM_CNF_T;
Packet description
The structure of parameter result data unParam (union in the Packet structure) depends on the
Mode parameter ulMode:
Mode ulMode Description union element of ulLen *
unParam
IP_PRM_GET_ARP_ENT Entry from ARP cache tArpEntry TCPIP_DATA_
RY_INDEX IP_CMD_GET_PARAM_CNF_SIZE_
(1) GET_ARP_ENTRY_INDEX (14)
IP_PRM_GET_ Entry from ARP cache tArpEntry TCPIP_DATA_
ARP_ENTRY_IP IP_CMD_GET_PARAM_CNF_SIZE_
(2) GET_ARP_ENTRY_IP (14)
IP_PRM_GET_ Entry from ARP cache tArpEntry TCPIP_DATA_
ARP_ENTRY_MAC IP_CMD_GET_PARAM_CNF_SIZE_
(3) GET_ARP_ENTRY_MAC (14)
IP_PRM_GET_ host name abHostName 4 + host name length
HOST_NAME
(10)
IP_PRM_GET_ domain name abDomainName 4 + domain name length
DOMAIN_NAME
(11)
Table 37: TCPIP_IP_CMD_GET_PARAM_CNF – Mode description for parameter data unParam
Union unParam
Structure tArpEntry
LIB_MEMCPY( &ptRsc->tLoc.abEthernetAddr[0],
&ptPck->tData.unParam.tArpEntry.abEthernetAddr[0],
sizeof( ptPck->tData.unParam.tArpEntry.abEthernetAddr ) );
}
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Note: In general, the binding to a port number can be accomplished as described below at
parameter ulPort in Table 40: TCPIP_TCP_UDP_CMD_OPEN_REQ – Request
command for opening a . However, the usage of TCP port addresses within the
firmware can be restricted to a specific range of available port addresses (such as
1024…2048, for instance) by the "Ethernet Interface TCP Port Numbers" tag list entry.
If this entry has been applied to the firmware file using the tag list editor, only the
restricted range of port addresses is applicable.
With this command the AP-task and the TCP_UDP-task have to exchange their End Point Identifier
of this socket connection that shall be established between both. The End Point Identifier is a 32-
Bit value specified by each process in order to associate incoming and address outgoing packets
to the right Communication End Point. The End Point Identifier of the TCP_UDP-task is used as
socket handle in the socket-based communication. The symbolic name for this socket handle for
the following TCPIP_TCP/UDP_xx commands is ulSocket.
The AP-task has to specify its End Point Identifier in the ulSrcId of the initializing
TCPIP_TCP_UDP_CMD_OPEN request packet. In the event of a successful Initialization, the
TCP_UDP-task uses this specified value in the ulSrcId variable of each Confirmation Packet and
in the ulDestId variable for Indication Packets (for example receive data indication command
TCPIP_TCP_UDP_CMD_RECEIVE) sent to the AP-task context from now on. This covers all
following socket-based packets (TCPIP_TCP/UDP_xx).
The TCP_UDP-task returns its End Pointer Reference (socket handle ulSocket) in ulDestId of
the Confirmation Packet of the TCPIP_TCP_UDP_CMD_OPEN packet. The AP-task has to use this
back coming value as ulDestId value from now on in all request and response
TCPIP_TCP/UDP_xx packets that are sent to the TCP_UDP-task context.
Using the Macro TLS_QUE_SENDPACKET_FIFO() will send the packet to the TCP_UDP-task
Process Queue.
When working with an UDP socket the application can start sending data right away
(TCPIP_UDP_CMD_SEND), once the socket is successfully opened. Some more steps are required
for TCP sockets: A connection must be established using either the
TCPIP_TCP_CMD_WAIT_CONNECT or TCPIP_TCP_CMD_CONNECT command before being able
transfer data.
Packet structure
/* Protocol types of packet ulProtocol variable */
#define TCP_PROTO_TCP (1)
#define TCP_PROTO_UDP (2)
} TCPIP_DATA_TCP_UDP_CMD_OPEN_REQ_T;
#define TCPIP_DATA_TCP_UDP_CMD_OPEN_REQ_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_OPEN_REQ_T))
} TCPIP_PACKET_TCP_UDP_CMD_OPEN_REQ_T;
Packet description
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for request packet.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 12 TCPIP_DATA_TCP_UDP_CMD_OPEN_REQ_SIZE - Packet data
length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLR_RESULT
ApTcpUdpCmdOpenReq( TCPIP_AP_TASK_RSC_T FAR* ptRsc )
{
TCPIP_PACKET_TCP_UDP_CMD_OPEN_REQ_T* ptPck;
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
ptPck->tHead.ulLen = TCPIP_DATA_TCP_UDP_CMD_OPEN_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_TCP_UDP_CMD_OPEN_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulIpAddr = 0;
/* 0 = Bind socket to currently configured IP */
/* address */
ptPck->tData.ulPort = LOCAL_PORT; /* 2 ... 65534 = Bind socket to */
/* specified port */
#if defined( TCP_CLIENT ) || defined( TCP_SERVER )
ptPck->tData.ulProtocol = TCP_PROTO_TCP;
#else
ptPck->tData.ulProtocol = TCP_PROTO_UDP;
#endif
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_OPEN_CNF_Ttag
{
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulPort;
TLR_UINT32 ulProtocol;
} TCPIP_DATA_TCP_UDP_CMD_OPEN_CNF_T;
#define TCPIP_DATA_TCP_UDP_CMD_OPEN_CNF_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_OPEN_CNF_T))
} TCPIP_PACKET_TCP_UDP_CMD_OPEN_CNF_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, socket handle ulSocket
ulPort UINT32 2 ... 65534 Local port number actually assigned to this socket
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
UDP sockets will always be closed immediately. The timeout value must be set to zero
in this case.
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_CLOSE_REQ_Ttag
{
TLR_UINT32 ulTimeout;
} TCPIP_DATA_TCP_UDP_CMD_CLOSE_REQ_T;
#define TCPIP_DATA_TCP_UDP_CMD_CLOSE_REQ_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_CLOSE_REQ_T))
} TCPIP_PACKET_TCP_UDP_CMD_CLOSE_REQ_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to the socket handle
ulSocket for request packet (Socket handle to close).
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 4 TCPIP_DATA_TCP_UDP_CMD_CLOSE_REQ_SIZE - Packet data
length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
ptPck->tHead.ulLen = TCPIP_DATA_TCP_UDP_CMD_CLOSE_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_TCP_UDP_CMD_CLOSE_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_PACKET_TCP_UDP_CMD_CLOSE_CNF_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_TCP_UDP_CMD_CLOSE_CNF_T;
Packet description
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_CLOSE_ALL_REQ_Ttag
{
TLR_UINT32 ulTimeout;
} TCPIP_DATA_TCP_UDP_CMD_CLOSE_ALL_REQ_T;
#define TCPIP_DATA_TCP_UDP_CMD_CLOSE_ALL_REQ_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_CLOSE_ALL_REQ_T))
} TCPIP_PACKET_TCP_UDP_CMD_CLOSE_ALL_REQ_T;
Packet description
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for request packet,
means close all sockets.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 4 TCPIP_DATA_TCP_UDP_CMD_CLOSE_ALL_REQ_SIZE - Packet
data length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
ptPck->tHead.ulLen = TCPIP_DATA_TCP_UDP_CMD_CLOSE_ALL_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_TCP_UDP_CMD_CLOSE_ALL_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_PACKET_TCP_UDP_CMD_CLOSE_ALL_CNF_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_TCP_UDP_CMD_CLOSE_ALL_CNF_T;
Packet description
Note: The confirmation command returns the result code from the last socket closed in its
status field ulSta. Error codes of
TLR_E_TCP_ERR_TIMEOUT_TCP_UDP_CMD_CLOSE_ALL (TCP Close timeout
expired), TLR_E_TCP_ERR_DEST_UNREACHABLE_TCP_UDP_CMD_CLOSE_ALL
(Destination is unreachable), and TLR_E_TCP_ERR_CONN_RESET (Connection reset)
rather should be treated as a notification code, because all sockets were closed in
these cases, too. However, if one of the other error codes is returned, the command
was rejected immediately and the socket’s state is not affected.
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
typedef struct TCPIP_DATA_TCP_CMD_WAIT_CONNECT_REQ_Ttag
{
TLR_UINT32 ulTimeoutSend;
TLR_UINT32 ulTimeoutListen;
} TCPIP_DATA_TCP_CMD_WAIT_CONNECT_REQ_T;
#define TCPIP_DATA_TCP_CMD_WAIT_CONNECT_REQ_SIZE \
(sizeof(TCPIP_DATA_TCP_CMD_WAIT_CONNECT_REQ_T))
} TCPIP_PACKET_TCP_CMD_WAIT_CONNECT_REQ_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to the socket handle
ulSocket for request packet (Handle of socket to connect).
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 8 TCPIP_DATA_TCP_CMD_WAIT_CONNECT_REQ_SIZE - Packet
data length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
ptPck->tHead.ulLen = TCPIP_DATA_TCP_CMD_WAIT_CONNECT_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_TCP_CMD_WAIT_CONNECT_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_TCP_CMD_WAIT_CONNECT_CNF_Ttag
{
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulPort;
} TCPIP_DATA_TCP_CMD_WAIT_CONNECT_CNF_T;
#define TCPIP_DATA_TCP_CMD_WAIT_CONNECT_CNF_SIZE \
(sizeof(TCPIP_DATA_TCP_CMD_WAIT_CONNECT_CNF_T))
} TCPIP_PACKET_TCP_CMD_WAIT_CONNECT_CNF_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, untouched (Handle of socket for the
incoming connection)
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, untouched
Table 47: TCPIP_TCP_CMD_WAIT_CONNECT_CNF – Confirmation command for waiting for an Incoming TCP connection
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
typedef struct TCPIP_DATA_TCP_CMD_CONNECT_REQ_Ttag
{
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulPort;
TLR_UINT32 ulTimeoutSend;
TLR_UINT32 ulTimeoutConnect;
} TCPIP_DATA_TCP_CMD_CONNECT_REQ_T;
#define TCPIP_DATA_TCP_CMD_CONNECT_REQ_SIZE \
(sizeof(TCPIP_DATA_TCP_CMD_CONNECT_REQ_T))
} TCPIP_PACKET_TCP_CMD_CONNECT_REQ_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to the socket handle
ulSocket for request packet (Handle of socket to connect to).
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 16 TCPIP_DATA_TCP_CMD_CONNECT_REQ_SIZE - Packet data
length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLR_RESULT
ApTcpCmdConnectReq( TCPIP_AP_TASK_RSC_T FAR* ptRsc )
{
TCPIP_PACKET_TCP_CMD_CONNECT_REQ_T* ptPck;
ptPck->tHead.ulLen = TCPIP_DATA_TCP_CMD_CONNECT_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_TCP_CMD_CONNECT_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulIpAddr = REMOTE_IP_ADDR;
ptPck->tData.ulPort = REMOTE_PORT;
ptPck->tData.ulTimeoutSend = 0; /* 0 = Default timeout (31 s) */
ptPck->tData.ulTimeoutConnect = 0; /* 0 = Default timeout (31 s) */
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_TCP_CMD_CONNECT_CNF_Ttag
{
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulPort;
} TCPIP_DATA_TCP_CMD_CONNECT_CNF_T;
#define TCPIP_DATA_TCP_CMD_CONNECT_CNF_SIZE \
(sizeof(TCPIP_DATA_TCP_CMD_CONNECT_CNF_T))
} TCPIP_PACKET_TCP_CMD_CONNECT_CNF_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, untouched (Handle of socket for the
incoming connection)
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, untouched
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Note: The application must not wait for the TCPIP_TCP_CMD_SEND confirmation command to
send the next TCPIP_TCP_CMD_SEND request command. The stack can buffer up to
ulQueFreeElemCnt (Startup parameter, Default =
TCPIP_SRT_QUE_FREE_ELEM_CNT_DEFAULT = 128) application request commands
(over all sockets!). In this case, the stack sent the data depending on the actual window
size of the remote TCP/IP stack in a more efficient way.
The stack starts to send the accumulated data, as soon as a full size TCP segment can be
assembled. The stack sends the data immediately, if the push flag TCP_SEND_OPT_PUSH in the
options field ulOptions is set.
Packet structure
/* Options of packet ulOptions variable */
#define TCP_SEND_OPT_PUSH (0x00000001)
} TCPIP_DATA_TCP_CMD_SEND_REQ_T;
} TCPIP_PACKET_TCP_CMD_SEND_REQ_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to the socket handle
ulSocket for request packet.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 4+n TCPIP_DATA_TCP_CMD_SEND_REQ_SIZE + n - Packet data length
in bytes
n is the Application data count of abData[1460] in bytes
n = 1 … TCPIP_MAX_TCP_DATA_CNT (1460)
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
#ifdef SET_TEST_DATA
for( uiIdx = 0; uiIdx < uiSendLen; uiIdx++ )
{
((TCPIP_PACKET_TCP_CMD_SEND_REQ_T*) ptPck)->tData.abData[uiIdx] \
= ptRsc->tLoc.bTestSndData++;
}
#endif /* #ifdef SET_TEST_DATA */
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_PACKET_TCP_CMD_SEND_CNF_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_TCP_CMD_SEND_CNF_T;
Packet description
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Note: Please note the following limitations, when sending UDP data: Up to
TCPIP_MAX_UDP_DATA_CNT (1472) bytes can be sent per UDP packet.
Packet structure
typedef struct TCPIP_DATA_UDP_CMD_SEND_REQ_Ttag
{
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulPort;
TLR_UINT32 ulOptions;
TLR_UINT8 abData[TCPIP_MAX_UDP_DATA_CNT];
} TCPIP_DATA_UDP_CMD_SEND_REQ_T;
} TCPIP_PACKET_UDP_CMD_SEND_REQ_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to the socket handle
ulSocket for request packet.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 12 + n TCPIP_DATA_UDP_CMD_SEND_REQ_SIZE + n - Packet data length
in bytes
n is the Application data count of abData[1472] in bytes
n = 1 … TCPIP_MAX_UDP_DATA_CNT (1472)
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLR_RESULT
ApUdpCmdSendReq( TCPIP_AP_TASK_RSC_T FAR* ptRsc,
TLR_UINT uiSendLen )
{
TCPIP_PACKET_UDP_CMD_SEND_REQ_T* ptPck;
TLR_UINT uiIdx; /* Data index */
ptPck->tData.ulIpAddr = REMOTE_IP_ADDR;
ptPck->tData.ulPort = REMOTE_PORT;
ptPck->tData.ulOptions = 0;
for( uiIdx = 0; uiIdx < uiSendLen; uiIdx++ ) /* Set test data also without def
{
((TCPIP_PACKET_UDP_CMD_SEND_REQ_T*) ptPck)->tData.abData[uiIdx] \
= ptRsc->tLoc.bTestSndData++;
}
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_PACKET_UDP_CMD_SEND_CNF_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_UDP_CMD_SEND_CNF_T;
Packet description
Note: A confirmation command reporting no error does not guarantee that the data was
successfully received by the communication partner.
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_REQ_Ttag
{
TLR_UINT32 ulMode;
union
{
TLR_UINT32 ulTtl;
TLR_UINT32 ulTimeoutSend;
TLR_UINT32 ulTimeoutInactive;
TLR_UINT32 ulTimeoutKeepAlive;
TLR_UINT32 ulMulticastGroup;
TLR_UINT32 ulMulticastTtl;
TLR_UINT32 ulMulticastLoop;
TLR_UINT32 ulTos;
struct
{
TLR_UINT8 bEnable;
TLR_UINT16 usId;
TLR_UINT8 bPriority;
}tVlanTag;
} unParam;
} TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_REQ_T;
#define TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_REQ_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_REQ_T))
} TCPIP_PACKET_TCP_UDP_CMD_SET_SOCK_OPTION_REQ_T;
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to the socket handle
ulSocket for request packet.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 8 TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_REQ_SIZE -
Packet data length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
ptPck->tHead.ulLen = TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_TCP_UDP_CMD_SET_SOCK_OPTION_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulMode = TCP_SOCK_SEND_TIMEOUT;
ptPck->tData.unParam.ulTimeoutSend = 10000; /* 10 s */
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_CNF_Ttag
{
TLR_UINT32 ulMode;
} TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_CNF_T;
#define TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_CNF_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_SET_SOCK_OPTION_CNF_T))
} TCPIP_PACKET_TCP_UDP_CMD_SET_SOCK_OPTION_CNF_T;
Packet description
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_REQ_Ttag
{
TLR_UINT32 ulMode;
} TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_REQ_T;
#define TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_REQ_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_REQ_T))
Packet description
ulDestId UINT32 1 ... 256 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to the socket handle
ulSocket for request packet.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 4 TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_REQ_SIZE -
Packet data length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
ptPck->tHead.ulLen = TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_TCP_UDP_CMD_GET_SOCK_OPTION_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulMode = TCP_SOCK_SEND_TIMEOUT;
if( TLS_QUE_SENDPACKET_FIFO( ptRsc->tRem.tQueTcpTask,
ptPck,
100 ) != TLR_S_OK )
{
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool, ptPck );
return( TLR_E_FAIL );
}
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_CNF_Ttag
{
TLR_UINT32 ulMode;
union
{
TLR_UINT32 ulTtl;
TLR_UINT32 ulTimeoutSend;
TLR_UINT32 ulProtocol;
TLR_UINT32 ulPort;
TLR_UINT32 ulTimeoutInactive;
TLR_UINT32 ulTimeoutKeepAlive;
TLR_UINT32 ulMulticastTtl;
TLR_UINT32 ulMulticastLoop;
TLR_UINT32 ulTos;
} unParam;
} TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_CNF_T;
#define TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_CNF_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_CNF_T))
typedef struct TCPIP_PACKET_TCP_UDP_CMD_GET_SOCK_OPTION_CNF_Ttag
{
TLR_PACKET_HEADER_T tHead;
TCPIP_DATA_TCP_UDP_CMD_GET_SOCK_OPTION_CNF_T tData;
} TCPIP_PACKET_TCP_UDP_CMD_GET_SOCK_OPTION_CNF_T;
Packet description
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
/* Options of packet ulOptions variable */
#define TCP_RECV_OPT_BROADCAST (0x00000001)
#define TCP_RECV_OPT_MULTICAST (0x00000002)
} TCPIP_DATA_TCP_UDP_CMD_RECEIVE_IND_T;
#define TCPIP_DATA_TCP_UDP_CMD_RECEIVE_IND_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_RECEIVE_IND_T) \
- TCPIP_MAX_TCP_UDP_DATA_CNT )
} TCPIP_PACKET_TCP_UDP_CMD_RECEIVE_IND_T;
Packet description
ulDestId UINT32 0 ... 232 -1 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process.
ulSrcId UINT32 1 ... 256 Source End Point Identifier, specifying the origin of the packet inside
the Source Process. Socket handle ulSocket of the receiving socket.
ulLen UINT32 12 + n TCPIP_DATA_TCP_UDP_CMD_RECEIVE_IND_SIZE + n - Packet
data length in bytes
n is the Application data count of abData[1472] in bytes
n = 1 … TCPIP_MAX_TCP_UDP_DATA_CNT (1472)
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
Table 63: TCPIP_TCP_UDP_CMD_RECEIVE_IND – Indication command for receiving TCP data and UDP data
ptRsc->tLoc.uiReceiveBufferLen = (ptPck->tHead.ulLen - \
TCPIP_DATA_TCP_UDP_CMD_RECEIVE_IND_SIZE);
}
/* else: Wrong socket handle */
TLS_QUE_RETURNPACKET( ptPck );
/* TLS_QUE_RETURNPACKET( ptPck ); */
return( eRslt );
}
Packet structure
typedef struct TCPIP_PACKET_TCP_UDP_CMD_SHUTDOWN_IND_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_TCP_UDP_CMD_SHUTDOWN_IND_T;
Packet description
ulDestId UINT32 0 ... 232 -1 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process.
ulSrcId UINT32 0 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 0 Packet data length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
return( eRslt );
}
Note:
However, the socket is not automatically closed after receiving this indication. Therefore, the
application has to take care that the socket is closed again.
For instance, if a TCP Client establishes a connection, transfers data and finally closes the
connection, the port will remain unreachable if the application does not react to this indication with
the sequence:
Packet structure
typedef struct TCPIP_DATA_TCP_UDP_CMD_RECEIVE_STOP_IND_Ttag
{
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulPort;
TLR_UINT32 ulOptions;
} TCPIP_DATA_TCP_UDP_CMD_RECEIVE_STOP_IND_T;
#define TCPIP_DATA_TCP_UDP_CMD_RECEIVE_STOP_IND_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_RECEIVE_STOP_IND_T))
} TCPIP_PACKET_TCP_UDP_CMD_RECEIVE_STOP_IND_T;
Packet description
ulDestId UINT32 0 ... 232 -1 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process.
ulSrcId UINT32 1 ... 256 Source End Point Identifier, specifying the origin of the packet inside
the Source Process. Socket handle ulSocket of the receiving socket.
ulLen UINT32 12 TCPIP_DATA_TCP_UDP_CMD_RECEIVE_STOP_IND_SIZE
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 See section Status/error codes (page 117).
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLS_QUE_RETURNPACKET( ptPck );
return( eRslt );
}
Packet structure
typedef struct TCPIP_DATA_IP_CMD_PING_REQ_Ttag
{
TLR_UINT32 ulIpAddr;
TLR_UINT32 ulTimeout;
} TCPIP_DATA_IP_CMD_PING_REQ_T;
#define TCPIP_DATA_IP_CMD_PING_REQ_SIZE (sizeof(TCPIP_DATA_IP_CMD_PING_REQ_T))
Packet description
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for TCPIP_IP_xx
packets.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 8 TCPIP_DATA_IP_CMD_PING_REQ_SIZE - Packet data length in
bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
TLR_RESULT
ApIpCmdPingReq( TCPIP_AP_TASK_RSC_T FAR* ptRsc )
{
TCPIP_PACKET_IP_CMD_PING_REQ_T* ptPck;
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
ptPck->tHead.ulLen = TCPIP_DATA_IP_CMD_PING_REQ_SIZE;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_IP_CMD_PING_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
ptPck->tData.ulIpAddr = REMOTE_IP_ADDR;
ptPck->tData.ulTimeout = 1000; /* 1 s */
return( TLR_S_OK );
}
Packet structure
typedef struct TCPIP_DATA_IP_CMD_PING_CNF_Ttag
{
TLR_UINT32 ulResponseTime;
} TCPIP_DATA_IP_CMD_PING_CNF_T;
} TCPIP_PACKET_IP_CMD_PING_CNF_T;
Packet description
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
Packet structure
typedef __TCPIP_PACKED_PRE struct TCPIP_DATA_IP_CMD_ICMP_IND_Ttag
{
TLR_UINT8 bType;
TLR_UINT8 bCode;
TLR_UINT16 usChecksum;
TLR_UINT8 abData[TCPIP_MAX_TCP_UDP_DATA_CNT];
} __TCPIP_PACKED_POST TCPIP_DATA_IP_CMD_ICMP_IND_T;
} TCPIP_PACKET_IP_CMD_ICMP_IND_T;
Packet description
ulDestId UINT32 0 ... 232 -1 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process.
ulSrcId UINT32 1 ... 256 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 4+n n is the Application data count of abData[1472] in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
usChecksum UINT16 This field contains error checking data calculated from the ICMP
header+data
abData[] UINT8[] Data of the ICMP request
Packet structure
/* Address conflict reasons */
#define TCPIP_ACD_CONFL_RSN_DEFAULT 1
#define TCPIP_ACD_CONFL_RSN_DEFENDED_IP 2
enum TCPIP_ACD_CONFLICT_EVENT_E
{
TCPIP_ACD_CONFLICT_EVENT_CONFLICT_OCCURRED = TCPIP_ACD_CONFL_RSN_DEFAULT,
TCPIP_ACD_CONFLICT_EVENT_ADDRESS_DEFENDED = TCPIP_ACD_CONFL_RSN_DEFENDED_IP,
TCPIP_ACD_CONFLICT_EVENT_CONFLICT_RESOLVED = TCPIP_ACD_CONFL_RSN_DEFENDED_IP + 1,
};
#define TCPIP_ACD_CONFLICT_STATE_PROBING 1
#define TCPIP_ACD_CONFLICT_STATE_ONGOING_DETECTION 2
#define TCPIP_ACD_CONFLICT_STATE_SEMI_ACTIVE 3
} TCPIP_ARP_PACKET;
#define TCPIP_DATA_TCP_UDP_CMD_ACD_CONFLICT_IND_SIZE \
(sizeof(TCPIP_DATA_TCP_UDP_CMD_ACD_CONFLICT_IND_T))
typedef struct TCPIP_PACKET_TCP_UDP_CMD_ACD_CONFLICT_IND_Ttag
{
TLR_PACKET_HEADER_T tHead;
TCPIP_DATA_TCP_UDP_CMD_ACD_CONFLICT_IND_T tData;
} TCPIP_PACKET_TCP_UDP_CMD_ACD_CONFLICT_IND_T;
Packet description
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulCmd UINT32 0x31A TCPIP_TCP_UDP_CMD_ACD_CONFLICT_IND - Command
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
2: TCPIP_ACD_CONFLICT_EVENT_ADDRESS_DEFENDED
Tcp stack defended its IP address (IP address is still in use).
3: TCPIP_ACD_CONFLICT_EVENT_CONFLICT_RESOLVED
The address conflict has been resolved.
bAcdActivity UINT8 1, 2, 3 1: TCPIP_ACD_CONFLICT_STATE_PROBING
Conflict occurred in state “Probing” (Active Phase)
2: TCPIP_ACD_CONFLICT_STATE_ONGOING_DETECTION
Conflict occurred in state “Ongoing Detection” (Passive Phase)
3: TCPIP_ACD_CONFLICT_STATE_SEMI_ACTIVE
Conflict occurred in state “Semi active probing” (Semi-active Phase)
tLastConflictArp Struct ARP packet from conflict partner
TCPIP_
ARP_P
ACKET
Table 71: TCPIP_TCP_UDP_CMD_ACD_CONFLICT_IND – Indication command for an address conflict
Structure TCPIP_ARP_PACKET
Packet structure
typedef struct TCPIP_PACKET_IP_CMD_GET_OPTIONS_REQ_Ttag
{
TLR_PACKET_HEADER_T tHead;
} TCPIP_PACKET_IP_CMD_GET_OPTIONS_REQ_T;
Packet description
ulDestId UINT32 0 Destination End Point Identifier, specifying the final receiver of the
packet within the Destination Process. Set to 0 for TCPIP_IP_xx
packets.
ulSrcId UINT32 0 ... 232 -1 Source End Point Identifier, specifying the origin of the packet inside
the Source Process.
ulLen UINT32 0 Packet data length in bytes
ulId UINT32 0 ... 232 -1 Packet identification as unique number generated by the source
process of the packet
ulSta UINT32 0x00000000 -
ulExt UINT32 0 Extension not in use, set to zero for compatibility reasons
ulRout UINT32 0 Routing not in use, set to zero for compatibility reasons
Table 73: TCPIP_IP_CMD_GET_OPTIONS_REQ – Request command for obtaining TCP/IP stack capabilities
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
TLS_QUE_LINK_SET_PACKET_SRC( ptPck, ptRsc->tLoc.tLnkSrc );
ptPck->tHead.ulLen = 0;
ptPck->tHead.ulId = ++ptRsc->tLoc.ulSndTcpId;
ptPck->tHead.ulSta = 0;
ptPck->tHead.ulCmd = TCPIP_IP_CMD_GET_OPTIONS_REQ;
ptPck->tHead.ulExt = 0;
ptPck->tHead.ulRout = 0;
return( TLR_S_OK );
}
Packet structure
/* Valid options of packet ulOptions variable */
#define IP_OPT_PROTO_TCP (0x00000001)
#define IP_OPT_PROTO_UDP (0x00000002)
#define IP_OPT_BOOTP (0x00000004)
#define IP_OPT_DHCP (0x00000008)
#define IP_OPT_MULTICAST (0x00000010)
} TCPIP_DATA_IP_CMD_GET_OPTIONS_CNF_T;
#define TCPIP_DATA_IP_CMD_GET_OPTIONS_CNF_SIZE \
(sizeof(TCPIP_DATA_IP_CMD_GET_OPTIONS_CNF_T))
} TCPIP_PACKET_IP_CMD_GET_OPTIONS_CNF_T;
Packet description
TLR_POOL_PACKET_RELEASE( ptRsc->tLoc.hPool,ptPck );
return( eRslt );
}
5 Special topics
5.1 TCP_UDP task
The TCP_UDP task is the main task of the TCP/IP stack. It is responsible for all application
interactions and represents the counterpart of the AP task within the existent TCP/IP stack
implementation.
To get the handle of the process queue of the TCP_UDP-task the macro TLS_QUE_IDENTIFY()
has to be used in conjunction with the following ASCII queue name.
ASCII queue name Description
"EN_TCPUDP_QUE" Name of the TCP_UDP task process queue
Table 76: TCP_UDP task process queue
The returned handle is a structure from type TLR_QUE_LINK_T and has to be used as queue
handle in conjunction with the macros like TLS_QUE_SENDPACKET_FIFO/LIFO() for sending a
packet to the TCP_UDP task. A source code example for understanding:
#define TCP_TASK_NAME "TCP_UDP"
#define EN_TCPUDP_PROCESS_QUEUE_NAME "EN_TCPUDP_QUE"
/* Task TCP_UDP */
eRslt = TLR_TSK_IDENTIFY( TCP_TASK_NAME, /* task name */
ptRsc->tLoc.uTskInst, /* task instance */
&ptRsc->tRem.hTskTcpTask, /* task handle */
&ptRsc->tRem.uToknTcpTask, /* task token */
&ptRsc->tRem.uPrioTcpTask ); /* task priority */
if( TLR_S_OK != eRslt )
{
return eRslt; /* Error */
}
TLS_QUE_LINK_SET_NEW_DESTID( ptRsc->tRem.tQueTcpTask, 0 );
/* ( tQueLink , ulDestId ) */
TLS_QUE_SENDPACKET_FIFO( ptRsc->tRem.tQueTcpTask,…
Remark: The macro TLS_QUE_LINK_SET_NEW_DESTID() set ulDestId for all further calls of
TLS_QUE_SENDPACKET_FIFO(). The parameter ulDestId is
0 for IP layer commands (TCPIP_IP_xx) and command
TCPIP_TCP_UDP_CMD_CLOSE_ALL_REQ
ulSocket (socket handle) for socket-based commands (TCPIP_TCP/UDP_xx). ulSocket is
the ulDestId parameter from confirmation command TCPIP_TCP_UDP_CMD_OPEN_CNF.
} TCPIP_TCP_TASK_STARTUPPARAMETER_T;
Note: The startup parameter ptEif is only for Hilscher internal use. Set it fix to NULL!
/* Modes (ulEifMode) */
/*#define TCPIP_SRT_EIF_MODE_PORT_FILTER (1) Only for V2.0.13.0!! */
#define TCPIP_SRT_EIF_MODE_PORT_FILTER_2 (2) /* V2.0.14.0 and newer. The */
/* new port filter mode is because of an incompatible change in struct */
/* TCPIP_TCP_TASK_SRT_EIF_T!! */
#define TCPIP_SRT_EIF_MODE_PORT_FILTER_3 (3) /* Same as */
/* TCPIP_SRT_EIF_MODE_PORT_FILTER_2, but netX stack process also ICMP and */
/* IGMP packets to the own IP address */
/* Flags (ulEifFlags) */
#define TCPIP_SRT_EIF_FLAG_EIF_REGISTER_RUN_TIME (0x00000001L) /* Activate */
/* run-time registration of Ethernet interface */
The following source code example from rcX configuration file (for example Config_netX.c)
show the use of the startup parameters.
6 Status/error codes
Values of ulSta.
7 Appendix
7.1 List of tables
Table 1: List of revisions...................................................................................................................................................... 4
Table 2: Technical data – TCP/IP ....................................................................................................................................... 6
Table 3: Terms, Abbreviations and Definitions .................................................................................................................... 7
Table 4: References to Documents ..................................................................................................................................... 7
Table 5: Start-up of the TCP/IP stack ................................................................................................................................ 18
Table 6 Events used in UDP socket statemachine............................................................................................................ 19
Table 7 Actions used in UDP socket statemachine ........................................................................................................... 19
Table 8 Events used in TCP socket statemachines .......................................................................................................... 21
Table 9 Actions used in TCP socket statemachines ......................................................................................................... 21
Table 10: Parameter ulFlags ......................................................................................................................................... 24
Table 11: TCPIP_IP_CMD_SET_CONFIG_REQ – Request command for providing configuration data ............................ 27
Table 12: TCPIP_IP_CMD_SET_CONFIG_CNF – Confirmation command for providing configuration data ..................... 29
Table 13: TCPIP_IP_CMD_GET_CONFIG_REQ – Request command for obtaining configuration data ............................ 30
Table 14: TCPIP_IP_CMD_GET_CONFIG_CNF – Confirmation command for obtaining configuration data ..................... 32
Table 15: TCPIP_IP_CMD_SET_PARAM_REQ – Request command for setting IP parameters ........................................ 36
Table 16: TCPIP_IP_CMD_SET_PARAM_REQ – Mode description for parameter data unParam ..................................... 37
Table 17: TCPIP_IP_CMD_SET_PARAM_REQ – Union unParam ..................................................................................... 38
Table 18: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tAddDelArpEntry of union unParam ...................................... 38
Table 19: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tDelArpEntryIp of union unParam ....................................... 38
Table 20: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tDelArpEntryMac of union unParam ..................................... 38
Table 21: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tSendArpReq of union unParam ............................................... 39
Table 22: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tSendArpTmtReq of union unParam ........................................ 39
Table 23: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tSetArpReqTmt of union unParam........................................... 39
Table 24: TCPIP_IP_CMD_SET_PARAM_REQ – Struct tRegisterIcmpService of union unParam............................ 39
Table 25: TCPIP_IP_CMD_SET_PARAM_CNF – Confirmation command for setting IP parameters ................................. 42
Table 26: TCPIP_IP_CMD_SET_PARAM_CNF – Mode Description for Parameter Data unParam ................................... 43
Table 27: TCPIP_IP_CMD_SET_PARAM_CNF – Union unParam ..................................................................................... 43
Table 28: TCPIP_IP_CMD_SET_PARAM_CNF – Struct tSendArpCnf of union unParam ............................................... 44
Table 29: TCPIP_IP_CMD_SET_PARAM_CNF – Struct tSendArpTmtCnf of union unParam ........................................ 44
Table 30: TCPIP_IP_CMD_GET_PARAM_REQ – Request command for obtaining IP parameters .................................... 46
Table 31: TCPIP_IP_CMD_GET_PARAM_REQ – Mode description for parameter data unParam ..................................... 47
Table 32: TCPIP_IP_CMD_GET_PARAM_REQ – Union unParam ..................................................................................... 47
Table 33: TCPIP_IP_CMD_GET_PARAM_REQ – Struct tArpEntryIndex of union unParam ........................................ 47
Table 34: TCPIP_IP_CMD_GET_PARAM_REQ – Struct tArpEntryIp of union unParam ............................................... 48
Table 35: TCPIP_IP_CMD_GET_PARAM_REQ – Struct tArpEntryMac of union unParam ............................................. 48
Table 36: TCPIP_IP_CMD_GET_PARAM_CNF – Confirmation Command for obtaining IP Parameters ............................ 50
Table 37: TCPIP_IP_CMD_GET_PARAM_CNF – Mode description for parameter data unParam ..................................... 50
Table 38: TCPIP_IP_CMD_GET_PARAM_CNF – Union unParam ..................................................................................... 51
Table 39: TCPIP_IP_CMD_GET_PARAM_CNF – Struct tArpEntry of union unParam ................................................... 51
Table 40: TCPIP_TCP_UDP_CMD_OPEN_REQ – Request command for opening a socket ............................................... 54
Table 41: TCPIP_TCP_UDP_CMD_OPEN_CNF – Confirmation command for opening a socket ........................................ 56
Table 42: TCPIP_TCP_UDP_CMD_CLOSE_REQ – Request command for closing a socket ............................................... 58
Table 43: TCPIP_TCP_UDP_CMD_CLOSE_CNF – Confirmation command for closing a socket ........................................ 60
Table 44: TCPIP_TCP_UDP_CMD_CLOSE_ALL_REQ – Request command for closing all sockets ................................... 62
Table 45: TCPIP_TCP_UDP_CMD_CLOSE_ALL_CNF – Confirmation command for closing all sockets ............................ 64
Table 46: TCPIP_TCP_CMD_WAIT_CONNECT_REQ – Request command for waiting for an incoming TCP connection ... 66
Table 47: TCPIP_TCP_CMD_WAIT_CONNECT_CNF – Confirmation command for waiting for an Incoming TCP connection
................................................................................................................................................................................. 68
Table 48: TCPIP_TCP_CMD_CONNECT_REQ – Request command for establishing a TCP connection ............................ 70
Table 49: TCPIP_TCP_CMD_CONNECT_CNF – Confirmation command for establishing a TCP connection ..................... 72
Table 50: TCPIP_TCP_CMD_SEND_REQ – Request command for sending TCP data ...................................................... 74
Table 51: TCPIP_TCP_CMD_SEND_REQ – TCP send options ulOptions ...................................................................... 74
Table 52: TCPIP_TCP_CMD_SEND_CNF – Confirmation command for sending TCP data ............................................... 76
Table 53: TCPIP_UDP_CMD_SEND_REQ – Request command for sending UDP data ...................................................... 78
Table 54: TCPIP_UDP_CMD_SEND_CNF – Confirmation command for sending UDP data ............................................... 80
Table 55: TCPIP_TCP_UDP_CMD_SET_SOCK_OPTION_REQ – Request command for setting socket options ................ 82
Table 56: TCPIP_TCP_UDP_CMD_SET_SOCK_OPTION_REQ – Socket option data unParam ......................................... 83
Table 57: TCPIP_TCP_UDP_CMD_SET_SOCK_OPTION_CNF – Confirmation command for setting socket options ......... 85
Table 58: TCPIP_TCP_UDP_CMD_SET_SOCK_OPTION_CNF – Parameter ulMode ........................................................ 86
Table 59: TCPIP_TCP_UDP_CMD_GET_SOCK_OPTION_REQ – Request command for obtaining socket options ............ 87
7.3 Contacts
Headquarters
Germany
Hilscher Gesellschaft für
Systemautomation mbH
Rheinstrasse 15
65795 Hattersheim
Phone: +49 (0) 6190 9907-0
Fax: +49 (0) 6190 9907-50
E-Mail: [email protected]
Support
Phone: +49 (0) 6190 9907-99
E-Mail: [email protected]
Subsidiaries
China Japan
Hilscher Systemautomation (Shanghai) Co. Ltd. Hilscher Japan KK
200010 Shanghai Tokyo, 160-0022
Phone: +86 (0) 21-6355-5161 Phone: +81 (0) 3-5362-0521
E-Mail: [email protected] E-Mail: [email protected]
Support Support
Phone: +86 (0) 21-6355-5161 Phone: +81 (0) 3-5362-0521
E-Mail: [email protected] E-Mail: [email protected]
France Korea
Hilscher France S.a.r.l. Hilscher Korea Inc.
69500 Bron Seongnam, Gyeonggi, 463-400
Phone: +33 (0) 4 72 37 98 40 Phone: +82 (0) 31-789-3715
E-Mail: [email protected] E-Mail: [email protected]
Support
Phone: +33 (0) 4 72 37 98 40 Switzerland
E-Mail: [email protected] Hilscher Swiss GmbH
4500 Solothurn
India Phone: +41 (0) 32 623 6633
Hilscher India Pvt. Ltd. E-Mail: [email protected]
Pune, Delhi, Mumbai Support
Phone: +91 8888 750 777 Phone: +49 (0) 6190 9907-99
E-Mail: [email protected] E-Mail: [email protected]
Italy USA
Hilscher Italia S.r.l. Hilscher North America, Inc.
20090 Vimodrone (MI) Lisle, IL 60532
Phone: +39 02 25007068 Phone: +1 630-505-5301
E-Mail: [email protected] E-Mail: [email protected]
Support Support
Phone: +39 02 25007068 Phone: +1 630-505-5301
E-Mail: [email protected] E-Mail: [email protected]