Subversion Repositories Kolibri OS

Rev

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

Rev 983 Rev 1019
Line 25... Line 25...
25
;;   22.09.2003 - [Mike Hibbett] : mikeh@oceanfree.net          ;;
25
;;   22.09.2003 - [Mike Hibbett] : mikeh@oceanfree.net          ;;
26
;;   11.11.2006 - [Johnny_B] and [smb]                          ;;
26
;;   11.11.2006 - [Johnny_B] and [smb]                          ;;
27
;;                                                              ;;
27
;;                                                              ;;
28
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 29... Line 29...
29
 
29
 
Line 30... Line 30...
30
$Revision: 983 $
30
$Revision: 1019 $
31
 
31
 
32
; socket data structure
32
; socket data structure
33
struct SOCKET
33
struct SOCKET
Line 52... Line 52...
52
  .RCV_NXT	  dd ? ; next receive sequence number to use
52
  .RCV_NXT	  dd ? ; next receive sequence number to use
53
  .RCV_WND	  dd ? ; receive window
53
  .RCV_WND	  dd ? ; receive window
54
  .SEG_LEN	  dd ? ; segment length
54
  .SEG_LEN	  dd ? ; segment length
55
  .SEG_WND	  dd ? ; segment window
55
  .SEG_WND	  dd ? ; segment window
56
  .wndsizeTimer   dd ? ; window size timer
56
  .wndsizeTimer   dd ? ; window size timer
-
 
57
  .lock           dd ? ; lock mutex
57
  .rxData	  dd ? ; receive data buffer here
58
  .rxData	  dd ? ; receive data buffer here
58
ends
59
ends
Line 59... Line 60...
59
 
60
 
60
; TCP opening modes
61
; TCP opening modes
Line 598... Line 599...
598
;        DEBUGF  1, "socket_read(0x%x)\n", ebx
599
;        DEBUGF  1, "socket_read(0x%x)\n", ebx
599
	stdcall net_socket_num_to_addr, ebx
600
	stdcall net_socket_num_to_addr, ebx
600
	or	eax, eax
601
	or	eax, eax
601
	jz	.error
602
	jz	.error
Line -... Line 603...
-
 
603
 
-
 
604
	lea	ebx, [eax + SOCKET.lock]
-
 
605
	call	wait_mutex
602
 
606
 
603
	mov	ebx, eax
607
	mov	ebx, eax
604
	mov	eax, [ebx + SOCKET.rxDataCount] 	; get count of bytes
608
	mov	eax, [ebx + SOCKET.rxDataCount] 	; get count of bytes
605
	test	eax, eax
609
	test	eax, eax
Line 606... Line 610...
606
	jz	.error
610
	jz	.error_release
607
 
611
 
608
	dec	eax
612
	dec	eax
609
	mov	esi, ebx				; esi is address of socket
613
	mov	esi, ebx				; esi is address of socket
Line 610... Line 614...
610
	mov	[ebx + SOCKET.rxDataCount], eax 	; store new count
614
	mov	[ebx + SOCKET.rxDataCount], eax 	; store new count
611
	movzx	ebx, byte[ebx + SOCKET.rxData]		; get the byte
615
	movzx	eax, byte[ebx + SOCKET.rxData]		; get the byte
612
 
616
 
613
	mov	ecx, SOCKETBUFFSIZE - SOCKET.rxData - 1
617
	mov	ecx, SOCKETBUFFSIZE - SOCKET.rxData - 1
Line 619... Line 623...
619
	rep	movsd
623
	rep	movsd
620
	pop	ecx
624
	pop	ecx
621
	and	ecx, 3
625
	and	ecx, 3
622
	rep	movsb
626
	rep	movsb
Line -... Line 627...
-
 
627
 
-
 
628
	mov	[ebx + SOCKET.lock], 0
-
 
629
	mov	ebx, eax
623
 
630
 
Line -... Line 631...
-
 
631
	ret
-
 
632
 
624
	ret
633
  .error_release:
625
 
634
	mov	[ebx + SOCKET.lock], 0
626
  .error:
635
  .error:
627
	xor	ebx, ebx
636
	xor	ebx, ebx
Line 643... Line 652...
643
;        DEBUGF  1, "socket_read_packet(0x%x)\n", ebx
652
;        DEBUGF  1, "socket_read_packet(0x%x)\n", ebx
644
	stdcall net_socket_num_to_addr, ebx		   ; get real socket address
653
	stdcall net_socket_num_to_addr, ebx		   ; get real socket address
645
	or	eax, eax
654
	or	eax, eax
646
	jz	.error
655
	jz	.error
Line -... Line 656...
-
 
656
 
-
 
657
	lea	ebx, [eax + SOCKET.lock]
-
 
658
	call	wait_mutex
647
 
659
 
648
	mov	ebx, eax
660
	mov	ebx, eax
649
	mov	eax, [ebx + SOCKET.rxDataCount] 	   ; get count of bytes
661
	mov	eax, [ebx + SOCKET.rxDataCount] 	   ; get count of bytes
650
	test	eax, eax				   ; if count of bytes is zero..
662
	test	eax, eax				   ; if count of bytes is zero..
Line 673... Line 685...
673
	pop	ecx
685
	pop	ecx
674
	and	ecx, 3
686
	and	ecx, 3
675
	rep	movsb					   ; copy remaining bytes
687
	rep	movsb					   ; copy remaining bytes
Line 676... Line 688...
676
 
688
 
-
 
689
  .exit:
677
  .exit:
690
	mov	[ebx + SOCKET.lock], 0
Line 678... Line 691...
678
	ret						   ; at last, exit
691
	ret						   ; at last, exit
679
 
692
 
680
  .error:
693
  .error:
Line 681... Line 694...
681
	xor	eax, eax
694
	xor	eax, eax
682
	ret
695
	ret
683
 
696
 
684
  .copy_all_bytes:
697
  .copy_all_bytes:
-
 
698
	xor	esi, esi
685
	xor	esi, esi
699
	mov	[ebx + SOCKET.rxDataCount], esi 	   ; store new count (zero)
Line 686... Line 700...
686
	mov	[ebx + SOCKET.rxDataCount], esi 	   ; store new count (zero)
700
	call	.start_copy
687
	call	.start_copy
701
	mov	[ebx + SOCKET.lock], 0
688
	ret
702
	ret