xref: /freebsd/contrib/unbound/services/outbound_list.h (revision 24e365220007c415f495cf8dcb228ece6002b8b7)
1b7579f77SDag-Erling Smørgrav /*
2b7579f77SDag-Erling Smørgrav  * services/outbound_list.h - keep list of outbound serviced queries.
3b7579f77SDag-Erling Smørgrav  *
4b7579f77SDag-Erling Smørgrav  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5b7579f77SDag-Erling Smørgrav  *
6b7579f77SDag-Erling Smørgrav  * This software is open source.
7b7579f77SDag-Erling Smørgrav  *
8b7579f77SDag-Erling Smørgrav  * Redistribution and use in source and binary forms, with or without
9b7579f77SDag-Erling Smørgrav  * modification, are permitted provided that the following conditions
10b7579f77SDag-Erling Smørgrav  * are met:
11b7579f77SDag-Erling Smørgrav  *
12b7579f77SDag-Erling Smørgrav  * Redistributions of source code must retain the above copyright notice,
13b7579f77SDag-Erling Smørgrav  * this list of conditions and the following disclaimer.
14b7579f77SDag-Erling Smørgrav  *
15b7579f77SDag-Erling Smørgrav  * Redistributions in binary form must reproduce the above copyright notice,
16b7579f77SDag-Erling Smørgrav  * this list of conditions and the following disclaimer in the documentation
17b7579f77SDag-Erling Smørgrav  * and/or other materials provided with the distribution.
18b7579f77SDag-Erling Smørgrav  *
19b7579f77SDag-Erling Smørgrav  * Neither the name of the NLNET LABS nor the names of its contributors may
20b7579f77SDag-Erling Smørgrav  * be used to endorse or promote products derived from this software without
21b7579f77SDag-Erling Smørgrav  * specific prior written permission.
22b7579f77SDag-Erling Smørgrav  *
23b7579f77SDag-Erling Smørgrav  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2417d15b25SDag-Erling Smørgrav  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2517d15b25SDag-Erling Smørgrav  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2617d15b25SDag-Erling Smørgrav  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2717d15b25SDag-Erling Smørgrav  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2817d15b25SDag-Erling Smørgrav  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
2917d15b25SDag-Erling Smørgrav  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
3017d15b25SDag-Erling Smørgrav  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3117d15b25SDag-Erling Smørgrav  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3217d15b25SDag-Erling Smørgrav  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3317d15b25SDag-Erling Smørgrav  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34b7579f77SDag-Erling Smørgrav  */
35b7579f77SDag-Erling Smørgrav 
36b7579f77SDag-Erling Smørgrav /**
37b7579f77SDag-Erling Smørgrav  * \file
38b7579f77SDag-Erling Smørgrav  *
39b7579f77SDag-Erling Smørgrav  * This file contains functions to help a module keep track of the
40b7579f77SDag-Erling Smørgrav  * queries it has outstanding to authoritative servers.
41b7579f77SDag-Erling Smørgrav  */
42b7579f77SDag-Erling Smørgrav #ifndef SERVICES_OUTBOUND_LIST_H
43b7579f77SDag-Erling Smørgrav #define SERVICES_OUTBOUND_LIST_H
44b7579f77SDag-Erling Smørgrav struct outbound_entry;
45b7579f77SDag-Erling Smørgrav struct serviced_query;
46b7579f77SDag-Erling Smørgrav struct module_qstate;
47b7579f77SDag-Erling Smørgrav 
48b7579f77SDag-Erling Smørgrav /**
49b7579f77SDag-Erling Smørgrav  * The outbound list. This structure is part of the module specific query
50b7579f77SDag-Erling Smørgrav  * state.
51b7579f77SDag-Erling Smørgrav  */
52b7579f77SDag-Erling Smørgrav struct outbound_list {
53b7579f77SDag-Erling Smørgrav 	/** The linked list of outbound query entries. */
54b7579f77SDag-Erling Smørgrav 	struct outbound_entry* first;
55b7579f77SDag-Erling Smørgrav };
56b7579f77SDag-Erling Smørgrav 
57b7579f77SDag-Erling Smørgrav /**
58b7579f77SDag-Erling Smørgrav  * Outbound list entry. A serviced query sent by a module processing the
59b7579f77SDag-Erling Smørgrav  * query from the qstate. Double linked list to aid removal.
60b7579f77SDag-Erling Smørgrav  */
61b7579f77SDag-Erling Smørgrav struct outbound_entry {
62b7579f77SDag-Erling Smørgrav 	/** next in list */
63b7579f77SDag-Erling Smørgrav 	struct outbound_entry* next;
64b7579f77SDag-Erling Smørgrav 	/** prev in list */
65b7579f77SDag-Erling Smørgrav 	struct outbound_entry* prev;
66b7579f77SDag-Erling Smørgrav 	/** The query that was sent out */
67b7579f77SDag-Erling Smørgrav 	struct serviced_query* qsent;
68b7579f77SDag-Erling Smørgrav 	/** the module query state that sent it */
69b7579f77SDag-Erling Smørgrav 	struct module_qstate* qstate;
70b7579f77SDag-Erling Smørgrav };
71b7579f77SDag-Erling Smørgrav 
72b7579f77SDag-Erling Smørgrav /**
73b7579f77SDag-Erling Smørgrav  * Init the user allocated outbound list structure
74b7579f77SDag-Erling Smørgrav  * @param list: the list structure.
75b7579f77SDag-Erling Smørgrav  */
76b7579f77SDag-Erling Smørgrav void outbound_list_init(struct outbound_list* list);
77b7579f77SDag-Erling Smørgrav 
78b7579f77SDag-Erling Smørgrav /**
79b7579f77SDag-Erling Smørgrav  * Clear the user owner outbound list structure.
80b7579f77SDag-Erling Smørgrav  * Deletes serviced queries.
81b7579f77SDag-Erling Smørgrav  * @param list: the list structure. It is cleared, but the list struct itself
82*24e36522SCy Schubert  * 	is callers responsibility to delete.
83b7579f77SDag-Erling Smørgrav  */
84b7579f77SDag-Erling Smørgrav void outbound_list_clear(struct outbound_list* list);
85b7579f77SDag-Erling Smørgrav 
86b7579f77SDag-Erling Smørgrav /**
87b7579f77SDag-Erling Smørgrav  * Insert new entry into the list. Caller must allocate the entry with malloc.
88b7579f77SDag-Erling Smørgrav  * qstate and qsent are set by caller.
89b7579f77SDag-Erling Smørgrav  * @param list: the list to add to.
90b7579f77SDag-Erling Smørgrav  * @param e: entry to add, it is only half initialised at call start, fully
91b7579f77SDag-Erling Smørgrav  *	initialised at call end.
92b7579f77SDag-Erling Smørgrav  */
93b7579f77SDag-Erling Smørgrav void outbound_list_insert(struct outbound_list* list,
94b7579f77SDag-Erling Smørgrav 	struct outbound_entry* e);
95b7579f77SDag-Erling Smørgrav 
96b7579f77SDag-Erling Smørgrav /**
97b7579f77SDag-Erling Smørgrav  * Remove an entry from the list, and deletes it.
98b7579f77SDag-Erling Smørgrav  * Deletes serviced query in the entry.
99b7579f77SDag-Erling Smørgrav  * @param list: the list to remove from.
100b7579f77SDag-Erling Smørgrav  * @param e: the entry to remove.
101b7579f77SDag-Erling Smørgrav  */
102b7579f77SDag-Erling Smørgrav void outbound_list_remove(struct outbound_list* list,
103b7579f77SDag-Erling Smørgrav 	struct outbound_entry* e);
104b7579f77SDag-Erling Smørgrav 
105b7579f77SDag-Erling Smørgrav #endif /* SERVICES_OUTBOUND_LIST_H */
106