From b9ca0d45632cf9e180cc6a76cf06dc34de57d159 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 22 Oct 2023 18:40:20 +0300 Subject: [PATCH] engine: common: network: more simple IP address copying from sockaddr to netadr_t and back --- engine/common/net_ws.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/engine/common/net_ws.c b/engine/common/net_ws.c index b65ee41b..ad3f3db9 100644 --- a/engine/common/net_ws.c +++ b/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 ) { - uint32_t ip; ((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_addr.s_addr = a->ip4; } 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 ) { 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; } else if( s->ss_family == AF_INET6 )