mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-12 08:08:02 +00:00
engine: common: network: more simple IP address copying from sockaddr to netadr_t and back
This commit is contained in:
parent
dcb3da53b0
commit
b9ca0d4563
@ -273,11 +273,9 @@ static void NET_NetadrToSockadr( netadr_t *a, struct sockaddr_storage *s )
|
|||||||
}
|
}
|
||||||
else if( a->type == NA_IP )
|
else if( a->type == NA_IP )
|
||||||
{
|
{
|
||||||
uint32_t ip;
|
|
||||||
((struct sockaddr_in *)s)->sin_family = AF_INET;
|
((struct sockaddr_in *)s)->sin_family = AF_INET;
|
||||||
memcpy( &ip, &a->ip, sizeof( ip ));
|
|
||||||
((struct sockaddr_in *)s)->sin_addr.s_addr = ip;
|
|
||||||
((struct sockaddr_in *)s)->sin_port = a->port;
|
((struct sockaddr_in *)s)->sin_port = a->port;
|
||||||
|
((struct sockaddr_in *)s)->sin_addr.s_addr = a->ip4;
|
||||||
}
|
}
|
||||||
else if( a->type6 == NA_IP6 )
|
else if( a->type6 == NA_IP6 )
|
||||||
{
|
{
|
||||||
@ -316,7 +314,7 @@ static void NET_SockadrToNetadr( const struct sockaddr_storage *s, netadr_t *a )
|
|||||||
if( s->ss_family == AF_INET )
|
if( s->ss_family == AF_INET )
|
||||||
{
|
{
|
||||||
a->type = NA_IP;
|
a->type = NA_IP;
|
||||||
memcpy( &a->ip, &((struct sockaddr_in *)s)->sin_addr.s_addr, sizeof( uint32_t ));
|
a->ip4 = ((struct sockaddr_in *)s)->sin_addr.s_addr;
|
||||||
a->port = ((struct sockaddr_in *)s)->sin_port;
|
a->port = ((struct sockaddr_in *)s)->sin_port;
|
||||||
}
|
}
|
||||||
else if( s->ss_family == AF_INET6 )
|
else if( s->ss_family == AF_INET6 )
|
||||||
|
Loading…
Reference in New Issue
Block a user