10 #include "NetTcpSocket.hpp"
11 #include "LibLinkedList.hpp"
12 #include "RtosSemaphore.hpp"
19 friend class NetTcpSocket;
22 const static int TIMER_SYN_SENT = 300;
23 const static int TIMER_SYN_RCVD = 300;
24 const static int TIMER_EST_KEEP_ALIVE = 1000;
25 const static int TIMER_SEGMENT_RETRY = 100;
26 const static int TIMER_SEGMENT_FLUSH = 10;
27 const static int TIMER_LAST_ACK = 100;
28 const static int TIMER_FIN_WAIT_1 = 100;
29 const static int TIMER_FIN_WAIT_2 = 100;
30 const static int TIMER_CLOSING = 100;
31 const static int TIMER_TIME_WAIT = 100;
33 const static int MAX_RETRIES_SYN_SENT = 3;
34 const static int MAX_RETRIES_SYN_RCVD = 3;
35 const static int MAX_RETRIES_EST_KEEP_ALIVE = 3;
36 const static int MAX_RETRIES_SEGMENT_RETRY = 5;
37 const static int MAX_RETRIES_LAST_ACK = 3;
38 const static int MAX_RETRIES_FIN_WAIT_1 = 5;
39 const static int MAX_RETRIES_FIN_WAIT_2 = 3;
40 const static int MAX_RETRIES_CLOSING = 3;
42 const static uint8_t OPTIONS_END_OF_LIST = 0x00;
43 const static uint8_t OPTIONS_NO_OP = 0x01;
44 const static uint8_t OPTIONS_MAX_SEG_SIZE = 0x02;
46 static void processFrame(NetDefs::FRAME& frame, NetDefs::TCP_HEADER& header,
int len);
47 static bool onSegmentReceived(NetDefs::FRAME& frame, NetDefs::TCP_HEADER& header, NetTcpSocket& s,
int len);
48 static void sendControlPacket(NetTcpSocket& s, uint8_t flags);
49 static void swapHeader(NetDefs::TCP_HEADER& header);
51 static void putHeader(NetDefs::FRAME& frame, NetTcpSocket& s, uint32_t seq, uint32_t checkSum,
int dataLen, uint8_t flags);
53 static LibLinkedList<NetTcpSocket> sSocketList;
56 static NetTcpSocket* findMatchingSocket(NetDefs::TCP_HEADER& header, NetDefs::IP_ADDR& remoteIpAddr);
59 static void addSocket(NetTcpSocket& socket);
60 static void removeSocket(NetTcpSocket& socket);
61 static void flushSegment(NetTcpSocket& s, NetTcpSocket::TX_SEGMENT& segment);
65 NetDefs::IP_ADDR remoteIpAddr;
68 NetTcpSocket::STATE state;
70 }__attribute__((packed)) SOCKET_INFO;
71 static
int getTcpSocketList(SOCKET_INFO* buffer,
int count);