sample-update.c revision 8664a1bd40814ed0b42eacfc5eb354b598dfd6df
/*
* Copyright (C) 2009, 2010, 2012-2017 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: sample-update.c,v 1.10 2010/12/09 00:54:34 marka Exp $ */
#include <config.h>
#ifndef WIN32
#include <netdb.h>
#include <unistd.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/commandline.h>
#include <isc/parseint.h>
#include <isc/sockaddr.h>
#include <dns/callbacks.h>
#include <dns/fixedname.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
#include <dns/rdatatype.h>
static isc_bufferlist_t usedbuffers;
static const char *port = "53";
ISC_PLATFORM_NORETURN_PRE static void
usage(void) ISC_PLATFORM_NORETURN_POST;
static void
usage(void) {
"-s "
"[-a auth_server] "
"[-k keyfile] "
"[-p prerequisite] "
"[-r recursive_server] "
"[-z zonename] "
"(add|delete) \"name TTL RRtype RDATA\"\n");
exit(1);
}
static isc_boolean_t
{
int gaierror;
#ifdef AI_NUMERICHOST
#endif
#ifdef AI_NUMERICSERV
#endif
if (gaierror != 0) {
return (ISC_FALSE);
}
return (ISC_TRUE);
}
int
int ch;
char *zonenamestr = NULL;
char *keyfilename = NULL;
unsigned int nsa_auth = 0, nsa_recursive = 0;
isc_buffer_t b, *buf;
unsigned int namelen;
switch (ch) {
case 'k':
break;
case 'a':
nsa_auth++;
break;
case 'p':
break;
case 'P':
break;
case 'r':
if (nsa_recursive <
sizeof(sa_recursive)/sizeof(*sa_recursive) &&
break;
case 's':
break;
case 'z':
break;
default:
usage();
}
}
if (argc < 2)
usage();
/* command line argument validation */
else {
exit(1);
}
"must be specified\n");
usage();
}
/* Initialization */
result = dns_lib_init();
if (result != ISC_R_SUCCESS) {
exit(1);
}
if (result != ISC_R_SUCCESS) {
exit(1);
}
if (result != ISC_R_SUCCESS) {
exit(1);
}
/* Construct zone name */
if (zonenamestr != NULL) {
isc_buffer_add(&b, namelen);
if (result != ISC_R_SUCCESS)
result);
}
/* Construct prerequisite name (if given) */
}
/* Construct update name */
if (keyfilename != NULL)
/* Perform update */
default_rdataclass, /* XXX: fixed */
auth_serversp, tsec, 0);
if (result != ISC_R_SUCCESS) {
} else
if (sendtwice) {
/* Perform 2nd update */
default_rdataclass, /* XXX: fixed */
auth_serversp, tsec, 0);
if (result != ISC_R_SUCCESS) {
} else
}
/* Cleanup */
}
}
}
}
}
}
}
return (0);
}
/*
* Subroutines borrowed from nsupdate.c
*/
static char *
char *s;
const char *d;
return (NULL);
break;
}
if (dc == 0)
break;
}
for (s = string; *s != '\0'; s++) {
sc = *s;
*s++ = '\0';
*stringp = s;
return (string);
}
}
}
return (string);
}
static void
exit(1);
}
static inline void
if (result != ISC_R_SUCCESS)
}
static void
char *word;
exit(1);
}
}
static void
{
isc_region_t r;
cmdline++;
&callbacks);
if (result == ISC_R_SUCCESS) {
isc_buffer_usedregion(buf, &r);
isc_buffer_usedregion(newbuf, &r);
} else {
exit(1);
}
} else {
}
}
static void
{
char *word;
/*
* Read the owner name.
*/
exit(1);
}
/*
* If this is an add, read the TTL and verify that it's in range.
* If it's a delete, ignore a TTL if present (for compatibility).
*/
if (!isdelete) {
exit(1);
}
else {
ttl = 0;
goto doneparsing;
}
}
if (result != ISC_R_SUCCESS) {
if (isdelete) {
ttl = 0;
goto parseclass;
} else {
exit(1);
}
}
if (isdelete)
ttl = 0;
exit(1);
}
/*
* Read the class or type.
*/
if (isdelete) {
goto doneparsing;
} else {
exit(1);
}
}
if (result == ISC_R_SUCCESS) {
/*
* Now read the type.
*/
if (isdelete) {
goto doneparsing;
} else {
exit(1);
}
}
if (result != ISC_R_SUCCESS) {
exit(1);
}
} else {
if (result != ISC_R_SUCCESS) {
exit(1);
}
}
if (isdelete) {
else
} else {
exit(1);
}
}
exit(1);
}
exit(1);
}
}
static void
{
char *word;
/*
* Read the owner name
*/
/*
* If this is an rrset prereq, read the class or type.
*/
if (isrrset) {
exit(1);
}
if (result == ISC_R_SUCCESS) {
/*
* Now read the type.
*/
exit(1);
}
if (result != ISC_R_SUCCESS) {
exit(1);
}
} else {
if (result != ISC_R_SUCCESS) {
exit(1);
}
}
} else
exit(1);
}
if (isrrset && ispositive)
else
exit(1);
}
if (ispositive) {
else
} else
exit(1);
}
}
static void
char *word;
exit(1);
}
} else {
exit(1);
}
}
static void
&dstkey);
if (result != ISC_R_SUCCESS) {
exit(1);
}
else
if (result != ISC_R_SUCCESS) {
exit(1);
}
}