summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-01-08 13:11:12 -0800
committerJeremy Allison <jra@samba.org>2008-01-08 13:11:12 -0800
commit7ca33d1112f415a41ed48be02a7f732a2c640ff7 (patch)
tree75e8fb14d3277c0d3bf02fe5d7f094a6245d26ea /source3/utils
parent791fe3119ef1756fc476b17b8c590241bee5de2e (diff)
downloadsamba-7ca33d1112f415a41ed48be02a7f732a2c640ff7.tar.gz
samba-7ca33d1112f415a41ed48be02a7f732a2c640ff7.tar.bz2
samba-7ca33d1112f415a41ed48be02a7f732a2c640ff7.zip
Move the DNS tsig update to using struct sockaddr_storage
from struct in_addr. Still only does IPv4 updates but now it'll be easy to add IPv6 when we have time. Jeremy. (This used to be commit ac3a433befca2c6b674fc7e7f2f2c700d78b0a0c)
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;