actube/src/capwap/sock_copyaddr.c
7u83@mail.ru 2bae9358d7 Initial commit
FossilOrigin-Name: c53d95729c009f8f80a7d63847cef7668ff73f8af0523ab65f7734696f85399c
2014-07-11 20:12:11 +00:00

29 lines
463 B
C

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include "sock.h"
void sock_copyaddr(struct sockaddr_storage *dst, const struct sockaddr * src){
int salen;
/* determine length */
switch(src->sa_family){
case AF_INET:
salen = sizeof(struct sockaddr_in);
break;
#ifdef WITH_IPV6
case AF_INET6:
salen = sizeof(struct sockaddr_in6);
break;
#endif
default:
return;
}
memcpy(dst,src,salen);
}