etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / bin / named / lwdnoop.c
blob95c29edf9ff3f4c8984dbf6bbd50416d9d58b0b3
1 /* $NetBSD: lwdnoop.c,v 1.4 2014/12/10 04:37:51 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: lwdnoop.c,v 1.13 2008/01/22 23:28:04 tbox Exp */
22 /*! \file */
24 #include <config.h>
26 #include <isc/socket.h>
27 #include <isc/util.h>
29 #include <named/types.h>
30 #include <named/lwdclient.h>
32 void
33 ns_lwdclient_processnoop(ns_lwdclient_t *client, lwres_buffer_t *b) {
34 lwres_nooprequest_t *req;
35 lwres_noopresponse_t resp;
36 isc_result_t result;
37 lwres_result_t lwres;
38 isc_region_t r;
39 lwres_buffer_t lwb;
41 REQUIRE(NS_LWDCLIENT_ISRECVDONE(client));
42 INSIST(client->byaddr == NULL);
44 req = NULL;
46 result = lwres_nooprequest_parse(client->clientmgr->lwctx,
47 b, &client->pkt, &req);
48 if (result != LWRES_R_SUCCESS)
49 goto send_error;
51 client->pkt.recvlength = LWRES_RECVLENGTH;
52 client->pkt.authtype = 0; /* XXXMLG */
53 client->pkt.authlength = 0;
54 client->pkt.result = LWRES_R_SUCCESS;
56 resp.datalength = req->datalength;
57 resp.data = req->data;
59 lwres = lwres_noopresponse_render(client->clientmgr->lwctx, &resp,
60 &client->pkt, &lwb);
61 if (lwres != LWRES_R_SUCCESS)
62 goto cleanup_req;
64 r.base = lwb.base;
65 r.length = lwb.used;
66 client->sendbuf = r.base;
67 client->sendlength = r.length;
68 result = ns_lwdclient_sendreply(client, &r);
69 if (result != ISC_R_SUCCESS)
70 goto cleanup_lwb;
73 * We can now destroy request.
75 lwres_nooprequest_free(client->clientmgr->lwctx, &req);
77 NS_LWDCLIENT_SETSEND(client);
79 return;
81 cleanup_lwb:
82 lwres_context_freemem(client->clientmgr->lwctx, lwb.base, lwb.length);
84 cleanup_req:
85 lwres_nooprequest_free(client->clientmgr->lwctx, &req);
87 send_error:
88 ns_lwdclient_errorpktsend(client, LWRES_R_FAILURE);