Subversion Repositories Kolibri OS

Rev

Rev 3555 | Rev 3626 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3555 Rev 3589
Line 58... Line 58...
58
 
58
 
Line 59... Line 59...
59
        ret
59
        ret
60
 
60
 
61
  .fail:
61
  .fail:
Line 62... Line 62...
62
        popf
62
        popf
Line 63... Line 63...
63
        DEBUGF  2, "TCP incoming queue is full, discarding packet!\n"
63
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
64
 
64
 
Line 95... Line 95...
95
        mov     ebx, [esi + TCP_queue_entry.device_ptr]
95
        mov     ebx, [esi + TCP_queue_entry.device_ptr]
96
        mov     ecx, [esi + TCP_queue_entry.segment_size]
96
        mov     ecx, [esi + TCP_queue_entry.segment_size]
97
        mov     edi, [esi + TCP_queue_entry.ip_ptr]                     ; ptr to ipv4 source address, followed by ipv4 destination address
97
        mov     edi, [esi + TCP_queue_entry.ip_ptr]                     ; ptr to ipv4 source address, followed by ipv4 destination address
98
        mov     esi, [esi + TCP_queue_entry.segment_ptr]                ; change esi last
98
        mov     esi, [esi + TCP_queue_entry.segment_ptr]                ; change esi last
Line 99... Line 99...
99
 
99
 
Line 100... Line 100...
100
        DEBUGF  1,"TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
100
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
Line 101... Line 101...
101
 
101
 
102
        mov     edx, esi
102
        mov     edx, esi
Line 125... Line 125...
125
        jb      .drop_no_socket                                         ; If not, drop the packet
125
        jb      .drop_no_socket                                         ; If not, drop the packet
Line 126... Line 126...
126
 
126
 
127
        movzx   eax, [edx + TCP_header.DataOffset]
127
        movzx   eax, [edx + TCP_header.DataOffset]
128
        sub     ecx, eax                                                ; substract TCP header size from total segment size
128
        sub     ecx, eax                                                ; substract TCP header size from total segment size
129
        jb      .drop_no_socket                                         ; If total segment size is less then the advertised header size, drop packet
129
        jb      .drop_no_socket                                         ; If total segment size is less then the advertised header size, drop packet
Line 130... Line 130...
130
        DEBUGF  1,"TCP_input: %u bytes of data\n", ecx
130
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: %u bytes of data\n", ecx
131
 
131
 
Line 132... Line 132...
132
;-------------------------------------------
132
;-------------------------------------------
Line 174... Line 174...
174
        cmp     [edx + TCP_header.SourcePort], ax
174
        cmp     [edx + TCP_header.SourcePort], ax
175
        je      .found_socket
175
        je      .found_socket
176
        test    ax, ax
176
        test    ax, ax
177
        jnz     .socket_loop
177
        jnz     .socket_loop
178
  .found_socket:                                        ; ebx now contains the socketpointer
178
  .found_socket:                                        ; ebx now contains the socketpointer
179
        DEBUGF  1,"TCP_input: socket ptr=%x state=%u flags=%x\n", ebx, [ebx + TCP_SOCKET.t_state], [edx + TCP_header.Flags]:2
179
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: socket ptr=%x state=%u flags=%x\n", ebx, [ebx + TCP_SOCKET.t_state], [edx + TCP_header.Flags]:2
Line 180... Line 180...
180
 
180
 
181
;-------------
181
;-------------
Line 182... Line 182...
182
; update stats
182
; update stats
Line 195... Line 195...
195
        pusha
195
        pusha
196
        lea     ecx, [ebx + SOCKET.mutex]
196
        lea     ecx, [ebx + SOCKET.mutex]
197
        call    mutex_lock
197
        call    mutex_lock
198
        popa
198
        popa
Line 199... Line 199...
199
 
199
 
Line 200... Line 200...
200
        DEBUGF  1,"TCP_input: socket locked\n"
200
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: socket locked\n"
201
 
201
 
Line 202... Line 202...
202
;---------------------------
202
;---------------------------
Line 218... Line 218...
218
; Are we accepting incoming connections?
218
; Are we accepting incoming connections?
Line 219... Line 219...
219
 
219
 
220
        test    [ebx + SOCKET.options], SO_ACCEPTCON
220
        test    [ebx + SOCKET.options], SO_ACCEPTCON
Line 221... Line 221...
221
        jz      .no_accept
221
        jz      .no_accept
Line 222... Line 222...
222
 
222
 
223
        DEBUGF  1,"TCP_input: Accepting new connection\n"
223
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Accepting new connection\n"
224
 
224
 
225
        pusha
225
        pusha
Line 261... Line 261...
261
 
261
 
262
        movzx   ecx, [edx + TCP_header.DataOffset]
262
        movzx   ecx, [edx + TCP_header.DataOffset]
263
        cmp     ecx, sizeof.TCP_header                  ; Does header contain any options?
263
        cmp     ecx, sizeof.TCP_header                  ; Does header contain any options?
Line 264... Line 264...
264
        je      .no_options
264
        je      .no_options
Line 265... Line 265...
265
 
265
 
266
        DEBUGF  1,"TCP_input: Segment has options\n"
266
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Segment has options\n"
267
 
267
 
Line 288... Line 288...
288
        je      .opt_sack_permit
288
        je      .opt_sack_permit
289
;        cmp     al, TCP_OPT_SACK
289
;        cmp     al, TCP_OPT_SACK
290
;        je      .opt_sack
290
;        je      .opt_sack
291
        cmp     al, TCP_OPT_TIMESTAMP
291
        cmp     al, TCP_OPT_TIMESTAMP
292
        je      .opt_timestamp
292
        je      .opt_timestamp
293
        DEBUGF  1,"TCP_input: unknown option:%u\n", al
293
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: unknown option:%u\n", al
294
        jmp     .no_options                     ; If we reach here, some unknown options were received, skip them all!
294
        jmp     .no_options                     ; If we reach here, some unknown options were received, skip them all!
Line 295... Line 295...
295
 
295
 
296
  .opt_maxseg:
296
  .opt_maxseg:
297
        lodsb
297
        lodsb
Line 301... Line 301...
301
        test    [edx + TCP_header.Flags], TH_SYN
301
        test    [edx + TCP_header.Flags], TH_SYN
302
        jz      @f
302
        jz      @f
Line 303... Line 303...
303
 
303
 
304
        lodsw
304
        lodsw
305
        rol     ax, 8
305
        rol     ax, 8
306
        DEBUGF  1,"TCP_input: Maxseg=%u\n", ax
306
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", ax
307
        call    TCP_mss
307
        call    TCP_mss
308
       @@:
308
       @@:
Line 315... Line 315...
315
        jne     .no_options
315
        jne     .no_options
Line 316... Line 316...
316
 
316
 
317
        test    [edx + TCP_header.Flags], TH_SYN
317
        test    [edx + TCP_header.Flags], TH_SYN
Line 318... Line 318...
318
        jz      @f
318
        jz      @f
319
 
319
 
Line 320... Line 320...
320
        DEBUGF  1,"TCP_input: Got window scale option\n"
320
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Got window scale option\n"
321
        or      [ebx + TCP_SOCKET.t_flags], TF_RCVD_SCALE
321
        or      [ebx + TCP_SOCKET.t_flags], TF_RCVD_SCALE
322
 
322
 
Line 334... Line 334...
334
        jne     .no_options
334
        jne     .no_options
Line 335... Line 335...
335
 
335
 
336
        test    [edx + TCP_header.Flags], TH_SYN
336
        test    [edx + TCP_header.Flags], TH_SYN
Line 337... Line 337...
337
        jz      @f
337
        jz      @f
338
 
338
 
Line 339... Line 339...
339
        DEBUGF  1,"TCP_input: Selective Acknowledgement permitted\n"
339
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Selective Acknowledgement permitted\n"
340
        or      [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT
340
        or      [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT
Line 346... Line 346...
346
  .opt_timestamp:
346
  .opt_timestamp:
347
        lodsb
347
        lodsb
348
        cmp     al, 10                          ; length must be 10
348
        cmp     al, 10                          ; length must be 10
349
        jne     .no_options
349
        jne     .no_options
Line 350... Line 350...
350
 
350
 
Line 351... Line 351...
351
        DEBUGF  1,"TCP_input: Got timestamp option\n"
351
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Got timestamp option\n"
352
 
352
 
353
        test    [edx + TCP_header.Flags], TH_SYN
353
        test    [edx + TCP_header.Flags], TH_SYN
354
        jz      @f
354
        jz      @f
Line 370... Line 370...
370
        test    eax, eax
370
        test    eax, eax
371
        jz      .no_paws
371
        jz      .no_paws
372
        cmp     eax, [ebx + TCP_SOCKET.ts_val]
372
        cmp     eax, [ebx + TCP_SOCKET.ts_val]
373
        jge     .no_paws
373
        jge     .no_paws
Line 374... Line 374...
374
 
374
 
Line 375... Line 375...
375
        DEBUGF  1,"TCP_input: PAWS: detected an old segment\n"
375
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: PAWS: detected an old segment\n"
376
 
376
 
Line 377... Line 377...
377
        mov     eax, [esp+4+4]                          ; tcp_now
377
        mov     eax, [esp+4+4]                          ; tcp_now
Line 448... Line 448...
448
 
448
 
449
; - The acknowledgment field in the segment is greater than the largest unacknowledged sequence number.
449
; - The acknowledgment field in the segment is greater than the largest unacknowledged sequence number.
450
        sub     eax, [ebx + TCP_SOCKET.SND_UNA]
450
        sub     eax, [ebx + TCP_SOCKET.SND_UNA]
Line 451... Line 451...
451
        jbe     .not_uni_xfer
451
        jbe     .not_uni_xfer
Line 452... Line 452...
452
 
452
 
453
        DEBUGF  1,"TCP_input: Header prediction: we are sender\n"
453
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are sender\n"
Line 454... Line 454...
454
 
454
 
Line 522... Line 522...
522
 
522
 
Line 523... Line 523...
523
;       jnz     .not_uni_xfer
523
;       jnz     .not_uni_xfer
Line 524... Line 524...
524
 
524
 
Line 525... Line 525...
525
; Complete processing of received data
525
; Complete processing of received data
Line 526... Line 526...
526
 
526
 
527
        DEBUGF  1,"TCP_input: Header prediction: we are receiving %u bytes\n", ecx
527
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are receiving %u bytes\n", ecx
Line 543... Line 543...
543
;--------------------------------------------------
543
;--------------------------------------------------
544
; Header prediction failed, do it the slow way
544
; Header prediction failed, do it the slow way
Line 545... Line 545...
545
 
545
 
Line 546... Line 546...
546
  .not_uni_xfer:
546
  .not_uni_xfer:
Line 547... Line 547...
547
 
547
 
Line 548... Line 548...
548
        DEBUGF  1,"TCP_input: Header prediction failed\n"
548
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction failed\n"
549
 
549
 
Line 556... Line 556...
556
        sub     edx, [ebx + TCP_SOCKET.RCV_NXT]
556
        sub     edx, [ebx + TCP_SOCKET.RCV_NXT]
557
        cmp     eax, edx
557
        cmp     eax, edx
558
        jg      @f
558
        jg      @f
559
        mov     eax, edx
559
        mov     eax, edx
560
       @@:
560
       @@:
561
        DEBUGF  1,"Receive window size=%d\n", eax
561
        DEBUGF  DEBUG_NETWORK_VERBOSE, "Receive window size=%d\n", eax
562
        mov     [ebx + TCP_SOCKET.RCV_WND], eax
562
        mov     [ebx + TCP_SOCKET.RCV_WND], eax
563
        pop     edx
563
        pop     edx
Line 564... Line 564...
564
 
564
 
Line 577... Line 577...
577
 
577
 
578
        mov     eax, [ebx + TCP_SOCKET.RCV_NXT]
578
        mov     eax, [ebx + TCP_SOCKET.RCV_NXT]
579
        sub     eax, [edx + TCP_header.SequenceNumber]
579
        sub     eax, [edx + TCP_header.SequenceNumber]
Line 580... Line 580...
580
        jle     .no_duplicate
580
        jle     .no_duplicate
Line 581... Line 581...
581
 
581
 
582
        DEBUGF  1,"TCP_input: %u bytes duplicate data!\n", eax
582
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: %u bytes duplicate data!\n", eax
Line 583... Line 583...
583
 
583
 
Line 584... Line 584...
584
        test    [edx + TCP_header.Flags], TH_SYN
584
        test    [edx + TCP_header.Flags], TH_SYN
585
        jz      .no_dup_syn
585
        jz      .no_dup_syn
Line 586... Line 586...
586
 
586
 
Line 611... Line 611...
611
; At this point the FIN must be out of sequence or a duplicate, drop it
611
; At this point the FIN must be out of sequence or a duplicate, drop it
612
        and     [edx + TCP_header.Flags], not TH_FIN
612
        and     [edx + TCP_header.Flags], not TH_FIN
Line 613... Line 613...
613
 
613
 
614
; send an ACK and resynchronize and drop any data.
614
; send an ACK and resynchronize and drop any data.
615
; But keep on processing for RST or ACK
615
; But keep on processing for RST or ACK
616
        DEBUGF  1, "616\n"
616
        DEBUGF  DEBUG_NETWORK_VERBOSE,  "616\n"
617
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
617
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
618
        mov     eax, ecx
618
        mov     eax, ecx
Line 619... Line 619...
619
;TODO: update stats
619
;TODO: update stats
Line 656... Line 656...
656
        add     eax, ecx
656
        add     eax, ecx
657
        sub     eax, [ebx + TCP_SOCKET.RCV_NXT]
657
        sub     eax, [ebx + TCP_SOCKET.RCV_NXT]
658
        sub     eax, [ebx + TCP_SOCKET.RCV_WND]         ; eax now holds the number of bytes to drop
658
        sub     eax, [ebx + TCP_SOCKET.RCV_WND]         ; eax now holds the number of bytes to drop
659
        jle     .no_excess_data
659
        jle     .no_excess_data
Line 660... Line 660...
660
 
660
 
Line 661... Line 661...
661
        DEBUGF  1,"%d bytes beyond right edge of window\n", eax
661
        DEBUGF  DEBUG_NETWORK_VERBOSE, "%d bytes beyond right edge of window\n", eax
662
 
662
 
663
;;; TODO: update stats
663
;;; TODO: update stats
664
        cmp     eax, ecx
664
        cmp     eax, ecx
Line 685... Line 685...
685
        jne     .drop_after_ack
685
        jne     .drop_after_ack
686
        mov     eax, [edx + TCP_header.SequenceNumber]
686
        mov     eax, [edx + TCP_header.SequenceNumber]
687
        cmp     eax, [ebx + TCP_SOCKET.RCV_NXT]
687
        cmp     eax, [ebx + TCP_SOCKET.RCV_NXT]
688
        jne     .drop_after_ack
688
        jne     .drop_after_ack
Line 689... Line 689...
689
 
689
 
690
        DEBUGF  1, "690\n"
690
        DEBUGF  DEBUG_NETWORK_VERBOSE,  "690\n"
691
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
691
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
692
;;; TODO: update stats
692
;;; TODO: update stats
693
        jmp     .no_excess_data
693
        jmp     .no_excess_data
694
  .dont_drop_all:
694
  .dont_drop_all:
Line 713... Line 713...
713
        dec     eax
713
        dec     eax
714
       @@:
714
       @@:
715
        sub     eax, ecx
715
        sub     eax, ecx
716
        jae     .no_timestamp
716
        jae     .no_timestamp
Line 717... Line 717...
717
 
717
 
Line 718... Line 718...
718
        DEBUGF  1,"Recording timestamp\n"
718
        DEBUGF  DEBUG_NETWORK_VERBOSE, "Recording timestamp\n"
719
 
719
 
720
        mov     eax, [esp + 4]                                  ; tcp_now
720
        mov     eax, [esp + 4]                                  ; tcp_now
721
        mov     [ebx + TCP_SOCKET.ts_recent_age], eax
721
        mov     [ebx + TCP_SOCKET.ts_recent_age], eax
Line 727... Line 727...
727
; Process RST flags
727
; Process RST flags
Line 728... Line 728...
728
 
728
 
729
        test    [edx + TCP_header.Flags], TH_RST
729
        test    [edx + TCP_header.Flags], TH_RST
Line 730... Line 730...
730
        jz      .no_rst
730
        jz      .no_rst
Line 731... Line 731...
731
 
731
 
732
        DEBUGF  1,"TCP_input: Got an RST flag\n"
732
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Got an RST flag\n"
733
 
733
 
Line 747... Line 747...
747
        dd      .rst_close      ; TCPS_LAST_ACK
747
        dd      .rst_close      ; TCPS_LAST_ACK
748
        dd      .econnreset     ; TCPS_FIN_WAIT_2
748
        dd      .econnreset     ; TCPS_FIN_WAIT_2
749
        dd      .rst_close      ; TCPS_TIMED_WAIT
749
        dd      .rst_close      ; TCPS_TIMED_WAIT
Line 750... Line 750...
750
 
750
 
751
  .econnrefused:
751
  .econnrefused:
Line 752... Line 752...
752
        DEBUGF  1,"TCP_input: Connection refused\n"
752
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Connection refused\n"
753
 
753
 
Line 754... Line 754...
754
        mov     [ebx + SOCKET.errorcode], ECONNREFUSED
754
        mov     [ebx + SOCKET.errorcode], ECONNREFUSED
755
        jmp     .close
755
        jmp     .close
Line 756... Line 756...
756
 
756
 
Line 757... Line 757...
757
  .econnreset:
757
  .econnreset:
758
        DEBUGF  1,"TCP_input: Connection reset\n"
758
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Connection reset\n"
Line 759... Line 759...
759
 
759
 
760
        mov     [ebx + SOCKET.errorcode], ECONNRESET
760
        mov     [ebx + SOCKET.errorcode], ECONNRESET
761
 
761
 
762
  .close:
762
  .close:
763
        DEBUGF  1,"TCP_input: Closing connection\n"
763
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Closing connection\n"
Line 764... Line 764...
764
 
764
 
765
        mov     [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
765
        mov     [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
Line 766... Line 766...
766
;;; TODO: update stats (tcp drops)
766
;;; TODO: update stats (tcp drops)
767
        mov     eax, ebx
767
        mov     eax, ebx
768
        call    TCP_close
768
        call    TCP_close
Line 797... Line 797...
797
 
797
 
798
        cmp     [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
798
        cmp     [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
799
        jb      .ack_processed                                  ; states: closed, listen, syn_sent
799
        jb      .ack_processed                                  ; states: closed, listen, syn_sent
Line 800... Line 800...
800
        ja      .no_syn_rcv                                     ; established, fin_wait_1, fin_wait_2, close_wait, closing, last_ack, time_wait
800
        ja      .no_syn_rcv                                     ; established, fin_wait_1, fin_wait_2, close_wait, closing, last_ack, time_wait
Line 801... Line 801...
801
 
801
 
802
        DEBUGF  1,"TCP_input: state=syn_received\n"
802
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: state=syn_received\n"
803
 
803
 
804
        mov     eax, [edx + TCP_header.AckNumber]
804
        mov     eax, [edx + TCP_header.AckNumber]
Line 844... Line 844...
844
 
844
 
845
        mov     eax, dword [edx + TCP_header.Window]
845
        mov     eax, dword [edx + TCP_header.Window]
846
        cmp     eax, [ebx + TCP_SOCKET.SND_WND]
846
        cmp     eax, [ebx + TCP_SOCKET.SND_WND]
Line 847... Line 847...
847
        jne     .reset_dupacks
847
        jne     .reset_dupacks
Line 848... Line 848...
848
 
848
 
849
        DEBUGF  1,"TCP_input: Processing duplicate ACK\n"
849
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Processing duplicate ACK\n"
850
 
850
 
Line 925... Line 925...
925
 
925
 
926
 
926
 
Line 927... Line 927...
927
  .no_re_xmit:
927
  .no_re_xmit:
Line 928... Line 928...
928
        jbe     .not_dup_ack
928
        jbe     .not_dup_ack
929
 
929
 
Line 930... Line 930...
930
        DEBUGF  1,"TCP_input: Increasing congestion window\n"
930
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Increasing congestion window\n"
Line 978... Line 978...
978
        mov     edi, [edx + TCP_header.AckNumber]
978
        mov     edi, [edx + TCP_header.AckNumber]
979
        sub     edi, [ebx + TCP_SOCKET.SND_UNA]         ; now we got the number of acked bytes in edi
979
        sub     edi, [ebx + TCP_SOCKET.SND_UNA]         ; now we got the number of acked bytes in edi
Line 980... Line 980...
980
 
980
 
Line 981... Line 981...
981
        ;;; TODO: update stats
981
        ;;; TODO: update stats
Line 982... Line 982...
982
 
982
 
983
        DEBUGF  1,"TCP_input: acceptable ACK for %u bytes\n", edi
983
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi
Line 984... Line 984...
984
 
984
 
Line 1071... Line 1071...
1071
        lea     eax, [ebx + STREAM_SOCKET.snd]
1071
        lea     eax, [ebx + STREAM_SOCKET.snd]
1072
        sub     [ebx + TCP_SOCKET.SND_WND], ecx
1072
        sub     [ebx + TCP_SOCKET.SND_WND], ecx
1073
        call    SOCKET_ring_free
1073
        call    SOCKET_ring_free
1074
        pop     ebx edx ecx
1074
        pop     ebx edx ecx
Line 1075... Line 1075...
1075
 
1075
 
1076
        DEBUGF  1,"TCP_input: our FIN is acked\n"
1076
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
Line 1077... Line 1077...
1077
        stc
1077
        stc
Line 1078... Line 1078...
1078
 
1078
 
Line 1086... Line 1086...
1086
        call    SOCKET_ring_free
1086
        call    SOCKET_ring_free
1087
        pop     ebx
1087
        pop     ebx
1088
        sub     [ebx + TCP_SOCKET.SND_WND], ecx
1088
        sub     [ebx + TCP_SOCKET.SND_WND], ecx
1089
        pop     edx ecx
1089
        pop     edx ecx
Line 1090... Line 1090...
1090
 
1090
 
1091
        DEBUGF  1,"TCP_input: our FIN is not acked\n"
1091
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is not acked\n"
Line 1092... Line 1092...
1092
        clc
1092
        clc
1093
 
1093
 
Line 1174... Line 1174...
1174
; LISTEN
1174
; LISTEN
Line 1175... Line 1175...
1175
 
1175
 
1176
align 4
1176
align 4
Line 1177... Line 1177...
1177
  .LISTEN:
1177
  .LISTEN:
Line 1178... Line 1178...
1178
 
1178
 
1179
        DEBUGF  1,"TCP_input: state=listen\n"
1179
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: state=listen\n"
Line 1180... Line 1180...
1180
 
1180
 
Line 1226... Line 1226...
1226
; Active Open
1226
; Active Open
Line 1227... Line 1227...
1227
 
1227
 
1228
align 4
1228
align 4
Line 1229... Line 1229...
1229
  .SYN_SENT:
1229
  .SYN_SENT:
Line 1230... Line 1230...
1230
 
1230
 
1231
        DEBUGF  1,"TCP_input: state=syn_sent\n"
1231
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: state=syn_sent\n"
Line 1232... Line 1232...
1232
 
1232
 
Line 1286... Line 1286...
1286
        jbe     .simultaneous_open
1286
        jbe     .simultaneous_open
Line 1287... Line 1287...
1287
 
1287
 
1288
        test    [edx + TCP_header.Flags], TH_ACK
1288
        test    [edx + TCP_header.Flags], TH_ACK
Line 1289... Line 1289...
1289
        jz      .simultaneous_open
1289
        jz      .simultaneous_open
Line 1290... Line 1290...
1290
 
1290
 
Line 1291... Line 1291...
1291
        DEBUGF  1,"TCP_input: active open\n"
1291
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: active open\n"
1292
 
1292
 
Line 1314... Line 1314...
1314
        call    TCP_xmit_timer
1314
        call    TCP_xmit_timer
1315
        jmp     .trim_then_step6
1315
        jmp     .trim_then_step6
Line 1316... Line 1316...
1316
 
1316
 
Line 1317... Line 1317...
1317
  .simultaneous_open:
1317
  .simultaneous_open:
1318
 
1318
 
1319
        DEBUGF  1,"TCP_input: simultaneous open\n"
1319
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: simultaneous open\n"
Line 1320... Line 1320...
1320
; We have received a syn but no ACK, so we are having a simultaneous open..
1320
; We have received a syn but no ACK, so we are having a simultaneous open..
1321
        mov     [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
1321
        mov     [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
Line 1337... Line 1337...
1337
;-------
1337
;-------
1338
; step 6
1338
; step 6
Line 1339... Line 1339...
1339
 
1339
 
Line 1340... Line 1340...
1340
  .ack_processed:
1340
  .ack_processed:
Line 1341... Line 1341...
1341
 
1341
 
1342
        DEBUGF  1,"TCP_input: ACK processed\n"
1342
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: ACK processed\n"
Line 1343... Line 1343...
1343
 
1343
 
Line 1371... Line 1371...
1371
        jbe     @f
1371
        jbe     @f
1372
        mov     [ebx + TCP_SOCKET.max_sndwnd], eax
1372
        mov     [ebx + TCP_SOCKET.max_sndwnd], eax
1373
       @@:
1373
       @@:
1374
        mov     [ebx + TCP_SOCKET.SND_WND], eax
1374
        mov     [ebx + TCP_SOCKET.SND_WND], eax
Line 1375... Line 1375...
1375
 
1375
 
Line 1376... Line 1376...
1376
        DEBUGF  1,"TCP_input: Updating window to %u\n", eax
1376
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Updating window to %u\n", eax
1377
 
1377
 
Line 1378... Line 1378...
1378
        push    [edx + TCP_header.SequenceNumber]
1378
        push    [edx + TCP_header.SequenceNumber]
Line 1465... Line 1465...
1465
 
1465
 
Line 1466... Line 1466...
1466
; Uh-oh, some data is out of order, lets call TCP reassemble for help
1466
; Uh-oh, some data is out of order, lets call TCP reassemble for help
Line 1467... Line 1467...
1467
 
1467
 
1468
        call    TCP_reassemble
1468
        call    TCP_reassemble
Line 1469... Line 1469...
1469
 
1469
 
Line 1470... Line 1470...
1470
        DEBUGF  1, "1470\n"
1470
        DEBUGF  DEBUG_NETWORK_VERBOSE,  "1470\n"
1471
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
1471
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
Line 1472... Line 1472...
1472
 
1472
 
1473
  .data_done:
1473
  .data_done:
Line 1474... Line 1474...
1474
 
1474
 
Line 1475... Line 1475...
1475
;---------------
1475
;---------------
1476
; FIN processing
1476
; FIN processing
Line 1477... Line 1477...
1477
 
1477
 
Line 1478... Line 1478...
1478
        test    [edx + TCP_header.Flags], TH_FIN
1478
        test    [edx + TCP_header.Flags], TH_FIN
1479
        jz      .final_processing
1479
        jz      .final_processing
Line 1480... Line 1480...
1480
 
1480
 
Line 1532... Line 1532...
1532
        mov     [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
1532
        mov     [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
1533
        jmp     .final_processing
1533
        jmp     .final_processing
Line 1534... Line 1534...
1534
 
1534
 
1535
 
1535
 
Line 1536... Line 1536...
1536
  .drop_after_ack:
1536
  .drop_after_ack:
1537
        DEBUGF  1,"TCP_input: Drop after ACK\n"
1537
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Drop after ACK\n"
1538
 
1538
 
1539
        push    edx ebx
1539
        push    edx ebx
Line 1546... Line 1546...
1546
 
1546
 
1547
        or      [eax + TCP_SOCKET.t_flags], TF_ACKNOW
1547
        or      [eax + TCP_SOCKET.t_flags], TF_ACKNOW
Line 1548... Line 1548...
1548
        jmp     .need_output
1548
        jmp     .need_output
1549
 
1549
 
Line 1550... Line 1550...
1550
  .drop_with_reset:
1550
  .drop_with_reset:
1551
        DEBUGF  1,"TCP_input: Drop with reset\n"
1551
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Drop with reset\n"
1552
 
1552
 
1553
        push    ebx edx
1553
        push    ebx edx
Line 1569... Line 1569...
1569
 
1569
 
1570
;-----------------
1570
;-----------------
Line 1571... Line 1571...
1571
; Final processing
1571
; Final processing
1572
 
1572
 
Line 1573... Line 1573...
1573
  .final_processing:
1573
  .final_processing:
1574
        DEBUGF  1,"TCP_input: Final processing\n"
1574
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Final processing\n"
1575
 
1575
 
1576
        push    ebx
1576
        push    ebx
Line 1581... Line 1581...
1581
        test    [eax + TCP_SOCKET.temp_bits], TCP_BIT_NEEDOUTPUT
1581
        test    [eax + TCP_SOCKET.temp_bits], TCP_BIT_NEEDOUTPUT
1582
        jnz     .need_output
1582
        jnz     .need_output
Line 1583... Line 1583...
1583
 
1583
 
1584
        test    [eax + TCP_SOCKET.t_flags], TF_ACKNOW
1584
        test    [eax + TCP_SOCKET.t_flags], TF_ACKNOW
1585
        jz      .dumpit
1585
        jz      .dumpit
Line 1586... Line 1586...
1586
        DEBUGF  1,"TCP_input: ACK now!\n"
1586
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: ACK now!\n"
1587
 
1587
 
1588
  .need_output:
1588
  .need_output:
Line 1589... Line 1589...
1589
        DEBUGF  1,"TCP_input: need output\n"
1589
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
1590
        call    TCP_output
1590
        call    TCP_output
Line 1591... Line 1591...
1591
 
1591
 
1592
  .dumpit:
1592
  .dumpit:
1593
        DEBUGF  1,"TCP_input: dumping\n"
1593
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
Line 1639... Line 1639...
1639
 
1639
 
1640
;-----
1640
;-----
Line 1641... Line 1641...
1641
; Drop
1641
; Drop
1642
 
1642
 
Line 1643... Line 1643...
1643
  .drop:
1643
  .drop:
1644
        DEBUGF  1,"TCP_input: Dropping segment\n"
1644
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Dropping segment\n"
1645
 
1645
 
1646
        pusha
1646
        pusha
Line 1654... Line 1654...
1654
 
1654
 
1655
        mov     eax, ebx
1655
        mov     eax, ebx
Line 1656... Line 1656...
1656
        call    SOCKET_free
1656
        call    SOCKET_free
1657
 
1657
 
Line 1658... Line 1658...
1658
  .drop_no_socket:
1658
  .drop_no_socket:
1659
        DEBUGF  1,"TCP_input: Drop (no socket)\n"
1659
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
1660
 
1660