Subversion Repositories Kolibri OS

Rev

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

Rev 5201 Rev 5565
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
Line 12... Line 12...
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
$Revision: 5155 $
17
$Revision: 5522 $
18
 
18
 
19
;-----------------------------------------------------------------
19
;-----------------------------------------------------------------
20
;
20
;
21
; TCP_input:
21
; TCP_input:
22
;
22
;
23
;       Add a segment to the incoming TCP queue
23
;       Add a segment to the incoming TCP queue
24
;
-
 
25
;  IN:  [esp] = ptr to buffer
24
;
26
;       [esp+4] = buffer size (dont care)
25
;  IN:  [esp] = ptr to buffer
27
;       ebx = ptr to device struct
26
;       ebx = ptr to device struct
28
;       ecx = segment size
27
;       ecx = segment size
29
;       esi = ptr to TCP segment
28
;       esi = ptr to TCP segment
Line 35... Line 34...
35
 
34
 
36
align 4
35
align 4
Line 37... Line 36...
37
TCP_input:
36
TCP_input:
38
 
37
 
39
; record the current time
-
 
40
        mov     eax, [timer_ticks]      ; in 1/100 seconds
-
 
41
        mov     [esp + 4], eax
38
; record the current time
42
 
39
        push    [timer_ticks]           ; in 1/100 seconds
Line 43... Line 40...
43
        push    ebx ecx esi edi         ; mind the order
40
        push    ebx ecx esi edi         ; mind the order (see TCP_queue_entry struct)
44
        mov     esi, esp
41
        mov     esi, esp
Line 62... Line 59...
62
 
59
 
63
        call    NET_ptr_to_num4
60
        call    NET_ptr_to_num4
Line 64... Line 61...
64
        inc     [TCP_segments_missed + edi]
61
        inc     [TCP_segments_missed + edi]
65
 
62
 
66
        add     esp, sizeof.TCP_queue_entry - 8
-
 
67
        call    NET_packet_free
-
 
68
        add     esp, 4
63
        add     esp, sizeof.TCP_queue_entry - 8
Line 69... Line -...
69
 
-
 
70
        ret
64
        call    NET_BUFF_free
71
 
65
        ret
Line 72... Line 66...
72
 
66
 
73
 
67
 
Line 392... Line 386...
392
        mov     eax, [timestamp]
386
        mov     eax, [timestamp]
393
        sub     eax, [ebx + TCP_SOCKET.ts_recent_age]
387
        sub     eax, [ebx + TCP_SOCKET.ts_recent_age]
Line 394... Line 388...
394
 
388
 
395
        pop     ecx
389
        pop     ecx
396
        cmp     eax, TCP_PAWS_IDLE
390
        cmp     eax, TCP_PAWS_IDLE
397
        jle     .drop_after_ack                         ; TODO: update stats
391
        jle     .paws_drop
398
        push    ecx
-
 
399
 
392
        push    ecx
400
        mov     [ebx + TCP_SOCKET.ts_recent], 0         ; timestamp was invalid, fix it.
393
        mov     [ebx + TCP_SOCKET.ts_recent], 0         ; timestamp was invalid, fix it.
401
  .no_paws:
394
  .no_paws:
Line -... Line 395...
-
 
395
        jmp     .opt_loop
-
 
396
 
-
 
397
  .paws_drop:
-
 
398
        inc     [TCPS_rcvduppack]                       ; update stats
-
 
399
        add     [TCPS_rcvdupbyte], ecx
-
 
400
        inc     [TCPS_pawsdrop]
402
        jmp     .opt_loop
401
        jmp     .drop_after_ack
Line 403... Line 402...
403
 
402
 
Line 404... Line 403...
404
  .no_options:
403
  .no_options:
Line 628... Line 627...
628
; send an ACK and resynchronize and drop any data.
627
; send an ACK and resynchronize and drop any data.
629
; But keep on processing for RST or ACK
628
; But keep on processing for RST or ACK
630
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
629
        or      [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
631
        mov     eax, ecx
630
        mov     eax, ecx
Line -... Line 631...
-
 
631
 
-
 
632
        inc     [TCPS_rcvpartduppack]
632
 
633
 
Line 633... Line 634...
633
;;; TODO: update stats
634
;;; TODO: update stats
634
 
635
 
Line 660... Line 661...
660
        test    ecx, ecx
661
        test    ecx, ecx
661
        jz      .not_terminated
662
        jz      .not_terminated
Line 662... Line 663...
662
 
663
 
663
        mov     eax, ebx
664
        mov     eax, ebx
664
        call    TCP_close
665
        call    TCP_close
665
;;; TODO: update stats
666
        inc     [TCPS_rcvafterclose]
Line 666... Line 667...
666
        jmp     .respond_seg_reset
667
        jmp     .respond_seg_reset
667
 
668
 
Line 983... Line 984...
983
        mov     [ebx + TCP_SOCKET.t_dupacks], 0
984
        mov     [ebx + TCP_SOCKET.t_dupacks], 0
Line 984... Line 985...
984
 
985
 
985
        mov     eax, [edx + TCP_header.AckNumber]
986
        mov     eax, [edx + TCP_header.AckNumber]
986
        cmp     eax, [ebx + TCP_SOCKET.SND_MAX]
987
        cmp     eax, [ebx + TCP_SOCKET.SND_MAX]
987
        jbe     @f
-
 
988
 
988
        jbe     @f
989
        ;;; TODO: update stats
989
        inc     [TCPS_rcvacktoomuch]
990
        jmp     .drop_after_ack
-
 
991
 
990
        jmp     .drop_after_ack
Line 992... Line 991...
992
       @@:
991
       @@:
993
 
992
 
994
        mov     edi, [edx + TCP_header.AckNumber]
-
 
995
        sub     edi, [ebx + TCP_SOCKET.SND_UNA]         ; now we got the number of acked bytes in edi
993
        mov     edi, [edx + TCP_header.AckNumber]
996
 
-
 
-
 
994
        sub     edi, [ebx + TCP_SOCKET.SND_UNA]         ; now we got the number of acked bytes in edi
997
        ;;; TODO: update stats
995
        inc     [TCPS_rcvackpack]
Line 998... Line 996...
998
 
996
        add     [TCPS_rcvackbyte], edi
999
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi
997
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi
Line 1207... Line 1205...
1207
        jnz     .drop_with_reset
1205
        jnz     .drop_with_reset
Line 1208... Line 1206...
1208
 
1206
 
1209
        test    [edx + TCP_header.Flags], TH_SYN
1207
        test    [edx + TCP_header.Flags], TH_SYN
Line -... Line 1208...
-
 
1208
        jz      .drop
-
 
1209
 
1210
        jz      .drop
1210
        inc     [TCPS_accepts]                          ; update stats
Line 1211... Line 1211...
1211
 
1211
 
1212
;;; TODO: check if it's a broadcast or multicast, and drop if so
1212
;;; TODO: check if it's a broadcast or multicast, and drop if so
Line 1587... Line 1587...
1587
        call    TCP_output
1587
        call    TCP_output
Line 1588... Line 1588...
1588
 
1588
 
1589
  .done:
1589
  .done:
Line 1590... Line 1590...
1590
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
1590
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
1591
 
1591
 
Line 1592... Line 1592...
1592
        call    NET_packet_free
1592
        call    NET_BUFF_free
1593
        jmp     .loop
1593
        jmp     .loop
Line 1706... Line 1706...
1706
; Drop the segment
1706
; Drop the segment
Line 1707... Line 1707...
1707
 
1707
 
1708
  .drop_no_socket:
1708
  .drop_no_socket:
Line 1709... Line 1709...
1709
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
1709
        DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
1710
 
1710
 
Line 1711... Line 1711...
1711
        call    NET_packet_free
1711
        call    NET_BUFF_free