2019-11-11 18:09:59 +01:00
|
|
|
/*
|
|
|
|
Code by blackb0x @ GBAtemp.net
|
|
|
|
This allows the Wii to download from servers that use SNI.
|
|
|
|
*/
|
|
|
|
#ifndef _HTTPS_H_
|
|
|
|
#define _HTTPS_H_
|
|
|
|
|
|
|
|
#include <libs/libwolfssl/ssl.h>
|
2020-11-08 22:29:44 +01:00
|
|
|
|
2019-11-11 18:09:59 +01:00
|
|
|
#include "dns.h"
|
2020-11-08 22:29:44 +01:00
|
|
|
#include "memory/mem2.h"
|
|
|
|
#include "picohttpparser.h"
|
2019-11-11 18:09:59 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// #define DEBUG_NETWORK
|
|
|
|
#define REDIRECT_LIMIT 3
|
2020-11-08 22:29:44 +01:00
|
|
|
#define CONNECT_TIMEOUT 10000
|
|
|
|
#define READ_WRITE_TIMEOUT 20000
|
|
|
|
#define BLOCK_SIZE 8192
|
2019-11-11 18:09:59 +01:00
|
|
|
|
|
|
|
struct download
|
|
|
|
{
|
2020-11-08 22:29:44 +01:00
|
|
|
bool skip_response; // Used by WiinnerTag
|
|
|
|
bool show_progress; // Used when downloading wiitdb.zip
|
2019-11-11 18:09:59 +01:00
|
|
|
u64 gametdbcheck; // Used when checking the GameTDB version
|
|
|
|
u64 content_length;
|
|
|
|
u64 size;
|
|
|
|
char *data;
|
|
|
|
};
|
|
|
|
|
2020-11-08 22:29:44 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
int pret;
|
|
|
|
size_t num_headers;
|
|
|
|
size_t buflen;
|
|
|
|
struct phr_header headers[100];
|
|
|
|
char data[4096];
|
|
|
|
} HTTP_RESPONSE;
|
|
|
|
|
2019-11-11 18:09:59 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
u8 use_https;
|
|
|
|
s32 sock;
|
|
|
|
WOLFSSL *ssl;
|
|
|
|
WOLFSSL_CTX *ctx;
|
|
|
|
} HTTP_INFO;
|
|
|
|
|
|
|
|
void downloadfile(const char *url, struct download *buffer);
|
|
|
|
int wolfSSL_CTX_UseSNI(WOLFSSL_CTX *ctx, unsigned char type, const void *data, unsigned short size);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _HTTPS_H_ */
|