Electroneum
Loading...
Searching...
No Matches
mesh.h
Go to the documentation of this file.
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
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright notice,
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
45
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;
63
68#define MESH_MAX_ACTIVATION 3000
69
75#define MESH_MAX_SUBSUB 1024
76
146
190
201
223
228typedef void (*mesh_cb_func_type)(void*, int, struct sldns_buffer*, enum sec_status,
229 char*);
230
253
254/* ------------------- Functions for worker -------------------- */
255
262struct mesh_area* mesh_create(struct module_stack* stack,
263 struct module_env* env);
264
269void mesh_delete(struct mesh_area* mesh);
270
287void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
288 struct respip_client_info* cinfo, uint16_t qflags,
289 struct edns_data* edns, struct comm_reply* rep, uint16_t qid);
290
306int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
307 uint16_t qflags, struct edns_data* edns, struct sldns_buffer* buf,
308 uint16_t qid, mesh_cb_func_type cb, void* cb_arg);
309
319void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo,
320 uint16_t qflags, time_t leeway);
321
332void mesh_report_reply(struct mesh_area* mesh, struct outbound_entry* e,
333 struct comm_reply* reply, int what);
334
335/* ------------------- Functions for module environment --------------- */
336
344void mesh_detach_subs(struct module_qstate* qstate);
345
370int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo,
371 uint16_t qflags, int prime, int valrec, struct module_qstate** newq);
372
398int mesh_add_sub(struct module_qstate* qstate, struct query_info* qinfo,
399 uint16_t qflags, int prime, int valrec, struct module_qstate** newq,
400 struct mesh_state** sub);
401
417void mesh_query_done(struct mesh_state* mstate);
418
430void mesh_walk_supers(struct mesh_area* mesh, struct mesh_state* mstate);
431
437void mesh_state_delete(struct module_qstate* qstate);
438
439/* ------------------- Functions for mesh -------------------- */
440
454 struct query_info* qinfo, struct respip_client_info* cinfo,
455 uint16_t qflags, int prime, int valrec);
456
464
471
478void mesh_state_cleanup(struct mesh_state* mstate);
479
484void mesh_delete_all(struct mesh_area* mesh);
485
499 struct respip_client_info* cinfo, struct query_info* qinfo,
500 uint16_t qflags, int prime, int valrec);
501
510int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub);
511
523int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
524 struct comm_reply* rep, uint16_t qid, uint16_t qflags,
525 const struct query_info* qinfo);
526
539int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
540 struct sldns_buffer* buf, mesh_cb_func_type cb, void* cb_arg,
541 uint16_t qid, uint16_t qflags);
542
552void mesh_run(struct mesh_area* mesh, struct mesh_state* mstate,
553 enum module_ev ev, struct outbound_entry* e);
554
560void mesh_stats(struct mesh_area* mesh, const char* str);
561
566void mesh_stats_clear(struct mesh_area* mesh);
567
572void mesh_log_list(struct mesh_area* mesh);
573
579size_t mesh_get_mem(struct mesh_area* mesh);
580
595int mesh_detect_cycle(struct module_qstate* qstate, struct query_info* qinfo,
596 uint16_t flags, int prime, int valrec);
597
599int mesh_state_compare(const void* ap, const void* bp);
600
602int mesh_state_ref_compare(const void* ap, const void* bp);
603
616int mesh_make_new_space(struct mesh_area* mesh, struct sldns_buffer* qbuf);
617
624void mesh_list_insert(struct mesh_state* m, struct mesh_state** fp,
625 struct mesh_state** lp);
626
633void mesh_list_remove(struct mesh_state* m, struct mesh_state** fp,
634 struct mesh_state** lp);
635
636#endif /* SERVICES_MESH_H */
void mesh_new_client(struct mesh_area *mesh, struct query_info *qinfo, struct respip_client_info *cinfo, uint16_t qflags, struct edns_data *edns, struct comm_reply *rep, uint16_t qid)
void mesh_list_insert(struct mesh_state *m, struct mesh_state **fp, struct mesh_state **lp)
int mesh_state_is_unique(struct mesh_state *mstate)
int mesh_new_callback(struct mesh_area *mesh, struct query_info *qinfo, uint16_t qflags, struct edns_data *edns, struct sldns_buffer *buf, uint16_t qid, mesh_cb_func_type cb, void *cb_arg)
size_t mesh_get_mem(struct mesh_area *mesh)
int mesh_state_add_reply(struct mesh_state *s, struct edns_data *edns, struct comm_reply *rep, uint16_t qid, uint16_t qflags, const struct query_info *qinfo)
int mesh_state_ref_compare(const void *ap, const void *bp)
int mesh_state_add_cb(struct mesh_state *s, struct edns_data *edns, struct sldns_buffer *buf, mesh_cb_func_type cb, void *cb_arg, uint16_t qid, uint16_t qflags)
int mesh_state_compare(const void *ap, const void *bp)
int mesh_detect_cycle(struct module_qstate *qstate, struct query_info *qinfo, uint16_t flags, int prime, int valrec)
void mesh_state_delete(struct module_qstate *qstate)
void mesh_stats(struct mesh_area *mesh, const char *str)
void mesh_delete_all(struct mesh_area *mesh)
void mesh_stats_clear(struct mesh_area *mesh)
void mesh_query_done(struct mesh_state *mstate)
int mesh_state_attachment(struct mesh_state *super, struct mesh_state *sub)
void mesh_state_make_unique(struct mesh_state *mstate)
struct mesh_state * mesh_area_find(struct mesh_area *mesh, struct respip_client_info *cinfo, struct query_info *qinfo, uint16_t qflags, int prime, int valrec)
struct mesh_state * mesh_state_create(struct module_env *env, struct query_info *qinfo, struct respip_client_info *cinfo, uint16_t qflags, int prime, int valrec)
void mesh_new_prefetch(struct mesh_area *mesh, struct query_info *qinfo, uint16_t qflags, time_t leeway)
int mesh_add_sub(struct module_qstate *qstate, struct query_info *qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate **newq, struct mesh_state **sub)
void mesh_list_remove(struct mesh_state *m, struct mesh_state **fp, struct mesh_state **lp)
void mesh_run(struct mesh_area *mesh, struct mesh_state *mstate, enum module_ev ev, struct outbound_entry *e)
struct mesh_area * mesh_create(struct module_stack *stack, struct module_env *env)
void mesh_delete(struct mesh_area *mesh)
int mesh_attach_sub(struct module_qstate *qstate, struct query_info *qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate **newq)
void mesh_walk_supers(struct mesh_area *mesh, struct mesh_state *mstate)
void mesh_report_reply(struct mesh_area *mesh, struct outbound_entry *e, struct comm_reply *reply, int what)
void mesh_log_list(struct mesh_area *mesh)
void mesh_state_cleanup(struct mesh_state *mstate)
int mesh_make_new_space(struct mesh_area *mesh, struct sldns_buffer *qbuf)
void(* mesh_cb_func_type)(void *, int, struct sldns_buffer *, enum sec_status, char *)
Definition mesh.h:228
void mesh_detach_subs(struct module_qstate *qstate)
module_ev
Definition module.h:536
sec_status
const char * buf
unsigned short uint16_t
Definition stdint.h:125
unsigned char uint8_t
Definition stdint.h:124
struct module_env * env
Definition mesh.h:84
size_t stats_jostled
Definition mesh.h:110
size_t num_forever_states
Definition mesh.h:102
struct timehist * histogram
Definition mesh.h:118
size_t num_reply_states
Definition mesh.h:96
size_t max_reply_states
Definition mesh.h:105
rbtree_type run
Definition mesh.h:87
struct mesh_state * forever_last
Definition mesh.h:136
struct timeval jostle_max
Definition mesh.h:144
struct timeval replies_sum_wait
Definition mesh.h:116
size_t ans_secure
Definition mesh.h:120
struct sldns_buffer * qbuf_bak
Definition mesh.h:130
rbtree_type all
Definition mesh.h:89
struct mesh_state * jostle_last
Definition mesh.h:142
struct mesh_state * forever_first
Definition mesh.h:134
size_t ans_bogus
Definition mesh.h:122
size_t max_forever_states
Definition mesh.h:107
size_t num_reply_addrs
Definition mesh.h:92
size_t stats_dropped
Definition mesh.h:112
size_t ans_nodata
Definition mesh.h:126
size_t ans_rcode[16]
Definition mesh.h:124
size_t num_detached_states
Definition mesh.h:100
size_t replies_sent
Definition mesh.h:114
struct mesh_state * jostle_first
Definition mesh.h:140
struct module_stack mods
Definition mesh.h:82
struct mesh_cb * next
Definition mesh.h:236
struct edns_data edns
Definition mesh.h:238
uint16_t qid
Definition mesh.h:240
void * cb_arg
Definition mesh.h:251
mesh_cb_func_type cb
Definition mesh.h:249
struct sldns_buffer * buf
Definition mesh.h:244
uint16_t qflags
Definition mesh.h:242
struct mesh_reply * next
Definition mesh.h:207
struct edns_data edns
Definition mesh.h:211
struct timeval start_time
Definition mesh.h:213
struct local_rrset * local_alias
Definition mesh.h:221
struct comm_reply query_reply
Definition mesh.h:209
uint16_t qflags
Definition mesh.h:217
uint8_t * qname
Definition mesh.h:219
uint16_t qid
Definition mesh.h:215
rbnode_type node
Definition mesh.h:197
struct mesh_state * s
Definition mesh.h:199
struct mesh_state * next
Definition mesh.h:180
struct module_qstate s
Definition mesh.h:163
struct mesh_cb * cb_list
Definition mesh.h:167
enum mesh_state::mesh_list_select list_select
rbnode_type run_node
Definition mesh.h:160
size_t num_activated
Definition mesh.h:175
struct mesh_reply * reply_list
Definition mesh.h:165
rbtree_type sub_set
Definition mesh.h:173
uint8_t replies_sent
Definition mesh.h:188
rbnode_type node
Definition mesh.h:158
struct mesh_state * unique
Definition mesh.h:185
rbtree_type super_set
Definition mesh.h:170
mesh_list_select
Definition mesh.h:182
@ mesh_no_list
Definition mesh.h:182
@ mesh_jostle_list
Definition mesh.h:183
@ mesh_forever_list
Definition mesh.h:182
struct mesh_state * prev
Definition mesh.h:178