mirror of
https://github.com/libretro/RetroArch
synced 2025-02-10 12:40:03 +00:00
Fix buggy log_connection.
This commit is contained in:
parent
d262049f6b
commit
20528b9d1f
15
netplay.c
15
netplay.c
@ -203,6 +203,7 @@ int16_t input_state_net(bool port, unsigned device, unsigned index, unsigned id)
|
|||||||
return netplay_callbacks(g_extern.netplay)->state_cb(port, device, index, id);
|
return netplay_callbacks(g_extern.netplay)->state_cb(port, device, index, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom inet_ntop. Win32 doesn't seem to support this ...
|
||||||
static void log_connection(const struct sockaddr_storage *their_addr, unsigned slot)
|
static void log_connection(const struct sockaddr_storage *their_addr, unsigned slot)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
@ -214,29 +215,30 @@ static void log_connection(const struct sockaddr_storage *their_addr, unsigned s
|
|||||||
u.storage = their_addr;
|
u.storage = their_addr;
|
||||||
|
|
||||||
const char *str = NULL;
|
const char *str = NULL;
|
||||||
|
char buf_v4[INET_ADDRSTRLEN] = {0};
|
||||||
|
char buf_v6[INET6_ADDRSTRLEN] = {0};
|
||||||
|
|
||||||
if (their_addr->ss_family == AF_INET)
|
if (their_addr->ss_family == AF_INET)
|
||||||
{
|
{
|
||||||
char buf[INET_ADDRSTRLEN] = {0};
|
str = buf_v4;
|
||||||
str = buf;
|
|
||||||
struct sockaddr_in in;
|
struct sockaddr_in in;
|
||||||
memset(&in, 0, sizeof(in));
|
memset(&in, 0, sizeof(in));
|
||||||
in.sin_family = AF_INET;
|
in.sin_family = AF_INET;
|
||||||
memcpy(&in.sin_addr, &u.v4->sin_addr, sizeof(struct in_addr));
|
memcpy(&in.sin_addr, &u.v4->sin_addr, sizeof(struct in_addr));
|
||||||
|
|
||||||
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), buf, sizeof(buf),
|
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), buf_v4, sizeof(buf_v4),
|
||||||
NULL, 0, NI_NUMERICHOST);
|
NULL, 0, NI_NUMERICHOST);
|
||||||
}
|
}
|
||||||
else if (their_addr->ss_family == AF_INET6)
|
else if (their_addr->ss_family == AF_INET6)
|
||||||
{
|
{
|
||||||
char buf[INET6_ADDRSTRLEN] = {0};
|
str = buf_v6;
|
||||||
str = buf;
|
|
||||||
struct sockaddr_in6 in;
|
struct sockaddr_in6 in;
|
||||||
memset(&in, 0, sizeof(in));
|
memset(&in, 0, sizeof(in));
|
||||||
in.sin6_family = AF_INET6;
|
in.sin6_family = AF_INET6;
|
||||||
memcpy(&in.sin6_addr, &u.v6->sin6_addr, sizeof(struct in6_addr));
|
memcpy(&in.sin6_addr, &u.v6->sin6_addr, sizeof(struct in6_addr));
|
||||||
|
|
||||||
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6),
|
getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6),
|
||||||
buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
|
buf_v6, sizeof(buf_v6), NULL, 0, NI_NUMERICHOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str)
|
if (str)
|
||||||
@ -244,6 +246,7 @@ static void log_connection(const struct sockaddr_storage *their_addr, unsigned s
|
|||||||
char msg[512];
|
char msg[512];
|
||||||
snprintf(msg, sizeof(msg), "Got connection from: \"%s\" (#%u)", str, slot);
|
snprintf(msg, sizeof(msg), "Got connection from: \"%s\" (#%u)", str, slot);
|
||||||
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
|
||||||
|
SSNES_LOG("Got connection from: \"%s\" (#%u)\n", str, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user