Subversion Repositories Kolibri OS

Rev

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

Rev 1299 Rev 1318
Line 11... Line 11...
11
;;          GNU GENERAL PUBLIC LICENSE                             ;;
11
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;             Version 2, June 1991                                ;;
12
;;             Version 2, June 1991                                ;;
13
;;                                                                 ;;
13
;;                                                                 ;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 15... Line 15...
15
 
15
 
Line 16... Line 16...
16
$Revision: 1299 $
16
$Revision: 1318 $
17
 
17
 
18
struct	SOCKET_head
18
struct	SOCKET_head
19
	 .PrevPtr		dd ? ; pointer to previous socket in list
19
	 .PrevPtr		dd ? ; pointer to previous socket in list
20
	 .NextPtr		dd ? ; pointer to next socket in list
20
	 .NextPtr		dd ? ; pointer to next socket in list
21
	 .Number		dd ? ; socket number (unique within single process)
21
	 .Number		dd ? ; socket number (unique within single process)
22
	 .PID			dd ? ; application process id
22
	 .PID			dd ? ; application process id
23
	 .Domain		dd ? ; INET/UNIX/..
23
	 .Domain		dd ? ; INET/UNIX/..
24
	 .Type			dd ? ; RAW/UDP/TCP/...
24
	 .Type			dd ? ; RAW/UDP/TCP/...
-
 
25
	 .Protocol		dd ? ; ICMP/IPv4/ARP/
25
	 .Protocol		dd ? ; ICMP/IPv4/ARP/
26
	 .lock			dd ? ; lock mutex
26
	 .lock			dd ? ; lock mutex
27
	 .errorcode		dd ?
Line 27... Line 28...
27
	 .end:
28
	 .end:
28
ends
29
ends
Line 53... Line 54...
53
	 .wndsizeTimer		dd ? ; window size timer
54
	 .wndsizeTimer		dd ? ; window size timer
Line 54... Line 55...
54
 
55
 
55
	; Transmission control block
56
	; Transmission control block
56
	 .state 		dd ? ; TCB state
57
	 .state 		dd ? ; TCB state
-
 
58
	 .timer 		dd ? ; TCB timer (seconds)
57
	 .timer 		dd ? ; TCB timer (seconds)
59
 
58
	 .ISS			dd ? ; initial send sequence number
60
	 .ISS			dd ? ; initial send sequence number
59
	 .IRS			dd ? ; initial receive sequence number
61
	 .IRS			dd ? ; initial receive sequence number
60
	 .SND_UNA		dd ? ; sequence number of unack'ed sent Packets
62
	 .SND_UNA		dd ? ; sequence number of unack'ed sent Packets
61
	 .SND_NXT		dd ? ; next send sequence number to use
63
	 .SND_NXT		dd ? ; next send sequence number to use
Line 189... Line 191...
189
 
191
 
190
	mov	[eax + SOCKET_head.Domain], ecx
192
	mov	[eax + SOCKET_head.Domain], ecx
191
	mov	[eax + SOCKET_head.Type], edx
193
	mov	[eax + SOCKET_head.Type], edx
Line -... Line 194...
-
 
194
	mov	[eax + SOCKET_head.Protocol], esi
-
 
195
 
-
 
196
	cmp	ecx, AF_INET4
-
 
197
	je	.af_inet4
-
 
198
 
-
 
199
	jmp	.done
-
 
200
 
-
 
201
 
-
 
202
  .af_inet4:
-
 
203
 
-
 
204
	cmp	edx, IP_PROTO_TCP
-
 
205
	je	.tcp
-
 
206
 
-
 
207
	jmp	.done
-
 
208
 
-
 
209
  .tcp:
-
 
210
 
-
 
211
	mov	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_CLOSED
-
 
212
 
-
 
213
	pseudo_random ebx
-
 
214
	mov	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.ISS], ebx
-
 
215
	mov	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.SND_NXT], ebx
192
	mov	[eax + SOCKET_head.Protocol], esi
216
 
193
 
217
  .done:
Line 194... Line -...
194
	stdcall net_socket_addr_to_num, eax
-
 
195
	DEBUGF	1,", socketnumber: %u\n", eax
-
 
196
 
218
	stdcall net_socket_addr_to_num, eax
Line 197... Line 219...
197
	; TODO: if it is a tcp socket, set state to TCB_CLOSED
219
	DEBUGF	1,", socketnumber: %u\n", eax
Line 511... Line 533...
511
 
533
 
Line 512... Line 534...
512
 
534
 
-
 
535
	ret
-
 
536
 
513
	ret
537
  .tcp:
Line 514... Line -...
514
 
-
 
515
  .tcp:
-
 
516
	; first, remove all resend entries for this socket
-
 
517
 
538
	mov	dword [esp+32],0
Line -... Line 539...
-
 
539
 
-
 
540
	; first, remove all resend entries for this socket
-
 
541
 
-
 
542
	call	TCP_remove_socket
-
 
543
 
518
	cmp	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_LISTEN
544
;        cmp     [eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_LISTEN
-
 
545
;        je      .destroy_tcb
-
 
546
;        cmp     [eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_SYN_SENT
-
 
547
;        je      .destroy_tcb
-
 
548
;        cmp     [eac + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_CLOSED
519
	je	.destroy_tcb
549
;        je      .destroy_tcb
-
 
550
	cmp	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_SYN_RECEIVED
Line 520... Line -...
520
	cmp	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_SYN_SENT
-
 
521
	je	.destroy_tcb
-
 
522
 
551
	je	.fin_wait
Line 523... Line 552...
523
	; Send a fin, then enter finwait2 state
552
	cmp	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_ESTABLISHED
Line 524... Line 553...
524
	mov	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_FIN_WAIT_1
553
	je	.fin_wait
-
 
554
	cmp	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_CLOSE_WAIT
-
 
555
	je	.last_ack
-
 
556
 
-
 
557
	stdcall net_socket_free, ebx
-
 
558
 
-
 
559
	ret
-
 
560
 
-
 
561
 
-
 
562
  .last_ack:
-
 
563
	mov	[eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state], TCB_LAST_ACK
Line 525... Line -...
525
 
-
 
526
	mov	bl, TH_FIN
-
 
527
	xor	ecx, ecx
564
	jmp	.send_fin