mesh.h (256281) | mesh.h (269257) |
---|---|
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 | 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 LIMITED 25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. | 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" | 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; |
|
54struct mesh_state; 55struct mesh_reply; 56struct mesh_cb; 57struct query_info; 58struct reply_info; 59struct outbound_entry; 60struct timehist; 61 --- 58 unchanged lines hidden (view full) --- 120 size_t ans_bogus; 121 /** (extended stats) rcodes in replies */ 122 size_t ans_rcode[16]; 123 /** (extended stats) rcode nodata in replies */ 124 size_t ans_nodata; 125 126 /** backup of query if other operations recurse and need the 127 * network buffers */ | 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 */ |
128 ldns_buffer* qbuf_bak; | 129 struct sldns_buffer* qbuf_bak; |
129 130 /** double linked list of the run-to-completion query states. 131 * These are query states with a reply */ 132 struct mesh_state* forever_first; 133 /** last entry in run forever list */ 134 struct mesh_state* forever_last; 135 136 /** double linked list of the query states that can be jostled out --- 77 unchanged lines hidden (view full) --- 214 /** qname from this query. len same as mesh qinfo. */ 215 uint8_t* qname; 216}; 217 218/** 219 * Mesh result callback func. 220 * called as func(cb_arg, rcode, buffer_with_reply, security, why_bogus); 221 */ | 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 */ |
222typedef void (*mesh_cb_func_t)(void*, int, ldns_buffer*, enum sec_status, | 223typedef void (*mesh_cb_func_t)(void*, int, struct sldns_buffer*, enum sec_status, |
223 char*); 224 225/** 226 * Callback to result routine 227 */ 228struct mesh_cb { 229 /** next in list */ 230 struct mesh_cb* next; 231 /** edns data from query */ 232 struct edns_data edns; 233 /** id of query, in network byteorder. */ 234 uint16_t qid; 235 /** flags of query, for reply flags */ 236 uint16_t qflags; 237 /** buffer for reply */ | 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 */ |
238 ldns_buffer* buf; | 239 struct sldns_buffer* buf; |
239 240 /** callback routine for results. if rcode != 0 buf has message. 241 * called as cb(cb_arg, rcode, buf, sec_state); 242 */ 243 mesh_cb_func_t cb; 244 /** user arg for callback */ 245 void* cb_arg; 246}; --- 42 unchanged lines hidden (view full) --- 289 * @param edns: edns data from client query. 290 * @param buf: buffer for reply contents. 291 * @param qid: query id to reply with. 292 * @param cb: callback function. 293 * @param cb_arg: callback user arg. 294 * @return 0 on error. 295 */ 296int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo, | 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, |
297 uint16_t qflags, struct edns_data* edns, ldns_buffer* buf, | 298 uint16_t qflags, struct edns_data* edns, struct sldns_buffer* buf, |
298 uint16_t qid, mesh_cb_func_t cb, void* cb_arg); 299 300/** 301 * New prefetch message. Create new query state if needed. 302 * Will run the mesh area queries to process if a new query state is created. 303 * 304 * @param mesh: the mesh. 305 * @param qinfo: query from client. 306 * @param qflags: flags from client query. 307 * @param leeway: TTL leeway what to expire earlier for this update. 308 */ 309void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo, | 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, |
310 uint16_t qflags, uint32_t leeway); | 311 uint16_t qflags, time_t leeway); |
311 312/** 313 * Handle new event from the wire. A serviced query has returned. 314 * The query state will be made runnable, and the mesh_area will process 315 * query states until processing is complete. 316 * 317 * @param mesh: the query mesh. 318 * @param e: outbound entry, with query state to run and reply pointer. --- 149 unchanged lines hidden (view full) --- 468 * @param buf: buffer for reply 469 * @param cb: callback to call with results. 470 * @param cb_arg: callback user arg. 471 * @param qid: ID of reply. 472 * @param qflags: original query flags. 473 * @return: 0 on alloc error. 474 */ 475int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns, | 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, |
476 ldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg, uint16_t qid, | 477 struct sldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg, uint16_t qid, |
477 uint16_t qflags); 478 479/** 480 * Run the mesh. Run all runnable mesh states. Which can create new 481 * runnable mesh states. Until completion. Automatically called by 482 * mesh_report_reply and mesh_new_client as needed. 483 * @param mesh: mesh area. 484 * @param mstate: first mesh state to run. --- 58 unchanged lines hidden (view full) --- 543 * This buffer is necessary, because the following sequence in calls 544 * can result in an overwrite of the incoming query: 545 * delete_other_mesh_query - iter_clean - serviced_delete - waiting 546 * udp query is sent - on error callback - callback sends SERVFAIL reply 547 * over the same network channel, and shared UDP buffer is overwritten. 548 * You can pass NULL if there is no buffer that must be backed up. 549 * @return false if no space is available. 550 */ | 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 */ |
551int mesh_make_new_space(struct mesh_area* mesh, ldns_buffer* qbuf); | 552int mesh_make_new_space(struct mesh_area* mesh, struct sldns_buffer* qbuf); |
552 553/** 554 * Insert mesh state into a double linked list. Inserted at end. 555 * @param m: mesh state. 556 * @param fp: pointer to the first-elem-pointer of the list. 557 * @param lp: pointer to the last-elem-pointer of the list. 558 */ 559void mesh_list_insert(struct mesh_state* m, struct mesh_state** fp, --- 12 unchanged lines hidden --- | 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 --- |