Libcurl

From Nintendo Switch Brew
Jump to navigation Jump to search

This page documents the libcurl package used by official sw. This is statically linked in the main-codebin, on old versions (~v2.x) this was a subsdk NSO. This page does not apply to the libcurl build included in the browser OSS NRO.

With sdkver 10.x, this is built with support for NGHTTP2 with the relevant Alpn cmds being used for this.

The changes to libcurl compared to the original libcurl are documented below, etc.

CURLOPT

The 50X/900 options are custom, the default values for some of these are set in Curl_init_userdefined.

CINIT name CINIT type CINIT number CURLoption value Default value
#URL STRINGPOINT 2 10002
#PROXYAUTOCONFIG LONG 500 500 1
#UNK501 LONG 501 501 0
OBJECTPOINT/STRINGPOINT 502 10502
FUNCTIONPOINT 503
FUNCTIONPOINT 504
OBJECTPOINT/STRINGPOINT 505 10505
#UNK506 LONG 506 506 0
#UNK507 LONG 507 507
#UNK900 LONG 900 900

URL

The following only runs when the #UNK900 flag is not set, otherwise the URL is set directly using the input string.

This was patched to use various string functionality and ResolveEx (only used if needed). sscanf is used twice with the following two format strings, with the input URL. If the first one returns <=1 and the second one returns <=0, the input URL is just copied to state, otherwise this continues with using ResolveEx etc. Format strings:

  • "%15[^\n:]://%[^\n/?:]%[^\n]"
  • "%[^\n/?:]%[^\n]"

Afterwards, ResolveEx is used with the first output string from the latter sscanf as the input. Then the final URL is constructed with the output from ResolveEx.

PROXYAUTOCONFIG

This option is handled as a bool.

A warning is printed if this option is set when CURLOPT_PROXY is already set - in which case CURLOPT_PROXY is freed.

This option controls whether to load the system proxy from nifm. The code handling this option was added to the start of the inlined create_conn_helper_init_proxy func.

UNK501

This option is handled as a bool.

This controls the value of the DataCheck VerifyOption bit.

UNK506

This option is handled as a bool.

This is used during Curl_resolver_getaddrinfo.

UNK507

This option is handled as a bool.

This controls the value of the SkipDefaultVerify option flag.

UNK900

This option is handled as a bool.

This is used during Curl_resolver_getaddrinfo. See also #URL.