util: move and improve sockaddr-specific functions

Move the functions to socket.c and improve them to require and check the
sockaddr length.
This commit is contained in:
Miroslav Lichvar
2019-07-18 09:42:11 +02:00
parent 91da65a782
commit 47e4cb31b2
6 changed files with 113 additions and 103 deletions

View File

@@ -124,4 +124,8 @@ extern int SCK_RemoveSocket(int sock_fd);
/* Close the socket */
extern void SCK_CloseSocket(int sock_fd);
/* Convert between IPSockAddr and sockaddr_in/in6 */
extern void SCK_SockaddrToIPSockAddr(struct sockaddr *sa, int sa_length, IPSockAddr *ip_sa);
extern int SCK_IPSockAddrToSockaddr(IPSockAddr *ip_sa, struct sockaddr *sa, int sa_length);
#endif