2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: lwdnoop.c,v 1.6.208.1 2004/03/06 10:21:19 marka Exp $ */
22 #include <isc/socket.h>
25 #include <named/types.h>
26 #include <named/lwdclient.h>
29 ns_lwdclient_processnoop(ns_lwdclient_t *client, lwres_buffer_t *b) {
30 lwres_nooprequest_t *req;
31 lwres_noopresponse_t resp;
37 REQUIRE(NS_LWDCLIENT_ISRECVDONE(client));
38 INSIST(client->byaddr == NULL);
42 result = lwres_nooprequest_parse(client->clientmgr->lwctx,
43 b, &client->pkt, &req);
44 if (result != LWRES_R_SUCCESS)
47 client->pkt.recvlength = LWRES_RECVLENGTH;
48 client->pkt.authtype = 0; /* XXXMLG */
49 client->pkt.authlength = 0;
50 client->pkt.result = LWRES_R_SUCCESS;
52 resp.datalength = req->datalength;
53 resp.data = req->data;
55 lwres = lwres_noopresponse_render(client->clientmgr->lwctx, &resp,
57 if (lwres != LWRES_R_SUCCESS)
62 client->sendbuf = r.base;
63 client->sendlength = r.length;
64 result = ns_lwdclient_sendreply(client, &r);
65 if (result != ISC_R_SUCCESS)
69 * We can now destroy request.
71 lwres_nooprequest_free(client->clientmgr->lwctx, &req);
73 NS_LWDCLIENT_SETSEND(client);
79 lwres_nooprequest_free(client->clientmgr->lwctx, &req);
82 lwres_context_freemem(client->clientmgr->lwctx,
83 lwb.base, lwb.length);
85 ns_lwdclient_errorpktsend(client, LWRES_R_FAILURE);