summaryrefslogtreecommitdiff
path: root/src/libknot/packet/query.h
blob: b99ca1a5a2d38d1a2bb0a91615e580ef95ccf5cc (plain)
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
/*!
 * \file query.h
 *
 * \author Lubos Slovak <lubos.slovak@nic.cz>
 *
 * \brief API for manipulating queries.
 *
 * \addtogroup libknot
 * @{
 */
/*  Copyright (C) 2011 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/>.
 */

#ifndef _KNOT_QUERY_H_
#define _KNOT_QUERY_H_

#include <stdint.h>
#include <string.h>

#include "libknot/packet/packet.h"
#include "libknot/dname.h"
#include "libknot/rrset.h"
#include "libknot/edns.h"

/*----------------------------------------------------------------------------*/
/*!
 * \brief Checks if DNSSEC was requested in the query (i.e. the DO bit was set).
 *
 * \param query Packet where the parsed query is stored.
 *
 * \retval 0 if the DO bit was not set in the query, or the query is not yet
 *         parsed.
 * \retval > 0 if DO bit was set in the query.
 */
int knot_query_dnssec_requested(const knot_packet_t *query);

/*!
 * \brief Checks if NSID was requested in the query (i.e. the NSID option was
 *        present in the query OPT RR).
 *
 * \param query Packet where the parsed query is stored.
 *
 * \retval 0 if the NSID option was not present in the query, or the query is
 *         not yet parsed.
 * \retval > 0 if the NSID option was present in the query.
 */
int knot_query_nsid_requested(const knot_packet_t *query);

int knot_query_edns_supported(const knot_packet_t *query);

int knot_query_init(knot_packet_t *query);

int knot_query_set_question(knot_packet_t *query,
                            const knot_dname_t *qname,
                            uint16_t qclass, uint16_t qtype);

int knot_query_set_opcode(knot_packet_t *query, uint8_t opcode);

/*!
 * \brief Adds a RRSet to the Authority section of the query.
 *
 * \param query Query to add the RRSet into.
 * \param rrset RRSet to be added.
 *
 * \retval KNOT_EOK if successful, or the RRSet was already in the query.
 * \retval KNOT_ENOMEM
 * \retval KNOT_ESPACE
 */
int knot_query_add_rrset_authority(knot_packet_t *query,
                                   const knot_rrset_t *rrset);

#endif /* _KNOT_QUERY_H_ */

/*! @} */