Subversion Repositories Kolibri OS

Rev

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

Rev 2309 Rev 2310
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: 2309 $
17
$Revision: 2310 $
18
 
18
 
19
;-----------------------------------------------------------------
19
;-----------------------------------------------------------------
20
;
20
;
21
; TCP_input:
21
; TCP_input:
22
;
22
;
23
;  IN:  [esp] = ptr to buffer
23
;  IN:  [esp] = ptr to buffer
24
;       [esp+4] = buffer size
24
;       [esp+4] = buffer size
25
;       ebx = ptr to device struct
25
;       ebx = ptr to device struct
26
;       ecx = segment size
26
;       ecx = segment size
27
;       edx = ptr to TCP segment
27
;       esi = ptr to TCP segment
28
;       edi = ptr to ipv4 source address, followed by ipv4 dest address
28
;       edi = ptr to ipv4 source address, followed by ipv4 dest address
29
;
29
;
30
;  OUT: /
30
;  OUT: /
Line 34... Line 34...
34
align 4
34
align 4
35
TCP_input:
35
TCP_input:
Line 36... Line 36...
36
 
36
 
Line 37... Line 37...
37
        DEBUGF  1,"TCP_input size=%u\n", ecx
37
        DEBUGF  1,"TCP_input size=%u\n", ecx
38
 
38
 
39
        and     [edx + TCP_header.DataOffset], 0xf0                     ; Calculate TCP segment header size (throwing away unused reserved bits in TCP header)
39
        and     [esi + TCP_header.DataOffset], 0xf0                     ; Calculate TCP segment header size (throwing away unused reserved bits in TCP header)
40
        shr     [edx + TCP_header.DataOffset], 2
40
        shr     [esi + TCP_header.DataOffset], 2
Line 41... Line 41...
41
        cmp     [edx + TCP_header.DataOffset], sizeof.TCP_header        ; Now see if it's at least the size of a standard TCP header
41
        cmp     [esi + TCP_header.DataOffset], sizeof.TCP_header        ; Now see if it's at least the size of a standard TCP header
42
        jb      .drop_not_locked                                        ; If not, drop the packet
42
        jb      .drop_not_locked                                        ; If not, drop the packet
Line 43... Line 43...
43
 
43
 
44
;-------------------------------
44
;-------------------------------
45
; Now, re-calculate the checksum
45
; Now, re-calculate the checksum
46
 
-
 
47
        push    ecx edx
46
 
48
        pushw   [edx + TCP_header.Checksum]
47
        push    ecx esi
49
        mov     [edx + TCP_header.Checksum], 0
48
        pushw   [esi + TCP_header.Checksum]
50
        mov     esi, edx
49
        mov     [esi + TCP_header.Checksum], 0
51
        TCP_checksum (edi), (edi+4)
50
        TCP_checksum (edi), (edi+4)
Line 52... Line 51...
52
        pop     cx              ; previous checksum
51
        pop     cx              ; previous checksum
Line -... Line 52...
-
 
52
        cmp     cx, dx
53
        cmp     cx, dx
53
        pop     edx ecx
54
        pop     edx ecx
54
        jnz     .drop_not_locked
55
        jnz     .drop_not_locked
55
 
Line 56... Line 56...
56
 
56
        DEBUGF  1,"Checksum ok\n"
57
        DEBUGF  1,"Checksum ok\n"
57
 
Line 58... Line 58...
58
 
58
        movzx   eax, [edx + TCP_header.DataOffset]
59
        sub     ecx, [edx + TCP_header.DataOffset]                      ; substract TCP header size from total segment size
59
        sub     ecx, eax                                                ; substract TCP header size from total segment size
60
        jb      .drop_not_locked                                        ; If total segment size is less then the advertised header size, drop packet
60
        jb      .drop_not_locked                                        ; If total segment size is less then the advertised header size, drop packet
Line 61... Line 61...
61
        DEBUGF  1,"we got %u bytes of data\n", ecx
61
        DEBUGF  1,"we got %u bytes of data\n", ecx
62
 
62
 
Line 200... Line 200...
200
        mov     [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
200
        mov     [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
Line 201... Line 201...
201
 
201
 
202
;--------------------
202
;--------------------
Line 203... Line 203...
203
; Process TCP options
203
; Process TCP options
204
 
204
 
205
        mov     eax, [edx + TCP_header.DataOffset]
205
        movzx   eax, [edx + TCP_header.DataOffset]
Line 206... Line 206...
206
        cmp     eax, TCP_header.DataOffset              ; Does header contain any options?
206
        cmp     eax, sizeof.TCP_header                  ; Does header contain any options?
Line 207... Line 207...
207
        je      .no_options
207
        je      .no_options