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 = cF1 > Bool < / span > < span class = cF0 > TCPHandleValidSEQ ( CTCPSocket * tcp_socket , CTCPHeader * header , < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_seq_num , < / span > < span class = cF9 > I64 < / span > < span class = cF0 > length , < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * data )
< a name = " l2 " > < / a > { < / span > < span class = cF2 > // returns the value of must_ack, used later in TCPHandleSocket. Copies data to receive buffer.</span><span class=cF0>
2021-07-04 23:11:34 +01:00
< a name = " l3 " > < / a > < / span > < span class = cF1 > Bool < / span > < span class = cF0 > must_ack = < / span > < span class = cF3 > FALSE < / span > < span class = cF0 > ;
< a name = " l4 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > write_position ;
< a name = " l5 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > next_position ;
< a name = " l6 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > i ;
2021-07-03 05:07:57 +01:00
< a name = " l7 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l8 " > < / a > < / span > < span class = cF2 > //</span><span class=cF0> </span><span class=cF2>tcp_socket->send_window = header->window_size;</span><span class=cF0>
< a name = " l9 " > < / a > tcp_socket - & gt ; send_window = < / span > < span class = cF5 > EndianU16 < / span > < span class = cF0 > ( header - & gt ; window_size ) ;
< a name = " l10 " > < / a > < / span > < span class = cF2 > // Shrine doesn't use EndianU16 (ntohs)? are these all being stored network byte order? ...</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l11 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l12 " > < / a > < / span > < span class = cF1 > switch < / span > < span class = cF0 > ( tcp_socket - & gt ; state )
< a name = " l13 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l14 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_ESTABLISHED :
< a name = " l15 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_FIN_WAIT1 :
< a name = " l16 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_FIN_WAIT2 : < / span > < span class = cF2 > // FIN2 check is ommitted in Shrine, yet used in below logic. Adding.</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l17 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l18 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLE VALID SEQ : Updating data in receive buffer . & quot ; < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l19 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l20 " > < / a > < / span > < span class = cF2 > // TODO: review while loops, make sure we DO NOT HANG INTERRUPT HANDLER.</span><span class=cF0>
< a name = " l21 " > < / a > write_position = tcp_socket - & gt ; write_position ;
2021-07-03 05:07:57 +01:00
< a name = " l22 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l23 " > < / a > < / span > < span class = cF1 > while < / span > < span class = cF0 > ( length & amp ; & amp ; segment_seq_num ! = tcp_socket - & gt ; next_recv_seq_num )
< a name = " l24 " > < / a > {
< a name = " l25 " > < / a > segment_seq_num = ( segment_seq_num + < / span > < span class = cFE > 1 < / span > < span class = cF0 > ) & amp ; < / span > < span class = cFE > 0xFFFFFFFF < / span > < span class = cF0 > ;
< a name = " l26 " > < / a > data + + ;
< a name = " l27 " > < / a > length - - ;
< a name = " l28 " > < / a > }
2021-07-03 05:07:57 +01:00
< a name = " l29 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l30 " > < / a > < / span > < span class = cF1 > for < / span > < span class = cF0 > ( i = < / span > < span class = cFE > 0 < / span > < span class = cF0 > ; i & lt ; length ; i + + )
< a name = " l31 " > < / a > {
< a name = " l32 " > < / a > < / span > < span class = cF2 > //</span><span class=cF0> </span><span class=cF2>next_position = (write_position + 1) & (tcp_socket->receive_buffer_size - 1);</span><span class=cF0>
< a name = " l33 " > < / a > next_position = ( write_position + < / span > < span class = cFE > 1 < / span > < span class = cF0 > ) % tcp_socket - & gt ; receive_buffer_size ;
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 > if < / span > < span class = cF0 > ( next_position = = tcp_socket - & gt ; read_position )
< a name = " l36 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ; < / span > < span class = cF2 > // ...?</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l37 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l38 " > < / a > tcp_socket - & gt ; receive_buffer [ write_position ] = data [ i ] ;
< a name = " l39 " > < / a > write_position = next_position ;
< a name = " l40 " > < / a > }
2021-07-03 05:07:57 +01:00
< a name = " l41 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l42 " > < / a > tcp_socket - & gt ; write_position = write_position ;
< a name = " l43 " > < / a > tcp_socket - & gt ; next_recv_seq_num + = i ;
2021-07-03 05:07:57 +01:00
< a name = " l44 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l45 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( i & gt ; < / span > < span class = cFE > 0 < / span > < span class = cF0 > )
< a name = " l46 " > < / a > must_ack = < / span > < span class = cF3 > TRUE < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l47 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l48 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_FIN < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l49 " > < / a > {
< a name = " l50 " > < / a > must_ack = < / span > < span class = cF3 > TRUE < / span > < span class = cF0 > ;
< a name = " l51 " > < / a > tcp_socket - & gt ; next_recv_seq_num + + ;
2021-07-03 05:07:57 +01:00
< a name = " l52 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l53 " > < / a > < / span > < span class = cF1 > switch < / span > < span class = cF0 > ( tcp_socket - & gt ; state )
< a name = " l54 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l55 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_ESTABLISHED :
< a name = " l56 " > < / a > tcp_socket - & gt ; state = TCP_STATE_CLOSE_WAIT ;
< a name = " l57 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
< a name = " l58 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_FIN_WAIT1 :
< a name = " l59 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_FIN_WAIT2 :
< a name = " l60 " > < / a > tcp_socket - & gt ; state = TCP_STATE_TIME_WAIT ;
< a name = " l61 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
< a name = " l62 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 > < / span > < span class = cF2 > // review RFC, whether more state checks needed here.</span><span class=cF0>
< a name = " l63 " > < / a > }
2021-07-03 05:07:57 +01:00
< a name = " l64 " > < / a >
< a name = " l65 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l66 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l67 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l68 " > < / a > < / span > < span class = cF1 > default < / span > < span class = cF0 > :
< a name = " l69 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
< a name = " l70 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l71 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l72 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > must_ack ;
2021-07-03 05:07:57 +01:00
< a name = " l73 " > < / a > }
< a name = " l74 " > < / a >
< a name = " l75 " > < / a >
< a name = " l76 " > < / a > < / span > < span class = cF1 > Bool < / span > < span class = cF0 > TCPHandleACK ( CTCPSocket * tcp_socket , CIPV4Packet * packet , CTCPHeader * header ,
2021-07-04 23:11:34 +01:00
< a name = " l77 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_seq_num , < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_ack_num , < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_length )
2021-07-03 05:07:57 +01:00
< a name = " l78 " > < / a > { < / span > < span class = cF2 > // returns the value of must_ack, used later in TCPHandleSocket</span><span class=cF0>
2021-07-04 23:11:34 +01:00
< a name = " l79 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > ack_relative ;
< a name = " l80 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > ack_next_relative ;
2021-07-03 05:07:57 +01:00
< a name = " l81 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l82 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_ACK < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l83 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l84 " > < / a > ack_relative = ( segment_ack_num - tcp_socket - & gt ; first_unacked_seq ) & amp ; < / span > < span class = cFE > 0xFFFFFFFF < / span > < span class = cF0 > ;
< a name = " l85 " > < / a > ack_next_relative = ( tcp_socket - & gt ; next_send_seq_num - tcp_socket - & gt ; first_unacked_seq ) & amp ; < / span > < span class = cFE > 0xFFFFFFFF < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l86 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l87 " > < / a > < / span > < span class = cF2 > // Shrine has comments here about RFC poor wording,</span><span class=cF0>
< a name = " l88 " > < / a > < / span > < span class = cF2 > // TODO: review RFC and implement more refined approach.</span><span class=cF0>
< a name = " l89 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( ack_relative & lt ; = ack_next_relative )
< a name = " l90 " > < / a > {
< a name = " l91 " > < / a > TCPAcknowledgePacket ( tcp_socket , segment_ack_num ) ;
2021-07-03 05:07:57 +01:00
< a name = " l92 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l93 " > < / a > < / span > < span class = cF2 > // "Accept ACK"</span><span class=cF0>
< a name = " l94 " > < / a > tcp_socket - & gt ; first_unacked_seq = segment_ack_num ;
2021-07-03 05:07:57 +01:00
< a name = " l95 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l96 " > < / a > < / span > < span class = cF1 > switch < / span > < span class = cF0 > ( tcp_socket - & gt ; state )
< a name = " l97 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l98 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_SYN_SENT :
< a name = " l99 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLE ACK : Acceptable ACK ; state : SYN_SENT & quot ; < / span > < span class = cF0 > ) ;
< a name = " l100 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( ! < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_SYN < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l101 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
< a name = " l102 " > < / a > < / span > < span class = cF2 > // else, fall-through</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l103 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l104 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_SYN_RECEIVED :
< a name = " l105 " > < / a > tcp_socket - & gt ; state = TCP_STATE_ESTABLISHED ;
< a name = " l106 " > < / a > tcp_socket - & gt ; srtt = < / span > < span class = cF5 > tS < / span > < span class = cF0 > - tcp_socket - & gt ; connection_time ;
< a name = " l107 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l108 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l109 " > < / a > < / span > < span class = cF1 > default < / span > < span class = cF0 > :
< a name = " l110 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
< a name = " l111 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l112 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLE ACK : Acceptable ACK returning ; state : 0 x % 0 X & quot ; < / span > < span class = cF0 > , tcp_socket - & gt ; state ) ;
< a name = " l113 " > < / a > }
< a name = " l114 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l115 " > < / a > {
< a name = " l116 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET : Invalid ACK . & quot ; < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l117 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l118 " > < / a > < / span > < span class = cF1 > switch < / span > < span class = cF0 > ( tcp_socket - & gt ; state )
< a name = " l119 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l120 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_LISTEN :
< a name = " l121 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_SYN_SENT :
< a name = " l122 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_SYN_RECEIVED :
< a name = " l123 " > < / a > TCPSend ( packet - & gt ; destination_ip_address ,
< a name = " l124 " > < / a > < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; destination_port < / span > < span class = cF7 > ) < / span > < span class = cF0 > ,
< a name = " l125 " > < / a > packet - & gt ; source_ip_address ,
< a name = " l126 " > < / a > < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; source_port < / span > < span class = cF7 > ) < / span > < span class = cF0 > ,
< a name = " l127 " > < / a > segment_ack_num ,
< a name = " l128 " > < / a > segment_seq_num + segment_length ,
< a name = " l129 " > < / a > TCPF_ACK | TCPF_RST ) ;
< a name = " l130 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l131 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l132 " > < / a > < / span > < span class = cF1 > default < / span > < span class = cF0 > :
< a name = " l133 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( IsTCPStateSync < / span > < span class = cF7 > ( < / span > < span class = cF0 > tcp_socket < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l134 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > < / span > < span class = cF3 > TRUE < / span > < span class = cF0 > ; < / span > < span class = cF2 > // must ACK the packet.</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l135 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l136 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
< a name = " l137 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l138 " > < / a > }
< a name = " l139 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l140 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l141 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > < / span > < span class = cF3 > FALSE < / span > < span class = cF0 > ; < / span > < span class = cF2 > // do not need to ACK the packet.</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l142 " > < / a > }
< a name = " l143 " > < / a >
< a name = " l144 " > < / a > < / span > < span class = cF1 > Bool < / span > < span class = cF0 > TCPHandleReset ( CTCPSocket * tcp_socket , CTCPHeader * header , < / span > < span class = cF1 > Bool < / span > < span class = cF0 > is_seq_valid )
< a name = " l145 " > < / a > { < / span > < span class = cF2 > // returns whether or not to stop overall TCP procedure.</span><span class=cF0>
2021-07-04 23:11:34 +01:00
< a name = " l146 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_RST < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l147 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l148 " > < / a > < / span > < span class = cF1 > switch < / span > < span class = cF0 > ( tcp_socket - & gt ; state )
< a name = " l149 " > < / a > {
< a name = " l150 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_SYN_SENT :
< a name = " l151 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( tcp_socket - & gt ; first_unacked_seq = = tcp_socket - & gt ; next_send_seq_num )
< a name = " l152 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l153 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET : Got RST , socket state SYN_SENT . Connection refused . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l154 " > < / a > tcp_socket - & gt ; state = TCP_STATE_CLOSED ;
< a name = " l155 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > < / span > < span class = cF3 > TRUE < / span > < span class = cF0 > ;
< a name = " l156 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l157 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l158 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l159 " > < / a > < / span > < span class = cF1 > default < / span > < span class = cF0 > :
< a name = " l160 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( is_seq_valid )
< a name = " l161 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l162 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET : Got RST , connection refused by remote host . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l163 " > < / a > tcp_socket - & gt ; state = TCP_STATE_CLOSED ;
< a name = " l164 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > < / span > < span class = cF3 > TRUE < / span > < span class = cF0 > ;
< a name = " l165 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l166 " > < / a > }
< a name = " l167 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l168 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l169 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > < / span > < span class = cF3 > FALSE < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l170 " > < / a > }
< a name = " l171 " > < / a >
< a name = " l172 " > < / a > < / span > < span class = cF1 > U0 < / span > < span class = cF0 > TCPHandleSocketListen ( CTCPSocket * tcp_socket , CIPV4Packet * packet , CTCPHeader * header , < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_seq_num )
< a name = " l173 " > < / a > { < / span > < span class = cF2 > // if SYN and socket listening, queue up the connection in the socket's accept queue.</span><span class=cF0>
2021-07-04 23:11:34 +01:00
< a name = " l174 " > < / a > CTCPAcceptQueue * new_connection ;
2021-07-03 05:07:57 +01:00
< a name = " l175 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l176 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_SYN < / span > < span class = cF7 > ) < / span > < span class = cF0 > & amp ; & amp ; < / span > < span class = cF5 > QueueSize < / span > < span class = cF7 > ( < / span > < span class = cF0 > tcp_socket - & gt ; accept_queue < / span > < span class = cF7 > ) < / span > < span class = cF0 > & lt ; tcp_socket - & gt ; accept_queue_limit )
< a name = " l177 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l178 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET LISTEN : Adding new connection to Socket accept queue & quot ; < / span > < span class = cF0 > ) ;
< a name = " l179 " > < / a > new_connection = < / span > < span class = cF5 > CAlloc < / span > < span class = cF0 > ( < / span > < span class = cF1 > sizeof < / span > < span class = cF7 > ( < / span > < span class = cF0 > CTCPAcceptQueue < / span > < span class = cF7 > ) < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l180 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l181 " > < / a > new_connection - & gt ; segment_seq_num = segment_seq_num ;
< a name = " l182 " > < / a > new_connection - & gt ; ipv4_address = packet - & gt ; source_ip_address ;
< a name = " l183 " > < / a > new_connection - & gt ; port = header - & gt ; source_port ;
2021-07-03 05:07:57 +01:00
< a name = " l184 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l185 " > < / a > < / span > < span class = cF5 > QueueInsertRev < / span > < span class = cF0 > ( new_connection , tcp_socket - & gt ; accept_queue ) ;
< a name = " l186 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l187 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l188 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 > < / span > < span class = cF2 > // refuse</span><span class=cF0>
< a name = " l189 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET LISTEN : Header flags not SYN or Queue full , REFUSING CONNECTION & quot ; < / span > < span class = cF0 > ) ;
< a name = " l190 " > < / a > TCPSend ( packet - & gt ; destination_ip_address ,
< a name = " l191 " > < / a > < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; destination_port < / span > < span class = cF7 > ) < / span > < span class = cF0 > ,
< a name = " l192 " > < / a > packet - & gt ; source_ip_address ,
< a name = " l193 " > < / a > < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; source_port < / span > < span class = cF7 > ) < / span > < span class = cF0 > ,
< a name = " l194 " > < / a > segment_seq_num + < / span > < span class = cFE > 1 < / span > < span class = cF0 > ,
< a name = " l195 " > < / a > segment_seq_num + < / span > < span class = cFE > 1 < / span > < span class = cF0 > ,
< a name = " l196 " > < / a > TCPF_ACK | TCPF_RST ) ;
< a name = " l197 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l198 " > < / a > }
< a name = " l199 " > < / a >
< a name = " l200 " > < / a > < / span > < span class = cF1 > U0 < / span > < span class = cF0 > TCPHandleSocket ( CTCPSocket * tcp_socket , CIPV4Packet * packet , CTCPHeader * header , < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * data , < / span > < span class = cF9 > I64 < / span > < span class = cF0 > length )
< a name = " l201 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l202 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_length = length ;
< a name = " l203 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_seq_num = < / span > < span class = cF5 > EndianU32 < / span > < span class = cF0 > ( header - & gt ; seq_num ) ;
< a name = " l204 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > segment_ack_num = < / span > < span class = cF5 > EndianU32 < / span > < span class = cF0 > ( header - & gt ; ack_num ) ;
< a name = " l205 " > < / a > < / span > < span class = cF1 > Bool < / span > < span class = cF0 > must_ack = < / span > < span class = cF3 > FALSE < / span > < span class = cF0 > ;
< a name = " l206 " > < / a > < / span > < span class = cF1 > Bool < / span > < span class = cF0 > is_seq_valid = < / span > < span class = cF3 > FALSE < / span > < span class = cF0 > ;
< a name = " l207 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > seq_relative ;
< a name = " l208 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > seq_end_relative ;
2021-07-03 05:07:57 +01:00
< a name = " l209 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l210 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_FIN < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l211 " > < / a > segment_length + + ;
< a name = " l212 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_SYN < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l213 " > < / a > segment_length + + ;
2021-07-03 05:07:57 +01:00
< a name = " l214 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l215 " > < / a > < / span > < span class = cF1 > switch < / span > < span class = cF0 > ( tcp_socket - & gt ; state )
< a name = " l216 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l217 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_LISTEN :
< a name = " l218 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET : Running TCP HANDLE SOCKET LISTEN & quot ; < / span > < span class = cF0 > ) ;
< a name = " l219 " > < / a > TCPHandleSocketListen ( tcp_socket , packet , header , segment_seq_num ) ;
< a name = " l220 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l221 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l222 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > TCP_STATE_CLOSED :
< a name = " l223 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET : Received packet but TCP Socket is CLOSED . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l224 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l225 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l226 " > < / a > < / span > < span class = cF1 > default < / span > < span class = cF0 > :
< a name = " l227 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > Bt < / span > < span class = cF7 > ( < / span > < span class = cF0 > & amp ; header - & gt ; flags , TCPf_SYN < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l228 " > < / a > {
< a name = " l229 " > < / a > tcp_socket - & gt ; next_recv_seq_num = + + segment_seq_num ;
2021-07-03 05:07:57 +01:00
< a name = " l230 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l231 " > < / a > must_ack = < / span > < span class = cF3 > TRUE < / span > < span class = cF0 > ;
< a name = " l232 " > < / a > }
2021-07-03 05:07:57 +01:00
< a name = " l233 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l234 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( segment_length = = < / span > < span class = cFE > 0 < / span > < span class = cF0 > & amp ; & amp ; tcp_socket - & gt ; receive_window = = < / span > < span class = cFE > 0 < / span > < span class = cF0 > )
< a name = " l235 " > < / a > {
< a name = " l236 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET : segment length = = 0 & amp ; & amp ; receive window = = 0 , SEQ valid if seq = = next recv seq & quot ; < / span > < span class = cF0 > ) ;
< a name = " l237 " > < / a > is_seq_valid = ( segment_seq_num = = tcp_socket - & gt ; next_recv_seq_num ) ;
< a name = " l238 " > < / a > }
< a name = " l239 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l240 " > < / a > {
< a name = " l241 " > < / a > seq_relative = ( segment_seq_num - tcp_socket - & gt ; next_recv_seq_num ) & amp ; < / span > < span class = cFE > 0xFFFFFFFF < / span > < span class = cF0 > ;
< a name = " l242 " > < / a > seq_end_relative = ( segment_seq_num + segment_length - < / span > < span class = cFE > 1 < / span > < span class = cF0 > - tcp_socket - & gt ; next_recv_seq_num ) & amp ; < / span > < span class = cFE > 0xFFFFFFFF < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l243 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l244 " > < / a > is_seq_valid = ( seq_relative & lt ; tcp_socket - & gt ; receive_window | |
< a name = " l245 " > < / a > seq_end_relative & lt ; tcp_socket - & gt ; receive_window ) ;
< a name = " l246 " > < / a > }
2021-07-03 05:07:57 +01:00
< a name = " l247 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l248 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( ! is_seq_valid )
< a name = " l249 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLE SOCKET : Invalid SEQ . & quot ; < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l250 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l251 " > < / a > must_ack | = TCPHandleACK ( tcp_socket , packet , header , segment_seq_num , segment_ack_num , segment_length ) ;
2021-07-03 05:07:57 +01:00
< a name = " l252 " > < / a >
< a name = " l253 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l254 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( TCPHandleReset < / span > < span class = cF7 > ( < / span > < span class = cF0 > tcp_socket , header , is_seq_valid < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l255 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l256 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l257 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( is_seq_valid )
< a name = " l258 " > < / a > must_ack | = TCPHandleValidSEQ ( tcp_socket , header , segment_seq_num , length , data ) ;
2021-07-03 05:07:57 +01:00
< a name = " l259 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l260 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( must_ack )
< a name = " l261 " > < / a > TCPSendFlags ( tcp_socket , TCPF_ACK ) ;
< a name = " l262 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l263 " > < / a >
< a name = " l264 " > < / a > }
< a name = " l265 " > < / a >
< a name = " l266 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > TCPHandleRefuse ( CIPV4Packet * packet , CTCPHeader * header , < / span > < span class = cF9 > I64 < / span > < span class = cF0 > length )
< a name = " l267 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l268 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > de_index ;
< a name = " l269 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > ack_num = < / span > < span class = cF5 > EndianU32 < / span > < span class = cF0 > ( header - & gt ; ack_num ) ;
< a name = " l270 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > seq_num = < / span > < span class = cF5 > EndianU32 < / span > < span class = cF0 > ( header - & gt ; seq_num ) ;
2021-07-03 05:07:57 +01:00
< a name = " l271 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l272 " > < / a > < / span > < span class = cF1 > no_warn < / span > < span class = cF0 > length ; < / span > < span class = cF2 > // TODO: Will reset generation need length ?</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l273 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l274 " > < / a > ack_num = + + seq_num ;
< a name = " l275 " > < / a > seq_num = < / span > < span class = cFE > 0 < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l276 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l277 " > < / a > < / span > < span class = cF2 > // review RFC Reset-Generation ...</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l278 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l279 " > < / a > de_index = TCPSend ( packet - & gt ; destination_ip_address ,
< a name = " l280 " > < / a > < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; destination_port < / span > < span class = cF7 > ) < / span > < span class = cF0 > ,
< a name = " l281 " > < / a > packet - & gt ; source_ip_address ,
< a name = " l282 " > < / a > < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; source_port < / span > < span class = cF7 > ) < / span > < span class = cF0 > ,
< a name = " l283 " > < / a > seq_num ,
< a name = " l284 " > < / a > ack_num ,
< a name = " l285 " > < / a > TCPF_RST | TCPF_ACK ) ;
< a name = " l286 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( de_index & lt ; < / span > < span class = cFE > 0 < / span > < span class = cF0 > )
< a name = " l287 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l288 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; TCP Handler Refuse : TCP Send failed . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l289 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > de_index ;
< a name = " l290 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l291 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l292 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > < / span > < span class = cFE > 0 < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l293 " > < / a > }
< a name = " l294 " > < / a >
< a name = " l295 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > TCPHandler ( CIPV4Packet * packet )
< a name = " l296 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l297 " > < / a > CTCPHeader * header ;
< a name = " l298 " > < / a > < / span > < span class = cF9 > U16 < / span > < span class = cF0 > destination_port ;
< a name = " l299 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * data ;
< a name = " l300 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > length ;
< a name = " l301 " > < / a > CTCPTreeNode * head = tcp_globals . bound_socket_tree ;
< a name = " l302 " > < / a > CTCPTreeNode * node ;
< a name = " l303 " > < / a > CTCPTreeQueue * queue ;
< a name = " l304 " > < / a > CTCPSocket * tcp_socket ;
< a name = " l305 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > error = TCPPacketParse ( & amp ; header , & amp ; data , & amp ; length , packet ) ;
2021-07-03 05:07:57 +01:00
< a name = " l306 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l307 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( error & lt ; < / span > < span class = cFE > 0 < / span > < span class = cF0 > )
< a name = " l308 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l309 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Packet Parse Error . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l310 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > error ;
< a name = " l311 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l312 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l313 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Caught packet with dest port of % 0 X ( B . E . ) & quot ; < / span > < span class = cF0 > , header - & gt ; destination_port ) ;
2021-07-03 05:07:57 +01:00
< a name = " l314 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l315 " > < / a > destination_port = < / span > < span class = cF5 > EndianU16 < / span > < span class = cF0 > ( header - & gt ; destination_port ) ; < / span > < span class = cF2 > // B.E. -> L.E.</span><span class=cF0>
< a name = " l316 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Caught packet with dest port of % 0 X ( L . E . ) & quot ; < / span > < span class = cF0 > , destination_port ) ;
2021-07-03 05:07:57 +01:00
< a name = " l317 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l318 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( head )
< a name = " l319 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l320 " > < / a > node = TCPTreeNodeFind ( destination_port , head ) ;
2021-07-03 05:07:57 +01:00
< a name = " l321 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l322 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( node )
< a name = " l323 " > < / a > {
< a name = " l324 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Found node for port , looking for address % 0 X ( L . E . ) & quot ; < / span > < span class = cF0 > , packet - & gt ; source_ip_address ) ;
< a name = " l325 " > < / a > queue = TCPTreeNodeQueueIPV4Find ( packet - & gt ; source_ip_address , node ) ; < / span > < span class = cF2 > // TODO: make sure bit order is correct here!!</span><span class=cF0>
< a name = " l326 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( queue )
< a name = " l327 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l328 " > < / a > tcp_socket = queue - & gt ; socket ;
< a name = " l329 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Port and Address are in bound tree . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l330 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l331 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l332 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l333 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Found node for port , but address is not in node queue . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l334 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP source ip : 0 x % 0 X . & quot ; < / span > < span class = cF0 > , packet - & gt ; source_ip_address ) ;
2021-07-03 05:07:57 +01:00
< a name = " l335 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l336 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Sending TCP RST ACK packet . Refusing connection . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l337 " > < / a > TCPHandleRefuse ( packet , header , length ) ;
< a name = " l338 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l339 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l340 " > < / a > }
< a name = " l341 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l342 " > < / a > {
< a name = " l343 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLER : NODE SEARCH FAILURE : PORT % 0 X & quot ; < / span > < span class = cF0 > , destination_port ) ;
< a name = " l344 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Node for Port is not in tree . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l345 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Sending TCP RST ACK packet . Refusing connection . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l346 " > < / a > TCPHandleRefuse ( packet , header , length ) ;
< a name = " l347 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l348 " > < / a > }
2021-07-03 05:07:57 +01:00
< a name = " l349 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l350 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l351 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l352 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l353 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Socket tree is currently empty . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l354 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Sending TCP RST ACK packet . Refusing connection . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l355 " > < / a > TCPHandleRefuse ( packet , header , length ) ;
< a name = " l356 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l357 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l358 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l359 " > < / a > < / span > < span class = cF2 > // at this point, tcp_socket is set, otherwise has already returned -1.</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l360 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l361 " > < / a > NetDebug ( < / span > < span class = cF6 > & quot ; TCP HANDLER : Running TCP HANDLE SOCKET & quot ; < / span > < span class = cF0 > ) ;
< a name = " l362 " > < / a > TCPHandleSocket ( tcp_socket , packet , header , data , length ) ;
2021-07-03 05:07:57 +01:00
< a name = " l363 " > < / a >
< a name = " l364 " > < / a > } < / span > < / pre > < / body >
< / html >