Subversion Repositories Kolibri OS

Rev

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

Rev 1831 Rev 1838
Line 12... Line 12...
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
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
$Revision: 1831 $
17
$Revision: 1838 $
18
 
18
 
19
;-----------------------------------------------------------------
19
;-----------------------------------------------------------------
20
;
20
;
Line 179... Line 179...
179
; Is this socket a listening socket?
179
; Is this socket a listening socket?
Line 180... Line 180...
180
 
180
 
181
	test	[ebx + SOCKET.options], SO_ACCEPTCON
181
	test	[ebx + SOCKET.options], SO_ACCEPTCON
Line -... Line 182...
-
 
182
	jz	.no_listening_socket
-
 
183
 
-
 
184
	DEBUGF	1,"Accepting new connection\n"
182
	jz	.no_listening_socket
185
 
183
 
-
 
Line 184... Line 186...
184
	call	SOCKET_fork
186
	mov	[ebx + SOCKET.lock], 0
185
	jz	.drop
187
	call	SOCKET_fork
Line 186... Line 188...
186
 
188
 
187
	push	[edx + TCP_segment.DestinationPort]
189
	test	eax, eax
Line 188... Line 190...
188
	pop	[eax + TCP_SOCKET.LocalPort]
190
	jz	.drop
189
 
191
 
Line 190... Line 192...
190
	push	[edx - IPv4_Packet.DataOrOptional + IPv4_Packet.DestinationAddress]	;;; FIXME
192
	push	[edx - IPv4_Packet.DataOrOptional + IPv4_Packet.DestinationAddress]	;;; FIXME
Line -... Line 193...
-
 
193
	pop	[eax + IP_SOCKET.LocalIP]
-
 
194
 
-
 
195
	push	[edx + TCP_segment.DestinationPort]
191
	pop	[eax + IP_SOCKET.LocalIP]
196
	pop	[eax + TCP_SOCKET.LocalPort]
Line 192... Line 197...
192
 
197
 
Line 193... Line 198...
193
	push	[edx - IPv4_Packet.DataOrOptional + IPv4_Packet.SourceAddress]	   ;;; FIXME
198
	mov	[eax + TCP_SOCKET.t_state], TCPS_LISTEN
194
	pop	[eax + IP_SOCKET.RemoteIP]
199
 
Line 465... Line 470...
465
	test	[edx + TCP_segment.Flags], TH_SYN
470
	test	[edx + TCP_segment.Flags], TH_SYN
466
	jz	.drop
471
	jz	.drop
Line 467... Line 472...
467
 
472
 
Line -... Line 473...
-
 
473
;;; TODO: check if it's a broadcast or multicast, and drop if so
468
;;; TODO: check if it's a broadcast or multicast, and drop if so
474
 
Line 469... Line 475...
469
 
475
	push	[edx - IPv4_Packet.DataOrOptional + IPv4_Packet.SourceAddress]	   ;;; FIXME
470
	add	[TCP_sequence_num], 64000
476
	pop	[ebx + IP_SOCKET.RemoteIP]
Line 471... Line 477...
471
 
477
 
472
	push	[edx + TCP_segment.SourcePort]
478
	push	[edx + TCP_segment.SourcePort]
Line 473... Line 479...
473
	pop	[eax + TCP_SOCKET.RemotePort]
479
	pop	[ebx + TCP_SOCKET.RemotePort]
-
 
480
 
474
 
481
	push	[edx + TCP_segment.SequenceNumber]
Line 475... Line 482...
475
	push	[edx + TCP_segment.SequenceNumber]
482
	pop	[ebx + TCP_SOCKET.IRS]
476
	pop	[eax + TCP_SOCKET.IRS]
483
 
Line -... Line 484...
-
 
484
	push	[TCP_sequence_num]     ;;;;;
-
 
485
	add	[TCP_sequence_num], 64000 / 2
-
 
486
	pop	[ebx + TCP_SOCKET.ISS]
477
 
487
 
478
	push	[eax + TCP_SOCKET.ISS]
488
	push	[ebx + TCP_SOCKET.ISS]
479
	pop	[eax + TCP_SOCKET.SND_NXT]
489
	pop	[ebx + TCP_SOCKET.SND_NXT]
Line 480... Line 490...
480
 
490
 
481
	TCP_sendseqinit eax
491
	TCP_sendseqinit ebx
Line 482... Line 492...
482
	TCP_rcvseqinit eax
492
	TCP_rcvseqinit ebx
483
 
493
 
Line 484... Line 494...
484
	mov	[eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
494
	mov	[ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
485
	mov	[eax + TCP_SOCKET.t_flags], TF_ACKNOW
-
 
Line 486... Line 495...
486
	mov	[eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval  ;;;; macro
495
	mov	[ebx + TCP_SOCKET.t_flags], TF_ACKNOW
Line -... Line 496...
-
 
496
	mov	[ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval  ;;;; macro
-
 
497
 
487
 
498
	lea	eax, [ebx + STREAM_SOCKET.snd]
488
	add	eax, STREAM_SOCKET.snd
499
	call	SOCKET_ring_create
Line 489... Line 500...
489
	call	SOCKET_ring_create
500
 
490
 
501
	lea	eax, [ebx + STREAM_SOCKET.rcv]
Line 660... Line 671...
660
 
671
 
661
	and	[edx + TCP_segment.Flags], not (TH_SYN)
672
	and	[edx + TCP_segment.Flags], not (TH_SYN)
Line 662... Line 673...
662
	inc	[edx + TCP_segment.SequenceNumber]
673
	inc	[edx + TCP_segment.SequenceNumber]
663
 
674
 
664
	cmp	[edx + TCP_segment.UrgentPointer], 1
-
 
665
	jl	@f
675
	cmp	[edx + TCP_segment.UrgentPointer], 1
666
 
-
 
667
	dec	[edx + TCP_segment.UrgentPointer]
676
	jle	@f
668
 
677
	dec	[edx + TCP_segment.UrgentPointer]
669
	jmp	.no_dup_syn
-
 
670
       @@:
678
	jmp	.dup_syn
-
 
679
       @@:
671
 
680
	and	[edx + TCP_segment.Flags], not (TH_URG)
672
	and	[edx + TCP_segment.Flags], not (TH_URG)
-
 
673
	dec	eax
681
  .dup_syn:
Line 674... Line 682...
674
	jz	.no_duplicate
682
	dec	eax
Line 675... Line 683...
675
  .no_dup_syn:
683
  .no_dup_syn:
Line 887... Line 895...
887
	jnz	.no_syn_rcv
895
	jnz	.no_syn_rcv
Line 888... Line 896...
888
 
896
 
Line 889... Line 897...
889
	DEBUGF	1,"TCP state = syn received\n"
897
	DEBUGF	1,"TCP state = syn received\n"
890
 
898
 
891
	mov	eax, [edx + TCP_segment.AckNumber]
899
	mov	eax, [edx + TCP_segment.AckNumber]
892
	cmp	eax, [ebx + TCP_SOCKET.SND_UNA]
-
 
893
	jg	.drop_with_reset
900
	cmp	[ebx + TCP_SOCKET.SND_UNA], eax
894
 
901
	jg	.drop_with_reset
-
 
902
	cmp	eax, [ebx + TCP_SOCKET.SND_MAX]
895
	cmp	[ebx + TCP_SOCKET.SND_MAX], eax
903
	jg	.drop_with_reset
896
	jg	.drop_with_reset
904
 
897
	;;; update stats
905
	;;; update stats
898
	mov	eax, ebx
906
	mov	eax, ebx
Line 1485... Line 1493...
1485
	and	[ebx + TCP_SOCKET.t_flags], TF_ACKNOW
1493
	and	[ebx + TCP_SOCKET.t_flags], TF_ACKNOW
Line 1486... Line 1494...
1486
 
1494
 
Line 1487... Line 1495...
1487
	mov	[ebx + SOCKET.lock], 0
1495
	mov	[ebx + SOCKET.lock], 0
1488
 
1496
 
1489
	push	ebx
1497
	push	ebx
-
 
1498
;        mov     cl, TH_ACK
-
 
1499
;        call    TCP_respond_socket
1490
	mov	cl, TH_ACK
1500
	mov	eax, ebx
Line 1491... Line 1501...
1491
	call	TCP_respond_socket
1501
	call	TCP_output
1492
	pop	ebx
1502
	pop	ebx
1493
 
1503