Subversion Repositories Kolibri OS

Rev

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

Rev 2362 Rev 2402
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: 2362 $
16
$Revision: 2402 $
Line 17... Line 17...
17
 
17
 
18
 
18
 
19
struct	SOCKET
19
struct  SOCKET
Line 20... Line 20...
20
 
20
 
Line 21... Line 21...
21
	NextPtr 		dd ? ; pointer to next socket in list
21
        NextPtr                 dd ? ; pointer to next socket in list
22
	PrevPtr 		dd ? ; pointer to previous socket in list
22
        PrevPtr                 dd ? ; pointer to previous socket in list
23
	Number			dd ? ; socket number
23
        Number                  dd ? ; socket number
24
 
24
 
Line 448... Line 448...
448
 
448
 
Line 449... Line 449...
449
	jmp	s_error
449
        jmp     s_error
450
 
450
 
-
 
451
align 4
451
align 4
452
  .udp:
452
  .udp:
453
        pusha
-
 
454
        lea     ecx, [eax + SOCKET.mutex]
Line 453... Line 455...
453
	lea	ebx, [eax + SOCKET.lock]
455
        call    mutex_lock
454
	call	wait_mutex
456
        popa
Line 455... Line 457...
455
 
457
 
Line 468... Line 470...
468
 
470
 
469
	push	eax
471
        push    eax
470
	init_queue (eax + SOCKET_QUEUE_LOCATION)	; Set up data receiving queue
472
        init_queue (eax + SOCKET_QUEUE_LOCATION)        ; Set up data receiving queue
Line 471... Line 473...
471
	pop	eax
473
        pop     eax
-
 
474
 
-
 
475
        lea     ecx, [eax + SOCKET.mutex]
472
 
476
        call    mutex_unlock
473
	mov	[eax + SOCKET.lock], 0
477
 
Line 474... Line 478...
474
	mov	dword [esp+32], 0
478
        mov     dword [esp+32], 0
475
	ret
479
        ret
-
 
480
 
476
 
481
align 4
477
align 4
482
  .tcp:
-
 
483
        pusha
Line 478... Line 484...
478
  .tcp:
484
        lea     ecx, [eax + SOCKET.mutex]
479
	lea	ebx, [eax + SOCKET.lock]
485
        call    mutex_lock
Line 480... Line 486...
480
	call	wait_mutex
486
        popa
Line 507... Line 513...
507
	call	SOCKET_ring_create
513
        call    SOCKET_ring_create
Line 508... Line 514...
508
 
514
 
509
	lea	eax, [ebx + STREAM_SOCKET.rcv]
515
        lea     eax, [ebx + STREAM_SOCKET.rcv]
Line -... Line 516...
-
 
516
        call    SOCKET_ring_create
510
	call	SOCKET_ring_create
517
 
-
 
518
        pusha
-
 
519
        lea     ecx, [ebx + SOCKET.mutex]
Line 511... Line 520...
511
 
520
        call    mutex_unlock
512
	mov	[ebx + SOCKET.lock], 0
521
        popa
Line 513... Line 522...
513
 
522
 
514
	mov	eax, ebx
523
        mov     eax, ebx
Line 515... Line 524...
515
	call	TCP_output
524
        call    TCP_output
516
 
525
 
-
 
526
        mov     dword [esp+32], 0
517
	mov	dword [esp+32], 0
527
        ret
518
	ret
528
 
-
 
529
align 4
Line 519... Line 530...
519
 
530
  .ip:
520
align 4
531
        pusha
Line 521... Line 532...
521
  .ip:
532
        lea     ecx, [eax + SOCKET.mutex]
522
	lea	ebx, [eax + SOCKET.lock]
533
        call    mutex_lock
523
	call	wait_mutex
534
        popa
Line 524... Line 535...
524
 
535
 
-
 
536
        pushd   [edx + 4]
-
 
537
        pop     [eax + IP_SOCKET.RemoteIP]
525
	pushd	[edx + 4]
538
 
526
	pop	[eax + IP_SOCKET.RemoteIP]
539
        push    eax
Line 527... Line 540...
527
 
540
        init_queue (eax + SOCKET_QUEUE_LOCATION)        ; Set up data receiving queue
Line 1049... Line 1062...
1049
 
1062
 
Line 1050... Line 1063...
1050
	add_to_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, SOCKET_input.full
1063
        add_to_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, SOCKET_input.full
1051
 
1064
 
-
 
1065
        DEBUGF  1,"SOCKET_input: queued packet successfully\n"
-
 
1066
        add     esp, sizeof.socket_queue_entry
1052
	DEBUGF	1,"SOCKET_input: queued packet successfully\n"
1067
 
-
 
1068
        pusha
-
 
1069
        lea     ecx, [eax + SOCKET.mutex]
-
 
1070
        call    mutex_unlock
1053
	add	esp, sizeof.socket_queue_entry
1071
        popa
Line 1054... Line 1072...
1054
	mov	[eax + SOCKET.lock], 0
1072
 
1055
	jmp	SOCKET_notify_owner
1073
        jmp     SOCKET_notify_owner
-
 
1074
 
-
 
1075
  .full:
1056
 
1076
        DEBUGF  2,"SOCKET_input: socket %x is full!\n", eax
-
 
1077
 
-
 
1078
        pusha
-
 
1079
        lea     ecx, [eax + SOCKET.mutex]
1057
  .full:
1080
        call    mutex_unlock
1058
	DEBUGF	2,"SOCKET_input: socket %x is full!\n", eax
1081
        popa
Line 1059... Line 1082...
1059
	mov	[eax + SOCKET.lock], 0
1082
 
Line 1362... Line 1385...
1362
	mov	[eax + SOCKET.PrevPtr], net_sockets
1385
        mov     [eax + SOCKET.PrevPtr], net_sockets
1363
	mov	[eax + SOCKET.NextPtr], ebx
1386
        mov     [eax + SOCKET.NextPtr], ebx
Line 1364... Line 1387...
1364
 
1387
 
1365
	test	ebx, ebx
1388
        test    ebx, ebx
-
 
1389
        jz      @f
-
 
1390
 
1366
	jz	@f
1391
        pusha
1367
	add	ebx, SOCKET.lock	; lock the next socket
1392
        lea     ecx, [ebx + SOCKET.mutex]
1368
	call	wait_mutex
1393
        call    mutex_lock
-
 
1394
        popa
1369
	sub	ebx, SOCKET.lock
1395
 
-
 
1396
        mov     [ebx + SOCKET.PrevPtr], eax
-
 
1397
 
1370
	mov	[ebx + SOCKET.PrevPtr], eax
1398
        pusha
-
 
1399
        lea     ecx, [ebx + SOCKET.mutex]
-
 
1400
        call    mutex_unlock
1371
	mov	[ebx + SOCKET.lock], 0	; and unlock it again
1401
        popa
Line 1372... Line 1402...
1372
       @@:
1402
       @@:
1373
 
1403
 
1374
	mov	[net_sockets + SOCKET.NextPtr], eax
1404
        mov     [net_sockets + SOCKET.NextPtr], eax
Line 1396... Line 1426...
1396
 
1426
 
1397
	call	SOCKET_check
1427
        call    SOCKET_check
Line 1398... Line 1428...
1398
	jz	.error
1428
        jz      .error
-
 
1429
 
-
 
1430
        push    ebx
1399
 
1431
 
1400
	push	ebx
1432
        pusha
-
 
1433
        lea     ecx, [eax + SOCKET.mutex]
Line 1401... Line 1434...
1401
	lea	ebx, [eax + SOCKET.lock]
1434
        call    mutex_lock
Line 1402... Line 1435...
1402
	call	wait_mutex
1435
        popa
1403
 
1436