Rev 2209 | Rev 2465 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2209 | Rev 2434 | ||
---|---|---|---|
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: 2209 $ |
30 | $Revision: 2434 $ |
31 | 31 | ||
32 | ; socket data structure |
32 | ; socket data structure |
33 | struct SOCKET |
33 | struct SOCKET |
34 | .PrevPtr dd ? ; pointer to previous socket in list |
34 | PrevPtr dd ? ; pointer to previous socket in list |
35 | .NextPtr dd ? ; pointer to next socket in list |
35 | NextPtr dd ? ; pointer to next socket in list |
36 | .Number dd ? ; socket number (unique within single process) |
36 | Number dd ? ; socket number (unique within single process) |
37 | .PID dd ? ; application process id |
37 | PID dd ? ; application process id |
38 | .LocalIP dd ? ; local IP address |
38 | LocalIP dd ? ; local IP address |
39 | .LocalPort dw ? ; local port |
39 | LocalPort dw ? ; local port |
40 | .RemoteIP dd ? ; remote IP address |
40 | RemoteIP dd ? ; remote IP address |
41 | .RemotePort dw ? ; remote port |
41 | RemotePort dw ? ; remote port |
42 | .OrigRemoteIP dd ? ; original remote IP address (used to reset to LISTEN state) |
42 | OrigRemoteIP dd ? ; original remote IP address (used to reset to LISTEN state) |
43 | .OrigRemotePort dw ? ; original remote port (used to reset to LISTEN state) |
43 | OrigRemotePort dw ? ; original remote port (used to reset to LISTEN state) |
44 | .rxDataCount dd ? ; rx data count |
44 | rxDataCount dd ? ; rx data count |
45 | .TCBState dd ? ; TCB state |
45 | TCBState dd ? ; TCB state |
46 | .TCBTimer dd ? ; TCB timer (seconds) |
46 | TCBTimer dd ? ; TCB timer (seconds) |
47 | .ISS dd ? ; initial send sequence |
47 | ISS dd ? ; initial send sequence |
48 | .IRS dd ? ; initial receive sequence |
48 | IRS dd ? ; initial receive sequence |
49 | .SND_UNA dd ? ; sequence number of unack'ed sent packets |
49 | SND_UNA dd ? ; sequence number of unack'ed sent packets |
50 | .SND_NXT dd ? ; bext send sequence number to use |
50 | SND_NXT dd ? ; bext send sequence number to use |
51 | .SND_WND dd ? ; send window |
51 | SND_WND dd ? ; send window |
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 MUTEX ; lock mutex |
57 | mutex MUTEX ; lock mutex |
Line 58... | Line 58... | ||
58 | .rxData dd ? ; receive data buffer here |
58 | rxData dd ? ; receive data buffer here |
59 | ends |
59 | ends |
60 | 60 | ||
Line 98... | Line 98... | ||
98 | xor eax, eax |
98 | xor eax, eax |
99 | rep stosd |
99 | rep stosd |
100 | pop eax |
100 | pop eax |
Line 101... | Line 101... | ||
101 | 101 | ||
102 | mov ebx, eax |
102 | mov ebx, eax |
103 | lea ecx, [eax+SOCKET.lock] |
103 | lea ecx, [eax+SOCKET.mutex] |
104 | call mutex_init |
104 | call mutex_init |
Line 105... | Line 105... | ||
105 | mov eax, ebx |
105 | mov eax, ebx |
106 | 106 | ||
Line 471... | Line 471... | ||
471 | 471 | ||
472 | mov ebx, TCB_LISTEN |
472 | mov ebx, TCB_LISTEN |
473 | cmp esi, SOCKET_PASSIVE |
473 | cmp esi, SOCKET_PASSIVE |
474 | je @f |
474 | je @f |
- | 475 | mov ebx, TCB_SYN_SENT |
|
475 | mov ebx, TCB_SYN_SENT |
476 | @@: |
Line 476... | Line 477... | ||
476 | @@: mov [eax + SOCKET.TCBState], ebx ; Indicate the state of the TCB |
477 | mov [eax + SOCKET.TCBState], ebx ; Indicate the state of the TCB |
477 | 478 | ||
Line 478... | Line 479... | ||
478 | cmp ebx, TCB_LISTEN |
479 | cmp ebx, TCB_LISTEN |
Line 568... | Line 569... | ||
568 | je @f ; found one |
569 | je @f ; found one |
569 | inc ecx |
570 | inc ecx |
570 | add esi, 8 |
571 | add esi, 8 |
571 | jmp .next_resendq |
572 | jmp .next_resendq |
Line -... | Line 573... | ||
- | 573 | ||
572 | 574 | @@: |
|
573 | @@: mov dword[esi + 4], 0 |
575 | mov dword[esi + 4], 0 |
574 | inc ecx |
576 | inc ecx |
575 | add esi, 8 |
577 | add esi, 8 |
Line 576... | Line 578... | ||
576 | jmp .next_resendq |
578 | jmp .next_resendq |
Line 707... | Line 709... | ||
707 | stdcall net_socket_num_to_addr, ebx |
709 | stdcall net_socket_num_to_addr, ebx |
708 | or eax, eax |
710 | or eax, eax |
709 | jz .error |
711 | jz .error |
Line 710... | Line 712... | ||
710 | 712 | ||
711 | mov ebx, eax |
713 | mov ebx, eax |
712 | lea ecx, [eax + SOCKET.lock] |
714 | lea ecx, [eax + SOCKET.mutex] |
Line 713... | Line 715... | ||
713 | call mutex_lock |
715 | call mutex_lock |
714 | 716 | ||
715 | mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes |
717 | mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes |
Line 730... | Line 732... | ||
730 | rep movsd |
732 | rep movsd |
731 | pop ecx |
733 | pop ecx |
732 | and ecx, 3 |
734 | and ecx, 3 |
733 | rep movsb |
735 | rep movsb |
Line 734... | Line 736... | ||
734 | 736 | ||
735 | lea ecx, [ebx + SOCKET.lock] |
737 | lea ecx, [ebx + SOCKET.mutex] |
736 | mov ebx, eax |
738 | mov ebx, eax |
737 | call mutex_unlock |
739 | call mutex_unlock |
738 | mov eax, ebx |
740 | mov eax, ebx |
Line 739... | Line 741... | ||
739 | ret |
741 | ret |
740 | 742 | ||
741 | .error_release: |
743 | .error_release: |
742 | lea ecx, [ebx + SOCKET.lock] |
744 | lea ecx, [ebx + SOCKET.mutex] |
743 | call mutex_unlock |
745 | call mutex_unlock |
744 | .error: |
746 | .error: |
745 | xor ebx, ebx |
747 | xor ebx, ebx |
Line 765... | Line 767... | ||
765 | jz .error |
767 | jz .error |
Line 766... | Line 768... | ||
766 | 768 | ||
Line 767... | Line 769... | ||
767 | mov ebx, eax |
769 | mov ebx, eax |
768 | 770 | ||
769 | push ecx edx |
771 | push ecx edx |
770 | lea ecx, [eax + SOCKET.lock] |
772 | lea ecx, [eax + SOCKET.mutex] |
Line 771... | Line 773... | ||
771 | call mutex_lock |
773 | call mutex_lock |
772 | pop edx ecx |
774 | pop edx ecx |
Line 798... | Line 800... | ||
798 | pop ecx |
800 | pop ecx |
799 | and ecx, 3 |
801 | and ecx, 3 |
800 | rep movsb ; copy remaining bytes |
802 | rep movsb ; copy remaining bytes |
Line 801... | Line 803... | ||
801 | 803 | ||
802 | .exit: |
804 | .exit: |
803 | lea ecx, [ebx + SOCKET.lock] |
805 | lea ecx, [ebx + SOCKET.mutex] |
804 | mov ebx,eax |
806 | mov ebx, eax |
805 | call mutex_unlock |
807 | call mutex_unlock |
806 | mov eax,ebx |
808 | mov eax, ebx |
Line 812... | Line 814... | ||
812 | 814 | ||
813 | .copy_all_bytes: |
815 | .copy_all_bytes: |
814 | xor esi, esi |
816 | xor esi, esi |
815 | mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero) |
817 | mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero) |
816 | call .start_copy |
818 | call .start_copy |
817 | lea ecx, [ebx + SOCKET.lock] |
819 | lea ecx, [ebx + SOCKET.mutex] |
818 | mov ebx,eax |
820 | mov ebx, eax |
819 | call mutex_unlock |
821 | call mutex_unlock |
820 | mov eax,ebx |
822 | mov eax, ebx |
Line 959... | Line 961... | ||
959 | ; (0 is reserved for 'not used') |
961 | ; (0 is reserved for 'not used') |
960 | test ax, ax |
962 | test ax, ax |
961 | jnz @f |
963 | jnz @f |
962 | mov ax, 0xffff |
964 | mov ax, 0xffff |
Line -... | Line 965... | ||
- | 965 | ||
963 | 966 | @@: |
|
964 | @@: xchg al, ah |
967 | xchg al, ah |
Line 965... | Line 968... | ||
965 | mov [edx + 20 + UDP_PACKET.Checksum], ax |
968 | mov [edx + 20 + UDP_PACKET.Checksum], ax |
966 | 969 | ||
967 | ; Fill in the IP header checksum |
970 | ; Fill in the IP header checksum |
Line 1077... | Line 1080... | ||
1077 | je @f ; found one |
1080 | je @f ; found one |
1078 | inc ecx |
1081 | inc ecx |
1079 | add esi, 8 |
1082 | add esi, 8 |
1080 | jmp .next_resendq |
1083 | jmp .next_resendq |
Line -... | Line 1084... | ||
- | 1084 | ||
1081 | 1085 | @@: |
|
Line 1082... | Line 1086... | ||
1082 | @@: push ebx |
1086 | push ebx |
1083 | 1087 | ||
1084 | ; OK, we have a buffer descriptor ptr in esi. |
1088 | ; OK, we have a buffer descriptor ptr in esi. |
1085 | ; resend entry # in ecx |
1089 | ; resend entry # in ecx |
Line 1096... | Line 1100... | ||
1096 | 1100 | ||
1097 | inc ecx |
1101 | inc ecx |
1098 | ; Now get buffer location, and copy buffer across. argh! more copying,, |
1102 | ; Now get buffer location, and copy buffer across. argh! more copying,, |
Line -... | Line 1103... | ||
- | 1103 | mov edi, resendBuffer - IPBUFFSIZE |
|
1099 | mov edi, resendBuffer - IPBUFFSIZE |
1104 | |
1100 | 1105 | @@: |
|
Line 1101... | Line 1106... | ||
1101 | @@: add edi, IPBUFFSIZE |
1106 | add edi, IPBUFFSIZE |
1102 | loop @b |
1107 | loop @b |
1103 | 1108 |