Rev 5363 | Rev 5584 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5522 | ||
---|---|---|---|
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: 5363 $ |
19 | $Revision: 5522 $ |
20 | 20 | ||
Line 21... | Line 21... | ||
21 | IPv4_MAX_FRAGMENTS = 64 |
21 | IPv4_MAX_FRAGMENTS = 64 |
Line 223... | Line 223... | ||
223 | ; |
223 | ; |
224 | ;----------------------------------------------------------------- |
224 | ;----------------------------------------------------------------- |
225 | align 4 |
225 | align 4 |
226 | IPv4_input: ; TODO: add IPv4 raw sockets support |
226 | IPv4_input: ; TODO: add IPv4 raw sockets support |
Line 227... | Line 227... | ||
227 | 227 | ||
228 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input, packet from: %u.%u.%u.%u ",\ |
228 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\ |
229 | [edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\ |
229 | [edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\ |
230 | [edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1 |
230 | [edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1 |
231 | DEBUGF DEBUG_NETWORK_VERBOSE, "to: %u.%u.%u.%u\n",\ |
231 | DEBUGF DEBUG_NETWORK_VERBOSE, "to %u.%u.%u.%u\n",\ |
232 | [edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\ |
232 | [edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\ |
Line 233... | Line 233... | ||
233 | [edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1 |
233 | [edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1 |
234 | 234 | ||
Line 321... | Line 321... | ||
321 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: unknown protocol %u\n", al |
321 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: unknown protocol %u\n", al |
Line 322... | Line 322... | ||
322 | 322 | ||
323 | .dump: |
323 | .dump: |
324 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n" |
324 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n" |
325 | inc [IPv4_packets_dumped] ; FIXME: use correct interface |
325 | inc [IPv4_packets_dumped] ; FIXME: use correct interface |
326 | call NET_packet_free |
- | |
327 | add esp, 4 ; pop (balance stack) |
326 | call NET_BUFF_free |
Line 328... | Line 327... | ||
328 | ret |
327 | ret |
329 | 328 | ||
Line 369... | Line 368... | ||
369 | mov [edi + IPv4_FRAGMENT_entry.NextPtr], eax ; update pointer of previous entry to the new entry |
368 | mov [edi + IPv4_FRAGMENT_entry.NextPtr], eax ; update pointer of previous entry to the new entry |
370 | mov [eax + IPv4_FRAGMENT_entry.NextPtr], -1 |
369 | mov [eax + IPv4_FRAGMENT_entry.NextPtr], -1 |
371 | mov [eax + IPv4_FRAGMENT_entry.PrevPtr], edi |
370 | mov [eax + IPv4_FRAGMENT_entry.PrevPtr], edi |
372 | mov [eax + IPv4_FRAGMENT_entry.Owner], ebx |
371 | mov [eax + IPv4_FRAGMENT_entry.Owner], ebx |
Line 373... | Line -... | ||
373 | - | ||
374 | add esp, 4 |
372 | |
Line 375... | Line 373... | ||
375 | ret |
373 | ret |
376 | 374 | ||
Line 403... | Line 401... | ||
403 | ; Now, replace ethernet header in original buffer with a FRAGMENT_entry structure |
401 | ; Now, replace ethernet header in original buffer with a FRAGMENT_entry structure |
404 | mov [eax + IPv4_FRAGMENT_entry.NextPtr], -1 |
402 | mov [eax + IPv4_FRAGMENT_entry.NextPtr], -1 |
405 | mov [eax + IPv4_FRAGMENT_entry.PrevPtr], -1 |
403 | mov [eax + IPv4_FRAGMENT_entry.PrevPtr], -1 |
406 | mov [eax + IPv4_FRAGMENT_entry.Owner], ebx |
404 | mov [eax + IPv4_FRAGMENT_entry.Owner], ebx |
Line 407... | Line -... | ||
407 | - | ||
408 | add esp, 4 ; balance stack and exit |
405 | |
Line 409... | Line 406... | ||
409 | ret |
406 | ret |
410 | 407 | ||
Line 504... | Line 501... | ||
504 | push eax |
501 | push eax |
505 | push [edx + IPv4_FRAGMENT_entry.Owner] ; we need to remeber the owner, in case this is the last packet |
502 | push [edx + IPv4_FRAGMENT_entry.Owner] ; we need to remeber the owner, in case this is the last packet |
506 | push [edx + IPv4_FRAGMENT_entry.NextPtr] ; Set edx to the next pointer |
503 | push [edx + IPv4_FRAGMENT_entry.NextPtr] ; Set edx to the next pointer |
507 | push edx ; Push pointer to fragment onto stack |
504 | push edx ; Push pointer to fragment onto stack |
508 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx |
505 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx |
509 | call NET_packet_free ; free the previous fragment buffer (this uses the value from stack) |
506 | call NET_BUFF_free ; free the previous fragment buffer (this uses the value from stack) |
510 | pop edx ebx eax |
507 | pop edx ebx eax |
511 | cmp edx, -1 ; Check if it is last fragment in chain |
508 | cmp edx, -1 ; Check if it is last fragment in chain |
512 | jne .rebuild_packet_loop |
509 | jne .rebuild_packet_loop |
Line 513... | Line 510... | ||
513 | 510 | ||
Line 652... | Line 649... | ||
652 | DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n" |
649 | DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n" |
653 | xor eax, eax |
650 | xor eax, eax |
654 | ret |
651 | ret |
Line 655... | Line 652... | ||
655 | 652 | ||
656 | .loopback: |
653 | .loopback: |
657 | mov dword [esp + 2], eax ; change source IP to dest IP |
654 | mov dword [esp], eax ; set source IP to dest IP |
658 | mov ecx, [esp + 10] |
655 | mov ecx, [esp + 10] |
659 | add ecx, sizeof.IPv4_header |
656 | add ecx, sizeof.IPv4_header |
660 | mov edi, AF_INET4 |
657 | mov edi, AF_INET4 |
661 | call LOOP_output |
658 | call LOOP_output |
Line 747... | Line 744... | ||
747 | 744 | ||
748 | ;-------------------------------------------------------- |
745 | ;-------------------------------------------------------- |
749 | ; |
746 | ; |
750 | ; |
747 | ; |
751 | ; IN: dword [esp] = pointer to buffer containing ipv4 packet to be fragmented |
- | |
752 | ; dword [esp+4] = buffer size |
748 | ; IN: dword [esp] = pointer to buffer containing ipv4 packet to be fragmented |
753 | ; esi = pointer to ip header in that buffer |
749 | ; esi = pointer to ip header in that buffer |
754 | ; ecx = max size of fragments |
750 | ; ecx = max size of fragments |
755 | ; |
751 | ; |
756 | ; OUT: / |
752 | ; OUT: / |
Line 855... | Line 851... | ||
855 | DEBUGF DEBUG_NETWORK_ERROR, "Ipv4_fragment: failed\n" |
851 | DEBUGF DEBUG_NETWORK_ERROR, "Ipv4_fragment: failed\n" |
856 | .done: |
852 | .done: |
857 | add esp, 12 + 4 + 6 |
853 | add esp, 12 + 4 + 6 |
858 | .err2: |
854 | .err2: |
859 | DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: dumping\n" |
855 | DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: dumping\n" |
860 | call NET_packet_free |
856 | call NET_BUFF_free |
861 | add esp, 4 |
- | |
862 | - | ||
863 | ret |
857 | ret |
Line 864... | Line 858... | ||
864 | 858 |