Rev 1635 | Rev 2150 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1635 | Rev 2130 | ||
---|---|---|---|
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: 1288 $ |
30 | $Revision: 2130 $ |
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 | .lock MUTEX ; lock mutex |
58 | .rxData dd ? ; receive data buffer here |
58 | .rxData dd ? ; receive data buffer here |
59 | ends |
59 | ends |
Line 60... | Line 60... | ||
60 | 60 | ||
61 | ; TCP opening modes |
61 | ; TCP opening modes |
Line 97... | Line 97... | ||
97 | cld |
97 | cld |
98 | xor eax, eax |
98 | xor eax, eax |
99 | rep stosd |
99 | rep stosd |
100 | pop eax |
100 | pop eax |
Line -... | Line 101... | ||
- | 101 | ||
- | 102 | mov ebx, eax |
|
- | 103 | lea ecx, [eax+SOCKET.lock] |
|
- | 104 | call mutex_init |
|
- | 105 | mov eax, ebx |
|
101 | 106 | ||
102 | ; add socket to the list by changing pointers |
107 | ; add socket to the list by changing pointers |
103 | mov ebx, net_sockets |
108 | mov ebx, net_sockets |
104 | push [ebx + SOCKET.NextPtr] |
109 | push [ebx + SOCKET.NextPtr] |
105 | mov [ebx + SOCKET.NextPtr], eax |
110 | mov [ebx + SOCKET.NextPtr], eax |
Line 701... | Line 706... | ||
701 | ; DEBUGF 1, "socket_read(0x%x)\n", ebx |
706 | ; DEBUGF 1, "socket_read(0x%x)\n", ebx |
702 | stdcall net_socket_num_to_addr, ebx |
707 | stdcall net_socket_num_to_addr, ebx |
703 | or eax, eax |
708 | or eax, eax |
704 | jz .error |
709 | jz .error |
Line 705... | Line -... | ||
705 | - | ||
706 | lea ebx, [eax + SOCKET.lock] |
- | |
707 | call wait_mutex |
- | |
708 | 710 | ||
- | 711 | mov ebx, eax |
|
- | 712 | lea ecx, [eax + SOCKET.lock] |
|
- | 713 | call mutex_lock |
|
709 | mov ebx, eax |
714 | |
710 | mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes |
715 | mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes |
711 | test eax, eax |
716 | test eax, eax |
Line 712... | Line 717... | ||
712 | jz .error_release |
717 | jz .error_release |
Line 725... | Line 730... | ||
725 | rep movsd |
730 | rep movsd |
726 | pop ecx |
731 | pop ecx |
727 | and ecx, 3 |
732 | and ecx, 3 |
728 | rep movsb |
733 | rep movsb |
Line 729... | Line 734... | ||
729 | 734 | ||
730 | mov [ebx + SOCKET.lock], 0 |
735 | lea ecx, [ebx + SOCKET.lock] |
731 | mov ebx, eax |
- | |
- | 736 | mov ebx, eax |
|
- | 737 | call mutex_unlock |
|
732 | 738 | mov eax, ebx |
|
Line 733... | Line 739... | ||
733 | ret |
739 | ret |
734 | 740 | ||
- | 741 | .error_release: |
|
735 | .error_release: |
742 | lea ecx, [ebx + SOCKET.lock] |
736 | mov [ebx + SOCKET.lock], 0 |
743 | call mutex_unlock |
- | 744 | .error: |
|
737 | .error: |
745 | xor ebx, ebx |
738 | xor ebx, ebx |
746 | xor eax, eax |
Line 739... | Line 747... | ||
739 | ret |
747 | ret |
740 | endp |
748 | endp |
Line 754... | Line 762... | ||
754 | ; DEBUGF 1, "socket_read_packet(0x%x)\n", ebx |
762 | ; DEBUGF 1, "socket_read_packet(0x%x)\n", ebx |
755 | stdcall net_socket_num_to_addr, ebx ; get real socket address |
763 | stdcall net_socket_num_to_addr, ebx ; get real socket address |
756 | or eax, eax |
764 | or eax, eax |
757 | jz .error |
765 | jz .error |
Line 758... | Line -... | ||
758 | - | ||
759 | lea ebx, [eax + SOCKET.lock] |
- | |
760 | call wait_mutex |
- | |
761 | 766 | ||
- | 767 | mov ebx, eax |
|
- | 768 | ||
- | 769 | lea ecx, [eax + SOCKET.lock] |
|
- | 770 | call mutex_lock |
|
762 | mov ebx, eax |
771 | |
763 | mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes |
772 | mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes |
764 | test eax, eax ; if count of bytes is zero.. |
773 | test eax, eax ; if count of bytes is zero.. |
Line 765... | Line 774... | ||
765 | jz .exit ; exit function (eax will be zero) |
774 | jz .exit ; exit function (eax will be zero) |
Line 787... | Line 796... | ||
787 | pop ecx |
796 | pop ecx |
788 | and ecx, 3 |
797 | and ecx, 3 |
789 | rep movsb ; copy remaining bytes |
798 | rep movsb ; copy remaining bytes |
Line 790... | Line 799... | ||
790 | 799 | ||
791 | .exit: |
800 | .exit: |
- | 801 | lea ecx, [ebx + SOCKET.lock] |
|
- | 802 | call mutex_unlock |
|
792 | mov [ebx + SOCKET.lock], 0 |
803 | mov eax, edx |
Line 793... | Line 804... | ||
793 | ret ; at last, exit |
804 | ret ; at last, exit |
794 | 805 | ||
795 | .error: |
806 | .error: |
Line 796... | Line 807... | ||
796 | xor eax, eax |
807 | xor eax, eax |
797 | ret |
808 | ret |
798 | 809 | ||
799 | .copy_all_bytes: |
810 | .copy_all_bytes: |
800 | xor esi, esi |
811 | xor esi, esi |
- | 812 | mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero) |
|
- | 813 | call .start_copy |
|
801 | mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero) |
814 | lea ecx, [ebx + SOCKET.lock] |
Line 802... | Line 815... | ||
802 | call .start_copy |
815 | call mutex_unlock |
803 | mov [ebx + SOCKET.lock], 0 |
816 | mov eax, edx |
804 | ret |
817 | ret |