2021-07-03 05:07:57 +01:00
< ! DOCTYPE HTML >
< html >
< head >
< meta http - equiv = " Content-Type " content = " text/html;charset=US-ASCII " >
< meta name = " generator " content = " ZealOS V0.05 " >
< style type = " text/css " >
body { background - color : # 000000 ; }
. cF0 { color : # ffffff ; background - color : # 000000 ; }
. cF1 { color : # 3465 a4 ; background - color : # 000000 ; }
. cF2 { color : # 4e9 a06 ; background - color : # 000000 ; }
. cF3 { color : # 06 989 a ; background - color : # 000000 ; }
. cF4 { color : # a24444 ; background - color : # 000000 ; }
. cF5 { color : # 75507 b ; background - color : # 000000 ; }
. cF6 { color : # ce982f ; background - color : # 000000 ; }
. cF7 { color : # bcc0b9 ; background - color : # 000000 ; }
. cF8 { color : # 555753 ; background - color : # 000000 ; }
. cF9 { color : # 729f cf ; background - color : # 000000 ; }
. cFA { color : # 82 bc49 ; background - color : # 000000 ; }
. cFB { color : # 34e2 e2 ; background - color : # 000000 ; }
. cFC { color : # ac3535 ; background - color : # 000000 ; }
. cFD { color : # ad7fa8 ; background - color : # 000000 ; }
. cFE { color : # fce94f ; background - color : # 000000 ; }
. cFF { color : # 000000 ; background - color : # 000000 ; }
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = " font-family:monospace;font-size:12pt " >
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< 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 >
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< 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>
2021-07-03 05:07:57 +01:00
< a name = " l12 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l13 " > < / a > # < / span > < span class = cF1 > define < / span > < span class = cF0 > TCP_TIMEOUT < / span > < span class = cFE > 5000 < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l14 " > < / a >
2021-07-04 23:11:34 +01:00
< 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 >
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< 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 >
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< 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 >
2021-07-03 05:07:57 +01:00
< 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>
2021-07-04 23:11:34 +01:00
< 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>
2021-07-03 05:07:57 +01:00
< a name = " l34 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l35 " > < / a > # < / span > < span class = cF1 > define < / span > < span class = cF0 > TCPF_FIN ( < / span > < span class = cFE > 1 < / span > < span class = cF0 > & lt ; & lt ; 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 > & lt ; & lt ; 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 > & lt ; & lt ; 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 > & lt ; & lt ; 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>
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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 ;
2021-07-03 05:07:57 +01:00
< a name = " l49 " > < / a >
2021-07-04 23:11:34 +01:00
< 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>
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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 ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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>
2021-07-03 05:07:57 +01:00
< a name = " l69 " > < / a >
2021-07-04 23:11:34 +01:00
< 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 ;
2021-07-03 05:07:57 +01:00
< a name = " l72 " > < / a >
2021-07-04 23:11:34 +01:00
< 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>
2021-07-03 05:07:57 +01:00
< a name = " l74 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l75 " > < / a > < / span > < span class = cF9 > U64 < / span > < span class = cF0 > accept_queue_limit ;
< a name = " l76 " > < / a > CTCPAcceptQueue * accept_queue ;
2021-07-03 05:07:57 +01:00
< a name = " l77 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l78 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > max_segment_size ;
2021-07-03 05:07:57 +01:00
< a name = " l79 " > < / a >
2021-07-04 23:11:34 +01:00
< 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 ;
2021-07-03 05:07:57 +01:00
< a name = " l85 " > < / a >
2021-07-04 23:11:34 +01:00
< 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>
2021-07-03 05:07:57 +01:00
< a name = " l88 " > < / a >
2021-07-04 23:11:34 +01:00
< 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 ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< a name = " l98 " > < / a > CTCPSocket * socket ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< a name = " l103 " > < / a > CTCPTreeQueue * queue ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< a name = " l108 " > < / a > CTCPTreeNode * node ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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 ;
2021-07-03 05:07:57 +01:00
< 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 > {
2021-07-04 23:11:34 +01:00
< 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>
2021-07-03 05:07:57 +01:00
< 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 >
2021-07-04 23:11:34 +01:00
< a name = " l137 " > < / a > CTCPTreeNode * bound_socket_tree ;
< a name = " l138 " > < / a > < / span > < span class = cF9 > U16 < / span > < span class = cF0 > next_source_port ;
2021-07-03 05:07:57 +01:00
< a name = " l139 " > < / a >
< a name = " l140 " > < / a > } tcp_globals ;
< a name = " l141 " > < / a >
< / span > < / pre > < / body >
< / html >