More work on IPStack, TCP and UDP slowly moving along
[tpg/acess2.git] / Modules / IPStack / tcp.h
1 /*
2  * Acess2 IP Stack
3  * - TCP Definitions
4  */
5 #ifndef _TCP_H_
6 #define _TCP_H_
7
8 #include "ipstack.h"
9
10 typedef struct sTCPHeader       tTCPHeader;
11 typedef struct sTCPListener     tTCPListener;
12 typedef struct sTCPConnection   tTCPConnection;
13
14 struct sTCPHeader
15 {
16         Uint16  SourcePort;
17         Uint16  DestPort;
18         Uint32  SequenceNumber;
19         Uint32  AcknowlegementNumber;
20         struct {
21                 unsigned DataOffset: 4; // Size of the header in 32-bit words
22                 unsigned Reserved:      4;
23         };
24         struct {
25                 unsigned CWR:   1;      // Congestion Window Reduced
26                 unsigned ECE:   1;      // ECN-Echo
27                 unsigned URG:   1;      // Urgent pointer is significant
28                 unsigned ACK:   1;      // Acknowlegement field is significant
29                 unsigned PSH:   1;      // Push Function
30                 unsigned RST:   1;      // Reset Connection
31                 unsigned SYN:   1;      // Synchronise Sequence Numbers
32                 unsigned FIN:   1;      // Last packet
33         } Flags;
34         Uint16  WindowSize;
35         
36         Uint16  Checksum;
37         Uint16  UrgentPointer;
38         
39         Uint8   Options[];
40 };
41
42 struct sTCPListener
43 {
44         struct sTCPListener     *Next;
45         Uint16  Port;
46         tInterface      *Interface;
47         tTCPConnection  *Connections;
48 };
49
50 struct sTCPConnection
51 {
52         struct sTCPConnection   *Next;
53          int    State;
54         Uint16  LocalPort;
55         Uint16  RemotePort;
56         tVFS_Node       Node;
57         
58         tInterface      *Interface;
59         union {
60                 tIPv4   v4;
61                 tIPv6   v6;
62         } RemoteIP;     // Type is determined by LocalInterface->Type
63 };
64
65 enum eTCPConnectionState
66 {
67         TCP_ST_CLOSED,
68         TCP_ST_HALFOPEN,
69         TCP_ST_OPEN
70 };
71
72 #endif

UCC git Repository :: git.ucc.asn.au