Rev 5584 | Rev 6011 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5584 | Rev 5842 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | ;; GNU GENERAL PUBLIC LICENSE ;; |
14 | ;; GNU GENERAL PUBLIC LICENSE ;; |
15 | ;; Version 2, June 1991 ;; |
15 | ;; Version 2, June 1991 ;; |
16 | ;; ;; |
16 | ;; ;; |
17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 18... | Line 18... | ||
18 | 18 | ||
Line 19... | Line 19... | ||
19 | $Revision: 5584 $ |
19 | $Revision: 5842 $ |
Line 20... | Line 20... | ||
20 | 20 | ||
Line 131... | Line 131... | ||
131 | ; and insert packets into sockets when needed |
131 | ; and insert packets into sockets when needed |
132 | ; |
132 | ; |
133 | ; IN: Pointer to buffer in [esp] |
133 | ; IN: Pointer to buffer in [esp] |
134 | ; ebx = pointer to device struct |
134 | ; ebx = pointer to device struct |
135 | ; ecx = ICMP Packet size |
135 | ; ecx = ICMP Packet size |
- | 136 | ; edx = ptr to IPv4 header |
|
136 | ; esi = ptr to ICMP Packet data |
137 | ; esi = ptr to ICMP Packet data |
137 | ; edi = ptr to ipv4 source and dest address |
138 | ; edi = interface number*4 |
138 | ; |
139 | ; |
139 | ; OUT: / |
140 | ; OUT: / |
140 | ; |
141 | ; |
141 | ;----------------------------------------------------------------- |
142 | ;----------------------------------------------------------------- |
142 | align 4 |
143 | align 4 |
143 | ICMP_input: |
144 | ICMP_input: |
Line 144... | Line 145... | ||
144 | 145 | ||
Line -... | Line 146... | ||
- | 146 | DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n" |
|
- | 147 | ||
- | 148 | ; Dump all multicasts and broadcasts |
|
- | 149 | mov eax, [IP_LIST + edi] |
|
- | 150 | cmp eax, [edx + IPv4_header.DestinationAddress] |
|
145 | DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n" |
151 | jne .dump |
146 | 152 | ||
147 | ; Check the checksum |
153 | ; Check the checksum |
148 | push esi ecx |
154 | push esi ecx edx |
149 | push [esi + ICMP_header.Checksum] |
155 | push [esi + ICMP_header.Checksum] |
150 | mov [esi + ICMP_header.Checksum], 0 |
156 | mov [esi + ICMP_header.Checksum], 0 |
151 | xor edx, edx |
157 | xor edx, edx |
152 | call checksum_1 |
158 | call checksum_1 |
153 | call checksum_2 |
159 | call checksum_2 |
154 | pop si |
160 | pop si |
155 | cmp dx, si |
161 | cmp dx, si |
Line 156... | Line 162... | ||
156 | pop ecx esi |
162 | pop edx ecx esi |
Line 157... | Line -... | ||
157 | jne .checksum_mismatch |
- | |
158 | - | ||
159 | DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: Checksum OK\n" |
- | |
160 | - | ||
161 | ; Ualidate device ptr |
- | |
162 | mov eax, edi |
- | |
163 | call NET_ptr_to_num4 |
163 | jne .checksum_mismatch |
164 | cmp edi, -1 |
164 | |
Line 165... | Line 165... | ||
165 | je .dump |
165 | DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: Checksum OK\n" |
166 | 166 | ||
Line 175... | Line 175... | ||
175 | pusha |
175 | pusha |
176 | mov ecx, socket_mutex |
176 | mov ecx, socket_mutex |
177 | call mutex_lock |
177 | call mutex_lock |
178 | popa |
178 | popa |
Line -... | Line 179... | ||
- | 179 | ||
- | 180 | add ecx, esi |
|
179 | 181 | sub ecx, edx |
|
180 | mov edx, [eax] ; ipv4 source address |
182 | mov esi, edx |
181 | mov eax, net_sockets |
- | |
182 | .try_more: |
- | |
183 | ; mov , [esi + ICMP_header.Identifier] |
183 | mov eax, net_sockets |
184 | .next_socket: |
184 | .next_socket: |
185 | mov eax, [eax + SOCKET.NextPtr] |
185 | mov eax, [eax + SOCKET.NextPtr] |
186 | or eax, eax |
186 | or eax, eax |
Line 190... | Line 190... | ||
190 | jne .next_socket |
190 | jne .next_socket |
Line 191... | Line 191... | ||
191 | 191 | ||
192 | cmp [eax + SOCKET.Protocol], IP_PROTO_ICMP |
192 | cmp [eax + SOCKET.Protocol], IP_PROTO_ICMP |
Line 193... | Line -... | ||
193 | jne .next_socket |
- | |
194 | - | ||
195 | cmp [eax + IP_SOCKET.RemoteIP], edx |
- | |
196 | jne .next_socket |
- | |
197 | - | ||
198 | ; cmp [eax + ICMP_SOCKET.Identifier], |
- | |
199 | ; jne .next_socket |
193 | jne .next_socket |
200 | 194 | ||
201 | pusha |
195 | pusha |
202 | mov ecx, socket_mutex |
196 | mov ecx, socket_mutex |
Line 374... | Line 368... | ||
374 | ; |
368 | ; |
375 | ; ICMP_output_raw |
369 | ; ICMP_output_raw |
376 | ; |
370 | ; |
377 | ; IN: eax = socket ptr |
371 | ; IN: eax = socket ptr |
378 | ; ecx = data length |
372 | ; ecx = data length |
379 | ; esi = data offset |
373 | ; edx = data pointer |
380 | ; |
374 | ; |
381 | ;----------------------------------------------------------------- |
375 | ;----------------------------------------------------------------- |
382 | align 4 |
376 | align 4 |
383 | ICMP_output_raw: |
377 | ICMP_output_raw: |
Line 384... | Line 378... | ||
384 | 378 | ||
Line 385... | Line 379... | ||
385 | DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx |
379 | DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx |
386 | - | ||
387 | push edx |
- | |
388 | - | ||
389 | mov di, IP_PROTO_ICMP SHL 8 + 128 ; TTL |
380 | |
- | 381 | push edx |
|
390 | mov edx, [eax + IP_SOCKET.LocalIP] |
382 | mov ebx, [eax + IP_SOCKET.device] |
- | 383 | mov edx, [eax + IP_SOCKET.LocalIP] |
|
- | 384 | mov edi, [eax + IP_SOCKET.RemoteIP] |
|
391 | mov ebx, [eax + IP_SOCKET.device] |
385 | mov al, [eax + IP_SOCKET.ttl] |
392 | mov eax, [eax + IP_SOCKET.RemoteIP] |
386 | mov ah, IP_PROTO_ICMP |
Line 393... | Line 387... | ||
393 | call IPv4_output |
387 | call IPv4_output |
394 | jz .exit |
388 | jz .fail |
Line 395... | Line 389... | ||
395 | 389 | ||
Line 415... | Line 409... | ||
415 | jnz @f |
409 | jnz @f |
416 | call NET_ptr_to_num4 |
410 | call NET_ptr_to_num4 |
417 | inc [ICMP_PACKETS_TX + edi] |
411 | inc [ICMP_PACKETS_TX + edi] |
418 | @@: |
412 | @@: |
419 | ret |
413 | ret |
- | 414 | ||
420 | .exit: |
415 | .fail: |
- | 416 | pop edx |
|
421 | DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n" |
417 | DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n" |
- | 418 | or eax, -1 |
|
- | 419 | mov ebx, EMSGSIZE ;;; FIXME |
|
422 | ret |
420 | ret |