The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
dns.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /** Functions to manipulate DNS labels
19  *
20  * @file src/lib/util/dns.h
21  *
22  * @copyright 2019 Network RADIUS SAS (legal@networkradius.com)
23  */
24 RCSIDH(dns_h, "$Id: ab003f0832b6ac2f452ddf8a12355e0221014a4d $")
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct {
34 
35 typedef struct {
36  uint8_t const *start; //!< start of packet
37  uint8_t const *end; //!< end of the packet
38  uint8_t *mark; //!< markup buffer used for decoding.
39  int num; //!< number of used labels
40  int max; //! maximum number of labels
41  fr_dns_block_t *blocks; //!< array holding "max" labels
43 
44 ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buflen, uint8_t *where, bool compression, fr_value_box_t const *value, fr_dns_labels_t *lb);
45 
47 
48 ssize_t fr_dns_label_uncompressed_length(uint8_t const *packet, uint8_t const *buf, size_t buf_len, uint8_t const **p_label, fr_dns_labels_t *lb);
49 
50 ssize_t fr_dns_labels_network_verify(uint8_t const *packet, uint8_t const *buf, size_t buf_len, uint8_t const *start, fr_dns_labels_t *lb) CC_HINT(nonnull(1,2,4));
51 
53  uint8_t const *src, size_t len, uint8_t const *label,
54  bool tainted, fr_dns_labels_t *lb);
55 
56 #ifdef __cplusplus
57 }
58 #endif
#define RCSIDH(h, id)
Definition: build.h:445
Test enumeration values.
Definition: dict_test.h:92
ssize_t fr_dns_label_uncompressed_length(uint8_t const *packet, uint8_t const *buf, size_t buf_len, uint8_t const **p_label, fr_dns_labels_t *lb)
Get the uncompressed length of a DNS label in a network buffer.
Definition: dns.c:884
ssize_t fr_dns_label_from_value_box_dbuff(fr_dbuff_t *dbuff, bool compression, fr_value_box_t const *value, fr_dns_labels_t *lb)
Encode a single value box of type string, serializing its contents to a dns label in a dbuff.
Definition: dns.c:604
ssize_t fr_dns_label_from_value_box(size_t *need, uint8_t *buf, size_t buflen, uint8_t *where, bool compression, fr_value_box_t const *value, fr_dns_labels_t *lb)
Encode a single value box of type string, serializing its contents to a dns label.
Definition: dns.c:639
uint16_t start
Definition: dns.h:31
uint8_t const * start
start of packet
Definition: dns.h:36
uint8_t const * end
end of the packet
Definition: dns.h:37
ssize_t fr_dns_label_to_value_box(TALLOC_CTX *ctx, fr_value_box_t *dst, uint8_t const *src, size_t len, uint8_t const *label, bool tainted, fr_dns_labels_t *lb)
Decode a fr_value_box_t from one DNS label.
Definition: dns.c:1225
fr_dns_block_t * blocks
maximum number of labels
Definition: dns.h:41
uint8_t * mark
markup buffer used for decoding.
Definition: dns.h:38
uint16_t end
Definition: dns.h:32
int max
Definition: dns.h:40
int num
number of used labels
Definition: dns.h:39
ssize_t fr_dns_labels_network_verify(uint8_t const *packet, uint8_t const *buf, size_t buf_len, uint8_t const *start, fr_dns_labels_t *lb))
Verify that a network buffer contains valid DNS labels.
Definition: dns.c:1137
unsigned short uint16_t
Definition: merged_model.c:31
long int ssize_t
Definition: merged_model.c:24
unsigned char uint8_t
Definition: merged_model.c:30
int nonnull(2, 5))