mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-31 17:56:30 +00:00
170 lines
13 KiB
HTML
Executable file
170 lines
13 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V1.08">
|
|
<style type="text/css">
|
|
body {background-color:#1f1f1f;}
|
|
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
|
|
.cF1{color:#4f84a6;background-color:#1f1f1f;}
|
|
.cF2{color:#73a255;background-color:#1f1f1f;}
|
|
.cF3{color:#297582;background-color:#1f1f1f;}
|
|
.cF4{color:#b34f4b;background-color:#1f1f1f;}
|
|
.cF5{color:#8a52c3;background-color:#1f1f1f;}
|
|
.cF6{color:#b7822f;background-color:#1f1f1f;}
|
|
.cF7{color:#444444;background-color:#1f1f1f;}
|
|
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
|
|
.cF9{color:#94bfde;background-color:#1f1f1f;}
|
|
.cFA{color:#a1ce97;background-color:#1f1f1f;}
|
|
.cFB{color:#6db4be;background-color:#1f1f1f;}
|
|
.cFC{color:#e88e88;background-color:#1f1f1f;}
|
|
.cFD{color:#ca94e8;background-color:#1f1f1f;}
|
|
.cFE{color:#d4b475;background-color:#1f1f1f;}
|
|
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>define</span><span class=cF0> TCP_MAX_PORT </span><span class=cFE>65535</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_SRTT_ALPHA </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>9</span><span class=cF0>
|
|
<a name="l4"></a>
|
|
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_RTO_BETA </span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l6"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_RTO_MIN </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l7"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_RTO_MAX </span><span class=cFE>10</span><span class=cF0>
|
|
<a name="l8"></a>
|
|
<a name="l9"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_WINDOW_SIZE </span><span class=cFE>8192</span><span class=cF0>
|
|
<a name="l10"></a>
|
|
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_MSS </span><span class=cFE>536</span><span class=cF0> </span><span class=cF2>// Max Segment Size default</span><span class=cF0>
|
|
<a name="l12"></a>
|
|
<a name="l13"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_TIMEOUT </span><span class=cFE>5000</span><span class=cF0>
|
|
<a name="l14"></a>
|
|
<a name="l15"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_CLOSED </span><span class=cFE>0</span><span class=cF0>
|
|
<a name="l16"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_LISTEN </span><span class=cFE>1</span><span class=cF0>
|
|
<a name="l17"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_SYN_SENT </span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l18"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_SYN_RECEIVED </span><span class=cFE>3</span><span class=cF0>
|
|
<a name="l19"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_ESTABLISHED </span><span class=cFE>4</span><span class=cF0>
|
|
<a name="l20"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_FIN_WAIT1 </span><span class=cFE>5</span><span class=cF0>
|
|
<a name="l21"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_FIN_WAIT2 </span><span class=cFE>6</span><span class=cF0>
|
|
<a name="l22"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_CLOSE_WAIT </span><span class=cFE>7</span><span class=cF0>
|
|
<a name="l23"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_CLOSING </span><span class=cFE>8</span><span class=cF0>
|
|
<a name="l24"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_LAST_ACK </span><span class=cFE>9</span><span class=cF0>
|
|
<a name="l25"></a>#</span><span class=cF1>define</span><span class=cF0> TCP_STATE_TIME_WAIT </span><span class=cFE>10</span><span class=cF0>
|
|
<a name="l26"></a>
|
|
<a name="l27"></a></span><span class=cF2>// TCP header flags. Test with Bt(), e.g. Bt(&flags, TCPf_RST)</span><span class=cF0>
|
|
<a name="l28"></a>#</span><span class=cF1>define</span><span class=cF0> TCPf_FIN </span><span class=cFE>0</span><span class=cF0>
|
|
<a name="l29"></a>#</span><span class=cF1>define</span><span class=cF0> TCPf_SYN </span><span class=cFE>1</span><span class=cF0>
|
|
<a name="l30"></a>#</span><span class=cF1>define</span><span class=cF0> TCPf_RST </span><span class=cFE>2</span><span class=cF0>
|
|
<a name="l31"></a></span><span class=cF2>//#define TCPf_PSH</span><span class=cF0> </span><span class=cF2>3 // most stacks don't implement PUSH.</span><span class=cF0>
|
|
<a name="l32"></a>#</span><span class=cF1>define</span><span class=cF0> TCPf_ACK </span><span class=cFE>4</span><span class=cF0>
|
|
<a name="l33"></a></span><span class=cF2>//#define TCPf_URG</span><span class=cF0> </span><span class=cF2>5 // most stacks don't implement URGENT.</span><span class=cF0>
|
|
<a name="l34"></a>
|
|
<a name="l35"></a>#</span><span class=cF1>define</span><span class=cF0> TCPF_FIN (</span><span class=cFE>1</span><span class=cF0> << TCPf_FIN)
|
|
<a name="l36"></a>#</span><span class=cF1>define</span><span class=cF0> TCPF_SYN (</span><span class=cFE>1</span><span class=cF0> << TCPf_SYN)
|
|
<a name="l37"></a>#</span><span class=cF1>define</span><span class=cF0> TCPF_RST (</span><span class=cFE>1</span><span class=cF0> << TCPf_RST)
|
|
<a name="l38"></a></span><span class=cF2>//#define TCPF_PSH</span><span class=cF0> </span><span class=cF2>(1 << TCPf_PSH) // most stacks don't implement PUSH.</span><span class=cF0>
|
|
<a name="l39"></a>#</span><span class=cF1>define</span><span class=cF0> TCPF_ACK (</span><span class=cFE>1</span><span class=cF0> << TCPf_ACK)
|
|
<a name="l40"></a></span><span class=cF2>//#define TCPF_URG</span><span class=cF0> </span><span class=cF2>(1 << TCPf_URG) // most stacks don't implement URGENT.</span><span class=cF0>
|
|
<a name="l41"></a>
|
|
<a name="l42"></a>
|
|
<a name="l43"></a></span><span class=cF1>class</span><span class=cF0> CTCPAckQueue:</span><span class=cF9>CQueue</span><span class=cF0>
|
|
<a name="l44"></a>{
|
|
<a name="l45"></a> </span><span class=cF1>F64</span><span class=cF0> time_sent;
|
|
<a name="l46"></a> </span><span class=cF9>U32</span><span class=cF0> retries;
|
|
<a name="l47"></a> </span><span class=cF9>U32</span><span class=cF0> start_seq_num;
|
|
<a name="l48"></a> </span><span class=cF9>U32</span><span class=cF0> end_seq_num;
|
|
<a name="l49"></a>
|
|
<a name="l50"></a> </span><span class=cF9>U32</span><span class=cF0> tcp_packet_size; </span><span class=cF2>// Size of memory allocation of U8* tcp_packet.</span><span class=cF0>
|
|
<a name="l51"></a> </span><span class=cF1>U8</span><span class=cF0> *tcp_packet; </span><span class=cF2>// Memory location of entire TCP Header + Data Payload.</span><span class=cF0>
|
|
<a name="l52"></a>};
|
|
<a name="l53"></a>
|
|
<a name="l54"></a></span><span class=cF2>// stores packet data of incoming connect() requests,</span><span class=cF0>
|
|
<a name="l55"></a></span><span class=cF2>// local accept() will search queue for pending connections,</span><span class=cF0>
|
|
<a name="l56"></a></span><span class=cF2>// and use this data to send out notification connection was accepted.</span><span class=cF0>
|
|
<a name="l57"></a></span><span class=cF1>class</span><span class=cF0> CTCPAcceptQueue:</span><span class=cF9>CQueue</span><span class=cF0>
|
|
<a name="l58"></a>{
|
|
<a name="l59"></a> </span><span class=cF9>U32</span><span class=cF0> segment_seq_num;
|
|
<a name="l60"></a> </span><span class=cF9>U32</span><span class=cF0> ipv4_address;
|
|
<a name="l61"></a> </span><span class=cF9>U16</span><span class=cF0> port;
|
|
<a name="l62"></a>};
|
|
<a name="l63"></a>
|
|
<a name="l64"></a></span><span class=cF1>class</span><span class=cF0> CTCPSocket
|
|
<a name="l65"></a>{
|
|
<a name="l66"></a> CSocket *socket;
|
|
<a name="l67"></a> </span><span class=cF1>U8</span><span class=cF0> state;
|
|
<a name="l68"></a> </span><span class=cF9>U64</span><span class=cF0> timeout; </span><span class=cF2>// timeout for socket calls. Initialized 0: non-blocking.</span><span class=cF0>
|
|
<a name="l69"></a>
|
|
<a name="l70"></a> CSocketAddressStorage source_address; </span><span class=cF2>// based on ->family, cast or assign to a var as IPV4/IPV6 CSocketAddress</span><span class=cF0>
|
|
<a name="l71"></a> CSocketAddressStorage destination_address;
|
|
<a name="l72"></a>
|
|
<a name="l73"></a> CTCPAckQueue *ack_queue; </span><span class=cF2>// Sent TCP packets awaiting an ACK collect here to be retransmitted. CQueue head.</span><span class=cF0>
|
|
<a name="l74"></a>
|
|
<a name="l75"></a> </span><span class=cF9>U64</span><span class=cF0> accept_queue_limit;
|
|
<a name="l76"></a> CTCPAcceptQueue *accept_queue;
|
|
<a name="l77"></a>
|
|
<a name="l78"></a> </span><span class=cF9>U32</span><span class=cF0> max_segment_size;
|
|
<a name="l79"></a>
|
|
<a name="l80"></a> </span><span class=cF9>U32</span><span class=cF0> first_unacked_seq; </span><span class=cF2>// SEQ number of first unacknowledged octet</span><span class=cF0>
|
|
<a name="l81"></a> </span><span class=cF9>U32</span><span class=cF0> next_send_seq_num;
|
|
<a name="l82"></a> </span><span class=cF9>U32</span><span class=cF0> next_recv_seq_num;
|
|
<a name="l83"></a> </span><span class=cF1>F64</span><span class=cF0> srtt; </span><span class=cF2>// Smoothed Round-Trip Time</span><span class=cF0>
|
|
<a name="l84"></a> </span><span class=cF1>F64</span><span class=cF0> connection_time;
|
|
<a name="l85"></a>
|
|
<a name="l86"></a> </span><span class=cF9>U32</span><span class=cF0> receive_window;</span><span class=cF2>// allowed # of unacknowledged incoming octets</span><span class=cF0>
|
|
<a name="l87"></a> </span><span class=cF9>U32</span><span class=cF0> send_window; </span><span class=cF2>// allowed # of unacknowledged outgoing octets</span><span class=cF0>
|
|
<a name="l88"></a>
|
|
<a name="l89"></a> </span><span class=cF9>I64</span><span class=cF0> write_position; </span><span class=cF2>// position in RX buffer to write incoming octets</span><span class=cF0>
|
|
<a name="l90"></a> </span><span class=cF9>I64</span><span class=cF0> read_position; </span><span class=cF2>// position in RX buffer Socket calls have read up to</span><span class=cF0>
|
|
<a name="l91"></a> </span><span class=cF9>I64</span><span class=cF0> receive_buffer_size;
|
|
<a name="l92"></a> </span><span class=cF1>U8</span><span class=cF0> *receive_buffer;
|
|
<a name="l93"></a>};
|
|
<a name="l94"></a>
|
|
<a name="l95"></a>
|
|
<a name="l96"></a></span><span class=cF1>class</span><span class=cF0> CTCPTreeQueue:</span><span class=cF9>CQueue</span><span class=cF0>
|
|
<a name="l97"></a>{
|
|
<a name="l98"></a> CTCPSocket *socket;
|
|
<a name="l99"></a>};
|
|
<a name="l100"></a>
|
|
<a name="l101"></a></span><span class=cF1>class</span><span class=cF0> CTCPTreeNode:CBST
|
|
<a name="l102"></a>{
|
|
<a name="l103"></a> CTCPTreeQueue *queue;
|
|
<a name="l104"></a>};
|
|
<a name="l105"></a>
|
|
<a name="l106"></a></span><span class=cF1>class</span><span class=cF0> CTCPRepEntry:</span><span class=cF9>CQueue</span><span class=cF0>
|
|
<a name="l107"></a>{
|
|
<a name="l108"></a> CTCPTreeNode *node;
|
|
<a name="l109"></a>};
|
|
<a name="l110"></a>
|
|
<a name="l111"></a>
|
|
<a name="l112"></a></span><span class=cF1>class</span><span class=cF0> CTCPHeader
|
|
<a name="l113"></a>{
|
|
<a name="l114"></a> </span><span class=cF9>U16</span><span class=cF0> source_port;
|
|
<a name="l115"></a> </span><span class=cF9>U16</span><span class=cF0> destination_port;
|
|
<a name="l116"></a> </span><span class=cF9>U32</span><span class=cF0> seq_num;
|
|
<a name="l117"></a> </span><span class=cF9>U32</span><span class=cF0> ack_num;
|
|
<a name="l118"></a> </span><span class=cF1>U8</span><span class=cF0> data_offset;
|
|
<a name="l119"></a> </span><span class=cF1>U8</span><span class=cF0> flags;
|
|
<a name="l120"></a> </span><span class=cF9>U16</span><span class=cF0> window_size;
|
|
<a name="l121"></a> </span><span class=cF9>U16</span><span class=cF0> checksum;
|
|
<a name="l122"></a> </span><span class=cF9>U16</span><span class=cF0> urgent_pointer;
|
|
<a name="l123"></a>};
|
|
<a name="l124"></a>
|
|
<a name="l125"></a></span><span class=cF1>class</span><span class=cF0> CTCPPseudoHeader
|
|
<a name="l126"></a>{
|
|
<a name="l127"></a> </span><span class=cF9>U32</span><span class=cF0> source_address;
|
|
<a name="l128"></a> </span><span class=cF9>U32</span><span class=cF0> destination_address;
|
|
<a name="l129"></a> </span><span class=cF1>U8</span><span class=cF0> zeros;
|
|
<a name="l130"></a> </span><span class=cF1>U8</span><span class=cF0> protocol;
|
|
<a name="l131"></a> </span><span class=cF9>U16</span><span class=cF0> tcp_length; </span><span class=cF2>// length of TCP headers & payload</span><span class=cF0>
|
|
<a name="l132"></a>};
|
|
<a name="l133"></a>
|
|
<a name="l134"></a></span><span class=cF1>class</span><span class=cF0> CTCPGlobals
|
|
<a name="l135"></a>{
|
|
<a name="l136"></a>
|
|
<a name="l137"></a> CTCPTreeNode *bound_socket_tree;
|
|
<a name="l138"></a> </span><span class=cF9>U16</span><span class=cF0> next_source_port;
|
|
<a name="l139"></a>
|
|
<a name="l140"></a>} tcp_globals;
|
|
<a name="l141"></a>
|
|
</span></pre></body>
|
|
</html>
|