engine: http: add TLS backend using mbedTLS

This commit is contained in:
Alibek Omarov
2026-06-07 05:56:54 +05:00
parent eae45b2e81
commit 034efb3b31
3 changed files with 312 additions and 4 deletions
+31 -4
View File
@@ -17,10 +17,37 @@ GNU General Public License for more details.
#include "xash3d_types.h"
// No TLS for you! Yet.
static inline qboolean HTTP_TlsAvailable( void )
typedef struct tlsctx_s tlsctx_t;
enum
{
return false;
}
HTTP_TLS_OK = 0, // handshake/op completed
HTTP_TLS_WANT = -1, // would block, retry next frame
HTTP_TLS_ERROR = -2 // permanent failure, tear the connection down
};
#if XASH_MBEDTLS
void HTTP_TlsInit( void );
void HTTP_TlsShutdown( void );
qboolean HTTP_TlsAvailable( void );
tlsctx_t *HTTP_TlsNew( int socket, const char *hostname );
void HTTP_TlsFree( tlsctx_t *ctx );
int HTTP_TlsHandshake( tlsctx_t *ctx );
int HTTP_TlsSend( tlsctx_t *ctx, const void *buf, int len );
int HTTP_TlsRecv( tlsctx_t *ctx, void *buf, int len );
#else // !XASH_MBEDTLS
static inline void HTTP_TlsInit( void ) { }
static inline void HTTP_TlsShutdown( void ) { }
static inline qboolean HTTP_TlsAvailable( void ) { return false; }
static inline tlsctx_t *HTTP_TlsNew( int socket, const char *hostname ) { return NULL; }
static inline void HTTP_TlsFree( tlsctx_t *ctx ) { }
static inline int HTTP_TlsHandshake( tlsctx_t *ctx ) { return HTTP_TLS_ERROR; }
static inline int HTTP_TlsSend( tlsctx_t *ctx, const void *buf, int len ) { return HTTP_TLS_ERROR; }
static inline int HTTP_TlsRecv( tlsctx_t *ctx, void *buf, int len ) { return HTTP_TLS_ERROR; }
#endif // XASH_MBEDTLS
#endif // NET_HTTP_TLS_H