summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_dns.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/source3/utils/net_dns.c b/source3/utils/net_dns.c
index 8b82a96892..c661c77ce6 100644
--- a/source3/utils/net_dns.c
+++ b/source3/utils/net_dns.c
@@ -32,14 +32,14 @@
DNS_ERROR DoDNSUpdate(char *pszServerName,
const char *pszDomainName, const char *pszHostName,
- const struct in_addr *iplist, size_t num_addrs );
+ const struct sockaddr_storage *sslist, size_t num_addrs );
/*********************************************************************
*********************************************************************/
DNS_ERROR DoDNSUpdate(char *pszServerName,
const char *pszDomainName, const char *pszHostName,
- const struct in_addr *iplist, size_t num_addrs )
+ const struct sockaddr_storage *sslist, size_t num_addrs )
{
DNS_ERROR err;
struct dns_connection *conn;
@@ -65,7 +65,7 @@ DNS_ERROR DoDNSUpdate(char *pszServerName,
*/
err = dns_create_probe(mem_ctx, pszDomainName, pszHostName,
- num_addrs, iplist, &req);
+ num_addrs, sslist, &req);
if (!ERR_DNS_IS_OK(err)) goto error;
err = dns_update_transaction(mem_ctx, conn, req, &resp);
@@ -81,7 +81,7 @@ DNS_ERROR DoDNSUpdate(char *pszServerName,
*/
err = dns_create_update_request(mem_ctx, pszDomainName, pszHostName,
- iplist, num_addrs, &req);
+ sslist, num_addrs, &req);
if (!ERR_DNS_IS_OK(err)) goto error;
err = dns_update_transaction(mem_ctx, conn, req, &resp);
@@ -141,30 +141,37 @@ error:
/*********************************************************************
*********************************************************************/
-int get_my_ip_address( struct in_addr **ips )
+int get_my_ip_address( struct sockaddr_storage **pp_ss )
+
{
struct iface_struct nics[MAX_INTERFACES];
int i, n;
- struct in_addr *list;
+ struct sockaddr_storage *list = NULL;
int count = 0;
/* find the first non-loopback address from our list of interfaces */
n = get_interfaces(nics, MAX_INTERFACES);
-
- if ( (list = SMB_MALLOC_ARRAY( struct in_addr, n )) == NULL ) {
+
+ if (n <= 0) {
+ return -1;
+ }
+
+ if ( (list = SMB_MALLOC_ARRAY( struct sockaddr_storage, n )) == NULL ) {
return -1;
}
for ( i=0; i<n; i++ ) {
+ if (is_loopback_addr(&nics[i].ip)) {
+ continue;
+ }
+#if defined(HAVE_IPV6)
if ((nics[i].ip.ss_family == AF_INET)) {
- struct in_addr ifip;
-
- ifip = ((const struct sockaddr_in *)&nics[i].ip)->sin_addr;
-
- if (!is_loopback_ip_v4(ifip)) {
- memcpy(&list[count++], &ifip, sizeof(struct in_addr));
- }
+ memcpy(&list[count++], &nics[i].ip);
+ } else
+#endif
+ if ((nics[i].ip.ss_family == AF_INET)) {
+ memcpy(&list[count++], &nics[i].ip);
}
}
*ips = list;