Changes

Jump to navigation Jump to search
4,381 bytes added ,  22:30, 21 June 2019
→‎sfdnsres: real cmd names
Line 1: Line 1: −
= bsd:u / bsd:s =
+
= bsd:u, bsd:s =
 
This is "nn::socket::sf::IClient".
 
This is "nn::socket::sf::IClient".
 +
 +
All the services commands but the first two return -1 on failure and set errno when that happens. Although Nintendo has the FreeBSD kernel's to socket stack, '''the errno macro definitions being in use actually come from Linux (and not from FreeBSD as one would expect!)'''.
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 12: Line 14:  
| 2  || [[#Socket]]
 
| 2  || [[#Socket]]
 
|-
 
|-
| 3  || [[#Socket||#SocketExempt]]
+
| 3  || [[#Socket|#SocketExempt]]
 
|-
 
|-
 
| 4  || [[#Open]]
 
| 4  || [[#Open]]
Line 60: Line 62:  
| 26 || Close
 
| 26 || Close
 
|-
 
|-
| 27 || DuplicateSocket
+
| 27 || [[#DuplicateSocket]]
 +
|-
 +
| 28 || [[#GetResourceStatistics]]
 +
|-
 +
| 29 || [3.0.0+] [[#RecvMMsg]]
 
|-
 
|-
| 28 || GetResourceStatistics
+
| 30 || [3.0.0+] [[#SendMMsg]]
 
|-
 
|-
| 29 || [3.0.0+] RecvMMsg
+
| 31 || [7.0.0+] EventFd
 
|-
 
|-
| 30 || [3.0.0+] SendMMsg
+
| 32 || [7.0.0+] RegisterResourceStatisticsName
 
|}
 
|}
    
== Initalize ==
 
== Initalize ==
   
Takes a [[#BsdBufferConfig]] (made-up name), the PID, the size of the transfer memory and a copy-handle of the latter.
 
Takes a [[#BsdBufferConfig]] (made-up name), the PID, the size of the transfer memory and a copy-handle of the latter.
    
=== BsdBufferConfig ===
 
=== BsdBufferConfig ===
   
  /// Configuration structure for bsdInitalize
 
  /// Configuration structure for bsdInitalize
 
  typedef struct  {
 
  typedef struct  {
Line 107: Line 111:  
<code>bsd:u</code> disallows the usage of the <code>SOCK_SEQPACKET</code> and <code>SOCK_RAW</code> types, with the exception of <code>(AF_INET, SOCK_RAW, IPPROTO_ICMP)</code> (IPv4 <code>ping</code>), <code>bsd:s</code> needs to be used for those.
 
<code>bsd:u</code> disallows the usage of the <code>SOCK_SEQPACKET</code> and <code>SOCK_RAW</code> types, with the exception of <code>(AF_INET, SOCK_RAW, IPPROTO_ICMP)</code> (IPv4 <code>ping</code>), <code>bsd:s</code> needs to be used for those.
   −
The only implemented domains are <code>AF_INET</code> and <code>AF_INET6</code>.
+
The only registered domains are <code>AF_INET</code> and <code>AF_ROUTE</code>.
    
SocketExempt: same as socket but the socket is immediately shutdown (disconnected) on creation.
 
SocketExempt: same as socket but the socket is immediately shutdown (disconnected) on creation.
Line 115: Line 119:     
== Sysctl ==
 
== Sysctl ==
This command is exclusive to <code>bsd:s</code> (FIXME: test whether this is actually the case).
+
FreeBSD's <code>sysctl</code> command. Privileged operations are reserved for <code>bsd:s</code>.
 +
<code>CTL_NET</code>, <code>CTL_VM</code>, <code>CTL_KERN</code> and <code>CTL_DEBUG</code> commands are implemented (?).
   −
FreeBSD's <code>sysctl</code> command, restricted to <code>CTL_NET</code> (?).
+
== Ioctl ==
 +
FreeBSD's <code>ioctl</code> function. The following ioctls are whitelisted, refer to FreeBSD's headers for more details: SIOCATMARK, BIOCGBLEN, BIOCSETF BIOCIMMEDIATE, BIOCSETIF, BIOCVERSION, FIONSPACE, FIONWRITE, FIONREAD, SIOCGETSGCNT, SIOCGIFMETRIC, SIOCSIFMETRIC, SIOCDIFADDR, SIOCGIFINDEX, SIOCGIFADDR, SIOCGIFCONF, SIOCGIFNETMASK, SIOCAIFADDR, SIOCGIFMTU, SIOCSIFMTU, SIOCGIFMEDIA, SIOCSIFLLADDR and SIOCGIFXMEDIA.
   −
== Ioctl ==
+
Nintendo use the following definition (hence changing all ioctls using this structure):
FreeBSD's <code>ioctl</code> function. The following ioctls are implemented, refer to FreeBSD's headers for more details: SIOCATMARK, BIOCGBLEN, BIOCIMMEDIATE, BIOCSETIF, SIOCGETSGCNT, SIOCGIFMETRIC, SIOCSIFMETRIC SIOCDIFADDR, SIOCGIFINDEX, SIOCGIFADDR, SIOCGIFCONF, SIOCGIFNETMASK, SIOCGIFMTU, SIOCSIFMTU, SIOCGIFMEDIA, SIOCSIFLLADDR and SIOCGIFXMEDIA.
+
struct bpf_program {
 +
u_int bf_len;
 +
struct bpf_insn bf_insns[BPF_MAXINSNS]; // [512]. This is a pointer in the official structure
 +
};
    
== Fcntl ==
 
== Fcntl ==
 
FreeBSD's <code>fcntl</code>, limited to <code>F_GETFL</code> and <code>F_SETFL</code> with <code>O_NONBLOCK</code>.
 
FreeBSD's <code>fcntl</code>, limited to <code>F_GETFL</code> and <code>F_SETFL</code> with <code>O_NONBLOCK</code>.
 +
 +
== DuplicateSocket ==
 +
Takes a socket file descriptor and an unused u64. Duplicates the socket (FreeBSD's <code>dup</code>). Reserved to <code>bsd:s</code>.
 +
 +
== GetResourceStatistics ==
 +
Takes a total of 8-bytes of input, a PID, a type-0x22 output buffer, and returns a total of 8-bytes of output.
 +
 +
[4.0.0+] Now takes an additional 8-bytes of input.
 +
 +
[7.0.0+] Now takes an additional type-0x21 input buffer.
 +
 +
== RecvMMsg ==
 +
Takes a total of 0x20-bytes of input, a type-0x22 output buffer, and returns a total of 8-bytes of output.
 +
 +
[7.0.0+] The buffer was replaced with a type-0x6 output buffer.
 +
 +
== SendMMsg ==
 +
Takes a total of 0xC-bytes of input, two type-0x21 input buffers, and returns a total of 8-bytes of output.
 +
 +
[7.0.0+] The buffers were replaced with a type-0x6 output buffer.
 +
 +
= bsdcfg =
 +
This is "nn::bsdsocket::cfg::ServerInterface".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0  || [[#SetIfUp]]
 +
|-
 +
| 1  || [[#SetIfUpWithEvent]]
 +
|-
 +
| 2  || CancelIf
 +
|-
 +
| 3  || SetIfDown
 +
|-
 +
| 4  || GetIfState
 +
|-
 +
| 5  || DhcpRenew
 +
|-
 +
| 6  || AddStaticArpEntry
 +
|-
 +
| 7  || RemoveArpEntry
 +
|-
 +
| 8  || LookupArpEntry
 +
|-
 +
| 9  || LookupArpEntry2
 +
|-
 +
| 10 || ClearArpEntries
 +
|-
 +
| 11 || ClearArpEntries2
 +
|-
 +
| 12 || PrintArpEntries
 +
|}
 +
 +
== SetIfUp ==
 +
Takes a total of 0x28-bytes of input and a type-0x5 input buffer, no output.
 +
 +
[3.0.0+] Takes an additional 4-bytes of input.
 +
 +
== SetIfUpWithEvent ==
 +
Takes a total of 0x28-bytes of input and a type-0x5 input buffer, returns an output handle.
 +
 +
[3.0.0+] Takes an additional 4-bytes of input.
 +
 +
= ethc:c =
 +
This is "nn::eth::sf::IEthInterface".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0  || Initialize
 +
|-
 +
| 1  || Cancel
 +
|-
 +
| 2  || GetResult
 +
|-
 +
| 3  || GetMediaList
 +
|-
 +
| 4  || SetMediaType
 +
|-
 +
| 5  || GetMediaType
 +
|}
 +
 +
= ethc:i =
 +
This is "nn::eth::sf::IEthInterfaceGroup".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0  || GetReadableHandle
 +
|-
 +
| 1  || Cancel
 +
|-
 +
| 2  || GetResult
 +
|-
 +
| 3  || GetInterfaceList
 +
|-
 +
| 4  || GetInterfaceCount
 +
|}
    
= sfdnsres =
 
= sfdnsres =
 
This is "nn::socket::resolver::IResolver".
 
This is "nn::socket::resolver::IResolver".
 +
 +
This service uses <code>bionic/libc/dns</code> to perform its tasks.
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 132: Line 245:  
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 || SetDnsAddressesPrivate
+
| 0 || SetDnsAddressesPrivateRequest (stubbed, returns 0x7FE03)
 
|-
 
|-
| 1 || GetDnsAddressPrivate
+
| 1 || GetDnsAddressPrivateRequest (stubbed, returns 0x7FE03)
 
|-
 
|-
| 2 || GetHostByName
+
| 2 || GetHostByNameRequest
 
|-
 
|-
| 3 || GetHostByAddr
+
| 3 || GetHostByAddrRequest
 
|-
 
|-
| 4 || GetHostStringError
+
| 4 || GetHostStringErrorRequest
 
|-
 
|-
| 5 || GetGaiStringError
+
| 5 || GetGaiStringErrorRequest
 
|-
 
|-
| 6 || [[#GetAddrInfo]]
+
| 6 || [[#GetAddrInfoRequest]]
 
|-
 
|-
| 7 || GetNameInfo
+
| 7 || GetNameInfoRequest
 
|-
 
|-
| 8 || RequestCancelHandle
+
| 8 || GetCancelHandleRequest
 
|-
 
|-
| 9 || CancelSocketCall
+
| 9 || CancelRequest
 +
|-
 +
| 10 || [5.0.0+] GetHostByNameRequestWithOptions
 +
|-
 +
| 11 || [5.0.0+] GetHostByAddrRequestWithOptions
 +
|-
 +
| 12 || [5.0.0+] GetAddrInfoRequestWithOptions
 +
|-
 +
| 13 || [5.0.0+] GetNameInfoRequestWithOptions
 +
|-
 +
| 14 || [5.0.0+] ResolverSetOptionRequest
 +
|-
 +
| 15 || [5.0.0+] ResolverGetOptionRequest
 
|}
 
|}
   −
=== GetAddrInfo ===
+
== GetAddrInfoRequest ==
 
   
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.
 
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 ===
 
=== 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.
 
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.
   Line 195: Line 318:  
The list should be terminated with a sentinel four-byte zero value.
 
The list should be terminated with a sentinel four-byte zero value.
   −
= nsd:u / nsd:a =
+
= nsd:u, nsd:a =
 
This is "nn::nsd::detail::IManager".
 
This is "nn::nsd::detail::IManager".
   Line 204: Line 327:  
| 10 || GetSettingName
 
| 10 || GetSettingName
 
|-
 
|-
| 11 || GetEnvironmentIdentifier
+
| 11 || [[#GetEnvironmentIdentifier]]
 
|-
 
|-
 
| 12 || GetDeviceId
 
| 12 || GetDeviceId
Line 211: Line 334:  
|-
 
|-
 
| 14 || ImportSettings
 
| 14 || ImportSettings
 +
|-
 +
| 15 || [4.0.0+]
 
|-
 
|-
 
| 20 || Resolve
 
| 20 || Resolve
Line 230: Line 355:  
| 50 || GetCurrentSetting
 
| 50 || GetCurrentSetting
 
|-
 
|-
| 60 || ReadSaveDataFromFsForTest
+
| 60 || [[#ReadSaveDataFromFsForTest]]
 +
|-
 +
| 61 || [[#WriteSaveDataToFsForTest]]
 
|-
 
|-
| 61 || WriteSaveDataToFsForTest
+
| 62 || [[#DeleteSaveDataOfFsForTest]]
 
|-
 
|-
| 62 || DeleteSaveDataOfFsForTest
+
| 63 || [4.0.0+] IsChangeEnvironmentIdentifierDisabled
 
|}
 
|}
 +
 +
== GetEnvironmentIdentifier ==
 +
Takes a type-0x16 buffer with size 8. Returns a string.
 +
 +
The output string is used by [[NIM_services|NIM]] for the "eid:%s" in the User-Agent strings.
 +
 +
This is the "lp1" string also used in domains.
 +
 +
== ReadSaveDataFromFsForTest ==
 +
Requires the <code>nsd!test_mode</code> setting to be equal to 1.
 +
 +
Mounts the system save data for bsdsockets as <code>nsdsave</code> and reads from <code>nsd:/file</code> to the specified buffer, at the specified size and offset with no checks whatsoever. <code>nsdsave</code> is then unmounted.
 +
 +
== WriteSaveDataToFsForTest ==
 +
Requires the <code>nsd!test_mode</code> setting to be equal to 1.
 +
 +
Mounts the system save data for bsdsockets as <code>nsdsave</code> and writes to <code>nsd:/file</code> (appending is allowed) using the specified buffer, at the specified size and offset, with no checks whatsoever. <code>nsdsave</code> is then commited and unmounted.
 +
 +
== DeleteSaveDataOfFsForTest ==
 +
Requires the <code>nsd!test_mode</code> setting to be equal to 1.
 +
 +
Deletes the system save data for bsdsockets.
 +
 +
[[Category:Services]]

Navigation menu