Subversion Repositories Kolibri OS

Rev

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

Rev 2555 Rev 2600
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: 2555 $
17
$Revision: 2600 $
18
 
18
 
19
;-----------------------------------------------------------------
19
;-----------------------------------------------------------------
20
;
20
;
Line 43... Line 43...
43
        mov     [esi + TCP_header.Checksum], 0
43
        mov     [esi + TCP_header.Checksum], 0
44
        TCP_checksum (edi), (edi+4)
44
        TCP_checksum (edi), (edi+4)
45
        pop     cx              ; previous checksum
45
        pop     cx              ; previous checksum
46
        cmp     cx, dx
46
        cmp     cx, dx
47
        pop     edx ecx
47
        pop     edx ecx
48
        jne     .drop_not_locked
48
        jne     .drop_no_socket
Line 49... Line 49...
49
 
49
 
Line 50... Line 50...
50
        DEBUGF  1,"Checksum ok\n"
50
        DEBUGF  1,"Checksum ok\n"
51
 
51
 
52
        and     [edx + TCP_header.DataOffset], 0xf0                     ; Calculate TCP segment header size (throwing away unused reserved bits in TCP header)
52
        and     [edx + TCP_header.DataOffset], 0xf0                     ; Calculate TCP segment header size (throwing away unused reserved bits in TCP header)
53
        shr     [edx + TCP_header.DataOffset], 2
53
        shr     [edx + TCP_header.DataOffset], 2
Line 54... Line 54...
54
        cmp     [edx + TCP_header.DataOffset], sizeof.TCP_header        ; Now see if it's at least the size of a standard TCP header
54
        cmp     [edx + TCP_header.DataOffset], sizeof.TCP_header        ; Now see if it's at least the size of a standard TCP header
55
        jb      .drop_not_locked                                        ; If not, drop the packet
55
        jb      .drop_no_socket                                         ; If not, drop the packet
56
 
56
 
57
        movzx   eax, [edx + TCP_header.DataOffset]
57
        movzx   eax, [edx + TCP_header.DataOffset]
Line 58... Line 58...
58
        sub     ecx, eax                                                ; substract TCP header size from total segment size
58
        sub     ecx, eax                                                ; substract TCP header size from total segment size
59
        jb      .drop_not_locked                                        ; If total segment size is less then the advertised header size, drop packet
59
        jb      .drop_no_socket                                         ; If total segment size is less then the advertised header size, drop packet
Line 105... Line 105...
105
        mov     si, [edx + TCP_header.DestinationPort]
105
        mov     si, [edx + TCP_header.DestinationPort]
Line 106... Line 106...
106
 
106
 
107
  .socket_loop:
107
  .socket_loop:
108
        mov     ebx, [ebx + SOCKET.NextPtr]
108
        mov     ebx, [ebx + SOCKET.NextPtr]
109
        or      ebx, ebx
109
        or      ebx, ebx
Line 110... Line 110...
110
        jz      .drop_with_reset_not_locked
110
        jz      .drop_with_reset_no_socket
111
 
111
 
Line 112... Line 112...
112
        cmp     [ebx + SOCKET.Domain], AF_INET4
112
        cmp     [ebx + SOCKET.Domain], AF_INET4
Line 1523... Line 1523...
1523
; Generate an RST, dropping incoming segment
1523
; Generate an RST, dropping incoming segment
Line 1524... Line 1524...
1524
 
1524
 
1525
align 4
1525
align 4
Line -... Line 1526...
-
 
1526
.drop_with_reset:
-
 
1527
 
1526
.drop_with_reset:
1528
        DEBUGF  1,"Drop with reset\n"
1527
 
1529
 
1528
        pusha
1530
        pusha
1529
        lea     ecx, [ebx + SOCKET.mutex]
1531
        lea     ecx, [ebx + SOCKET.mutex]
Line 1530... Line -...
1530
        call    mutex_unlock
-
 
1531
        popa
-
 
1532
 
-
 
1533
.drop_with_reset_not_locked:
-
 
1534
 
1532
        call    mutex_unlock
1535
        DEBUGF  1,"Drop with reset\n"
1533
        popa
Line 1536... Line 1534...
1536
 
1534
 
Line 1553... Line 1551...
1553
 
1551
 
1554
        push    ebx
1552
        push    ebx
1555
        mov     cl, TH_RST
1553
        mov     cl, TH_RST
1556
        call    TCP_respond_socket
1554
        call    TCP_respond_socket
1557
        pop     ebx
-
 
1558
 
1555
        pop     ebx
Line 1559... Line 1556...
1559
        jmp     .destroy_new_socket
1556
        jmp     .destroy_new_socket
Line 1560... Line 1557...
1560
 
1557
 
1561
 
1558
 
1562
  .respond_syn:
1559
  .respond_syn:
1563
 
1560
 
1564
        push    ebx
-
 
1565
        mov     cl, TH_RST + TH_ACK
1561
        push    ebx
Line 1566... Line -...
1566
        call    TCP_respond_socket
-
 
1567
        pop     ebx
-
 
1568
 
1562
        mov     cl, TH_RST + TH_ACK
1569
        jmp     .destroy_new_socket
1563
        call    TCP_respond_socket
Line 1570... Line 1564...
1570
 
1564
        pop     ebx
1571
 
1565
        jmp     .destroy_new_socket
Line 1596... Line 1590...
1596
        ;;;; kill the newly created socket
1590
        ;;;; kill the newly created socket
Line 1597... Line 1591...
1597
 
1591
 
1598
        call    kernel_free
1592
        call    kernel_free
1599
        add     esp, 4
1593
        add     esp, 4
1600
        ret
1594
        ret
-
 
1595
 
-
 
1596
 
-
 
1597
 
-
 
1598
 
-
 
1599
.drop_with_reset_no_socket:
-
 
1600
 
-
 
1601
        DEBUGF  1,"Drop with reset (no socket)\n"
-
 
1602
 
-
 
1603
        test    [edx + TCP_header.Flags], TH_RST
-
 
1604
        jnz     .drop_no_socket
-
 
1605
 
-
 
1606
        ;;; if its a multicast/broadcast, also drop
-
 
1607
 
-
 
1608
        test    [edx + TCP_header.Flags], TH_ACK
-
 
1609
        jnz     .respond_seg_ack
-
 
1610
 
-
 
1611
        test    [edx + TCP_header.Flags], TH_SYN
-
 
1612
        jnz     .respond_seg_syn
-
 
1613
 
-
 
1614
.drop_no_socket:
-
 
1615
 
-
 
1616
        DEBUGF  1,"Drop (no socket)\n"
-
 
1617
 
-
 
1618
        call    kernel_free
-
 
1619
        add     esp, 4
-
 
1620
        ret
-
 
1621
 
-
 
1622
  .respond_seg_ack:
-
 
1623
 
-
 
1624
        mov     cl, TH_RST
-
 
1625
        call    TCP_respond_segment
-
 
1626
        jmp     .drop_no_socket
-
 
1627
 
-
 
1628
  .respond_seg_syn:
-
 
1629
 
-
 
1630
        mov     cl, TH_RST + TH_ACK
-
 
1631
        call    TCP_respond_segment
-
 
1632
        jmp     .drop_no_socket
1601
>
1633
>