Rev 6723 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6723 | Rev 7297 | ||
---|---|---|---|
Line 429... | Line 429... | ||
429 | cmp [ecx+addrinfo.ai_family], AF_INET4 |
429 | cmp [ecx+addrinfo.ai_family], AF_INET4 |
430 | jnz .ret |
430 | jnz .ret |
431 | @@: |
431 | @@: |
432 | ; 1e. Valid combinations for ai_socktype/ai_protocol: 0/0 for any or |
432 | ; 1e. Valid combinations for ai_socktype/ai_protocol: 0/0 for any or |
433 | ; SOCK_STREAM/IPPROTO_TCP, SOCK_DGRAM/IPPROTO_UDP |
433 | ; SOCK_STREAM/IPPROTO_TCP, SOCK_DGRAM/IPPROTO_UDP |
434 | ; (raw socketnums are not yet supported by the kernel) |
- | |
435 | xor edx, edx ; assume 0=any if no hints |
434 | xor edx, edx ; assume 0=any if no hints |
436 | jecxz .socketnum_type_ok |
435 | jecxz .socket_type_ok |
437 | mov edx, [ecx+addrinfo.ai_socktype] |
436 | mov edx, [ecx+addrinfo.ai_socktype] |
438 | mov esi, [ecx+addrinfo.ai_protocol] |
437 | mov esi, [ecx+addrinfo.ai_protocol] |
439 | ; 1f. Test for ai_socktype=0 and ai_protocol=0. |
438 | ; 1f. Test for ai_socktype=0 and ai_protocol=0. |
440 | test edx, edx |
439 | test edx, edx |
441 | jnz .check_socktype |
440 | jnz .check_socktype |
442 | test esi, esi |
441 | test esi, esi |
443 | jz .socketnum_type_ok |
442 | jz .socket_type_ok |
444 | ; 1g. ai_socktype=0, ai_protocol is nonzero. |
443 | ; 1g. ai_socktype=0, ai_protocol is nonzero. |
445 | push EAI_SERVICE |
444 | push EAI_SERVICE |
446 | pop eax |
445 | pop eax |
447 | inc edx ; edx = SOCK_STREAM |
446 | inc edx ; edx = SOCK_STREAM |
448 | cmp esi, IPPROTO_TCP |
447 | cmp esi, IPPROTO_TCP |
449 | jz .socketnum_type_ok |
448 | jz .socket_type_ok |
450 | inc edx ; edx = SOCK_DGRAM |
449 | inc edx ; edx = SOCK_DGRAM |
451 | cmp esi, IPPROTO_UDP |
450 | cmp esi, IPPROTO_UDP |
452 | jz .socketnum_type_ok |
451 | jz .socket_type_ok |
453 | .ret: |
452 | .ret: |
454 | ; Restore saved registers, destroy stack frame and return. |
453 | ; Restore saved registers, destroy stack frame and return. |
455 | mov esp, ebp |
454 | mov esp, ebp |
456 | pop ebp |
455 | pop ebp |
457 | pop edi esi ebx |
456 | pop edi esi ebx |
Line 463... | Line 462... | ||
463 | cmp edx, SOCK_STREAM |
462 | cmp edx, SOCK_STREAM |
464 | jz .check_tcp |
463 | jz .check_tcp |
465 | cmp edx, SOCK_DGRAM |
464 | cmp edx, SOCK_DGRAM |
466 | jnz .ret |
465 | jnz .ret |
467 | test esi, esi |
466 | test esi, esi |
468 | jz .socketnum_type_ok |
467 | jz .socket_type_ok |
469 | cmp esi, IPPROTO_UDP |
468 | cmp esi, IPPROTO_UDP |
470 | jz .socketnum_type_ok |
469 | jz .socket_type_ok |
471 | jmp .ret |
470 | jmp .ret |
472 | .check_tcp: |
471 | .check_tcp: |
473 | test esi, esi |
472 | test esi, esi |
474 | jz .socketnum_type_ok |
473 | jz .socket_type_ok |
475 | cmp esi, IPPROTO_TCP |
474 | cmp esi, IPPROTO_TCP |
476 | jnz .ret |
475 | jnz .ret |
477 | .socketnum_type_ok: |
476 | .socket_type_ok: |
478 | mov [ebx+__gai_reqdata.socktype], dl |
477 | mov [ebx+__gai_reqdata.socktype], dl |
479 | ; 2. Resolve service. |
478 | ; 2. Resolve service. |
480 | ; 2a. If no name is given, remember value -1. |
479 | ; 2a. If no name is given, remember value -1. |
481 | push -1 |
480 | push -1 |
482 | pop edx |
481 | pop edx |
Line 512... | Line 511... | ||
512 | ; 2d. Save result to reqdata. |
511 | ; 2d. Save result to reqdata. |
513 | mov [ebx+__gai_reqdata.service], edx |
512 | mov [ebx+__gai_reqdata.service], edx |
514 | ; 3. Process host name. |
513 | ; 3. Process host name. |
515 | mov esi, [.hostname] |
514 | mov esi, [.hostname] |
516 | ; 3a. If hostname is not given, |
515 | ; 3a. If hostname is not given, |
517 | ; use localhost for active socketnums and INADDR_ANY for passive socketnums. |
516 | ; use localhost for active sockets and INADDR_ANY for passive sockets. |
518 | mov eax, 0x0100007F ; 127.0.0.1 in network byte order |
517 | mov eax, 0x0100007F ; 127.0.0.1 in network byte order |
519 | test byte [ebx+__gai_reqdata.flags], AI_PASSIVE |
518 | test byte [ebx+__gai_reqdata.flags], AI_PASSIVE |
520 | jz @f |
519 | jz @f |
521 | xor eax, eax |
520 | xor eax, eax |
522 | @@: |
521 | @@: |
Line 678... | Line 677... | ||
678 | ; 7. Get DNS server address. |
677 | ; 7. Get DNS server address. |
679 | mcall 76, API_IPv4 + (1 shl 8) + 4 ; protocol IP=0, device number=0, function=get DNS address |
678 | mcall 76, API_IPv4 + (1 shl 8) + 4 ; protocol IP=0, device number=0, function=get DNS address |
680 | cmp eax, -1 |
679 | cmp eax, -1 |
681 | je .ret.dnserr |
680 | je .ret.dnserr |
682 | push eax ; save server address to the stack |
681 | push eax ; save server address to the stack |
683 | ; 8. Open UDP socketnum to DNS server, port 53. |
682 | ; 8. Open UDP socket to DNS server, port 53. |
684 | ; 8a. Create new socketnum. |
683 | ; 8a. Create new socket. |
685 | mcall 75, 0, AF_INET4, SOCK_DGRAM, 0 |
684 | mcall 75, 0, AF_INET4, SOCK_DGRAM, 0 |
686 | pop esi ; restore server address saved at step 7 |
685 | pop esi ; restore server address saved at step 7 |
687 | cmp eax, -1 ; error? |
686 | cmp eax, -1 ; error? |
688 | jz .ret.dnserr |
687 | jz .ret.dnserr |
689 | mov ecx, eax ; put socketnum handle to ecx |
688 | mov ecx, eax ; put socket handle to ecx |
690 | ; 8b. Create sockaddr structure on the stack. |
689 | ; 8b. Create sockaddr structure on the stack. |
691 | push 0 |
690 | push 0 |
692 | push 0 ; sin_zero |
691 | push 0 ; sin_zero |
693 | push esi ; sin_addr |
692 | push esi ; sin_addr |
694 | push AF_INET4 + (53 shl 24) |
693 | push AF_INET4 + (53 shl 24) |
Line 922... | Line 921... | ||
922 | call freeaddrinfo |
921 | call freeaddrinfo |
923 | and dword [esi], 0 |
922 | and dword [esi], 0 |
924 | @@: |
923 | @@: |
925 | pop eax |
924 | pop eax |
926 | .ret.close: |
925 | .ret.close: |
927 | ; 15. Close socketnum. |
926 | ; 15. Close socket. |
928 | push eax |
927 | push eax |
929 | mov ecx, [.reqdata] |
928 | mov ecx, [.reqdata] |
930 | mov ecx, [ecx+__gai_reqdata.socketnum] |
929 | mov ecx, [ecx+__gai_reqdata.socketnum] |
931 | mcall 75, 1 |
930 | mcall 75, 1 |
932 | pop eax |
931 | pop eax |
Line 1193... | Line 1192... | ||
1193 | pop eax |
1192 | pop eax |
1194 | xor esi, esi |
1193 | xor esi, esi |
1195 | ret |
1194 | ret |
Line 1196... | Line 1195... | ||
1196 | 1195 | ||
1197 | .set_socktype: |
1196 | .set_socktype: |
1198 | ; Set ai_socktype and ai_protocol fields by given socketnum type. |
1197 | ; Set ai_socktype and ai_protocol fields by given socket type. |
1199 | mov byte [edi+addrinfo.ai_socktype], cl |
1198 | mov byte [edi+addrinfo.ai_socktype], cl |
1200 | dec cl |
1199 | dec cl |
1201 | jnz .set_udp |
1200 | jnz .set_udp |
1202 | .set_tcp: |
1201 | .set_tcp: |