1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

lib: Move sockaddr_storage_to_samba_sockaddr() to lib/

This can be useful outside of source3/libsmb/namequery.c as Samba
moves towards samba_sockaddr.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
This commit is contained in:
Volker Lendecke 2020-12-30 22:43:07 +01:00
parent 564b62a6f7
commit 4aa3ff574f
4 changed files with 29 additions and 28 deletions

View File

@ -1065,3 +1065,29 @@ void set_socket_options(int fd, const char *options)
TALLOC_FREE(ctx);
print_socket_options(fd);
}
/*
* Utility function that copes only with AF_INET and AF_INET6
* as that's all we're going to get out of DNS / NetBIOS / WINS
* name resolution functions.
*/
bool sockaddr_storage_to_samba_sockaddr(
struct samba_sockaddr *sa, const struct sockaddr_storage *ss)
{
sa->u.ss = *ss;
switch (ss->ss_family) {
case AF_INET:
sa->sa_socklen = sizeof(struct sockaddr_in);
break;
#ifdef HAVE_IPV6
case AF_INET6:
sa->sa_socklen = sizeof(struct sockaddr_in6);
break;
#endif
default:
return false;
}
return true;
}

View File

@ -123,4 +123,7 @@ char *print_canonical_sockaddr(TALLOC_CTX *ctx,
void set_socket_options(int fd, const char *options);
bool sockaddr_storage_to_samba_sockaddr(
struct samba_sockaddr *sa, const struct sockaddr_storage *ss);
#endif /* _SAMBA_UTIL_NET_H_ */

View File

@ -39,32 +39,6 @@
/* nmbd.c sets this to True. */
bool global_in_nmbd = False;
/*
* Utility function that copes only with AF_INET and AF_INET6
* as that's all we're going to get out of DNS / NetBIOS / WINS
* name resolution functions.
*/
bool sockaddr_storage_to_samba_sockaddr(struct samba_sockaddr *sa,
const struct sockaddr_storage *ss)
{
sa->u.ss = *ss;
switch (ss->ss_family) {
case AF_INET:
sa->sa_socklen = sizeof(struct sockaddr_in);
break;
#ifdef HAVE_IPV6
case AF_INET6:
sa->sa_socklen = sizeof(struct sockaddr_in6);
break;
#endif
default:
return false;
}
return true;
}
/*
* Utility function to convert from a sockaddr_storage
* array to a struct samba_sockaddr array.

View File

@ -23,8 +23,6 @@
#include <tevent.h>
/* The following definitions come from libsmb/namequery.c */
bool sockaddr_storage_to_samba_sockaddr(struct samba_sockaddr *sa,
const struct sockaddr_storage *ss);
bool saf_store( const char *domain, const char *servername );
bool saf_join_store( const char *domain, const char *servername );
bool saf_delete( const char *domain );