Rev 3589 | Rev 3725 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3589 | Rev 3626 | ||
---|---|---|---|
Line 56... | Line 56... | ||
56 | 56 | ||
57 | 57 | ||
Line 58... | Line 58... | ||
58 | align 4 |
58 | align 4 |
59 | uglobal |
59 | uglobal |
60 | 60 | ||
61 | IP_LIST rd MAX_NET_DEVICES |
61 | IP_LIST rd NET_DEVICES_MAX |
62 | SUBNET_LIST rd MAX_NET_DEVICES |
62 | SUBNET_LIST rd NET_DEVICES_MAX |
63 | DNS_LIST rd MAX_NET_DEVICES |
63 | DNS_LIST rd NET_DEVICES_MAX |
64 | GATEWAY_LIST rd MAX_NET_DEVICES |
64 | GATEWAY_LIST rd NET_DEVICES_MAX |
65 | BROADCAST_LIST rd MAX_NET_DEVICES |
65 | BROADCAST_LIST rd NET_DEVICES_MAX |
66 | 66 | ||
Line 67... | Line 67... | ||
67 | IP_packets_tx rd MAX_NET_DEVICES |
67 | IP_packets_tx rd NET_DEVICES_MAX |
68 | IP_packets_rx rd MAX_NET_DEVICES |
68 | IP_packets_rx rd NET_DEVICES_MAX |
Line 81... | Line 81... | ||
81 | ;----------------------------------------------------------------- |
81 | ;----------------------------------------------------------------- |
82 | macro IPv4_init { |
82 | macro IPv4_init { |
Line 83... | Line 83... | ||
83 | 83 | ||
84 | xor eax, eax |
84 | xor eax, eax |
85 | mov edi, IP_LIST |
85 | mov edi, IP_LIST |
86 | mov ecx, 7*MAX_NET_DEVICES + (sizeof.FRAGMENT_slot*MAX_FRAGMENTS)/4 |
86 | mov ecx, 7*NET_DEVICES_MAX + (sizeof.FRAGMENT_slot*MAX_FRAGMENTS)/4 |
Line 87... | Line 87... | ||
87 | rep stosd |
87 | rep stosd |
Line 566... | Line 566... | ||
566 | ; |
566 | ; |
567 | ;------------------------------------------------------------------ |
567 | ;------------------------------------------------------------------ |
568 | align 4 |
568 | align 4 |
569 | IPv4_output: |
569 | IPv4_output: |
Line 570... | Line 570... | ||
570 | 570 | ||
Line 571... | Line 571... | ||
571 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u\n", ecx |
571 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax |
572 | 572 | ||
Line 573... | Line 573... | ||
573 | cmp ecx, 65500 ; Max IPv4 packet size |
573 | cmp ecx, 65500 ; Max IPv4 packet size |
Line 574... | Line -... | ||
574 | ja .too_large |
- | |
575 | - | ||
576 | push ecx eax edx di |
- | |
577 | 574 | ja .too_large |
|
- | 575 | ||
- | 576 | push ecx eax edx di |
|
- | 577 | ||
- | 578 | call IPv4_route ; outputs device number in edi, dest ip in eax |
|
578 | cmp eax, 1 shl 24 + 127 |
579 | |
579 | je .loopback |
580 | test edi, edi |
580 | 581 | jz .loopback |
|
581 | call IPv4_route ; outputs device number in edi, dest ip in eax |
582 | |
582 | call ARP_IP_to_MAC |
583 | call ARP_IP_to_MAC |
Line 583... | Line 584... | ||
583 | test eax, 0xffff0000 ; error bits |
584 | test eax, 0xffff0000 ; error bits |
Line 584... | Line 585... | ||
584 | jnz .arp_error |
585 | jnz .arp_error |
585 | push ebx ; push the mac onto the stack |
586 | push ebx ; push the mac onto the stack |
586 | push ax |
587 | push ax |
587 | 588 | ||
588 | inc [IP_packets_tx + edi] ; update stats |
589 | inc [IP_packets_tx + 4*edi] ; update stats |
589 | 590 | ||
590 | mov ebx, [NET_DRV_LIST + edi] |
591 | mov ebx, [NET_DRV_LIST + 4*edi] |
591 | lea eax, [ebx + ETH_DEVICE.mac] |
592 | lea eax, [ebx + ETH_DEVICE.mac] |
592 | mov edx, esp |
593 | mov edx, esp |
Line 593... | Line 594... | ||
593 | mov ecx, [esp + 10 + 6] |
594 | mov ecx, [esp + 10 + 6] |
Line 616... | Line 617... | ||
616 | add edi, sizeof.IPv4_header |
617 | add edi, sizeof.IPv4_header |
617 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n" |
618 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n" |
618 | ret |
619 | ret |
Line 619... | Line 620... | ||
619 | 620 | ||
620 | .eth_error: |
621 | .eth_error: |
621 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: ethernet error\n" |
622 | DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n" |
622 | add esp, 3*4+2+6 |
623 | add esp, 3*4+2+6 |
623 | xor edi, edi |
624 | xor edi, edi |
Line 624... | Line 625... | ||
624 | ret |
625 | ret |
625 | 626 | ||
626 | .arp_error: |
627 | .arp_error: |
627 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: ARP error=%x\n", eax |
628 | DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax |
628 | add esp, 3*4+2 |
629 | add esp, 3*4+2 |
Line 629... | Line 630... | ||
629 | xor edi, edi |
630 | xor edi, edi |
630 | ret |
631 | ret |
631 | 632 | ||
632 | .too_large: |
633 | .too_large: |
Line 633... | Line 634... | ||
633 | DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n" |
634 | DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n" |
- | 635 | xor edi, edi |
|
634 | xor edi, edi |
636 | ret |
635 | ret |
637 | |
636 | 638 | .loopback: |
|
637 | .loopback: |
639 | mov dword [esp + 2], eax ; change source IP to dest IP |
638 | mov dword [esp + 2], eax |
640 | mov ecx, [esp + 10] |
Line 673... | Line 675... | ||
673 | jnz .arp_error |
675 | jnz .arp_error |
Line 674... | Line 676... | ||
674 | 676 | ||
675 | push ebx ; push the mac |
677 | push ebx ; push the mac |
Line 676... | Line 678... | ||
676 | push ax |
678 | push ax |
677 | 679 | ||
678 | inc [IP_packets_tx + edi] |
680 | inc [IP_packets_tx + 4*edi] |
679 | mov ebx, [NET_DRV_LIST + edi] |
681 | mov ebx, [NET_DRV_LIST + 4*edi] |
680 | lea eax, [ebx + ETH_DEVICE.mac] |
682 | lea eax, [ebx + ETH_DEVICE.mac] |
681 | mov edx, esp |
683 | mov edx, esp |
682 | mov ecx, [esp + 6 + 4] |
684 | mov ecx, [esp + 6 + 4] |
683 | add ecx, sizeof.IPv4_header |
685 | add ecx, sizeof.IPv4_header |
684 | mov di, ETHER_IPv4 |
686 | mov di, ETHER_PROTO_IPv4 |
Line 685... | Line 687... | ||
685 | call ETH_output |
687 | call ETH_output |
Line 773... | Line 775... | ||
773 | DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment" |
775 | DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment" |
Line 774... | Line 776... | ||
774 | 776 | ||
775 | 777 | ||
776 | mov eax, [esp + 3*4] |
778 | mov eax, [esp + 3*4] |
777 | lea ebx, [esp + 4*4] |
779 | lea ebx, [esp + 4*4] |
Line 778... | Line 780... | ||
778 | mov di , ETHER_IPv4 |
780 | mov di , ETHER_PROTO_IPv4 |
779 | call ETH_output |
781 | call ETH_output |
Line 853... | Line 855... | ||
853 | ;--------------------------------------------------------------------------- |
855 | ;--------------------------------------------------------------------------- |
854 | ; |
856 | ; |
855 | ; IPv4_route |
857 | ; IPv4_route |
856 | ; |
858 | ; |
857 | ; IN: eax = Destination IP |
859 | ; IN: eax = Destination IP |
858 | ; OUT: edi = device id * 4 |
860 | ; OUT: edi = device number |
859 | ; eax = ip of gateway if nescessary, unchanged otherwise |
861 | ; eax = ip of gateway if nescessary, unchanged otherwise |
860 | ; |
862 | ; |
861 | ;--------------------------------------------------------------------------- |
863 | ;--------------------------------------------------------------------------- |
862 | align 4 |
864 | align 4 |
863 | IPv4_route: |
865 | IPv4_route: |
Line 864... | Line 866... | ||
864 | 866 | ||
865 | cmp eax, 0xffffffff |
867 | cmp eax, 0xffffffff |
Line 866... | Line 868... | ||
866 | je .broadcast |
868 | je .broadcast |
867 | 869 | ||
868 | xor edi, edi |
870 | xor edi, edi |
869 | mov ecx, MAX_NET_DEVICES |
871 | mov ecx, NET_DEVICES_MAX |
870 | .loop: |
872 | .loop: |
871 | mov ebx, [IP_LIST+edi] |
873 | mov ebx, [IP_LIST+edi] |
872 | and ebx, [SUBNET_LIST+edi] |
874 | and ebx, [SUBNET_LIST+edi] |
873 | jz .next |
875 | jz .next |
Line 874... | Line 876... | ||
874 | mov edx, eax |
876 | mov edx, eax |
875 | and edx, [SUBNET_LIST+edi] |
877 | and edx, [SUBNET_LIST+edi] |
- | 878 | ||
- | 879 | cmp ebx, edx |
|
- | 880 | jne .next |
|
- | 881 | ||
876 | 882 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi |
|
877 | cmp ebx, edx |
883 | ret |
878 | je .found_it |
884 | |
879 | .next: |
885 | .next: |
Line 880... | Line 886... | ||
880 | add edi, 4 |
886 | add edi, 4 |
881 | dec ecx |
- | |
882 | jnz .loop |
887 | dec ecx |
883 | - | ||
884 | .invalid: |
- | |
885 | xor edi, edi ; if none found, use device 0 as default |
- | |
886 | mov eax, [GATEWAY_LIST] |
- | |
887 | - | ||
888 | .found_it: |
888 | jnz .loop |
- | 889 | ||
889 | DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi |
890 | .invalid: |
890 | ret |
891 | mov eax, [GATEWAY_LIST+4] ;;; FIXME |
Line 891... | Line 892... | ||
891 | 892 | .broadcast: |
|
Line 971... | Line 972... | ||
971 | mov ebx, [SUBNET_LIST + eax] |
972 | mov ebx, [SUBNET_LIST + eax] |
972 | not ebx |
973 | not ebx |
973 | or ebx, ecx |
974 | or ebx, ecx |
974 | mov [BROADCAST_LIST + eax], ebx |
975 | mov [BROADCAST_LIST + eax], ebx |
Line -... | Line 976... | ||
- | 976 | ||
975 | 977 | mov ebx, [NET_DRV_LIST + eax] |
|
976 | mov eax, ecx |
978 | mov eax, [IP_LIST + eax] |
Line 977... | Line 979... | ||
977 | call ARP_output_request ; now send a gratuitous ARP |
979 | call ARP_output_request ; now send a gratuitous ARP |
978 | 980 | ||
979 | call NET_send_event |
981 | call NET_send_event |