(WiiU) enable networking.

This commit is contained in:
aliaspider 2017-05-23 10:24:23 +01:00
parent 6b57791b0a
commit 934f7c58ba
19 changed files with 169 additions and 74 deletions

View file

@ -37,7 +37,8 @@ ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_RGUI -DHAVE_LIBRETRODB
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB -DHAVE_CC_RESAMPLER
DEFINES += -DHAVE_STB_FONT -DHAVE_LANGEXTRA -DHAVE_LIBRETRODB
DEFINES += -DHAVE_STB_FONT -DHAVE_LANGEXTRA -DHAVE_LIBRETRODB -DHAVE_NETWORKING
# DEFINES += -DWANT_IFADDRS
# DEFINES += -DHAVE_FREETYPE
DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
else
@ -58,11 +59,14 @@ else
# HAVE_FREETYPE = 1
HAVE_LANGEXTRA = 1
HAVE_LIBRETRODB = 1
HAVE_NETWORKING = 1
# WANT_IFADDRS = 1
include Makefile.common
BLACKLIST :=
BLACKLIST += input/input_overlay.o
BLACKLIST += tasks/task_overlay.o
BLACKLIST += $(LIBRETRO_COMM_DIR)/net/net_ifinfo.o
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
OBJ += gfx/drivers/wiiu_gfx.o
@ -144,6 +148,7 @@ CFLAGS += -ffast-math -Werror=implicit-function-declaration
#todo: remove -DWIIU and use the built-in macros instead (HW_WUP or __wiiu__).
CFLAGS += -DWIIU -DMSB_FIRST
CFLAGS += -DHAVE_MAIN
CFLAGS += -DHAVE_UPDATE_ASSETS
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)

View file

@ -603,6 +603,8 @@ static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/linux/
#else
static char buildbot_server_url[] = "";
#endif
#elif defined(WIIU)
static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/nintendo/wiiu/latest/";
#else
static char buildbot_server_url[] = "";
#endif

View file

@ -38,7 +38,9 @@
#include "tasks/tasks_internal.h"
#include "../../retroarch.h"
#include <net/net_compat.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "fs/fs_utils.h"
#include "fs/sd_fat_devoptab.h"
#include "system/dynamic.h"
@ -79,10 +81,9 @@ static void frontend_wiiu_get_environment_settings(int *argc, char *argv[],
void *args, void *params_data)
{
(void)args;
DEBUG_LINE();
fill_pathname_basedir(g_defaults.dir.port, elf_path_cst, sizeof(g_defaults.dir.port));
DEBUG_LINE();
RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port);
fill_pathname_join(g_defaults.dir.core_assets, g_defaults.dir.port,
@ -403,7 +404,7 @@ int main(int argc, char **argv)
#endif
ProcUIInit(&SaveCallback);
socket_lib_init();
network_init();
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
log_init(PC_DEVELOPMENT_IP_ADDRESS, PC_DEVELOPMENT_TCP_PORT);
devoptab_list[STD_OUT] = &dotab_stdout;

View file

@ -158,8 +158,6 @@ static void wiiu_gfx_update_viewport(wiiu_video_t* wiiu)
(wiiu->vp.y + wiiu->vp.height) * scale_h);
wiiu->should_resize = false;
DEBUG_LINE();
}
static void wiiu_gfx_set_aspect_ratio(void* data, unsigned aspect_ratio_idx)

View file

@ -201,7 +201,7 @@ bool mkdir_norecurse(const char *dir)
#if defined(VITA)
if ((ret == SCE_ERROR_ERRNO_EEXIST) && path_is_directory(dir))
ret = 0;
#elif defined(PSP) || defined(_3DS)
#elif defined(PSP) || defined(_3DS) || defined(WIIU)
if ((ret == -1) && path_is_directory(dir))
ret = 0;
#else

View file

@ -168,7 +168,7 @@ int getaddrinfo_retro(const char *node, const char *service,
if (!hints->ai_family)
{
#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY)
#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) || defined(WIIU)
hints->ai_family = AF_INET;
#else
hints->ai_family = AF_UNSPEC;
@ -300,6 +300,8 @@ bool network_init(void)
char t[16];
if (if_config(t, NULL, NULL, TRUE, 10) < 0)
return false;
#elif defined(WIIU)
socket_lib_init();
#else
signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */
#endif
@ -365,6 +367,8 @@ const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt)
{
#if defined(VITA) || defined(__ORBIS__)
return sceNetInetNtop(af,src,dst,cnt);
#elif defined(WIIU)
return inet_ntop(af, src, dst, cnt);
#else
if (af == AF_INET)
{

View file

@ -171,7 +171,7 @@ static bool natt_open_port(struct natt_status *status,
bool natt_open_port_any(struct natt_status *status, uint16_t port, enum socket_protocol proto)
{
#ifndef HAVE_SOCKET_LEGACY
#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU)
struct net_ifinfo list;
bool ret = false;
size_t i;

View file

@ -110,7 +110,7 @@ int socket_receive_all_blocking(int fd, void *data_, size_t size)
bool socket_nonblock(int fd)
{
#if defined(__CELLOS_LV2__) || defined(VITA)
#if defined(__CELLOS_LV2__) || defined(VITA) || defined(WIIU)
int i = 1;
setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int));
return true;
@ -127,7 +127,7 @@ int socket_close(int fd)
#if defined(_WIN32) && !defined(_XBOX360)
/* WinSock has headers from the stone age. */
return closesocket(fd);
#elif defined(__CELLOS_LV2__)
#elif defined(__CELLOS_LV2__) || defined(WIIU)
return socketclose(fd);
#elif defined(VITA)
return sceNetSocketClose(fd);
@ -227,8 +227,7 @@ int socket_connect(int fd, void *data, bool timeout_enable)
{
struct addrinfo *addr = (struct addrinfo*)data;
#ifndef _WIN32
#ifndef VITA
#if !defined(_WIN32) && !defined(VITA) && !defined(WIIU)
if (timeout_enable)
{
struct timeval timeout;
@ -237,7 +236,6 @@ int socket_connect(int fd, void *data, bool timeout_enable)
setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout);
}
#endif
#endif
return connect(fd, addr->ai_addr, addr->ai_addrlen);

View file

@ -360,7 +360,7 @@ static int menu_displaylist_parse_netplay(
return 0;
}
#ifndef HAVE_SOCKET_LEGACY
#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU)
#include <net/net_ifinfo.h>
static int menu_displaylist_parse_network_info(menu_displaylist_info_t *info)
@ -6103,10 +6103,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
info->need_push = true;
break;
case DISPLAYLIST_NETWORK_INFO:
#ifdef HAVE_NETWORKING
#ifndef HAVE_SOCKET_LEGACY
#if defined(HAVE_NETWORKING) && !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU)
menu_displaylist_parse_network_info(info);
#endif
#endif
info->need_push = true;
info->need_refresh = true;

View file

@ -43,7 +43,7 @@
/* TODO/FIXME - replace netplay_log_connection with calls
* to inet_ntop_compat and move runloop message queue pushing
* outside */
#ifndef HAVE_SOCKET_LEGACY
#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU)
/* Custom inet_ntop. Win32 doesn't seem to support this ... */
void netplay_log_connection(const struct sockaddr_storage *their_addr,
unsigned slot, const char *nick, char *s, size_t len)

View file

@ -20,6 +20,7 @@
#include "../ControllerPatcher.hpp"
#include "sys/socket.h"
#include "netinet/in.h"
#include "wiiu/os.h"
#define WIIU_CP_TCP_HANDSHAKE WIIU_CP_TCP_HANDSHAKE_VERSION_3

View file

@ -20,6 +20,7 @@
#include "../ControllerPatcher.hpp"
#include "sys/socket.h"
#include "netinet/in.h"
#define DEFAULT_UDP_CLIENT_PORT 8114

20
wiiu/include/arpa/inet.h Normal file
View file

@ -0,0 +1,20 @@
#ifndef _ARPA_INET_H
#define _ARPA_INET_H
#ifdef __cplusplus
extern "C" {
#endif
#include <netinet/in.h>
char *inet_ntoa(struct in_addr in);
const char *inet_ntop(int af, const void *cp, char *buf, socklen_t len);
int inet_aton(const char *cp, struct in_addr *inp);
int inet_pton(int af, const char *cp, void *buf);
#ifdef __cplusplus
}
#endif
#endif /* _ARPA_INET_H */

42
wiiu/include/netdb.h Normal file
View file

@ -0,0 +1,42 @@
#ifndef _NETDB_H
#define _NETDB_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef uint32_t socklen_t;
#define NI_NUMERICHOST 2
#define NI_NUMERICSERV 8
#define AI_PASSIVE 1
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
struct addrinfo {
int ai_flags; /* AI_PASSIVE, AI_CANONNAME,
AI_NUMERICHOST, .. */
int ai_family; /* AF_xxx */
int ai_socktype; /* SOCK_xxx */
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
int ai_addrlen; /* length of ai_addr */
char *ai_canonname; /* canonical name for node name */
struct sockaddr *ai_addr; /* binary address */
struct addrinfo *ai_next; /* next structure in linked list */
};
int getaddrinfo(const char *node, const char *service, struct addrinfo *hints, struct addrinfo **res);
void freeaddrinfo(struct addrinfo *__ai);
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags);
#ifdef __cplusplus
}
#endif
#endif /* _NETDB_H */

36
wiiu/include/netinet/in.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef _NETINET_IN_H
#define _NETINET_IN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
struct in_addr
{
unsigned int s_addr;
};
#define IPPROTO_IP 0
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
struct sockaddr_in
{
short sin_family;
unsigned short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
uint32_t ntohl (uint32_t netlong);
uint16_t ntohs (uint16_t netshort);
uint32_t htonl (uint32_t hostlong);
uint16_t htons (uint16_t hostshort);
#ifdef __cplusplus
}
#endif
#endif /* _NETINET_IN_H */

View file

@ -0,0 +1,14 @@
#ifndef _NETINET_TCP_H
#define _NETINET_TCP_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* _NETINET_TCP_H */

View file

@ -11,45 +11,18 @@ extern "C" {
#define INADDR_ANY 0
#define PF_UNSPEC 0
#define PF_INET 2
#define PF_INET6 23
#define AF_UNSPEC PF_UNSPEC
#define AF_INET PF_INET
#define AF_INET6 PF_INET6
#define AF_UNSPEC 0
#define AF_INET 2
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define MSG_OOB 0x0001
#define MSG_PEEK 0x0002
#define MSG_DONTWAIT 0x0004
#define MSG_DONTROUTE 0x0000 // ???
#define MSG_WAITALL 0x0000 // ???
#define MSG_MORE 0x0000 // ???
#define MSG_NOSIGNAL 0x0000 // there are no signals
#define MSG_DONTWAIT 0x0020
//#define MSG_DONTWAIT 0x0004
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#define SO_REUSEADDR 0x0004
#define SO_NBIO 0x1014
#define IPPROTO_IP 0
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
/*
* SOL_SOCKET options
*/
#define SO_REUSEADDR 0x0004 // reuse address
#define SO_LINGER 0x0080 // linger (no effect?)
#define SO_OOBINLINE 0x0100 // out-of-band data inline (no effect?)
#define SO_SNDBUF 0x1001 // send buffer size
#define SO_RCVBUF 0x1002 // receive buffer size
#define SO_SNDLOWAT 0x1003 // send low-water mark (no effect?)
#define SO_RCVLOWAT 0x1004 // receive low-water mark
#define SO_TYPE 0x1008 // get socket type
#define SO_ERROR 0x1009 // get socket error
typedef uint32_t socklen_t;
typedef uint16_t sa_family_t;
@ -72,19 +45,6 @@ struct linger
int l_linger;
};
struct in_addr
{
unsigned int s_addr;
};
struct sockaddr_in
{
short sin_family;
unsigned short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
void socket_lib_init();
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
@ -102,8 +62,6 @@ int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t
int shutdown(int sockfd, int how);
int socket(int domain, int type, int protocol);
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
char *inet_ntoa(struct in_addr in);
int inet_aton(const char *cp, struct in_addr *inp);
#ifdef __cplusplus
}

View file

@ -100,16 +100,33 @@ IMPORT_END();
IMPORT_BEGIN(nsysnet);
IMPORT(socket_lib_init);
IMPORT(socket);
IMPORT(setsockopt);
IMPORT(bind);
IMPORT(listen);
IMPORT(getaddrinfo);
IMPORT(freeaddrinfo);
IMPORT(getnameinfo);
IMPORT(inet_ntoa);
IMPORT(inet_ntop);
IMPORT(inet_aton);
IMPORT(inet_pton);
IMPORT(ntohl);
IMPORT(ntohs);
IMPORT(htonl);
IMPORT(htons);
IMPORT(accept);
IMPORT(recv);
IMPORT(bind);
IMPORT(socketclose);
IMPORT(connect);
IMPORT(getpeername);
IMPORT(getsockname);
IMPORT(getsockopt);
IMPORT(listen);
IMPORT(recv);
IMPORT(recvfrom);
IMPORT(send);
IMPORT(inet_aton);
IMPORT(sendto);
IMPORT(setsockopt);
IMPORT(shutdown);
IMPORT(socket);
IMPORT(select);
IMPORT_END();

View file

@ -17,7 +17,7 @@ void DisassemblePPCRange(void *start, void *end, void* printf_func, void* GetSym
#define DEBUG_DISASM(start, count) DisassemblePPCRange((void*)start, (u32*)(start) + (count), printf, OSGetSymbolName, 0)
//#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
#define DEBUG_LINE() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);}while(0)
#define DEBUG_LINE() do{printf("%s:%4d %s().\n", __FILE__, __LINE__, __FUNCTION__);fflush(stdout);}while(0)
#define DEBUG_STR(X) printf( "%s: %s\n", #X, (char*)(X))
#define DEBUG_VAR(X) printf( "%-20s: 0x%08X\n", #X, (u32)(X))
#define DEBUG_VAR2(X) printf( "%-20s: 0x%08X (%i)\n", #X, (u32)(X), (int)(X))