2 * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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.11.130.2 2008/01/22 23:27:35 tbox Exp $ */
24 #include <isc/socket.h>
27 #include <named/types.h>
28 #include <named/lwdclient.h>
31 ns_lwdclient_processnoop(ns_lwdclient_t
*client
, lwres_buffer_t
*b
) {
32 lwres_nooprequest_t
*req
;
33 lwres_noopresponse_t resp
;
39 REQUIRE(NS_LWDCLIENT_ISRECVDONE(client
));
40 INSIST(client
->byaddr
== NULL
);
44 result
= lwres_nooprequest_parse(client
->clientmgr
->lwctx
,
45 b
, &client
->pkt
, &req
);
46 if (result
!= LWRES_R_SUCCESS
)
49 client
->pkt
.recvlength
= LWRES_RECVLENGTH
;
50 client
->pkt
.authtype
= 0; /* XXXMLG */
51 client
->pkt
.authlength
= 0;
52 client
->pkt
.result
= LWRES_R_SUCCESS
;
54 resp
.datalength
= req
->datalength
;
55 resp
.data
= req
->data
;
57 lwres
= lwres_noopresponse_render(client
->clientmgr
->lwctx
, &resp
,
59 if (lwres
!= LWRES_R_SUCCESS
)
64 client
->sendbuf
= r
.base
;
65 client
->sendlength
= r
.length
;
66 result
= ns_lwdclient_sendreply(client
, &r
);
67 if (result
!= ISC_R_SUCCESS
)
71 * We can now destroy request.
73 lwres_nooprequest_free(client
->clientmgr
->lwctx
, &req
);
75 NS_LWDCLIENT_SETSEND(client
);
80 lwres_context_freemem(client
->clientmgr
->lwctx
, lwb
.base
, lwb
.length
);
83 lwres_nooprequest_free(client
->clientmgr
->lwctx
, &req
);
86 ns_lwdclient_errorpktsend(client
, LWRES_R_FAILURE
);