Line 85: |
Line 85: |
| | 5 || GetGaiStringError | | | 5 || GetGaiStringError |
| |- | | |- |
− | | 6 || GetAddrInfo | + | | 6 || [[#GetAddrInfo]] |
| |- | | |- |
| | 7 || GetNameInfo | | | 7 || GetNameInfo |
Line 94: |
Line 94: |
| |} | | |} |
| | | |
| + | === GetAddrInfo === |
| + | |
| + | Takes three type 5 buffers (host, port, and hints), and a type 6 buffer (the output addrinfos). Also takes a u8 (padded to 4 bytes so the next raw parameter can align), a u32, and a u64. The u8 is a boolean for whether to enable "nsd resolve" (1) or not (0). Not sure what the u32 is. It seems to either come from a parameter to <tt>GetAddrInfo</tt> or be zero. The u64 is most likely a placeholder for the server to copy the PID into and should be zero. Both hints and the output buffer contain serialized addrinfo chains. The hints buffer is sized 0x400 bytes long by default, and the output buffer 0x1000 bytes. |
| + | |
| + | === Addrinfo Serialization Format === |
| + | |
| + | Each struct addrinfo in the linked list is serialized according to this format and then written to the buffer. All numbers are in network byte order. |
| + | |
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! Size (bytes) || Name || Notes |
| + | |- |
| + | | 4 || Magic || Needs to be 0xBEEFCAFE. Seriously. |
| + | |- |
| + | | 4 || ai_flags || |
| + | |- |
| + | | 4 || ai_family || |
| + | |- |
| + | | 4 || ai_socktype || |
| + | |- |
| + | | 4 || ai_protocol || |
| + | |- |
| + | | 4 || ai_addrlen || |
| + | |- |
| + | | ai_addrlen ? ai_addrlen : 4 || ai_addr || |
| + | |- |
| + | | null-terminated string || ai_canonname || |
| + | |} |
| + | |
| + | If <tt>ai_addrlen</tt> is zero, <tt>ai_addr</tt> will occupy 4 bytes. |
| + | |
| + | {| class="wikitable" border="1" |
| + | |- |
| + | ! Size (bytes) || Name || Notes |
| + | |- |
| + | | 4 || ai_addr |
| + | |} |
| + | |
| + | If <tt>ai_family</tt> is recognized as AF_INET6 (28) or AF_INET (2), <tt>ai_addr</tt> is read as <tt>struct sockaddr_in</tt> or <tt>struct sockaddr_in6</tt>. Otherwise, it's just read as <tt>u8[ai_addrlen]</tt>. |
| + | |
| + | The list should be terminated with a sentinel four-byte zero value. |
| | | |
| = nsd:u / nsd:a = | | = nsd:u / nsd:a = |