Subversion Repositories Kolibri OS

Rev

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

Rev 9739 Rev 9917
Line 13... Line 13...
13
;;         GNU GENERAL PUBLIC LICENSE                              ;;
13
;;         GNU GENERAL PUBLIC LICENSE                              ;;
14
;;          Version 2, June 1991                                   ;;
14
;;          Version 2, June 1991                                   ;;
15
;;                                                                 ;;
15
;;                                                                 ;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 17... Line 17...
17
 
17
 
Line 18... Line 18...
18
$Revision: 9739 $
18
$Revision: 9917 $
Line 19... Line 19...
19
 
19
 
20
struct  SOCKET
20
struct  SOCKET
Line 38... Line 38...
38
        backlog                 dw ?    ; number of incoming connections that can be queued
38
        backlog                 dw ?    ; number of incoming connections that can be queued
Line 39... Line 39...
39
 
39
 
40
        snd_proc                dd ?
40
        snd_proc                dd ?
41
        rcv_proc                dd ?
41
        rcv_proc                dd ?
-
 
42
        connect_proc            dd ?
-
 
43
        ;sndto_proc              dd ?
Line 42... Line 44...
42
        connect_proc            dd ?
44
        ;rcvfrom_proc            dd ?
Line 43... Line 45...
43
 
45
 
Line 254... Line 256...
254
;                                                                 ;
256
;                                                                 ;
255
;-----------------------------------------------------------------;
257
;-----------------------------------------------------------------;
256
align 4
258
align 4
257
sys_socket:
259
sys_socket:
Line 258... Line 260...
258
 
260
 
Line 259... Line 261...
259
        mov     dword[esp+20], 0        ; Set error code to 0
261
        mov     dword[esp + SYSCALL_STACK.ebx], 0        ; Set error code to 0
260
 
262
 
Line 261... Line 263...
261
        cmp     ebx, 255
263
        cmp     ebx, 255
Line 275... Line 277...
275
        dd      socket_send             ; 6
277
        dd      socket_send             ; 6
276
        dd      socket_receive          ; 7
278
        dd      socket_receive          ; 7
277
        dd      socket_set_opt          ; 8
279
        dd      socket_set_opt          ; 8
278
        dd      socket_get_opt          ; 9
280
        dd      socket_get_opt          ; 9
279
        dd      socket_pair             ; 10
281
        dd      socket_pair             ; 10
-
 
282
 
-
 
283
        ;dd      socket_sendto           ; 11
-
 
284
        ;dd      socket_recvfrom         ; 12
280
  .number = ($ - .table) / 4 - 1
285
  .number = ($ - .table) / 4 - 1
Line 281... Line 286...
281
 
286
 
282
  .error:
287
  .error:
283
        mov     dword[esp+32], -1
288
        mov     dword[esp + SYSCALL_STACK.eax], -1
Line 284... Line 289...
284
        mov     dword[esp+20], EINVAL
289
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
Line 285... Line 290...
285
 
290
 
286
        ret
291
        ret
Line 307... Line 312...
307
        call    socket_alloc
312
        call    socket_alloc
308
        pop     esi edx ecx
313
        pop     esi edx ecx
309
        test    eax, eax
314
        test    eax, eax
310
        jz      .nobuffs
315
        jz      .nobuffs
Line 311... Line 316...
311
 
316
 
312
        mov     [esp+32], edi           ; return socketnumber
317
        mov     [esp + SYSCALL_STACK.eax], edi    ; return socketnumber
Line 313... Line 318...
313
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_open: socknum=%u\n", edi
318
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_open: socknum=%u\n", edi
314
 
319
 
315
        test    edx, SO_NONBLOCK
320
        test    edx, SO_NONBLOCK
Line 347... Line 352...
347
  .no_ppp:
352
  .no_ppp:
348
  .unsupported:
353
  .unsupported:
349
        push    eax
354
        push    eax
350
        call    socket_free
355
        call    socket_free
351
        pop     eax
356
        pop     eax
352
        mov     dword[esp+20], EOPNOTSUPP
357
        mov     dword[esp + SYSCALL_STACK.ebx], EOPNOTSUPP
353
        mov     dword[esp+32], -1
358
        mov     dword[esp + SYSCALL_STACK.eax], -1
354
        ret
359
        ret
Line 355... Line 360...
355
 
360
 
356
  .nobuffs:
361
  .nobuffs:
357
        mov     dword[esp+20], ENOBUFS
362
        mov     dword[esp + SYSCALL_STACK.ebx], ENOBUFS
358
        mov     dword[esp+32], -1
363
        mov     dword[esp + SYSCALL_STACK.eax], -1
Line 359... Line 364...
359
        ret
364
        ret
360
 
365
 
361
  .raw:
366
  .raw:
Line 457... Line 462...
457
 
462
 
458
        cmp     word[edx], AF_LOCAL
463
        cmp     word[edx], AF_LOCAL
Line 459... Line 464...
459
        je      .af_local
464
        je      .af_local
460
 
465
 
461
  .notsupp:
466
  .notsupp:
462
        mov     dword[esp+20], EOPNOTSUPP
467
        mov     dword[esp + SYSCALL_STACK.ebx], EOPNOTSUPP
Line 463... Line 468...
463
        mov     dword[esp+32], -1
468
        mov     dword[esp + SYSCALL_STACK.eax], -1
464
        ret
469
        ret
465
 
470
 
466
  .invalid:
471
  .invalid:
Line 467... Line 472...
467
        mov     dword[esp+20], EINVAL
472
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
468
        mov     dword[esp+32], -1
473
        mov     dword[esp + SYSCALL_STACK.eax], -1
469
        ret
474
        ret
470
 
475
 
Line 471... Line 476...
471
  .af_local:
476
  .af_local:
472
        ; TODO: write code here
477
        ; TODO: write code here
473
        mov     dword[esp+32], 0
478
        mov     dword[esp + SYSCALL_STACK.eax], 0
Line 503... Line 508...
503
  .done:
508
  .done:
504
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_bind: local ip=%u.%u.%u.%u\n",\
509
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_bind: local ip=%u.%u.%u.%u\n",\
505
        [eax + IP_SOCKET.LocalIP + 0]:1,[eax + IP_SOCKET.LocalIP + 1]:1,\
510
        [eax + IP_SOCKET.LocalIP + 0]:1,[eax + IP_SOCKET.LocalIP + 1]:1,\
506
        [eax + IP_SOCKET.LocalIP + 2]:1,[eax + IP_SOCKET.LocalIP + 3]:1
511
        [eax + IP_SOCKET.LocalIP + 2]:1,[eax + IP_SOCKET.LocalIP + 3]:1
Line 507... Line 512...
507
 
512
 
508
        mov     dword[esp+32], 0
513
        mov     dword[esp + SYSCALL_STACK.eax], 0
Line 509... Line 514...
509
        ret
514
        ret
510
 
515
 
511
  .addrinuse:
516
  .addrinuse:
512
        mov     dword[esp+32], -1
517
        mov     dword[esp + SYSCALL_STACK.eax], -1
Line 547... Line 552...
547
        test    [eax + SOCKET.options], SO_ACCEPTCON
552
        test    [eax + SOCKET.options], SO_ACCEPTCON
548
        jnz     .notsupp
553
        jnz     .notsupp
Line 549... Line 554...
549
 
554
 
Line 550... Line 555...
550
        call    [eax + SOCKET.connect_proc]
555
        call    [eax + SOCKET.connect_proc]
551
 
556
 
552
        mov     dword[esp+20], ebx
557
        mov     dword[esp + SYSCALL_STACK.ebx], ebx
Line 553... Line 558...
553
        mov     dword[esp+32], eax
558
        mov     dword[esp + SYSCALL_STACK.eax], eax
554
        ret
559
        ret
555
 
560
 
556
 
561
 
Line 557... Line 562...
557
  .notsupp:
562
  .notsupp:
558
        mov     dword[esp+20], EOPNOTSUPP
563
        mov     dword[esp + SYSCALL_STACK.ebx], EOPNOTSUPP
559
        mov     dword[esp+32], -1
564
        mov     dword[esp + SYSCALL_STACK.eax], -1
560
        ret
565
        ret
Line 561... Line 566...
561
 
566
 
562
  .invalid:
567
  .invalid:
563
        mov     dword[esp+20], EINVAL
568
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
564
        mov     dword[esp+32], -1
569
        mov     dword[esp + SYSCALL_STACK.eax], -1
Line 565... Line 570...
565
        ret
570
        ret
566
 
571
 
Line 625... Line 630...
625
 
630
 
626
        push    eax
631
        push    eax
627
        init_queue (eax + SOCKET_QUEUE_LOCATION)                ; Set up sockets queue
632
        init_queue (eax + SOCKET_QUEUE_LOCATION)                ; Set up sockets queue
Line 628... Line 633...
628
        pop     eax
633
        pop     eax
629
 
634
 
Line 630... Line 635...
630
        mov     dword[esp+32], 0
635
        mov     dword[esp + SYSCALL_STACK.eax], 0
631
        ret
636
        ret
632
 
637
 
633
  .notsupp:
638
  .notsupp:
Line 634... Line 639...
634
        mov     dword[esp+20], EOPNOTSUPP
639
        mov     dword[esp + SYSCALL_STACK.ebx], EOPNOTSUPP
635
        mov     dword[esp+32], -1
640
        mov     dword[esp + SYSCALL_STACK.eax], -1
636
        ret
641
        ret
637
 
642
 
Line 638... Line 643...
638
  .invalid:
643
  .invalid:
639
        mov     dword[esp+20], EINVAL
644
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
640
        mov     dword[esp+32], -1
645
        mov     dword[esp + SYSCALL_STACK.eax], -1
641
        ret
646
        ret
Line 642... Line 647...
642
 
647
 
643
  .already:
648
  .already:
Line 692... Line 697...
692
        mov     ebx, [ebx + APPDATA.tid]
697
        mov     ebx, [ebx + APPDATA.tid]
693
        mov     [eax + SOCKET.TID], ebx
698
        mov     [eax + SOCKET.TID], ebx
Line 694... Line 699...
694
 
699
 
695
; Return socket number to caller
700
; Return socket number to caller
696
        mov     eax, [eax + SOCKET.Number]
701
        mov     eax, [eax + SOCKET.Number]
697
        mov     [esp+32], eax
702
        mov     [esp + SYSCALL_STACK.eax], eax
Line 698... Line 703...
698
        ret
703
        ret
699
 
704
 
700
  .block:
705
  .block:
Line 701... Line 706...
701
        test    [eax + SOCKET.options], SO_NONBLOCK
706
        test    [eax + SOCKET.options], SO_NONBLOCK
702
        jnz     .wouldblock
707
        jnz     .wouldblock
Line 703... Line 708...
703
 
708
 
704
        call    socket_block
709
        call    socket_block
705
        jmp     .loop
710
        jmp     .loop
706
 
711
 
Line 707... Line 712...
707
  .wouldblock:
712
  .wouldblock:
708
        mov     dword[esp+20], EWOULDBLOCK
713
        mov     dword[esp + SYSCALL_STACK.ebx], EWOULDBLOCK
709
        mov     dword[esp+32], -1
714
        mov     dword[esp + SYSCALL_STACK.eax], -1
710
        ret
715
        ret
Line 711... Line 716...
711
 
716
 
712
  .invalid:
717
  .invalid:
713
        mov     dword[esp+20], EINVAL
718
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
714
        mov     dword[esp+32], -1
719
        mov     dword[esp + SYSCALL_STACK.eax], -1
Line 715... Line 720...
715
        ret
720
        ret
716
 
721
 
717
  .notsupp:
722
  .notsupp:
Line 737... Line 742...
737
 
742
 
738
        call    socket_num_to_ptr
743
        call    socket_num_to_ptr
739
        test    eax, eax
744
        test    eax, eax
Line 740... Line 745...
740
        jz      .invalid
745
        jz      .invalid
Line 741... Line 746...
741
 
746
 
Line 742... Line 747...
742
        mov     dword[esp+32], 0                                ; The socket exists, so we will succeed in closing it.
747
        mov     dword[esp + SYSCALL_STACK.eax], 0               ; The socket exists, so we will succeed in closing it.
743
 
748
 
Line 770... Line 775...
770
;       call    socket_free
775
;       call    socket_free
771
        ret
776
        ret
Line 772... Line 777...
772
 
777
 
773
 
778
 
774
  .invalid:
779
  .invalid:
775
        mov     dword[esp+20], EINVAL
780
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
Line 776... Line 781...
776
        mov     dword[esp+32], -1
781
        mov     dword[esp + SYSCALL_STACK.eax], -1
777
        ret
782
        ret
Line 829... Line 834...
829
        push    EINVAL
834
        push    EINVAL
830
        pop     ebx
835
        pop     ebx
831
  .return_err:
836
  .return_err:
832
        mov     ecx, -1
837
        mov     ecx, -1
833
  .return:
838
  .return:
834
        mov     [esp+20], ebx
839
        mov     [esp + SYSCALL_STACK.ebx], ebx
835
        mov     [esp+32], ecx
840
        mov     [esp + SYSCALL_STACK.eax], ecx
836
        ret
841
        ret
Line 837... Line 842...
837
 
842
 
838
  .last_data:
843
  .last_data:
839
        test    ecx, ecx
844
        test    ecx, ecx
Line 1017... Line 1022...
1017
        mov     esi, edx
1022
        mov     esi, edx
Line 1018... Line 1023...
1018
 
1023
 
Line 1019... Line 1024...
1019
        jmp     [eax + SOCKET.snd_proc]
1024
        jmp     [eax + SOCKET.snd_proc]
1020
 
1025
 
1021
  .invalid:
1026
  .invalid:
1022
        mov     dword[esp+20], EINVAL
1027
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
Line 1023... Line 1028...
1023
        mov     dword[esp+32], -1
1028
        mov     dword[esp + SYSCALL_STACK.eax], -1
1024
        ret
1029
        ret
Line 1025... Line 1030...
1025
 
1030
 
Line 1026... Line 1031...
1026
 
1031
 
1027
align 4
1032
align 4
1028
socket_send_udp:
1033
socket_send_udp:
1029
 
1034
 
1030
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: UDP\n"
1035
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: UDP\n"
Line 1031... Line 1036...
1031
 
1036
 
1032
        mov     [esp+32], ecx
1037
        mov     [esp + SYSCALL_STACK.eax], ecx
1033
        call    udp_output
1038
        call    udp_output
1034
        cmp     eax, -1
1039
        cmp     eax, -1
Line 1035... Line 1040...
1035
        je      .error
1040
        je      .error
1036
        ret
1041
        ret
Line 1049... Line 1054...
1049
        push    eax
1054
        push    eax
1050
        add     eax, STREAM_SOCKET.snd
1055
        add     eax, STREAM_SOCKET.snd
1051
        call    socket_ring_write
1056
        call    socket_ring_write
1052
        pop     eax
1057
        pop     eax
Line 1053... Line 1058...
1053
 
1058
 
1054
        mov     [esp+32], ecx
1059
        mov     [esp + SYSCALL_STACK.eax], ecx
1055
        mov     [eax + SOCKET.errorcode], 0
1060
        mov     [eax + SOCKET.errorcode], 0
1056
        push    eax
1061
        push    eax
1057
        call    tcp_output              ; FIXME: this doesnt look pretty, does it?
1062
        call    tcp_output              ; FIXME: this doesnt look pretty, does it?
1058
        pop     eax
1063
        pop     eax
1059
        mov     eax, [eax + SOCKET.errorcode]
1064
        mov     eax, [eax + SOCKET.errorcode]
1060
        mov     [esp+20], eax
1065
        mov     [esp + SYSCALL_STACK.ebx], eax
Line 1061... Line 1066...
1061
        ret
1066
        ret
1062
 
1067
 
Line 1063... Line 1068...
1063
 
1068
 
Line 1064... Line 1069...
1064
align 4
1069
align 4
1065
socket_send_ip:
1070
socket_send_ip:
1066
 
1071
 
1067
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: IPv4\n"
1072
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: IPv4\n"
1068
 
1073
 
Line 1069... Line 1074...
1069
        mov     [esp+32], ecx
1074
        mov     [esp + SYSCALL_STACK.eax], ecx
1070
        call    ipv4_output_raw
1075
        call    ipv4_output_raw
1071
        cmp     eax, -1
1076
        cmp     eax, -1
1072
        je      .error
1077
        je      .error
Line 1073... Line 1078...
1073
        ret
1078
        ret
1074
 
1079
 
Line 1075... Line 1080...
1075
  .error:
1080
  .error:
Line 1076... Line 1081...
1076
        mov     dword[esp+32], eax
1081
        mov     dword[esp + SYSCALL_STACK.eax], eax
1077
        mov     dword[esp+20], ebx
1082
        mov     dword[esp + SYSCALL_STACK.ebx], ebx
1078
        ret
1083
        ret
1079
 
1084
 
1080
 
1085
 
Line 1081... Line 1086...
1081
align 4
1086
align 4
1082
socket_send_icmp:
1087
socket_send_icmp:
1083
 
1088
 
1084
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: ICMP\n"
1089
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: ICMP\n"
Line 1085... Line 1090...
1085
 
1090
 
1086
        mov     [esp+32], ecx
1091
        mov     [esp + SYSCALL_STACK.eax], ecx
1087
        call    icmp_output_raw
1092
        call    icmp_output_raw
1088
        cmp     eax, -1
1093
        cmp     eax, -1
1089
        je      .error
1094
        je      .error
1090
        ret
1095
        ret
1091
 
1096
 
1092
  .error:
1097
  .error:
1093
        mov     dword[esp+32], eax
1098
        mov     dword[esp + SYSCALL_STACK.eax], eax
1094
        mov     dword[esp+20], ebx
1099
        mov     dword[esp + SYSCALL_STACK.ebx], ebx
1095
        ret
1100
        ret
1096
 
1101
 
1097
 
1102
 
1098
;align 4
1103
;align 4
1099
;socket_send_pppoe:
1104
;socket_send_pppoe:
1100
;
1105
;
1101
;        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n"
1106
;        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n"
Line 1102... Line 1107...
1102
;
1107
;
Line 1145... Line 1150...
1145
        add     eax, STREAM_SOCKET.rcv
1150
        add     eax, STREAM_SOCKET.rcv
1146
        call    socket_ring_write
1151
        call    socket_ring_write
1147
        pop     eax
1152
        pop     eax
Line 1148... Line 1153...
1148
 
1153
 
1149
        ; return the number of written bytes (or errorcode) to application
1154
        ; return the number of written bytes (or errorcode) to application
Line 1150... Line 1155...
1150
        mov     [esp+32], ecx
1155
        mov     [esp + SYSCALL_STACK.eax], ecx
1151
 
1156
 
Line 1152... Line 1157...
1152
        ; and notify the other end
1157
        ; and notify the other end
Line 1153... Line 1158...
1153
        call    socket_notify
1158
        call    socket_notify
1154
 
1159
 
1155
        ret
1160
        ret
1156
 
1161
 
Line 1157... Line 1162...
1157
  .invalid:
1162
  .invalid:
1158
        mov     dword[esp+32], -1
1163
        mov     dword[esp + SYSCALL_STACK.eax], -1
Line 1211... Line 1216...
1211
        mov     eax, [edx+8]
1216
        mov     eax, [edx+8]
1212
        test    eax, eax
1217
        test    eax, eax
1213
        jz      @f
1218
        jz      @f
1214
        mov     [eax], ecx
1219
        mov     [eax], ecx
1215
@@:
1220
@@:
1216
        mov     dword [esp+32], 0
1221
        mov     dword [esp + SYSCALL_STACK.eax], 0
1217
        ret
1222
        ret
Line 1218... Line 1223...
1218
 
1223
 
1219
  .invalid:
1224
  .invalid:
1220
        mov     dword[esp+32], -1
1225
        mov     dword[esp + SYSCALL_STACK.eax], -1
1221
        mov     dword[esp+20], EINVAL
1226
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
Line 1222... Line 1227...
1222
        ret
1227
        ret
1223
 
1228
 
Line 1265... Line 1270...
1265
        jz      .already
1270
        jz      .already
1266
        mov     [eax + SOCKET.device], edx
1271
        mov     [eax + SOCKET.device], edx
Line 1267... Line 1272...
1267
 
1272
 
Line 1268... Line 1273...
1268
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_set_opt: Bound socket %x to device %x\n", eax, edx
1273
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_set_opt: Bound socket %x to device %x\n", eax, edx
1269
 
1274
 
Line 1270... Line 1275...
1270
        mov     dword[esp+32], 0        ; success!
1275
        mov     dword[esp + SYSCALL_STACK.eax], 0        ; success!
1271
        ret
1276
        ret
Line 1272... Line 1277...
1272
 
1277
 
1273
  .unbind:
1278
  .unbind:
Line 1274... Line 1279...
1274
        mov     [eax + SOCKET.device], 0
1279
        mov     [eax + SOCKET.device], 0
1275
 
1280
 
1276
        mov     dword[esp+32], 0        ; success!
1281
        mov     dword[esp + SYSCALL_STACK.eax], 0        ; success!
Line 1277... Line 1282...
1277
        ret
1282
        ret
1278
 
1283
 
1279
  .ip:
1284
  .ip:
Line 1280... Line 1285...
1280
        cmp     [edx + socket_options.optname], IP_TTL
1285
        cmp     [edx + socket_options.optname], IP_TTL
1281
        jne     .invalid
1286
        jne     .invalid
Line 1282... Line 1287...
1282
 
1287
 
1283
  .ttl:
1288
  .ttl:
1284
        mov     bl, byte[edx + socket_options.optval]
1289
        mov     bl, byte[edx + socket_options.optval]
1285
        mov     [eax + IP_SOCKET.ttl], bl
1290
        mov     [eax + IP_SOCKET.ttl], bl
Line 1286... Line 1291...
1286
 
1291
 
1287
        mov     dword[esp+32], 0        ; success!
1292
        mov     dword[esp + SYSCALL_STACK.eax], 0        ; success!
1288
        ret
1293
        ret
1289
 
1294
 
Line 1318... Line 1323...
1318
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_pair\n"
1323
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_pair\n"
Line 1319... Line 1324...
1319
 
1324
 
1320
        call    socket_alloc
1325
        call    socket_alloc
1321
        test    eax, eax
1326
        test    eax, eax
1322
        jz      .nomem1
1327
        jz      .nomem1
Line 1323... Line 1328...
1323
        mov     [esp+32], edi   ; application's eax
1328
        mov     [esp + SYSCALL_STACK.eax], edi   ; application's eax
1324
 
1329
 
1325
        mov     [eax + SOCKET.Domain], AF_LOCAL
1330
        mov     [eax + SOCKET.Domain], AF_LOCAL
1326
        mov     [eax + SOCKET.Type], SOCK_STREAM
1331
        mov     [eax + SOCKET.Type], SOCK_STREAM
Line 1331... Line 1336...
1331
        mov     ebx, eax
1336
        mov     ebx, eax
Line 1332... Line 1337...
1332
 
1337
 
1333
        call    socket_alloc
1338
        call    socket_alloc
1334
        test    eax, eax
1339
        test    eax, eax
1335
        jz      .nomem2
1340
        jz      .nomem2
Line 1336... Line 1341...
1336
        mov     [esp+20], edi   ; application's ebx
1341
        mov     [esp + SYSCALL_STACK.ebx], edi   ; application's ebx
1337
 
1342
 
1338
        mov     [eax + SOCKET.Domain], AF_LOCAL
1343
        mov     [eax + SOCKET.Domain], AF_LOCAL
1339
        mov     [eax + SOCKET.Type], SOCK_STREAM
1344
        mov     [eax + SOCKET.Type], SOCK_STREAM
Line 1357... Line 1362...
1357
        jz      .nomem2
1362
        jz      .nomem2
Line 1358... Line 1363...
1358
 
1363
 
Line 1359... Line 1364...
1359
        ret
1364
        ret
1360
 
1365
 
1361
  .nomem2:
1366
  .nomem2:
Line 1362... Line 1367...
1362
        mov     eax, [esp+20]
1367
        mov     eax, [esp + SYSCALL_STACK.ebx]
1363
        call    socket_free
1368
        call    socket_free
1364
 
1369
 
Line 1365... Line 1370...
1365
  .nomem1:
1370
  .nomem1:
1366
        mov     eax, [esp+32]
1371
        mov     eax, [esp + SYSCALL_STACK.eax]
1367
        call    socket_free
1372
        call    socket_free
Line 1368... Line 1373...
1368
 
1373
 
Line 1418... Line 1423...
1418
        stosd
1423
        stosd
1419
        jmp     .next_socket
1424
        jmp     .next_socket
1420
  .done:
1425
  .done:
1421
        xor     eax, eax
1426
        xor     eax, eax
1422
        stosd
1427
        stosd
1423
        mov     dword[esp+32], eax
1428
        mov     dword[esp + SYSCALL_STACK.eax], eax
1424
        ret
1429
        ret
Line 1425... Line 1430...
1425
 
1430
 
1426
  .invalid:
1431
  .invalid:
1427
        mov     dword[esp+32], -1
1432
        mov     dword[esp + SYSCALL_STACK.eax], -1
1428
        mov     dword[esp+20], EINVAL
1433
        mov     dword[esp + SYSCALL_STACK.ebx], EINVAL
Line 1429... Line 1434...
1429
        ret
1434
        ret
1430
 
1435
 
Line 1902... Line 1907...
1902
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: %x\n", eax
1907
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: %x\n", eax
Line 1903... Line 1908...
1903
 
1908
 
1904
        call    socket_check
1909
        call    socket_check
Line 1905... Line 1910...
1905
        jz      .error
1910
        jz      .error
1906
 
1911
 
1907
; Find the associated thread's TASK_DATA
1912
; Find the associated thread's
1908
        push    ebx ecx esi
1913
        push    ebx ecx esi
1909
        mov     ebx, [eax + SOCKET.TID]
1914
        mov     ebx, [eax + SOCKET.TID]
1910
        test    ebx, ebx
1915
        test    ebx, ebx
Line 1934... Line 1939...
1934
        test    [eax + SOCKET.state], SS_BLOCKED
1939
        test    [eax + SOCKET.state], SS_BLOCKED
1935
        jnz     .un_block
1940
        jnz     .un_block
Line 1936... Line 1941...
1936
 
1941
 
1937
; Socket and thread exists and socket is of non blocking type.
1942
; Socket and thread exists and socket is of non blocking type.
1938
; We'll try to flag an event to the thread.
-
 
1939
        shl     ecx, BSF sizeof.APPDATA
1943
; We'll try to flag an event to the thread.
Line 1940... Line 1944...
1940
        or      [SLOT_BASE + ecx + APPDATA.occurred_events], EVENT_NETWORK
1944
        or      [esi + APPDATA.occurred_events], EVENT_NETWORK
1941
 
1945
 
1942
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", ebx
1946
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", ebx
Line 1943... Line 1947...
1943
        pop     esi ecx ebx
1947
        pop     esi ecx ebx
1944
        ret
1948
        ret
1945
 
1949
 
1946
 
1950
 
1947
  .un_block:
-
 
1948
; Socket and thread exists and socket is of blocking type
1951
  .un_block:
Line 1949... Line 1952...
1949
; We'll try to unblock it.
1952
; Socket and thread exists and socket is of blocking type
1950
        and     [eax + SOCKET.state], not SS_BLOCKED    ; Clear the 'socket is blocked' flag
1953
; We'll try to unblock it.
1951
        shl     ecx, BSF sizeof.APPDATA
1954
        and     [eax + SOCKET.state], not SS_BLOCKED    ; Clear the 'socket is blocked' flag
Line 2537... Line 2540...
2537
        or      [eax + SOCKET.state], SS_CANTSENDMORE
2540
        or      [eax + SOCKET.state], SS_CANTSENDMORE
2538
        mov     [eax + SOCKET.snd_proc], .notconn
2541
        mov     [eax + SOCKET.snd_proc], .notconn
2539
        jmp     socket_notify
2542
        jmp     socket_notify
Line 2540... Line 2543...
2540
 
2543
 
2541
  .notconn:
2544
  .notconn:
2542
        mov     dword[esp+20], ENOTCONN
2545
        mov     dword[esp + SYSCALL_STACK.ebx], ENOTCONN
2543
        mov     dword[esp+32], -1
2546
        mov     dword[esp + SYSCALL_STACK.eax], -1