(network) Turn functions that are not accessed outside static

This commit is contained in:
twinaphex 2020-05-24 20:38:50 +02:00
parent 8bf11e9b18
commit 737718ba5d
5 changed files with 60 additions and 56 deletions

View File

@ -75,8 +75,6 @@ struct ad_packet
int netplay_room_count = 0;
struct netplay_room *netplay_room_list = NULL;
static bool netplay_lan_ad_client(void);
/* LAN discovery sockets */
static int lan_ad_server_fd = -1;
static int lan_ad_client_fd = -1;
@ -90,6 +88,9 @@ static size_t discovered_hosts_allocated;
static struct netplay_room netplay_host_room = {0};
/* Forward declarations */
static bool netplay_lan_ad_client(void);
struct netplay_room* netplay_get_host_room(void)
{
return &netplay_host_room;

View File

@ -37,14 +37,48 @@
#include "../../retroarch.h"
#include "../../version.h"
struct nick_buf_s
{
uint32_t cmd[2];
char nick[NETPLAY_NICK_LEN];
};
struct password_buf_s
{
uint32_t cmd[2];
char password[NETPLAY_PASS_HASH_LEN];
};
struct info_buf_s
{
uint32_t cmd[2];
char core_name[NETPLAY_NICK_LEN];
char core_version[NETPLAY_NICK_LEN];
uint32_t content_crc;
};
#define RECV(buf, sz) \
recvd = netplay_recv(&connection->recv_packet_buffer, connection->fd, (buf), (sz), false); \
if (recvd >= 0 && recvd < (ssize_t) (sz)) \
{ \
netplay_recv_reset(&connection->recv_packet_buffer); \
return true; \
} \
else if (recvd < 0)
static netplay_t *handshake_password_netplay = NULL;
const uint32_t netplay_magic = 0x52414E50; /* RANP */
static unsigned long simple_rand_next = 1;
/* TODO/FIXME - replace netplay_log_connection with calls
* to inet_ntop_compat and move runloop message queue pushing
* outside */
#if !defined(HAVE_SOCKET_LEGACY) && !defined(WIIU) && !defined(_3DS)
/* Custom inet_ntop. Win32 doesn't seem to support this ... */
void netplay_log_connection(const struct sockaddr_storage *their_addr,
static void netplay_log_connection(
const struct sockaddr_storage *their_addr,
unsigned slot, const char *nick, char *s, size_t len)
{
union
@ -104,16 +138,15 @@ void netplay_log_connection(const struct sockaddr_storage *their_addr,
nick);
}
}
#else
void netplay_log_connection(const struct sockaddr_storage *their_addr,
static void netplay_log_connection(
const struct sockaddr_storage *their_addr,
unsigned slot, const char *nick, char *s, size_t len)
{
/* Stub code - will need to be implemented */
snprintf(s, len, msg_hash_to_str(MSG_GOT_CONNECTION_FROM),
nick);
}
#endif
/**
@ -122,7 +155,7 @@ void netplay_log_connection(const struct sockaddr_storage *their_addr,
* A pseudo-hash of the RetroArch and Netplay version, so only compatible
* versions play together.
*/
uint32_t netplay_impl_magic(void)
static uint32_t netplay_impl_magic(void)
{
size_t i;
uint32_t res = 0;
@ -169,8 +202,6 @@ static bool netplay_endian_mismatch(uint32_t pma, uint32_t pmb)
return (pma & ebit) != (pmb & ebit);
}
static unsigned long simple_rand_next = 1;
static int simple_rand(void)
{
simple_rand_next = simple_rand_next * 1103515245 + 12345;
@ -235,37 +266,6 @@ bool netplay_handshake_init_send(netplay_t *netplay,
return true;
}
struct nick_buf_s
{
uint32_t cmd[2];
char nick[NETPLAY_NICK_LEN];
};
struct password_buf_s
{
uint32_t cmd[2];
char password[NETPLAY_PASS_HASH_LEN];
};
struct info_buf_s
{
uint32_t cmd[2];
char core_name[NETPLAY_NICK_LEN];
char core_version[NETPLAY_NICK_LEN];
uint32_t content_crc;
};
#define RECV(buf, sz) \
recvd = netplay_recv(&connection->recv_packet_buffer, connection->fd, (buf), (sz), false); \
if (recvd >= 0 && recvd < (ssize_t) (sz)) \
{ \
netplay_recv_reset(&connection->recv_packet_buffer); \
return true; \
} \
else if (recvd < 0)
static netplay_t *handshake_password_netplay = NULL;
#ifdef HAVE_MENU
static void handshake_password(void *ignore, const char *line)
{
@ -496,7 +496,7 @@ static void netplay_handshake_ready(netplay_t *netplay,
*
* Send an INFO command.
*/
bool netplay_handshake_info(netplay_t *netplay,
static bool netplay_handshake_info(netplay_t *netplay,
struct netplay_connection *connection)
{
struct info_buf_s info_buf;
@ -545,7 +545,7 @@ bool netplay_handshake_info(netplay_t *netplay,
*
* Send a SYNC command.
*/
bool netplay_handshake_sync(netplay_t *netplay,
static bool netplay_handshake_sync(netplay_t *netplay,
struct netplay_connection *connection)
{
/* If we're the server, now we send sync info */
@ -690,7 +690,7 @@ bool netplay_handshake_sync(netplay_t *netplay,
* Data receiver for the second stage of handshake, receiving the other side's
* nickname.
*/
bool netplay_handshake_pre_nick(netplay_t *netplay,
static bool netplay_handshake_pre_nick(netplay_t *netplay,
struct netplay_connection *connection, bool *had_input)
{
struct nick_buf_s nick_buf;
@ -753,7 +753,7 @@ bool netplay_handshake_pre_nick(netplay_t *netplay,
* Data receiver for the third, optional stage of server handshake, receiving
* the password and sending core/content info.
*/
bool netplay_handshake_pre_password(netplay_t *netplay,
static bool netplay_handshake_pre_password(netplay_t *netplay,
struct netplay_connection *connection, bool *had_input)
{
struct password_buf_s password_buf;
@ -833,7 +833,7 @@ bool netplay_handshake_pre_password(netplay_t *netplay,
* Data receiver for the third stage of server handshake, receiving
* the password.
*/
bool netplay_handshake_pre_info(netplay_t *netplay,
static bool netplay_handshake_pre_info(netplay_t *netplay,
struct netplay_connection *connection, bool *had_input)
{
struct info_buf_s info_buf;
@ -937,7 +937,7 @@ bool netplay_handshake_pre_info(netplay_t *netplay,
* Data receiver for the client's third handshake stage, receiving the
* synchronization information.
*/
bool netplay_handshake_pre_sync(netplay_t *netplay,
static bool netplay_handshake_pre_sync(netplay_t *netplay,
struct netplay_connection *connection, bool *had_input)
{
uint32_t cmd[2];

View File

@ -269,7 +269,7 @@ static bool netplay_init_socket_buffers(netplay_t *netplay)
return true;
}
bool netplay_init_serialization(netplay_t *netplay)
static bool netplay_init_serialization(netplay_t *netplay)
{
unsigned i;
retro_ctx_size_info_t info;

View File

@ -32,7 +32,7 @@
#ifdef HAVE_DISCORD
#include "../discord.h"
/* TODO/FIXME - global */
/* TODO/FIXME - global public variable */
extern bool discord_is_inited;
#endif
@ -75,7 +75,8 @@ static void print_state(netplay_t *netplay)
* Mark a particular remote connection as unpaused and, if relevant, inform
* every one else that they may resume.
*/
static void remote_unpaused(netplay_t *netplay, struct netplay_connection *connection)
static void remote_unpaused(netplay_t *netplay,
struct netplay_connection *connection)
{
size_t i;
connection->paused = false;
@ -98,7 +99,8 @@ static void remote_unpaused(netplay_t *netplay, struct netplay_connection *conne
*
* Disconnects an active Netplay connection due to an error
*/
void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection)
void netplay_hangup(netplay_t *netplay,
struct netplay_connection *connection)
{
char msg[512];
const char *dmsg;
@ -188,8 +190,8 @@ void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection)
/**
* netplay_delayed_state_change:
*
* Handle any pending state changes which are ready as of the beginning of the
* current frame.
* Handle any pending state changes which are ready
* as of the beginning of the current frame.
*/
void netplay_delayed_state_change(netplay_t *netplay)
{

View File

@ -27,6 +27,11 @@
#include "../../driver.h"
#include "../../input/input_driver.h"
struct vote_count
{
uint16_t votes[32];
};
#if 0
#define DEBUG_NONDETERMINISTIC_CORES
#endif
@ -86,10 +91,6 @@ void netplay_update_unread_ptr(netplay_t *netplay)
}
}
struct vote_count {
uint16_t votes[32];
};
/**
* netplay_device_client_state
* @netplay : pointer to netplay object