Moonlight-XboxOG latest
Moonlight Xbox OG is a port of the Moonlight Game Streaming client to the original Xbox console.
openssl_compat.h File Reference

Declares OpenSSL compatibility shims for nxdk. More...

#include <lwip/opt.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
Include dependency graph for openssl_compat.h:

Go to the source code of this file.

Classes

struct  fd_set
 Minimal socket descriptor set used by the lwIP-backed select shim. More...
 

Macros

#define __STDC_WANT_LIB_EXT1__   1
 Request Annex K declarations such as gmtime_s when the C library provides them.
 
#define _close   moonlight_nxdk_openssl__close
 Redirect _close to the nxdk OpenSSL compatibility shim.
 
#define _fdopen   moonlight_nxdk_openssl__fdopen
 Redirect _fdopen to the nxdk OpenSSL compatibility shim.
 
#define _open   moonlight_nxdk_openssl__open
 Redirect _open to the nxdk OpenSSL compatibility shim.
 
#define _unlink   moonlight_nxdk_openssl__unlink
 Redirect _unlink to the nxdk OpenSSL compatibility shim.
 
#define access   moonlight_nxdk_openssl_access
 Redirect access to the nxdk OpenSSL compatibility shim.
 
#define AF_UNIX   (-1)
 Placeholder address-family value used when AF_UNIX is unavailable on nxdk.
 
#define chmod   moonlight_nxdk_openssl_chmod
 Redirect chmod to the nxdk OpenSSL compatibility shim.
 
#define close   moonlight_nxdk_openssl_close
 Redirect close to the nxdk OpenSSL compatibility shim.
 
#define F_OK   0
 Test access mode flag for file existence checks.
 
#define FD_CLR(n, p)
 Clear a socket descriptor from an fd_set.
 
#define FD_ISSET(n, p)
 Return whether a socket descriptor is present in an fd_set.
 
#define FD_SET(n, p)
 Mark a socket descriptor as present in an fd_set.
 
#define FD_SETSIZE   MEMP_NUM_NETCONN
 Maximum number of sockets tracked by the compatibility fd_set.
 
#define FD_ZERO(p)
 Reset an fd_set so that it tracks no descriptors.
 
#define fdopen   moonlight_nxdk_openssl_fdopen
 Redirect fdopen to the nxdk OpenSSL compatibility shim.
 
#define fileno   moonlight_nxdk_openssl_fileno
 Redirect fileno to the nxdk OpenSSL compatibility shim.
 
#define getegid   moonlight_nxdk_openssl_getegid
 Redirect getegid to the nxdk OpenSSL compatibility shim.
 
#define geteuid   moonlight_nxdk_openssl_geteuid
 Redirect geteuid to the nxdk OpenSSL compatibility shim.
 
#define getgid   moonlight_nxdk_openssl_getgid
 Redirect getgid to the nxdk OpenSSL compatibility shim.
 
#define getuid   moonlight_nxdk_openssl_getuid
 Redirect getuid to the nxdk OpenSSL compatibility shim.
 
#define gmtime_s   moonlight_nxdk_openssl_gmtime_s
 Redirect gmtime_s to the nxdk OpenSSL compatibility shim.
 
#define LWIP_SOCKET_OFFSET   0
 Offset applied by lwIP when translating socket descriptors.
 
#define open   moonlight_nxdk_openssl_open
 Redirect open to the nxdk OpenSSL compatibility shim.
 
#define R_OK   4
 Test access mode flag for read permission checks.
 
#define read   moonlight_nxdk_openssl_read
 Redirect read to the nxdk OpenSSL compatibility shim.
 
#define select(maxfdp1, readset, writeset, exceptset, timeout)
 Route select calls through the lwIP compatibility shim on nxdk builds.
 
#define W_OK   2
 Test access mode flag for write permission checks.
 
#define write   moonlight_nxdk_openssl_write
 Redirect write to the nxdk OpenSSL compatibility shim.
 
#define X_OK   1
 Test access mode flag for execute permission checks.
 

Typedefs

typedef struct fd_set fd_set
 Minimal socket descriptor set used by the lwIP-backed select shim.
 

Functions

ssize_t lwip_recv (int s, void *mem, size_t len, int flags)
 Receive bytes through the lwIP socket backend.
 
int lwip_select (int maxfdp1, struct fd_set *readset, struct fd_set *writeset, struct fd_set *exceptset, struct timeval *timeout)
 Wait for lwIP socket readiness using the nxdk select implementation.
 
ssize_t lwip_send (int s, const void *dataptr, size_t size, int flags)
 Send bytes through the lwIP socket backend.
 

Detailed Description

Declares OpenSSL compatibility shims for nxdk.

Macro Definition Documentation

◆ FD_CLR

#define FD_CLR ( n,
p )
Value:
((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] = (unsigned char) ((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] & ~(1u << (((n) - LWIP_SOCKET_OFFSET) & 7))))
#define LWIP_SOCKET_OFFSET
Offset applied by lwIP when translating socket descriptors.
Definition openssl_compat.h:64

Clear a socket descriptor from an fd_set.

◆ FD_ISSET

#define FD_ISSET ( n,
p )
Value:
(((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] & (1u << (((n) - LWIP_SOCKET_OFFSET) & 7))) != 0)

Return whether a socket descriptor is present in an fd_set.

◆ FD_SET

#define FD_SET ( n,
p )
Value:
((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] = (unsigned char) ((p)->fd_bits[((n) - LWIP_SOCKET_OFFSET) / 8] | (1u << (((n) - LWIP_SOCKET_OFFSET) & 7))))

Mark a socket descriptor as present in an fd_set.

◆ FD_ZERO

#define FD_ZERO ( p)
Value:
memset((void *) (p), 0, sizeof(*(p)))

Reset an fd_set so that it tracks no descriptors.

◆ select

#define select ( maxfdp1,
readset,
writeset,
exceptset,
timeout )
Value:
lwip_select(maxfdp1, readset, writeset, exceptset, timeout)
int lwip_select(int maxfdp1, struct fd_set *readset, struct fd_set *writeset, struct fd_set *exceptset, struct timeval *timeout)
Wait for lwIP socket readiness using the nxdk select implementation.

Route select calls through the lwIP compatibility shim on nxdk builds.

Function Documentation

◆ lwip_recv()

ssize_t lwip_recv ( int s,
void * mem,
size_t len,
int flags )

Receive bytes through the lwIP socket backend.

Parameters
slwIP socket descriptor.
memDestination buffer.
lenMaximum number of bytes to receive.
flagslwIP receive flags.
Returns
Number of bytes received, or a negative value on failure.

◆ lwip_select()

int lwip_select ( int maxfdp1,
struct fd_set * readset,
struct fd_set * writeset,
struct fd_set * exceptset,
struct timeval * timeout )

Wait for lwIP socket readiness using the nxdk select implementation.

Parameters
maxfdp1One greater than the highest descriptor to inspect.
readsetOptional descriptor set watched for readability.
writesetOptional descriptor set watched for writability.
exceptsetOptional descriptor set watched for exceptional conditions.
timeoutOptional timeout value.
Returns
Number of ready descriptors, zero on timeout, or a negative value on failure.

◆ lwip_send()

ssize_t lwip_send ( int s,
const void * dataptr,
size_t size,
int flags )

Send bytes through the lwIP socket backend.

Parameters
slwIP socket descriptor.
dataptrSource buffer.
sizeNumber of bytes to send.
flagslwIP send flags.
Returns
Number of bytes sent, or a negative value on failure.