Rev 5841 | Rev 5976 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5841 | Rev 5842 | ||
---|---|---|---|
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: 5841 $ |
17 | $Revision: 5842 $ |
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 | ; |
24 | ; |
25 | ; IN: [esp] = ptr to buffer |
25 | ; IN: [esp] = ptr to buffer |
- | 26 | ; ebx = ptr to device struct |
|
26 | ; ebx = ptr to device struct |
27 | ; ecx = TCP segment size |
27 | ; ecx = segment size |
28 | ; edx = ptr to IPv4 header |
28 | ; esi = ptr to TCP segment |
29 | ; esi = ptr to TCP segment |
29 | ; edi = ptr to ipv4 source address, followed by ipv4 dest address |
30 | ; edi = interface number*4 |
30 | ; |
31 | ; |
31 | ; OUT: / |
32 | ; OUT: / |
Line 32... | Line 33... | ||
32 | ; |
33 | ; |
33 | ;----------------------------------------------------------------- |
34 | ;----------------------------------------------------------------- |
Line 34... | Line 35... | ||
34 | 35 | ||
35 | align 4 |
36 | align 4 |
36 | TCP_input: |
37 | TCP_input: |
37 | 38 | ||
Line -... | Line 39... | ||
- | 39 | ; record the current time |
|
38 | ; record the current time |
40 | push [timer_ticks] ; in 1/100 seconds |
- | 41 | push ebx ecx esi edx ; mind the order (see TCP_queue_entry struct) |
|
39 | push [timer_ticks] ; in 1/100 seconds |
42 | mov esi, esp |
Line 40... | Line -... | ||
40 | push ebx ecx esi edi ; mind the order (see TCP_queue_entry struct) |
- | |
41 | mov esi, esp |
43 | |
Line 42... | Line 44... | ||
42 | 44 | push edi |
|
43 | add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail |
45 | add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail |
44 | add esp, sizeof.TCP_queue_entry |
46 | pop edi |
Line 53... | Line 55... | ||
53 | call raise_event |
55 | call raise_event |
Line 54... | Line 56... | ||
54 | 56 | ||
Line 55... | Line 57... | ||
55 | ret |
57 | ret |
- | 58 | ||
56 | 59 | .fail: |
|
Line 57... | Line 60... | ||
57 | .fail: |
60 | pop edi |
58 | DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n" |
61 | DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n" |
Line 92... | Line 95... | ||
92 | pop [timestamp] |
95 | pop [timestamp] |
93 | push [esi + TCP_queue_entry.buffer_ptr] |
96 | push [esi + TCP_queue_entry.buffer_ptr] |
Line 94... | Line 97... | ||
94 | 97 | ||
95 | mov ebx, [esi + TCP_queue_entry.device_ptr] |
98 | mov ebx, [esi + TCP_queue_entry.device_ptr] |
96 | mov ecx, [esi + TCP_queue_entry.segment_size] |
99 | 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 |
100 | mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 header |
Line 98... | Line 101... | ||
98 | mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last |
101 | mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last |
Line 99... | Line 102... | ||
99 | 102 | ||
Line 109... | Line 112... | ||
109 | jnz .checksum_ok |
112 | jnz .checksum_ok |
Line 110... | Line 113... | ||
110 | 113 | ||
111 | push ecx esi |
114 | push ecx esi |
112 | pushw [esi + TCP_header.Checksum] |
115 | pushw [esi + TCP_header.Checksum] |
113 | mov [esi + TCP_header.Checksum], 0 |
116 | mov [esi + TCP_header.Checksum], 0 |
114 | TCP_checksum (edi), (edi+4) |
117 | TCP_checksum (edi+IPv4_header.SourceAddress), (edi+IPv4_header.DestinationAddress) |
115 | pop cx ; previous checksum |
118 | pop cx ; previous checksum |
116 | cmp cx, dx |
119 | cmp cx, dx |
117 | pop edx ecx |
120 | pop edx ecx |
118 | jne .drop_no_socket |
121 | jne .drop_no_socket |
Line 168... | Line 171... | ||
168 | 171 | ||
169 | cmp [ebx + TCP_SOCKET.LocalPort], si |
172 | cmp [ebx + TCP_SOCKET.LocalPort], si |
Line 170... | Line 173... | ||
170 | jne .socket_loop |
173 | jne .socket_loop |
171 | 174 | ||
172 | mov eax, [ebx + IP_SOCKET.RemoteIP] |
175 | mov eax, [ebx + IP_SOCKET.RemoteIP] |
173 | cmp eax, [edi] ; Ipv4 source address |
176 | cmp eax, [edi + IPv4_header.SourceAddress] |
174 | je @f |
177 | je @f |
175 | test eax, eax |
178 | test eax, eax |
Line 231... | Line 234... | ||
231 | pusha |
234 | pusha |
232 | lea ecx, [ebx + SOCKET.mutex] |
235 | lea ecx, [ebx + SOCKET.mutex] |
233 | call mutex_unlock |
236 | call mutex_unlock |
234 | popa |
237 | popa |
Line 235... | Line 238... | ||
235 | 238 | ||
236 | push ecx edx esi edi ;;; |
239 | push ecx edx esi edi |
237 | call SOCKET_fork |
240 | call SOCKET_fork |
Line 238... | Line 241... | ||
238 | pop edi esi edx ecx |
241 | pop edi esi edx ecx |
239 | 242 | ||
Line 240... | Line 243... | ||
240 | test eax, eax |
243 | test eax, eax |
Line 241... | Line 244... | ||
241 | jz .drop_no_socket |
244 | jz .drop_no_socket |
Line 242... | Line 245... | ||
242 | 245 | ||
243 | mov ebx, eax |
246 | mov ebx, eax |
Line 244... | Line 247... | ||
244 | 247 | ||
245 | mov [temp_bits], TCP_BIT_DROPSOCKET |
248 | mov [temp_bits], TCP_BIT_DROPSOCKET |
Line 1209... | Line 1212... | ||
1209 | 1212 | ||
Line 1210... | Line 1213... | ||
1210 | inc [TCPS_accepts] ; update stats |
1213 | inc [TCPS_accepts] ; update stats |
Line 1211... | Line 1214... | ||
1211 | 1214 | ||
1212 | ;;; TODO: check if it's a broadcast or multicast, and drop if so |
1215 | ;;; TODO: check if it's a broadcast or multicast, and drop if so |
Line 1213... | Line 1216... | ||
1213 | 1216 | ||
1214 | push dword [edi] ; Ipv4 source addres |
1217 | push [edi + IPv4_header.SourceAddress] |
Line 1671... | Line 1674... | ||
1671 | 1674 | ||
Line 1672... | Line 1675... | ||
1672 | jmp .drop_no_socket |
1675 | jmp .drop_no_socket |
1673 | 1676 | ||
- | 1677 | .respond_seg_ack: |
|
1674 | .respond_seg_ack: |
1678 | mov cl, TH_RST |
1675 | mov cl, TH_RST |
1679 | xor ebx, ebx ; FIXME: find a way to get the receiving device ptr |
Line 1676... | Line 1680... | ||
1676 | call TCP_respond_segment |
1680 | call TCP_respond_segment |
1677 | jmp .drop_no_socket |
1681 | jmp .drop_no_socket |
- | 1682 | ||
1678 | 1683 | .respond_seg_syn: |
|
1679 | .respond_seg_syn: |
1684 | mov cl, TH_RST + TH_ACK |
Line 1680... | Line 1685... | ||
1680 | mov cl, TH_RST + TH_ACK |
1685 | xor ebx, ebx ; FIXME: find a way to get the receiving device ptr |
1681 | call TCP_respond_segment |
1686 | call TCP_respond_segment |