sample-update.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2009, 2010, 2012-2016 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;
ISC_PLATFORM_NORETURN_PRE static void
usage(void) ISC_PLATFORM_NORETURN_POST;
static void
usage(void) {
"[-a auth_server] "
"[-k keyfile] "
"[-p prerequisite] "
"[-r recursive_server] "
"[-z zonename] "
"(add|delete) \"name TTL RRtype RDATA\"\n");
exit(1);
}
int
int ch;
int gai_error;
char *zonenamestr = NULL;
char *keyfilename = NULL;
char *auth_server = NULL;
char *recursive_server = NULL;
isc_buffer_t b, *buf;
unsigned int namelen;
switch (ch) {
case 'k':
break;
case 'a':
break;
case 'p':
break;
case 'r':
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);
}
/* Set the authoritative server */
if (auth_server != NULL) {
#ifdef AI_NUMERICHOST
#endif
if (gai_error != 0) {
exit(1);
}
}
/* Set the recursive server */
if (recursive_server != NULL) {
#ifdef AI_NUMERICHOST
#endif
if (gai_error != 0) {
exit(1);
}
NULL, &rec_servers);
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_servers, 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);
}
}