rndc.c revision 1a69a1a78cfaa86f3b68bbc965232b7876d4da2a
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Copyright (C) 2000 Internet Software Consortium.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Permission to use, copy, modify, and distribute this software for any
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * purpose with or without fee is hereby granted, provided that the above
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * copyright notice and this permission notice appear in all copies.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
f41f183f628a148860a6d1f0070208cddd45b0c6Bob Halley/* $Id: rndc.c,v 1.11 2000/05/08 14:33:19 tale Exp $ */
9a2127f8335bad323451d7825119cd9f72e32464Mark Andrews * Principal Author: DCL
b6d52ee5bea1b9d9074698e693b49ce96edff47bMark Andrewstypedef struct ndc_object {
76117ff568dc788ed24937cfea916a18db285960Mark Andrews * Send a control command to the server.
76117ff568dc788ed24937cfea916a18db285960Mark Andrewssend_command(omapi_object_t *manager, char *command) {
65c4736d9c0ebc6d9b1d991593b55566909da9cdBrian Wellington * Create a new message object to store the information that will
8a896bc645a6236e9a47e33fb57510a451009a90Mark Andrews * be sent to the server.
911ed0d3bee586b3bec42cb6c376d5cc6c0e1e24Brian Wellington * Specify the OPEN operation, with the UPDATE option if requested.
501941f0b6cce74c2ff75b10aff3f230d5d37e4cEvan Hunt result = omapi_object_setinteger(message, "op", OMAPI_OP_OPEN);
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt result = omapi_object_setboolean(message, "update", ISC_TRUE);
87708bde16713bc02ff2598f4a82f98c699a2f2dMark Andrews * Tell the server the type of the object being opened; it needs
55e5c51e661e23e24573db84114a3837817745c9Evan Hunt * to know this so that it can apply the proper object methods
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews result = omapi_object_setstring(message, "type",
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt * Associate the ndc object with the message, so that it will have its
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt * values stuffed in the message. Without it, the OPEN operation will
8a896bc645a6236e9a47e33fb57510a451009a90Mark Andrews * fail because there is no name/value pair to use as a key for looking
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * up the desired object at the server; this is true even though the
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence * particular object being accessed on the server does not need a key
7e9ccec63889f2aabee59b94307be492a77fa93bMark Andrews * to be found.
7e9ccec63889f2aabee59b94307be492a77fa93bMark Andrews * This object will also have its signal handler called with a
76117ff568dc788ed24937cfea916a18db285960Mark Andrews * "status" signal that sends the result of the operation on the
ba751492fcc4f161a18b983d4f018a1a52938cb9Evan Hunt result = omapi_object_setobject(message, "object",
494576ce20cfd98d74955698cf8f7b37dce2f740Mark Andrews * Create a generic object to be the outer object for ndc_g_ndc, to
84dc4b3e7eea3e9c8fafa5f4fd632a51ee8b356fMukund Sivaraman * handle the job of storing the command and stuffing it into the
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt * XXXDCL provide API so client does not need to refer to the
a8783019814daa36dd57afe3f527462822834c3bEvan Hunt * outer member -- does not even need to know about how the whole
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt * outer/inner thing works.
501941f0b6cce74c2ff75b10aff3f230d5d37e4cEvan Hunt result = omapi_object_create(&ndc_g_ndc.outer, NULL, 0);
0cfb24736841b3e98bb25853229a0efabab88bddEvan Hunt * Set the command being sent.
55e5c51e661e23e24573db84114a3837817745c9Evan Hunt result = omapi_object_setboolean((omapi_object_t *)&ndc_g_ndc,
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt * Add the new message to the list of known messages. When the
422009fe5b15e31e7f5d09212bd1480121a1464eEvan Hunt * server's response comes back, the client will verify that
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt * the response was for a message it really sent.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Deliver the message to the server and await its
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt * Free the generic object and the message.
193738b819e3c699f9edd18864a6810fcfcec855Andreas Gustafsson * The signal handler gets the "status" signals when the server's response
fd35453765c6494d077edca44f4d998af5fd4cfaDavid Lawrence * is processed. It also gets the "updated" signal after all the values
fd35453765c6494d077edca44f4d998af5fd4cfaDavid Lawrence * from the server have been incorporated via ndc_setvalue.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrewsndc_signalhandler(omapi_object_t *handle, const char *name, va_list ap) {
f687e639f00a31e0884fb2c95a627b10b50c364bEvan Hunt * "status" is signalled with the result of the message's
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * operation.
6d7585b3e948dd31bf78321d83ac0e024f44a71bMark Andrews * Even if the waitresult was not ISC_R_SUCCESS, the processing
6d5dcd0dc9bdbd679282b1ffc47987d24c3a1346Bob Halley * by the function still was.
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley * Nothing to do, really.
5d51e67c3b4f35c1be742574aacc1d88fe6ed444Mark Andrews * Pass any unknown signal any internal object.
118394ef2ec7cef253c55359a3d70d202ddc2fa0Mark Andrews * (This normally does not happen; there is no
118394ef2ec7cef253c55359a3d70d202ddc2fa0Mark Andrews * inner object, nor anything else being signalled.)
b99bfa184bc9375421b5df915eea7dfac6a68a99Evan Hunt fprintf(stderr, "%s: ndc_signalhandler: unknown signal: %s",
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halley result = omapi_object_passsignal(handle, name, ap);
b66b333f59cf51ef87f973084a5023acd9317fb2Evan HuntUsage: %s [-c config] [-s server] [-p port] [-m] command [command ...]\n\
b66b333f59cf51ef87f973084a5023acd9317fb2Evan HuntWhere command is one of the following for named:\n\
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt *status Display ps(1) status of named.\n\
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt *dumpdb Dump database and cache to /var/tmp/named_dump.db.\n\
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt reload Reload configuration file and zones.\n\
289ae548d52bc8f982d9823af64cafda7bd92232Mark Andrews *stats Dump statistics to /var/tmp/named.stats.\n\
progname);
char *command;
unsigned int algorithm;
int ch;
progname++;
switch (ch) {
progname);
usage();
usage();
progname);
&keyname));
progname);
if (show_final_mem)