Deleted Added
sdiff udiff text old ( 256281 ) new ( 269257 )
full compact
1/*
2 * services/mesh.h - deal with mesh of query states and handle events for that.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 7 unchanged lines hidden (view full) ---

16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * This file contains functions to assist in dealing with a mesh of
40 * query states. This mesh is supposed to be thread-specific.
41 * It consists of query states (per qname, qtype, qclass) and connections

--- 4 unchanged lines hidden (view full) ---

46#ifndef SERVICES_MESH_H
47#define SERVICES_MESH_H
48
49#include "util/rbtree.h"
50#include "util/netevent.h"
51#include "util/data/msgparse.h"
52#include "util/module.h"
53#include "services/modstack.h"
54struct sldns_buffer;
55struct mesh_state;
56struct mesh_reply;
57struct mesh_cb;
58struct query_info;
59struct reply_info;
60struct outbound_entry;
61struct timehist;
62

--- 58 unchanged lines hidden (view full) ---

121 size_t ans_bogus;
122 /** (extended stats) rcodes in replies */
123 size_t ans_rcode[16];
124 /** (extended stats) rcode nodata in replies */
125 size_t ans_nodata;
126
127 /** backup of query if other operations recurse and need the
128 * network buffers */
129 struct sldns_buffer* qbuf_bak;
130
131 /** double linked list of the run-to-completion query states.
132 * These are query states with a reply */
133 struct mesh_state* forever_first;
134 /** last entry in run forever list */
135 struct mesh_state* forever_last;
136
137 /** double linked list of the query states that can be jostled out

--- 77 unchanged lines hidden (view full) ---

215 /** qname from this query. len same as mesh qinfo. */
216 uint8_t* qname;
217};
218
219/**
220 * Mesh result callback func.
221 * called as func(cb_arg, rcode, buffer_with_reply, security, why_bogus);
222 */
223typedef void (*mesh_cb_func_t)(void*, int, struct sldns_buffer*, enum sec_status,
224 char*);
225
226/**
227 * Callback to result routine
228 */
229struct mesh_cb {
230 /** next in list */
231 struct mesh_cb* next;
232 /** edns data from query */
233 struct edns_data edns;
234 /** id of query, in network byteorder. */
235 uint16_t qid;
236 /** flags of query, for reply flags */
237 uint16_t qflags;
238 /** buffer for reply */
239 struct sldns_buffer* buf;
240
241 /** callback routine for results. if rcode != 0 buf has message.
242 * called as cb(cb_arg, rcode, buf, sec_state);
243 */
244 mesh_cb_func_t cb;
245 /** user arg for callback */
246 void* cb_arg;
247};

--- 42 unchanged lines hidden (view full) ---

290 * @param edns: edns data from client query.
291 * @param buf: buffer for reply contents.
292 * @param qid: query id to reply with.
293 * @param cb: callback function.
294 * @param cb_arg: callback user arg.
295 * @return 0 on error.
296 */
297int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
298 uint16_t qflags, struct edns_data* edns, struct sldns_buffer* buf,
299 uint16_t qid, mesh_cb_func_t cb, void* cb_arg);
300
301/**
302 * New prefetch message. Create new query state if needed.
303 * Will run the mesh area queries to process if a new query state is created.
304 *
305 * @param mesh: the mesh.
306 * @param qinfo: query from client.
307 * @param qflags: flags from client query.
308 * @param leeway: TTL leeway what to expire earlier for this update.
309 */
310void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo,
311 uint16_t qflags, time_t leeway);
312
313/**
314 * Handle new event from the wire. A serviced query has returned.
315 * The query state will be made runnable, and the mesh_area will process
316 * query states until processing is complete.
317 *
318 * @param mesh: the query mesh.
319 * @param e: outbound entry, with query state to run and reply pointer.

--- 149 unchanged lines hidden (view full) ---

469 * @param buf: buffer for reply
470 * @param cb: callback to call with results.
471 * @param cb_arg: callback user arg.
472 * @param qid: ID of reply.
473 * @param qflags: original query flags.
474 * @return: 0 on alloc error.
475 */
476int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
477 struct sldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg, uint16_t qid,
478 uint16_t qflags);
479
480/**
481 * Run the mesh. Run all runnable mesh states. Which can create new
482 * runnable mesh states. Until completion. Automatically called by
483 * mesh_report_reply and mesh_new_client as needed.
484 * @param mesh: mesh area.
485 * @param mstate: first mesh state to run.

--- 58 unchanged lines hidden (view full) ---

544 * This buffer is necessary, because the following sequence in calls
545 * can result in an overwrite of the incoming query:
546 * delete_other_mesh_query - iter_clean - serviced_delete - waiting
547 * udp query is sent - on error callback - callback sends SERVFAIL reply
548 * over the same network channel, and shared UDP buffer is overwritten.
549 * You can pass NULL if there is no buffer that must be backed up.
550 * @return false if no space is available.
551 */
552int mesh_make_new_space(struct mesh_area* mesh, struct sldns_buffer* qbuf);
553
554/**
555 * Insert mesh state into a double linked list. Inserted at end.
556 * @param m: mesh state.
557 * @param fp: pointer to the first-elem-pointer of the list.
558 * @param lp: pointer to the last-elem-pointer of the list.
559 */
560void mesh_list_insert(struct mesh_state* m, struct mesh_state** fp,

--- 12 unchanged lines hidden ---