[Listener] Fix strict-aliasing rule warning

This commit is contained in:
Matteo Cypriani 2010-10-20 17:20:47 +02:00
parent ed7828a339
commit 3c0f74fcb3
1 changed files with 4 additions and 4 deletions

View File

@ -799,6 +799,7 @@ void get_ip_addr(char *eth, char ip[16])
struct ifreq ifr;
int sockfd ;
struct sockaddr_in sa ;
struct in_addr ip_addr ;
sockfd = socket(AF_INET, SOCK_DGRAM, 0) ;
if(sockfd < 0)
@ -812,10 +813,9 @@ void get_ip_addr(char *eth, char ip[16])
if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0)
return ;
strncpy(ip,
inet_ntoa(*(struct in_addr *)
&ifr.ifr_addr.sa_data[sizeof(sa.sin_port)]),
16) ;
memcpy(&ip_addr, &ifr.ifr_addr.sa_data[sizeof(sa.sin_port)],
sizeof(ip_addr)) ;
strncpy(ip, inet_ntoa(ip_addr), 16) ;
}