Subversion Repositories Kolibri OS

Rev

Rev 1256 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1256 Rev 1257
Line 13... Line 13...
13
;;             Version 2, June 1991                                ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
 
17
 
18
$Revision: 1256 $
18
$Revision: 1257 $
19
 
19
 
20
TCP_RETRIES		equ 5		; Number of times to resend a Packet
-
 
21
TCP_PACKET_TTL		equ 50		; resend if not replied to in 1/100 s
20
TCP_RETRIES		equ 5		; Number of times to resend a Packet
Line 22... Line 21...
22
TCP_SOCKET_TTL		equ 10		; # of secs to wait before closing socket
21
TCP_PACKET_TTL		equ 50		; resend if not replied to in 1/100 s
23
 
22
TCP_SOCKET_TTL		equ 10		; # of secs to wait before closing socket
Line 49... Line 48...
49
				rd  (tcp_out_queue_entry.size*TCP_QUEUE_SIZE)/4
48
				rd  (tcp_out_queue_entry.size*TCP_QUEUE_SIZE)/4
50
endg
49
endg
Line 51... Line 50...
51
 
50
 
52
align 4
51
align 4
53
iglobal
-
 
54
 
52
iglobal
Line 55... Line 53...
55
stateHandler:
53
stateHandler:
56
 
54
 
57
  dd  stateTCB_LISTEN
55
  dd  stateTCB_LISTEN
Line 77... Line 75...
77
;
75
;
78
;  IN:  /
76
;  IN:  /
79
;  OUT: /
77
;  OUT: /
80
;
78
;
81
;-----------------------------------------------------------------
79
;-----------------------------------------------------------------
82
 
-
 
83
align 4
80
align 4
84
TCP_init:
81
TCP_init:
Line 85... Line 82...
85
 
82
 
86
	xor	eax, eax
83
	xor	eax, eax
87
	mov	edi, TCP_PACKETS_TX
84
	mov	edi, TCP_PACKETS_TX
88
	mov	ecx, 2*MAX_IP
85
	mov	ecx, 2*MAX_IP
Line 89... Line 86...
89
	rep	stosd
86
	rep	stosd
Line 90... Line 87...
90
 
87
 
-
 
88
	init_queue TCP_IN_QUEUE
-
 
89
 
-
 
90
	; tcp_out_queue is a special type of queue:
-
 
91
	; The first dword is a counter of total packets queued.
-
 
92
	; The remaining bytes are socket 'slots' wich use tcp_out_queue_entry data structure.
91
	init_queue TCP_IN_QUEUE
93
	; An empty slot is know by the fact that tcp_out_queue_entry.data_ptr (first dword of the slot) is set to 0
92
 
94
	; There are TCP_OUT_QUEUE_SIZE number of slots
93
	; tcp_out_queue is a special type of queue
95
 
94
	xor	eax, eax
96
	xor	eax, eax
Line 105... Line 107...
105
;
107
;
106
;  IN:  /
108
;  IN:  /
107
;  OUT: /
109
;  OUT: /
108
;
110
;
109
;-----------------------------------------------------------------
111
;-----------------------------------------------------------------
110
 
-
 
111
align 4
112
align 4
112
TCP_decrease_socket_ttls:
113
TCP_decrease_socket_ttls:
113
	; scan through all the sockets, decrementing active timers
114
	; scan through all the sockets, decrementing active timers
Line 114... Line 115...
114
 
115
 
Line 166... Line 167...
166
;
167
;
167
;  IN:  /
168
;  IN:  /
168
;  OUT: /
169
;  OUT: /
169
;
170
;
170
;-----------------------------------------------------------------
171
;-----------------------------------------------------------------
171
 
-
 
172
align 4
172
align 4
173
TCP_send_queued:
173
TCP_send_queued:
Line 174... Line 174...
174
 
174
 
175
	cmp	[TCP_OUT_QUEUE], 0
175
	cmp	[TCP_OUT_QUEUE], 0
Line 203... Line 203...
203
 
203
 
204
	mov	ebx, [esi + tcp_out_queue_entry.owner]
204
	mov	ebx, [esi + tcp_out_queue_entry.owner]
205
	push	[esi + tcp_out_queue_entry.data_size]
205
	push	[esi + tcp_out_queue_entry.data_size]
206
	push	[esi + tcp_out_queue_entry.data_ptr]
206
	push	[esi + tcp_out_queue_entry.data_ptr]
-
 
207
	DEBUGF 1,"Now sending TCP packet %x, size: %u, owner: %x, sendproc %x\n", [esp], [esp+4], ebx, [esi + tcp_out_queue_entry.sendproc]
207
	DEBUGF 1,"Now sending TCP packet %x, size: %u, owner: %x, sendproc %x\n", [esp], [esp+4], ebx, [esi + tcp_out_queue_entry.sendproc]
208
	inc	[TCP_PACKETS_TX]
208
	call	[esi + tcp_out_queue_entry.sendproc]
209
	call	[esi + tcp_out_queue_entry.sendproc]
209
	add	esp, 8
210
	add	esp, 8
Line 210... Line 211...
210
	pop	esi ecx eax
211
	pop	esi ecx eax
Line 235... Line 236...
235
;       esi = sender proc
236
;       esi = sender proc
236
;       edx = acknum
237
;       edx = acknum
237
;  OUT: /
238
;  OUT: /
238
;
239
;
239
;-----------------------------------------------------------------
240
;-----------------------------------------------------------------
240
 
-
 
241
align 4
241
align 4
242
TCP_add_to_queue:
242
TCP_add_to_queue:
Line 243... Line 243...
243
 
243
 
Line 296... Line 296...
296
;       pointer to TCP Packet data in edx
296
;       pointer to TCP Packet data in edx
297
;       SourceAddres in esi
297
;       SourceAddres in esi
298
;  OUT: /
298
;  OUT: /
299
;
299
;
300
;-----------------------------------------------------------------
300
;-----------------------------------------------------------------
301
 
-
 
302
align 4
301
align 4
303
TCP_handler :
302
TCP_handler :
Line 304... Line 303...
304
 
303
 
Line 336... Line 335...
336
 
335
 
Line 337... Line 336...
337
  .change_state:
336
  .change_state:
Line -... Line 337...
-
 
337
 
-
 
338
       DEBUGF 1,"Found valid socket for packet\n"
338
 
339
 
339
       DEBUGF 1,"Found valid socket for packet\n"
340
	inc	[TCP_PACKETS_RX]
340
 
341
 
341
	push	ebx
342
	push	ebx
Line 423... Line 424...
423
; IN: eax = socket pointer
424
; IN: eax = socket pointer
424
;     ecx = number of bytes to send
425
;     ecx = number of bytes to send
425
;     esi = pointer to data
426
;     esi = pointer to data
426
;
427
;
427
;-----------------------------------------------------------------
428
;-----------------------------------------------------------------
428
 
-
 
429
align 4
429
align 4
430
TCP_socket_send:
430
TCP_socket_send:
Line 431... Line 431...
431
 
431
 
Line 521... Line 521...
521
;
521
;
522
; IN: eax = socket pointer
522
; IN: eax = socket pointer
523
;      bl = flags
523
;      bl = flags
524
;
524
;
525
;-----------------------------------------------------------------
525
;-----------------------------------------------------------------
526
 
-
 
527
align 4
526
align 4
528
TCP_send_ack:
527
TCP_send_ack:
Line 529... Line 528...
529
 
528
 
Line 568... Line 567...
568
;        inc_INET esi
567
;        inc_INET esi
Line 569... Line 568...
569
 
568
 
570
; Now, calculate the checksum
569
; Now, calculate the checksum
571
	pushw	TCP_Packet.Options shl 8
570
	pushw	TCP_Packet.Options shl 8
572
	pushw	IP_PROTO_TCP shl 8
571
	pushw	IP_PROTO_TCP shl 8
573
	pushd	[edi-4] ; destination address
572
	pushd	[edi-4] ; destination address  ; TODO: fix this, IPv4 packet could have options..
Line 574... Line 573...
574
	pushd	[edi-8] ; source address
573
	pushd	[edi-8] ; source address
575
 
574
 
576
	xor	edx, edx
575
	xor	edx, edx
Line 977... Line 976...
977
;      ecx, edx, .. depends on subfunction
976
;      ecx, edx, .. depends on subfunction
978
;
977
;
979
; OUT:
978
; OUT:
980
;
979
;
981
;---------------------------------------------------------------------------
980
;---------------------------------------------------------------------------
982
 
-
 
983
align 4
981
align 4
984
TCP_API:
982
TCP_API:
Line 985... Line 983...
985
 
983
 
986
	movzx	eax, bh
984
	movzx	eax, bh