Subversion Repositories Kolibri OS

Rev

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

Rev 1530 Rev 1541
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: 1530 $
19
$Revision: 1541 $
20
 
20
 
21
MAX_FRAGMENTS	equ 64
21
MAX_FRAGMENTS	equ 64
Line 651... Line 651...
651
	DEBUGF	1,"IPv4_create_packet: Failed\n"
651
	DEBUGF	1,"IPv4_create_packet: Failed\n"
652
	sub	edi, edi
652
	sub	edi, edi
653
	ret
653
	ret
Line -... Line 654...
-
 
654
 
-
 
655
 
-
 
656
 
-
 
657
 
-
 
658
 
-
 
659
;------------------------------------------------------------------
-
 
660
;
-
 
661
; IPv4_output_raw
-
 
662
;
-
 
663
; IN: eax = socket ptr
-
 
664
;     ecx = data length
-
 
665
;     esi = data ptr
-
 
666
;
-
 
667
; OUT: /
-
 
668
;
-
 
669
;------------------------------------------------------------------
-
 
670
align 4
-
 
671
IPv4_output_raw:
-
 
672
 
-
 
673
	DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
-
 
674
 
-
 
675
	cmp	ecx, 1480		;;;;;
-
 
676
	jg	.too_large
-
 
677
 
-
 
678
	sub	esp, 8
-
 
679
	push	esi eax
-
 
680
 
-
 
681
	call	ARP_IP_to_MAC
-
 
682
 
-
 
683
	test	eax, 0xffff0000 	; error bits
-
 
684
	jnz	.arp_error
-
 
685
 
-
 
686
  .continue:
-
 
687
 
-
 
688
	push	ebx	; push the mac
-
 
689
	push	ax
-
 
690
 
-
 
691
	call	IPv4_dest_to_dev
-
 
692
	inc	[IP_PACKETS_TX+edi]
-
 
693
	mov	ebx, [NET_DRV_LIST+edi]
-
 
694
	lea	eax, [ebx + ETH_DEVICE.mac]
-
 
695
	mov	edx, esp
-
 
696
	mov	ecx, [esp + 6+4]
-
 
697
	add	ecx, IPv4_Packet.DataOrOptional
-
 
698
	mov	di, ETHER_IPv4
-
 
699
	call	ETH_output
-
 
700
	jz	.error
-
 
701
 
-
 
702
	add	esp, 6	; pop the mac
-
 
703
 
-
 
704
	mov	dword[esp+4+4], edx
-
 
705
	mov	dword[esp+4+4+4], eax
-
 
706
 
-
 
707
	pop	eax esi
-
 
708
;; todo: check socket options if we should add header, or just compute checksum
-
 
709
 
-
 
710
	push	edi ecx
-
 
711
	rep	movsb
-
 
712
	pop	ecx edi
-
 
713
 
-
 
714
;        [edi + IPv4_Packet.VersionAndIHL]              ; IPv4, normal length (no Optional header)
-
 
715
;        [edi + IPv4_Packet.TypeOfService]              ; nothing special, just plain ip packet
-
 
716
;        [edi + IPv4_Packet.TotalLength]
-
 
717
;        [edi + IPv4_Packet.TotalLength]                ; internet byte order
-
 
718
;        [edi + IPv4_Packet.FlagsAndFragmentOffset]
-
 
719
 
-
 
720
	mov	[edi + IPv4_Packet.HeaderChecksum], 0
-
 
721
 
-
 
722
;        [edi + IPv4_Packet.TimeToLive]                 ; ttl shl 8 + protocol
-
 
723
;        [edi + IPv4_Packet.Protocol]
-
 
724
;        [edi + IPv4_Packet.Identification]             ; fragment id
-
 
725
;        [edi + IPv4_Packet.SourceAddress]
-
 
726
;        [edi + IPv4_Packet.DestinationAddress]
-
 
727
 
-
 
728
	IPv4_checksum edi			;;;; todo: checksum for IP packet with options!
-
 
729
	add	edi, IPv4_Packet.DataOrOptional
-
 
730
	DEBUGF	1,"IPv4 Packet for device %x created successfully\n", ebx
-
 
731
	call	[ebx + NET_DEVICE.transmit]
-
 
732
	ret
-
 
733
 
-
 
734
  .error:
-
 
735
	add	esp, 6
-
 
736
  .arp_error:
-
 
737
	add	esp, 8+4+4
-
 
738
  .too_large:
-
 
739
	DEBUGF	1,"IPv4_output_raw: Failed\n"
-
 
740
	sub	edi, edi
-
 
741
	ret
654
 
742
 
655
 
743
 
656
;--------------------------------------------------------
744
;--------------------------------------------------------
657
;
745
;
658
;
746
;