From 18f8ded154ca5e085ec3b1a501b98f8f132ff772 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 18:42:13 +0200 Subject: [PATCH] Flesh out socket_create some more --- libretro-common/include/net/net_socket.h | 12 +++++++- libretro-common/net/net_socket.c | 38 +++++++++++++++++++----- netlogger.c | 4 +-- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 854f307036..8399cf9e03 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -43,6 +43,12 @@ enum socket_type SOCKET_TYPE_SEQPACKET }; +enum socket_protocol +{ + SOCKET_PROTOCOL_NONE = 0, + SOCKET_PROTOCOL_UDP +}; + int socket_init(void **address, uint16_t port, const char *server, enum socket_type type); int socket_close(int fd); @@ -63,7 +69,11 @@ bool socket_bind(int fd, void *data); int socket_connect(int fd, void *data, bool timeout_enable); -int socket_create(const char *name, enum socket_domain domain_type, enum socket_type socket_type, int protocol); +int socket_create( + const char *name, + enum socket_domain domain_type, + enum socket_type socket_type, + enum socket_protocol protocol_type); RETRO_END_DECLS diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 189d00cf42..5a884cf0fa 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -217,13 +217,14 @@ int socket_connect(int fd, void *data, bool timeout_enable) int socket_create( const char *name, - enum socket_domain domain_type, - enum socket_type socket_type, - int protocol) + enum socket_domain domain_type, + enum socket_type socket_type, + enum socket_protocol protocol_type) { #ifdef VITA - int type = 0; - int domain = 0; + int type = 0; + int domain = 0; + int protocol = 0; switch (domain_type) { @@ -244,10 +245,22 @@ int socket_create( /* TODO/FIXME - implement */ break; } + + switch (protocol_type) + { + case SOCKET_PROTOCOL_NONE: + protocol = 0; + break; + case SOCKET_PROTOCOL_UDP: + /* TODO/FIXME - implement */ + break; + } + return sceNetSocket(name, domain, type, protocol); #else - int type = 0; - int domain = 0; + int type = 0; + int domain = 0; + int protocol = 0; switch (domain_type) { @@ -268,6 +281,17 @@ int socket_create( /* TODO/FIXME - implement */ break; } + + switch (protocol_type) + { + case SOCKET_PROTOCOL_NONE: + protocol = 0; + break; + case SOCKET_PROTOCOL_UDP: + /* TODO/FIXME - implement */ + break; + } + return socket(domain, type, protocol); #endif } diff --git a/netlogger.c b/netlogger.c index 06dd34a0b0..3b7b8b6363 100644 --- a/netlogger.c +++ b/netlogger.c @@ -67,7 +67,7 @@ static int network_interface_up(struct sockaddr_in *target, int index, "ra_netlogger", SOCKET_DOMAIN_INET, SOCKET_TYPE_DATAGRAM, - 0); + SOCKET_PROTOCOL_NONE); target->sin_family = PSP2_NET_AF_INET; target->sin_port = sceNetHtons(udp_port); @@ -108,7 +108,7 @@ static int network_interface_up(struct sockaddr_in *target, int index, "ra_netlogger", SOCKET_DOMAIN_INET, SOCKET_TYPE_DATAGRAM, - 0); + SOCKET_PROTOCOL_NONE); target->sin_family = AF_INET; target->sin_port = htons(udp_port);