"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/bin/named/lwderror.c" (7 Sep 2020, 2173 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "lwderror.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 /* $Id: lwderror.c,v 1.12 2007/06/19 23:46:59 tbox Exp $ */
   13 
   14 /*! \file */
   15 
   16 #include <config.h>
   17 
   18 #include <isc/socket.h>
   19 #include <isc/util.h>
   20 
   21 #include <named/types.h>
   22 #include <named/lwdclient.h>
   23 
   24 /*%
   25  * Generate an error packet for the client, schedule a send, and put us in
   26  * the SEND state.
   27  *
   28  * The client->pkt structure will be modified to form an error return.
   29  * The receiver needs to verify that it is in fact an error, and do the
   30  * right thing with it.  The opcode will be unchanged.  The result needs
   31  * to be set before calling this function.
   32  *
   33  * The only change this code makes is to set the receive buffer size to the
   34  * size we use, set the reply bit, and recompute any security information.
   35  */
   36 void
   37 ns_lwdclient_errorpktsend(ns_lwdclient_t *client, uint32_t _result) {
   38     isc_result_t result;
   39     int lwres;
   40     isc_region_t r;
   41     lwres_buffer_t b;
   42 
   43     REQUIRE(NS_LWDCLIENT_ISRUNNING(client));
   44 
   45     /*
   46      * Since we are only sending the packet header, we can safely toss
   47      * the receive buffer.  This means we won't need to allocate space
   48      * for sending an error reply.  This is a Good Thing.
   49      */
   50     client->pkt.length = LWRES_LWPACKET_LENGTH;
   51     client->pkt.pktflags |= LWRES_LWPACKETFLAG_RESPONSE;
   52     client->pkt.recvlength = LWRES_RECVLENGTH;
   53     client->pkt.authtype = 0; /* XXXMLG */
   54     client->pkt.authlength = 0;
   55     client->pkt.result = _result;
   56 
   57     lwres_buffer_init(&b, client->buffer, LWRES_RECVLENGTH);
   58     lwres = lwres_lwpacket_renderheader(&b, &client->pkt);
   59     if (lwres != LWRES_R_SUCCESS) {
   60         ns_lwdclient_stateidle(client);
   61         return;
   62     }
   63 
   64     r.base = client->buffer;
   65     r.length = b.used;
   66     client->sendbuf = client->buffer;
   67     result = ns_lwdclient_sendreply(client, &r);
   68     if (result != ISC_R_SUCCESS) {
   69         ns_lwdclient_stateidle(client);
   70         return;
   71     }
   72 
   73     NS_LWDCLIENT_SETSEND(client);
   74 }