Browse Source

engine: common: network: more simple IP address copying from sockaddr to netadr_t and back

pull/2/head
Alibek Omarov 1 year ago
parent
commit
b9ca0d4563
  1. 6
      engine/common/net_ws.c

6
engine/common/net_ws.c

@ -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…
Cancel
Save