1 /* $NetBSD: lwdnoop.c,v 1.4 2014/12/10 04:37:51 christos Exp $ */
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 */
26 #include <isc/socket.h>
29 #include <named/types.h>
30 #include <named/lwdclient.h>
33 ns_lwdclient_processnoop(ns_lwdclient_t
*client
, lwres_buffer_t
*b
) {
34 lwres_nooprequest_t
*req
;
35 lwres_noopresponse_t resp
;
41 REQUIRE(NS_LWDCLIENT_ISRECVDONE(client
));
42 INSIST(client
->byaddr
== NULL
);
46 result
= lwres_nooprequest_parse(client
->clientmgr
->lwctx
,
47 b
, &client
->pkt
, &req
);
48 if (result
!= LWRES_R_SUCCESS
)
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
,
61 if (lwres
!= LWRES_R_SUCCESS
)
66 client
->sendbuf
= r
.base
;
67 client
->sendlength
= r
.length
;
68 result
= ns_lwdclient_sendreply(client
, &r
);
69 if (result
!= ISC_R_SUCCESS
)
73 * We can now destroy request.
75 lwres_nooprequest_free(client
->clientmgr
->lwctx
, &req
);
77 NS_LWDCLIENT_SETSEND(client
);
82 lwres_context_freemem(client
->clientmgr
->lwctx
, lwb
.base
, lwb
.length
);
85 lwres_nooprequest_free(client
->clientmgr
->lwctx
, &req
);
88 ns_lwdclient_errorpktsend(client
, LWRES_R_FAILURE
);