From: Jeremy Allison Date: Thu, 27 Aug 2020 18:59:20 +0000 (-0700) Subject: s3: libsmb: Add internal conversion function ip_service_to_samba_sockaddr(). X-Git-Tag: talloc-2.3.2~577 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dad456d8cb4fa2b03396cce9c04c07d6c3c96c7;p=thirdparty%2Fsamba.git s3: libsmb: Add internal conversion function ip_service_to_samba_sockaddr(). Compiles but commented out as not yet used. Next commit will change that. Signed-off-by: Jeremy Allison Reviewed-by: Noel Power --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index f2d5866c372..c284e4dc5b6 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -64,6 +64,49 @@ bool sockaddr_storage_to_samba_sockaddr(struct samba_sockaddr *sa, return true; } +#if 0 +/* + * Utility function to convert from a struct ip_service + * array to a struct samba_sockaddr array. Will go away + * once ip_service is gone. + */ + +static NTSTATUS ip_service_to_samba_sockaddr(TALLOC_CTX *ctx, + struct samba_sockaddr **sa_out, + const struct ip_service *iplist_in, + size_t count) +{ + struct samba_sockaddr *sa = NULL; + size_t i; + bool ok; + + if (count == 0) { + /* + * Zero length arrays are returned as NULL. + * in the name resolution code. + */ + *sa_out = NULL; + return NT_STATUS_OK; + } + sa = talloc_zero_array(ctx, + struct samba_sockaddr, + count); + if (sa == NULL) { + return NT_STATUS_NO_MEMORY; + } + for (i = 0; i < count; i++) { + ok = sockaddr_storage_to_samba_sockaddr(&sa[i], + &iplist_in[i].ss); + if (!ok) { + TALLOC_FREE(sa); + return NT_STATUS_INVALID_PARAMETER; + } + } + *sa_out = sa; + return NT_STATUS_OK; +} +#endif + /**************************** * SERVER AFFINITY ROUTINES * ****************************/