XenevaOS
Loading...
Searching...
No Matches
tcp.h
Go to the documentation of this file.
1
30#ifndef __TCP_H__
31#define __TCP_H__
32
33#include <list.h>
34#include <Net/socket.h>
35#include <Net/ipv4.h>
36#include <Fs/vfs.h>
37
38#define TCP_FLAGS_FIN (1<<0)
39#define TCP_FLAGS_SYN (1<<1)
40#define TCP_FLAGS_RST (1<<2)
41#define TCP_FLAGS_PSH (1<<3)
42#define TCP_FLAGS_ACK (1<<4)
43#define TCP_FLAGS_URG (1<<5)
44#define TCP_FLAGS_ECE (1<<6)
45#define TCP_FLAGS_CWR (1<<7)
46#define TCP_FLAGS_NS (1<<8)
47#define TCP_DATA_OFFSET_5 (0x5 << 12)
48
49#define TCP_DEFAULT_WIN_SZ 65535
50
51#ifdef ARCH_X64
52#pragma pack(push,1)
53#endif
54typedef struct _tcphead_ {
55 unsigned short srcPort;
56 unsigned short destPort;
57 unsigned sequenceNum;
58 unsigned ackNum;
59 unsigned short dataOffsetFlags;
60 unsigned short window;
61 unsigned short checksum;
62 unsigned short urgentPointer;
64#ifdef ARCH_X64
65#pragma pack(pop)
66#endif
67
68/*
69* CreateTCPSocket -- creates a new TCP Socket
70*/
71extern int CreateTCPSocket();
72
73/*
74 * TCPGetSocketList -- return the current socket
75 * list of TCP
76 */
77extern list_t* TCPGetSocketList();
78
79/*
80 * AuTCPAcknowledge -- send ack packets
81 * @param nic -- Pointer to NIC device
82 * @param sock -- Pointer to session socket
83 * @param ippack -- Pointer to IPv4 packet
84 * @param payloadLen -- length of the payload
85*/
86extern int AuTCPAcknowledge(AuVFSNode* nic, AuSocket* sock, IPv4Header* ippack, size_t payloadLen);
87
88/*
89 * TCPProtocolInstall -- initialize the TCP protocol
90 */
91extern void TCPProtocolInstall();
92
93#endif
AuVFSNode * nic
Definition e1000.cpp:67
Definition vfs.h:98
Definition ipv4.h:36
Definition list.h:46
Definition socket.h:101
Definition tcp.h:54
unsigned short urgentPointer
Definition tcp.h:62
unsigned short window
Definition tcp.h:60
unsigned short srcPort
Definition tcp.h:55
unsigned short checksum
Definition tcp.h:61
unsigned short destPort
Definition tcp.h:56
unsigned ackNum
Definition tcp.h:58
unsigned sequenceNum
Definition tcp.h:57
unsigned short dataOffsetFlags
Definition tcp.h:59
struct _tcphead_ TCPHeader
int CreateTCPSocket()
Definition tcp.cpp:345
list_t * TCPGetSocketList()
Definition tcp.cpp:379
void TCPProtocolInstall()
Definition tcp.cpp:386
int AuTCPAcknowledge(AuVFSNode *nic, AuSocket *sock, IPv4Header *ippack, size_t payloadLen)
Definition tcp.cpp:161