socket.h
Go to the documentation of this file.
1 /**
2  * @file socket.h
3  * @brief Socket API
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.8
29  **/
30 
31 #ifndef _SOCKET_H
32 #define _SOCKET_H
33 
34 //Forward declaration of Socket structure
35 struct _Socket;
36 #define Socket struct _Socket
37 
38 //Dependencies
39 #include "core/net.h"
40 #include "core/ethernet.h"
41 #include "core/ip.h"
42 #include "core/tcp.h"
43 
44 //Number of sockets that can be opened simultaneously
45 #ifndef SOCKET_MAX_COUNT
46  #define SOCKET_MAX_COUNT 16
47 #elif (SOCKET_MAX_COUNT < 1)
48  #error SOCKET_MAX_COUNT parameter is not valid
49 #endif
50 
51 //Dynamic port range (lower limit)
52 #ifndef SOCKET_EPHEMERAL_PORT_MIN
53  #define SOCKET_EPHEMERAL_PORT_MIN 49152
54 #elif (SOCKET_EPHEMERAL_PORT_MIN < 1024)
55  #error SOCKET_EPHEMERAL_PORT_MIN parameter is not valid
56 #endif
57 
58 //Dynamic port range (upper limit)
59 #ifndef SOCKET_EPHEMERAL_PORT_MAX
60  #define SOCKET_EPHEMERAL_PORT_MAX 65535
61 #elif (SOCKET_EPHEMERAL_PORT_MAX <= SOCKET_EPHEMERAL_PORT_MIN || SOCKET_EPHEMERAL_PORT_MAX > 65535)
62  #error SOCKET_EPHEMERAL_PORT_MAX parameter is not valid
63 #endif
64 
65 //C++ guard
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 
71 /**
72  * @brief Socket types
73  **/
74 
75 typedef enum
76 {
82 } SocketType;
83 
84 
85 /**
86  * @brief IP protocols
87  **/
88 
89 typedef enum
90 {
97 
98 
99 /**
100  * @brief Ethernet protocols
101  **/
102 
103 typedef enum
104 {
111 
112 
113 /**
114  * @brief Flags used by I/O functions
115  **/
116 
117 typedef enum
118 {
128 } SocketFlags;
129 
130 
131 //The SOCKET_FLAG_BREAK macro causes the I/O functions to stop reading
132 //data whenever the specified break character is encountered
133 #define SOCKET_FLAG_BREAK(c) (SOCKET_FLAG_BREAK_CHAR | LSB(c))
134 
135 
136 /**
137  * @brief Flags used by shutdown function
138  **/
139 
140 typedef enum
141 {
146 
147 
148 /**
149  * @brief Socket events
150  **/
151 
152 typedef enum
153 {
165 } SocketEvent;
166 
167 
168 /**
169  * @brief Host types
170  **/
171 
172 typedef enum
173 {
177 } HostType;
178 
179 
180 /**
181  * @brief Name resolution protocols
182  **/
183 
184 typedef enum
185 {
192 
193 
194 /**
195  * @brief Message and ancillary data
196  **/
197 
198 typedef struct
199 {
200  void *data; ///<Pointer to the payload
201  size_t size; ///<Size of the payload, in bytes
202  size_t length; ///<Actual length of the payload, in bytes
203  uint8_t ttl; ///<Time-to-live value
204  IpAddr srcIpAddr; ///<Source IP address
205  uint16_t srcPort; ///<Source port
206  IpAddr destIpAddr; ///<Destination IP address
207  uint16_t destPort; ///<Destination port
208 #if (ETH_SUPPORT == ENABLED)
209  MacAddr srcMacAddr; ///<Source MAC address
210  MacAddr destMacAddr; ///<Destination MAC address
211 #endif
212 #if (ETH_PORT_TAGGING_SUPPORT == ENABLED)
213  uint8_t switchPort; ///<Switch port identifier
214 #endif
215 #if (ETH_TIMESTAMP_SUPPORT == ENABLED)
216  int32_t timestampId; ///<Unique identifier for hardware time stamping
217  NetTimestamp timestamp; ///<Captured time stamp
218 #endif
219 } SocketMsg;
220 
221 
222 /**
223  * @brief Receive queue item
224  **/
225 
226 typedef struct _SocketQueueItem
227 {
230  uint16_t srcPort;
233  size_t offset;
236 
237 
238 /**
239  * @brief Structure describing a socket
240  **/
241 
242 struct _Socket
243 {
249  uint16_t localPort;
251  uint16_t remotePort;
253  uint8_t ttl; ///<Time-to-live value for unicast datagrams
254  uint8_t multicastTtl; ///<Time-to-live value for multicast datagrams
255 #if (IP_DIFF_SERV_SUPPORT == ENABLED)
256  uint8_t dscp; ///<Differentiated services codepoint
257 #endif
258 #if (ETH_VLAN_SUPPORT == ENABLED)
259  int8_t vlanPcp; ///<VLAN priority (802.1Q)
260  int8_t vlanDei; ///<Drop eligible indicator
261 #endif
262 #if (ETH_VMAN_SUPPORT == ENABLED)
263  int8_t vmanPcp; ///<VMAN priority (802.1ad)
264  int8_t vmanDei; ///<Drop eligible indicator
265 #endif
271 
272 //TCP specific variables
273 #if (TCP_SUPPORT == ENABLED)
274  TcpState state; ///<Current state of the TCP finite state machine
275  bool_t ownedFlag; ///<The user is the owner of the TCP socket
276  bool_t closedFlag; ///<The connection has been closed properly
277  bool_t resetFlag; ///<The connection has been reset
278 
279  uint16_t smss; ///<Sender maximum segment size
280  uint16_t rmss; ///<Receiver maximum segment size
281  uint32_t iss; ///<Initial send sequence number
282  uint32_t irs; ///<Initial receive sequence number
283 
284  uint32_t sndUna; ///<Data that have been sent but not yet acknowledged
285  uint32_t sndNxt; ///<Sequence number of the next byte to be sent
286  uint16_t sndUser; ///<Amount of data buffered but not yet sent
287  uint16_t sndWnd; ///<Size of the send window
288  uint16_t maxSndWnd; ///<Maximum send window it has seen so far on the connection
289  uint32_t sndWl1; ///<Segment sequence number used for last window update
290  uint32_t sndWl2; ///<Segment acknowledgment number used for last window update
291 
292  uint32_t rcvNxt; ///<Receive next sequence number
293  uint16_t rcvUser; ///<Number of data received but not yet consumed
294  uint16_t rcvWnd; ///<Receive window
295 
296  bool_t rttBusy; ///<RTT measurement is being performed
297  uint32_t rttSeqNum; ///<Sequence number identifying a TCP segment
298  systime_t rttStartTime; ///<Round-trip start time
299  systime_t srtt; ///<Smoothed round-trip time
300  systime_t rttvar; ///<Round-trip time variation
301  systime_t rto; ///<Retransmission timeout
302 
303 #if (TCP_CONGEST_CONTROL_SUPPORT == ENABLED)
304  TcpCongestState congestState; ///<Congestion state
305  uint16_t cwnd; ///<Congestion window
306  uint16_t ssthresh; ///<Slow start threshold
307  uint_t dupAckCount; ///<Number of consecutive duplicate ACKs
308  uint_t n; ///<Number of bytes acknowledged during the whole round-trip
309  uint32_t recover; ///<NewReno modification to TCP's fast recovery algorithm
310 #endif
311 
312  TcpTxBuffer txBuffer; ///<Send buffer
313  size_t txBufferSize; ///<Size of the send buffer
314  TcpRxBuffer rxBuffer; ///<Receive buffer
315  size_t rxBufferSize; ///<Size of the receive buffer
316 
317  TcpQueueItem *retransmitQueue; ///<Retransmission queue
318  TcpTimer retransmitTimer; ///<Retransmission timer
319  uint_t retransmitCount; ///<Number of retransmissions
320 
321  TcpSynQueueItem *synQueue; ///<SYN queue for listening sockets
322  uint_t synQueueSize; ///<Maximum number of pending connections for listening sockets
323 
324  uint_t wndProbeCount; ///<Zero window probe counter
325  systime_t wndProbeInterval; ///<Interval between successive probes
326 
327  TcpTimer persistTimer; ///<Persist timer
328  TcpTimer overrideTimer; ///<Override timer
329  TcpTimer finWait2Timer; ///<FIN-WAIT-2 timer
330  TcpTimer timeWaitTimer; ///<2MSL timer
331 
332  bool_t sackPermitted; ///<SACK Permitted option received
333  TcpSackBlock sackBlock[TCP_MAX_SACK_BLOCKS]; ///<List of non-contiguous blocks that have been received
334  uint_t sackBlockCount; ///<Number of non-contiguous blocks that have been received
335 #endif
336 
337 //UDP specific variables
338 #if (UDP_SUPPORT == ENABLED || RAW_SOCKET_SUPPORT == ENABLED)
340 #endif
341 };
342 
343 
344 /**
345  * @brief Structure describing socket events
346  **/
347 
348 typedef struct
349 {
350  Socket *socket; ///<Handle to a socket to monitor
351  uint_t eventMask; ///<Requested events
352  uint_t eventFlags; ///<Returned events
354 
355 
356 //Global constants
357 extern const SocketMsg SOCKET_DEFAULT_MSG;
358 
359 //Global variables
361 
362 //Socket related functions
363 error_t socketInit(void);
364 
366 
368 
371 
372 error_t socketSetDscp(Socket *socket, uint8_t dscp);
373 
374 error_t socketSetVlanPcp(Socket *socket, uint8_t pcp);
376 error_t socketSetVmanPcp(Socket *socket, uint8_t pcp);
378 
381 
384 
385 error_t socketBind(Socket *socket, const IpAddr *localIpAddr, uint16_t localPort);
386 error_t socketConnect(Socket *socket, const IpAddr *remoteIpAddr, uint16_t remotePort);
388 Socket *socketAccept(Socket *socket, IpAddr *clientIpAddr, uint16_t *clientPort);
389 
390 error_t socketSend(Socket *socket, const void *data, size_t length,
391  size_t *written, uint_t flags);
392 
394  const void *data, size_t length, size_t *written, uint_t flags);
395 
397 
399  size_t size, size_t *received, uint_t flags);
400 
402  void *data, size_t size, size_t *received, uint_t flags);
403 
405  IpAddr *destIpAddr, void *data, size_t size, size_t *received, uint_t flags);
406 
408 
409 error_t socketGetLocalAddr(Socket *socket, IpAddr *localIpAddr, uint16_t *localPort);
410 error_t socketGetRemoteAddr(Socket *socket, IpAddr *remoteIpAddr, uint16_t *remotePort);
411 
413 void socketClose(Socket *socket);
414 
415 error_t socketPoll(SocketEventDesc *eventDesc, uint_t size, OsEvent *extEvent,
416  systime_t timeout);
417 
418 void socketRegisterEvents(Socket *socket, OsEvent *event, uint_t eventMask);
421 
423  const char_t *name, IpAddr *ipAddr, uint_t flags);
424 
425 //C++ guard
426 #ifdef __cplusplus
427 }
428 #endif
429 
430 #endif
SocketQueueItem * receiveQueue
Definition: socket.h:339
TcpTimer retransmitTimer
Retransmission timer.
Definition: socket.h:318
uint8_t length
Definition: coap_common.h:190
error_t socketConnect(Socket *socket, const IpAddr *remoteIpAddr, uint16_t remotePort)
Establish a connection to a specified socket.
Definition: socket.c:642
uint16_t maxSndWnd
Maximum send window it has seen so far on the connection.
Definition: socket.h:288
HostType
Host types.
Definition: socket.h:172
Retransmission queue item.
Definition: tcp.h:358
uint32_t sndNxt
Sequence number of the next byte to be sent.
Definition: socket.h:285
HostnameResolver
Name resolution protocols.
Definition: socket.h:184
int bool_t
Definition: compiler_port.h:49
error_t socketListen(Socket *socket, uint_t backlog)
Place a socket in the listening state.
Definition: socket.c:705
int8_t vmanPcp
VMAN priority (802.1ad)
Definition: socket.h:263
uint32_t rcvNxt
Receive next sequence number.
Definition: socket.h:292
uint8_t data[]
Definition: ethernet.h:209
signed int int_t
Definition: compiler_port.h:44
IP network address.
Definition: ip.h:78
uint16_t cwnd
Congestion window.
Definition: socket.h:305
TcpCongestState
TCP congestion states.
Definition: tcp.h:251
IpAddr remoteIpAddr
Definition: socket.h:250
uint8_t ttl
Time-to-live value for unicast datagrams.
Definition: socket.h:253
OsEvent * userEvent
Definition: socket.h:270
TcpTimer overrideTimer
Override timer.
Definition: socket.h:328
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
uint_t wndProbeCount
Zero window probe counter.
Definition: socket.h:324
Message and ancillary data.
Definition: socket.h:198
SocketIpProtocol
IP protocols.
Definition: socket.h:89
Event object.
__start_packed struct @5 MacAddr
MAC address.
uint16_t sndUser
Amount of data buffered but not yet sent.
Definition: socket.h:286
uint16_t srcPort
Definition: socket.h:230
error_t socketBind(Socket *socket, const IpAddr *localIpAddr, uint16_t localPort)
Associate a local address with a socket.
Definition: socket.c:616
uint32_t irs
Initial receive sequence number.
Definition: socket.h:282
OsEvent event
Definition: socket.h:267
uint_t type
Definition: socket.h:245
uint32_t sndWl2
Segment acknowledgment number used for last window update.
Definition: socket.h:290
void * data
Pointer to the payload.
Definition: socket.h:200
size_t txBufferSize
Size of the send buffer.
Definition: socket.h:313
IpAddr srcIpAddr
Definition: socket.h:229
uint_t eventFlags
Definition: socket.h:269
uint8_t multicastTtl
Time-to-live value for multicast datagrams.
Definition: socket.h:254
error_t socketSendMsg(Socket *socket, const SocketMsg *message, uint_t flags)
Send a message to a connectionless socket.
Definition: socket.c:892
uint16_t rmss
Receiver maximum segment size.
Definition: socket.h:280
char_t name[]
bool_t resetFlag
The connection has been reset.
Definition: socket.h:277
uint16_t destPort
Definition: tcp.h:303
NetTimestamp timestamp
Captured time stamp.
Definition: socket.h:217
uint32_t recover
NewReno modification to TCP's fast recovery algorithm.
Definition: socket.h:309
Ipv4Addr srcIpAddr
Definition: ipcp.h:77
uint_t socketGetEvents(Socket *socket)
Retrieve event flags for a specified socket.
Definition: socket.c:1479
struct _SocketQueueItem * next
Definition: socket.h:228
error_t socketSetTimeout(Socket *socket, systime_t timeout)
Set timeout value for blocking operations.
Definition: socket.c:256
systime_t srtt
Smoothed round-trip time.
Definition: socket.h:299
SocketType
Socket types.
Definition: socket.h:75
uint_t descriptor
Definition: socket.h:244
Structure describing socket events.
Definition: socket.h:348
void socketClose(Socket *socket)
Close an existing socket.
Definition: socket.c:1259
int8_t vlanPcp
VLAN priority (802.1Q)
Definition: socket.h:259
Ethernet.
uint8_t dscp
Differentiated services codepoint.
Definition: socket.h:256
void socketUnregisterEvents(Socket *socket)
Unsubscribe previously registered events.
Definition: socket.c:1456
error_t socketSetMulticastTtl(Socket *socket, uint8_t ttl)
Set TTL value for multicast datagrams.
Definition: socket.c:306
error_t socketSend(Socket *socket, const void *data, size_t length, size_t *written, uint_t flags)
Send data to a connected socket.
Definition: socket.c:775
TcpRxBuffer rxBuffer
Receive buffer.
Definition: socket.h:314
TcpCongestState congestState
Congestion state.
Definition: socket.h:304
uint16_t destPort
Destination port.
Definition: socket.h:207
#define TCP_MAX_SACK_BLOCKS
Definition: tcp.h:208
TcpTimer finWait2Timer
FIN-WAIT-2 timer.
Definition: socket.h:329
systime_t rto
Retransmission timeout.
Definition: socket.h:301
NetRxAncillary ancillary
Definition: socket.h:234
TcpState
TCP FSM states.
Definition: tcp.h:231
size_t length
Actual length of the payload, in bytes.
Definition: socket.h:202
error_t socketReceiveFrom(Socket *socket, IpAddr *srcIpAddr, uint16_t *srcPort, void *data, size_t size, size_t *received, uint_t flags)
Receive a datagram from a connectionless socket.
Definition: socket.c:972
TcpTimer timeWaitTimer
2MSL timer
Definition: socket.h:330
char_t type
Timestamp.
Definition: net_misc.h:97
error_t
Error codes.
Definition: error.h:42
const SocketMsg SOCKET_DEFAULT_MSG
Definition: socket.c:52
IpAddr localIpAddr
Definition: socket.h:248
uint8_t protocol
uint16_t rcvWnd
Receive window.
Definition: socket.h:294
uint16_t rcvUser
Number of data received but not yet consumed.
Definition: socket.h:293
struct _SocketQueueItem SocketQueueItem
Receive queue item.
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
Definition: bsd_socket.c:108
uint16_t remotePort
Definition: socket.h:251
uint16_t smss
Sender maximum segment size.
Definition: socket.h:279
NetInterface * socketGetInterface(Socket *socket)
Retrieve the underlying interface.
Definition: socket.c:593
SocketShutdownFlags
Flags used by shutdown function.
Definition: socket.h:140
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
IpAddr srcIpAddr
Source IP address.
Definition: socket.h:204
TcpTxBuffer txBuffer
Send buffer.
Definition: socket.h:312
Socket * socketAccept(Socket *socket, IpAddr *clientIpAddr, uint16_t *clientPort)
Permit an incoming connection attempt on a socket.
Definition: socket.c:742
uint16_t localPort
Definition: socket.h:249
uint8_t switchPort
Switch port identifier.
Definition: socket.h:213
error_t socketSetVmanPcp(Socket *socket, uint8_t pcp)
Set VMAN priority.
Definition: socket.c:435
int32_t timestampId
Unique identifier for hardware time stamping.
Definition: socket.h:216
IpAddr destIpAddr
Definition: socket.h:231
TcpTimer persistTimer
Persist timer.
Definition: socket.h:327
uint_t eventMask
Definition: socket.h:268
bool_t closedFlag
The connection has been closed properly.
Definition: socket.h:276
TcpSynQueueItem * synQueue
SYN queue for listening sockets.
Definition: socket.h:321
uint16_t ssthresh
Slow start threshold.
Definition: socket.h:306
uint_t eventFlags
Returned events.
Definition: socket.h:352
size_t rxBufferSize
Size of the receive buffer.
Definition: socket.h:315
uint_t retransmitCount
Number of retransmissions.
Definition: socket.h:319
error_t socketSetVmanDei(Socket *socket, bool_t dei)
Set VMAN DEI flag.
Definition: socket.c:472
MacAddr srcMacAddr
Source MAC address.
Definition: socket.h:209
error_t socketSetTxBufferSize(Socket *socket, size_t size)
Specify the size of the send buffer.
Definition: socket.c:505
uint_t dupAckCount
Number of consecutive duplicate ACKs.
Definition: socket.h:307
bool_t sackPermitted
SACK Permitted option received.
Definition: socket.h:332
Socket socketTable[SOCKET_MAX_COUNT]
Definition: socket.c:49
Receive queue item.
Definition: socket.h:226
uint32_t iss
Initial send sequence number.
Definition: socket.h:281
NetInterface * interface
Definition: socket.h:247
IpAddr destIpAddr
Destination IP address.
Definition: socket.h:206
uint8_t flags
Definition: tcp.h:314
SocketFlags
Flags used by I/O functions.
Definition: socket.h:117
error_t socketSetTtl(Socket *socket, uint8_t ttl)
Set TTL value for unicast datagrams.
Definition: socket.c:281
MacAddr destMacAddr
Destination MAC address.
Definition: socket.h:210
char char_t
Definition: compiler_port.h:43
error_t socketSetVlanDei(Socket *socket, bool_t dei)
Set VLAN DEI flag.
Definition: socket.c:402
error_t socketSendTo(Socket *socket, const IpAddr *destIpAddr, uint16_t destPort, const void *data, size_t length, size_t *written, uint_t flags)
Send a datagram to a specific destination.
Definition: socket.c:796
SACK block.
Definition: tcp.h:388
uint_t synQueueSize
Maximum number of pending connections for listening sockets.
Definition: socket.h:322
error_t socketSetVlanPcp(Socket *socket, uint8_t pcp)
Set VLAN priority.
Definition: socket.c:365
uint32_t sndWl1
Segment sequence number used for last window update.
Definition: socket.h:289
Socket * socketOpen(uint_t type, uint_t protocol)
Create a socket (UDP or TCP)
Definition: socket.c:119
bool_t rttBusy
RTT measurement is being performed.
Definition: socket.h:296
IPv4 and IPv6 common routines.
systime_t wndProbeInterval
Interval between successive probes.
Definition: socket.h:325
int8_t vlanDei
Drop eligible indicator.
Definition: socket.h:260
TCP (Transmission Control Protocol)
error_t socketReceive(Socket *socket, void *data, size_t size, size_t *received, uint_t flags)
Receive data from a connected socket.
Definition: socket.c:950
error_t socketPoll(SocketEventDesc *eventDesc, uint_t size, OsEvent *extEvent, systime_t timeout)
Wait for one of a set of sockets to become ready to perform I/O.
Definition: socket.c:1319
#define Socket
Definition: socket.h:36
TCP timer.
Definition: tcp.h:346
error_t socketGetRemoteAddr(Socket *socket, IpAddr *remoteIpAddr, uint16_t *remotePort)
Retrieve the address of the peer to which a socket is connected.
Definition: socket.c:1192
uint8_t message[]
Definition: chap.h:152
int8_t vmanDei
Drop eligible indicator.
Definition: socket.h:264
size_t size
Size of the payload, in bytes.
Definition: socket.h:201
void socketRegisterEvents(Socket *socket, OsEvent *event, uint_t eventMask)
Subscribe to the specified socket events.
Definition: socket.c:1405
uint16_t sndWnd
Size of the send window.
Definition: socket.h:287
error_t socketReceiveMsg(Socket *socket, SocketMsg *message, uint_t flags)
Receive a message from a connectionless socket.
Definition: socket.c:1106
SYN queue item.
Definition: tcp.h:372
error_t socketSetInterface(Socket *socket, NetInterface *interface)
Bind a socket to a particular network interface.
Definition: socket.c:573
uint32_t sndUna
Data that have been sent but not yet acknowledged.
Definition: socket.h:284
error_t socketInit(void)
Socket related initialization.
Definition: socket.c:81
TcpSackBlock sackBlock[TCP_MAX_SACK_BLOCKS]
List of non-contiguous blocks that have been received.
Definition: socket.h:333
uint_t protocol
Definition: socket.h:246
error_t socketShutdown(Socket *socket, uint_t how)
Disable reception, transmission, or both.
Definition: socket.c:1222
systime_t timeout
Definition: socket.h:252
error_t socketSetRxBufferSize(Socket *socket, size_t size)
Specify the size of the receive buffer.
Definition: socket.c:539
bool_t ownedFlag
The user is the owner of the TCP socket.
Definition: socket.h:275
error_t socketGetLocalAddr(Socket *socket, IpAddr *localIpAddr, uint16_t *localPort)
Retrieve the local address for a given socket.
Definition: socket.c:1165
uint32_t ttl
Definition: dns_common.h:205
Structure describing a socket.
Definition: socket.h:242
uint16_t srcPort
Definition: tcp.h:302
Socket * socket
Handle to a socket to monitor.
Definition: socket.h:350
SocketEthProtocol
Ethernet protocols.
Definition: socket.h:103
Receive buffer.
Definition: tcp.h:411
TcpQueueItem * retransmitQueue
Retransmission queue.
Definition: socket.h:317
Transmit buffer.
Definition: tcp.h:399
unsigned int uint_t
Definition: compiler_port.h:45
systime_t rttvar
Round-trip time variation.
Definition: socket.h:300
TCP/IP stack core.
TcpState state
Current state of the TCP finite state machine.
Definition: socket.h:274
uint_t sackBlockCount
Number of non-contiguous blocks that have been received.
Definition: socket.h:334
uint8_t ttl
Time-to-live value.
Definition: socket.h:203
#define SOCKET_MAX_COUNT
Definition: socket.h:46
systime_t rttStartTime
Round-trip start time.
Definition: socket.h:298
uint32_t rttSeqNum
Sequence number identifying a TCP segment.
Definition: socket.h:297
SocketEvent
Socket events.
Definition: socket.h:152
uint16_t srcPort
Source port.
Definition: socket.h:205
uint32_t systime_t
Definition: compiler_port.h:46
uint8_t ipAddr[4]
Definition: mib_common.h:187
uint_t n
Number of bytes acknowledged during the whole round-trip.
Definition: socket.h:308
NetBuffer * buffer
Definition: socket.h:232
uint_t eventMask
Requested events.
Definition: socket.h:351
error_t socketReceiveEx(Socket *socket, IpAddr *srcIpAddr, uint16_t *srcPort, IpAddr *destIpAddr, void *data, size_t size, size_t *received, uint_t flags)
Receive a datagram.
Definition: socket.c:994
int_t errnoCode
Definition: socket.h:266
size_t offset
Definition: socket.h:233
error_t socketSetDscp(Socket *socket, uint8_t dscp)
Set DSCP field.
Definition: socket.c:331
error_t getHostByName(NetInterface *interface, const char_t *name, IpAddr *ipAddr, uint_t flags)
Resolve a host name into an IP address.
Definition: socket.c:1515
Ipv4Addr destIpAddr
Definition: ipcp.h:78