Subversion Repositories Kolibri OS

Rev

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

Rev 2311 Rev 2315
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: 2311 $
16
$Revision: 2315 $
Line 17... Line 17...
17
 
17
 
Line 267... Line 267...
267
align 4
267
align 4
268
SOCKET_open:
268
SOCKET_open:
Line 269... Line 269...
269
 
269
 
Line -... Line 270...
-
 
270
        DEBUGF  1,"SOCKET_open: domain: %u, type: %u protocol: %x\n", ecx, edx, esi
270
        DEBUGF  1,"SOCKET_open: domain: %u, type: %u protocol: %x\n", ecx, edx, esi
271
 
-
 
272
        push    ecx edx esi
271
 
273
        call    SOCKET_alloc
Line 272... Line 274...
272
        call    SOCKET_alloc
274
        pop     esi edx ecx
Line 273... Line 275...
273
        jz      s_error
275
        jz      s_error
Line 1306... Line 1308...
1306
;
1308
;
1307
;--------------------------------------------------------------------
1309
;--------------------------------------------------------------------
1308
align 4
1310
align 4
1309
SOCKET_alloc:
1311
SOCKET_alloc:
Line 1310... Line 1312...
1310
 
1312
 
Line 1311... Line 1313...
1311
        push    ecx ebx
1313
        push    ebx
1312
 
1314
 
1313
        stdcall kernel_alloc, SOCKETBUFFSIZE
1315
        stdcall kernel_alloc, SOCKETBUFFSIZE
1314
        DEBUGF  1, "SOCKET_alloc: ptr=%x\n", eax
1316
        DEBUGF  1, "SOCKET_alloc: ptr=%x\n", eax
Line 1315... Line 1317...
1315
        or      eax, eax
1317
        or      eax, eax
1316
        jz      .exit
1318
        jz      .exit
1317
 
1319
 
1318
; zero-initialize allocated memory
1320
; zero-initialize allocated memory
1319
        push    eax edi
1321
        push    eax
1320
        mov     edi, eax
1322
        mov     edi, eax
1321
        mov     ecx, SOCKETBUFFSIZE / 4
1323
        mov     ecx, SOCKETBUFFSIZE / 4
Line 1322... Line 1324...
1322
        xor     eax, eax
1324
        xor     eax, eax
1323
        rep     stosd
1325
        rep     stosd
1324
        pop     edi eax
1326
        pop     eax
Line 1325... Line 1327...
1325
 
1327
 
1326
; set send-and receive procedures to return -1
1328
; set send-and receive procedures to return -1
1327
        mov     [eax + SOCKET.snd_proc], s_error
1329
        mov     [eax + SOCKET.snd_proc], s_error
1328
        mov     [eax + SOCKET.rcv_proc], s_error
1330
        mov     [eax + SOCKET.rcv_proc], s_error
1329
 
1331
 
1330
; find first free socket number and use it
1332
; find first free socket number and use it
1331
        mov     ecx, [last_socket_num]
1333
        mov     edi, [last_socket_num]
1332
  .next_socket_number:
1334
  .next_socket_number:
1333
        inc     ecx
1335
        inc     edi
1334
        jz      .next_socket_number     ; avoid socket nr 0
1336
        jz      .next_socket_number     ; avoid socket nr 0
1335
        cmp     ecx, -1
1337
        cmp     edi, -1
1336
        je      .next_socket_number     ; avoid socket nr -1
1338
        je      .next_socket_number     ; avoid socket nr -1
Line 1337... Line 1339...
1337
        mov     ebx, net_sockets
1339
        mov     ebx, net_sockets
1338
  .next_socket:
1340
  .next_socket:
1339
        mov     ebx, [ebx + SOCKET.NextPtr]
1341
        mov     ebx, [ebx + SOCKET.NextPtr]
Line 1340... Line 1342...
1340
        test    ebx, ebx
1342
        test    ebx, ebx
1341
        jz      .last_socket
1343
        jz      .last_socket
1342
 
1344
 
1343
        cmp     [ebx + SOCKET.Number], ecx
1345
        cmp     [ebx + SOCKET.Number], edi
1344
        jne     .next_socket
-
 
Line 1345... Line 1346...
1345
        jmp     .next_socket_number
1346
        jne     .next_socket
1346
 
1347
        jmp     .next_socket_number
1347
  .last_socket:
1348
 
1348
        mov     [last_socket_num], ecx
1349
  .last_socket:
Line 1371... Line 1372...
1371
       @@:
1372
       @@:
Line 1372... Line 1373...
1372
 
1373
 
1373
        mov     [net_sockets + SOCKET.NextPtr], eax
1374
        mov     [net_sockets + SOCKET.NextPtr], eax
1374
        or      eax, eax                ; used to clear zero flag
1375
        or      eax, eax                ; used to clear zero flag
1375
  .exit:
1376
  .exit:
Line 1376... Line 1377...
1376
        pop     ebx ecx
1377
        pop     ebx
Line 1377... Line 1378...
1377
 
1378
 
Line 1457... Line 1458...
1457
        mov     eax, [ebx + SOCKET_QUEUE_LOCATION + queue.size]
1458
        mov     eax, [ebx + SOCKET_QUEUE_LOCATION + queue.size]
1458
        cmp     ax, [ebx + SOCKET.backlog]
1459
        cmp     ax, [ebx + SOCKET.backlog]
1459
        jae     .fail
1460
        jae     .fail
Line 1460... Line 1461...
1460
 
1461
 
-
 
1462
; Allocate new socket
1461
; Allocate new socket
1463
        push    ebx
-
 
1464
        call    SOCKET_alloc
1462
        call    SOCKET_alloc
1465
        pop     ebx
Line 1463... Line -...
1463
        jz      .fail
-
 
1464
 
1466
        jz      .fail
1465
        push    esi ecx edi
1467
 
1466
        push    eax
1468
        push    eax
1467
        mov     esi, esp
1469
        mov     esi, esp
Line 1474... Line 1476...
1474
        lea     edi, [eax + SOCKET.PID]
1476
        lea     edi, [eax + SOCKET.PID]
1475
        mov     ecx, (SOCKET_QUEUE_LOCATION - SOCKET.PID + 3)/4
1477
        mov     ecx, (SOCKET_QUEUE_LOCATION - SOCKET.PID + 3)/4
1476
        rep     movsd
1478
        rep     movsd
Line 1477... Line 1479...
1477
 
1479
 
1478
        and     [eax + SOCKET.options], not SO_ACCEPTCON
-
 
Line 1479... Line 1480...
1479
        pop     edi ecx esi
1480
        and     [eax + SOCKET.options], not SO_ACCEPTCON
Line 1480... Line 1481...
1480
 
1481
 
1481
        ret
1482
        ret