/usr/include/libknot/processing/requestor.h is in libknot-dev 2.1.1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | /* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <sys/socket.h>
#include <sys/time.h>
#include "libknot/processing/overlay.h"
#include "libknot/rrtype/tsig.h"
#include "libknot/mm_ctx.h"
struct knot_request;
/* Requestor flags. */
enum {
KNOT_RQ_UDP = 1 << 0 /* Use UDP for requests. */
};
/*! \brief Requestor structure.
*
* Requestor holds a FIFO of pending queries.
*/
struct knot_requestor {
knot_mm_t *mm; /*!< Memory context. */
void *pending; /*!< Pending requests (FIFO). */
struct knot_overlay overlay; /*!< Response processing overlay. */
};
/*! \brief Request data (socket, payload, response, TSIG and endpoints). */
struct knot_request {
int fd;
unsigned flags;
struct sockaddr_storage remote, origin;
knot_sign_context_t sign;
knot_pkt_t *query;
knot_pkt_t *resp;
};
/*!
* \brief Make request out of endpoints and query.
*
* \param mm Memory context.
* \param dst Remote endpoint address.
* \param src Source address (or NULL).
* \param query Query message.
* \param flags Request flags.
*
* \return Prepared request or NULL in case of error.
*/
struct knot_request *knot_request_make(knot_mm_t *mm,
const struct sockaddr *dst,
const struct sockaddr *src,
knot_pkt_t *query,
unsigned flags);
/*!
* \brief Free request and associated data.
*
* \param request Freed request.
* \param mm Memory context.
*/
void knot_request_free(struct knot_request *request, knot_mm_t *mm);
/*!
* \brief Initialize requestor structure.
*
* \param requestor Requestor instance.
* \param mm Memory context.
*
* \return KNOT_EOK or error
*/
int knot_requestor_init(struct knot_requestor *requestor, knot_mm_t *mm);
/*!
* \brief Clear the requestor structure and close pending queries.
*
* \param requestor Requestor instance.
*/
void knot_requestor_clear(struct knot_requestor *requestor);
/*!
* \brief Return true if there are no pending queries.
*
* \param requestor Requestor instance.
*/
bool knot_requestor_finished(struct knot_requestor *requestor);
/*!
* \brief Add a processing layer.
*
* \param requestor Requestor instance.
* \param proc Response processing module.
* \param param Processing module parameters.
*/
int knot_requestor_overlay(struct knot_requestor *requestor,
const knot_layer_api_t *proc, void *param);
/*!
* \brief Enqueue a query for processing.
*
* \note This function asynchronously creates a new connection to remote, but
* it does not send any data until requestor_exec().
*
* \param requestor Requestor instance.
* \param request Prepared request.
*
* \return KNOT_EOK or error
*/
int knot_requestor_enqueue(struct knot_requestor *requestor,
struct knot_request *request);
/*!
* \brief Close first pending request.
*
* \param requestor Requestor instance.
*
* \return KNOT_EOK or error
*/
int knot_requestor_dequeue(struct knot_requestor *requestor);
/*!
* \brief Execute next pending query (FIFO).
*
* \param requestor Requestor instance.
* \param timeout_ms Timeout of each operation in miliseconds (-1 for infinity).
*
* \return KNOT_EOK or error
*/
int knot_requestor_exec(struct knot_requestor *requestor, int timeout_ms);
|