00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include <isc/socket.h>
00025 #include <isc/util.h>
00026
00027 #include <named/types.h>
00028 #include <named/lwdclient.h>
00029
00030 void
00031 ns_lwdclient_processnoop(ns_lwdclient_t *client, lwres_buffer_t *b) {
00032 lwres_nooprequest_t *req;
00033 lwres_noopresponse_t resp;
00034 isc_result_t result;
00035 lwres_result_t lwres;
00036 isc_region_t r;
00037 lwres_buffer_t lwb;
00038
00039 REQUIRE(NS_LWDCLIENT_ISRECVDONE(client));
00040 INSIST(client->byaddr == NULL);
00041
00042 req = NULL;
00043
00044 result = lwres_nooprequest_parse(client->clientmgr->lwctx,
00045 b, &client->pkt, &req);
00046 if (result != LWRES_R_SUCCESS)
00047 goto send_error;
00048
00049 client->pkt.recvlength = LWRES_RECVLENGTH;
00050 client->pkt.authtype = 0;
00051 client->pkt.authlength = 0;
00052 client->pkt.result = LWRES_R_SUCCESS;
00053
00054 resp.datalength = req->datalength;
00055 resp.data = req->data;
00056
00057 lwres = lwres_noopresponse_render(client->clientmgr->lwctx, &resp,
00058 &client->pkt, &lwb);
00059 if (lwres != LWRES_R_SUCCESS)
00060 goto cleanup_req;
00061
00062 r.base = lwb.base;
00063 r.length = lwb.used;
00064 client->sendbuf = r.base;
00065 client->sendlength = r.length;
00066 result = ns_lwdclient_sendreply(client, &r);
00067 if (result != ISC_R_SUCCESS)
00068 goto cleanup_lwb;
00069
00070
00071
00072
00073 lwres_nooprequest_free(client->clientmgr->lwctx, &req);
00074
00075 NS_LWDCLIENT_SETSEND(client);
00076
00077 return;
00078
00079 cleanup_lwb:
00080 lwres_context_freemem(client->clientmgr->lwctx, lwb.base, lwb.length);
00081
00082 cleanup_req:
00083 lwres_nooprequest_free(client->clientmgr->lwctx, &req);
00084
00085 send_error:
00086 ns_lwdclient_errorpktsend(client, LWRES_R_FAILURE);
00087 }