mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Astyled network.c
This commit is contained in:
parent
ed0071bcbc
commit
bb6566e436
|
@ -36,28 +36,27 @@
|
|||
|
||||
static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t bufsize)
|
||||
{
|
||||
if(family == AF_INET)
|
||||
{
|
||||
if (family == AF_INET) {
|
||||
struct sockaddr_in saddr = { 0 };
|
||||
saddr.sin_family = AF_INET;
|
||||
saddr.sin_addr = *(struct in_addr*)addr;
|
||||
saddr.sin_addr = *(struct in_addr *)addr;
|
||||
|
||||
DWORD len = bufsize;
|
||||
if(WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len))
|
||||
|
||||
if (WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len))
|
||||
return NULL;
|
||||
|
||||
return buf;
|
||||
}
|
||||
else if(family == AF_INET6)
|
||||
{
|
||||
} else if (family == AF_INET6) {
|
||||
struct sockaddr_in6 saddr = { 0 };
|
||||
saddr.sin6_family = AF_INET6;
|
||||
saddr.sin6_addr = *(struct in6_addr*)addr;
|
||||
saddr.sin6_addr = *(struct in6_addr *)addr;
|
||||
|
||||
DWORD len = bufsize;
|
||||
if(WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len))
|
||||
|
||||
if (WSAAddressToString((LPSOCKADDR)&saddr, sizeof(saddr), NULL, buf, &len))
|
||||
return NULL;
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -66,30 +65,27 @@ static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t b
|
|||
|
||||
static int inet_pton(sa_family_t family, const char *addrString, void *addrbuf)
|
||||
{
|
||||
if(family == AF_INET)
|
||||
{
|
||||
if (family == AF_INET) {
|
||||
struct sockaddr_in saddr = { 0 };
|
||||
|
||||
|
||||
INT len = sizeof(saddr);
|
||||
|
||||
if(WSAStringToAddress((LPTSTR)addrString, AF_INET, NULL, (LPSOCKADDR)&saddr, &len))
|
||||
|
||||
if (WSAStringToAddress((LPTSTR)addrString, AF_INET, NULL, (LPSOCKADDR)&saddr, &len))
|
||||
return 0;
|
||||
|
||||
*(struct in_addr*)addrbuf = saddr.sin_addr;
|
||||
|
||||
*(struct in_addr *)addrbuf = saddr.sin_addr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if(family == AF_INET6)
|
||||
{
|
||||
} else if (family == AF_INET6) {
|
||||
struct sockaddr_in6 saddr = { 0 };
|
||||
|
||||
|
||||
INT len = sizeof(saddr);
|
||||
|
||||
if(WSAStringToAddress((LPTSTR)addrString, AF_INET6, NULL, (LPSOCKADDR)&saddr, &len))
|
||||
|
||||
if (WSAStringToAddress((LPTSTR)addrString, AF_INET6, NULL, (LPSOCKADDR)&saddr, &len))
|
||||
return 0;
|
||||
|
||||
*(struct in6_addr*)addrbuf = saddr.sin6_addr;
|
||||
|
||||
|
||||
*(struct in6_addr *)addrbuf = saddr.sin6_addr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -477,7 +473,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
|||
#ifdef LOGGING
|
||||
res =
|
||||
#endif
|
||||
setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char*)&mreq, sizeof(mreq));
|
||||
setsockopt(temp->sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq));
|
||||
#ifdef LOGGING
|
||||
|
||||
if (res < 0) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user