#endif /* not lint */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*! \file
* \brief
* Based on the Dynamic DNS reference implementation by Viraj Bais
* <viraj_bais@ccm.fm.intel.com>
*/
#include "port_before.h"
#include <errno.h>
#include <limits.h>
#include <netdb.h>
#include <res_update.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <resolv.h>
#include "port_after.h"
#include "res_private.h"
/*%
* Separate a linked list of records into groups so that all records
* in a group will belong to a single zone on the nameserver.
* Create a dynamic update packet for each zone and send it to the
* nameservers for that zone, and await answer.
* Abort if error occurs in updating any zone.
* Return the number of zones updated on success, < 0 on error.
*
* On error, caller must deal with the unsynchronized zones
* eg. an A record might have been successfully added to the forward
* zone but the corresponding PTR record would be missing if error
* was encountered while updating the reverse zone.
*/
struct zonegrp {
int z_nscount;
int z_flags;
};
/* Forward. */
/* Macros. */
#define DPRINTF(x) do {\
int save_errno = errno; \
errno = save_errno; \
} while (0)
/* Public. */
int
DPRINTF(("malloc failed"));
return (0);
}
/* Thread all of the updates onto a list of groups. */
int nscnt;
/* Find the origin for it if there is one. */
if (nscnt <= 0) {
goto done;
}
/* Find the group for it if there is one. */
break;
/* Make a group for it if there isn't one. */
DPRINTF(("malloc failed"));
goto done;
}
}
/* Thread this rrecp onto the right group. */
}
/* Construct zone section and prepend it. */
DPRINTF(("res_mkupdrec failed"));
goto done;
}
/* Marshall the update message. */
DPRINTF(("res_mkupdate -> %d", n));
if (n < 0)
goto done;
/* Temporarily replace the resolver's nameserver set. */
/* Send the update and remember the result. */
else
if (n < 0) {
DPRINTF(("res_nsend: send error, n=%d (%s)\n",
goto done;
}
nzones++;
/* Restore resolver's nameserver set. */
nscount = 0;
}
done:
}
if (nscount != 0)
return (nzones);
}
/* Private. */
static void
}