3 Samba Unix/Linux Dynamic DNS Update
6 Copyright (C) Krishna Ganugapati (krishnag@centeris.com) 2006
7 Copyright (C) Gerald Carter 2006
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "utils/net.h"
28 #if defined(WITH_DNS_UPDATES)
30 /*********************************************************************
31 *********************************************************************/
33 int DoDNSUpdate( char *pszServerName, const char *pszDomainName,
34 char *pszHostName, struct in_addr *iplist, int num_addrs )
38 HANDLE hDNSServer = ( HANDLE ) NULL;
39 int32 dwResponseCode = 0;
40 DNS_UPDATE_RESPONSE *pDNSUpdateResponse = NULL;
42 DNS_UPDATE_RESPONSE *pDNSSecureUpdateResponse = NULL;
45 if ( (num_addrs <= 0) || !iplist ) {
49 dns_status = DNSOpen( pszServerName, DNS_TCP, &hDNSServer );
50 BAIL_ON_DNS_ERROR( dns_status );
52 dwError = DNSSendUpdate( hDNSServer, pszDomainName, pszHostName,
53 iplist, num_addrs, &pDNSUpdateResponse );
54 BAIL_ON_ERROR( dwError );
56 dwError = DNSUpdateGetResponseCode( pDNSUpdateResponse,
58 if ( dwResponseCode == DNS_REFUSED ) {
61 BAIL_ON_ERROR( dwError );
70 /*********************************************************************
71 *********************************************************************/
73 int get_my_ip_address( struct in_addr **ips )
75 struct iface_struct nics[MAX_INTERFACES];
77 struct in_addr loopback_ip = *interpret_addr2("127.0.0.1");
81 /* find the first non-loopback address from our list of interfaces */
83 n = get_interfaces(nics, MAX_INTERFACES);
85 if ( (list = SMB_MALLOC_ARRAY( struct in_addr, n )) == NULL ) {
89 for ( i=0; i<n; i++ ) {
90 if ( nics[i].ip.s_addr != loopback_ip.s_addr ) {
91 memcpy( &list[count++], &nics[i].ip, sizeof( struct in_addr ) );
99 #endif /* defined(WITH_DNS_UPDATES) */