Electroneum
dname.h
Go to the documentation of this file.
1 /*
2  * util/data/dname.h - domain name routines
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 #ifndef UTIL_DATA_DNAME_H
46 #define UTIL_DATA_DNAME_H
47 #include "util/storage/lruhash.h"
48 struct sldns_buffer;
49 
51 #define MAX_COMPRESS_PTRS 256
52 
59 size_t query_dname_len(struct sldns_buffer* query);
60 
67 size_t dname_valid(uint8_t* dname, size_t len);
68 
70 void query_dname_tolower(uint8_t* dname);
71 
78 void pkt_dname_tolower(struct sldns_buffer* pkt, uint8_t* dname);
79 
99 int query_dname_compare(uint8_t* d1, uint8_t* d2);
100 
110 size_t pkt_dname_len(struct sldns_buffer* pkt);
111 
121 int dname_pkt_compare(struct sldns_buffer* pkt, uint8_t* d1, uint8_t* d2);
122 
131 
143  hashvalue_type h);
144 
151 void dname_pkt_copy(struct sldns_buffer* pkt, uint8_t* to, uint8_t* dname);
152 
159 int dname_buffer_write(struct sldns_buffer* pkt, uint8_t* dname);
160 
166 int dname_count_labels(uint8_t* dname);
167 
174 int dname_count_size_labels(uint8_t* dname, size_t* size);
175 
186 int dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs);
187 
197 int dname_lab_startswith(uint8_t* label, char* prefix, char** endptr);
198 
208 int dname_strict_subdomain(uint8_t* d1, int labs1, uint8_t* d2, int labs2);
209 
217 
224 int dname_subdomain_c(uint8_t* d1, uint8_t* d2);
225 
232 void dname_print(FILE* out, struct sldns_buffer* pkt, uint8_t* dname);
233 
242 void dname_str(uint8_t* dname, char* str);
243 
249 int dname_is_root(uint8_t* dname);
250 
257 void dname_remove_label(uint8_t** dname, size_t* len);
258 
267 void dname_remove_labels(uint8_t** dname, size_t* len, int n);
268 
276 
282 int dname_is_wild(uint8_t* dname);
283 
295 int dname_canon_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2,
296  int* mlabs);
297 
307 
315 
316 #endif /* UTIL_DATA_DNAME_H */
hashvalue_type dname_pkt_hash(struct sldns_buffer *pkt, uint8_t *dname, hashvalue_type h)
void dname_print(FILE *out, struct sldns_buffer *pkt, uint8_t *dname)
int dname_canon_lab_cmp(uint8_t *d1, int labs1, uint8_t *d2, int labs2, int *mlabs)
int query_dname_compare(uint8_t *d1, uint8_t *d2)
int dname_pkt_compare(struct sldns_buffer *pkt, uint8_t *d1, uint8_t *d2)
hashvalue_type dname_query_hash(uint8_t *dname, hashvalue_type h)
uint8_t * dname_get_shared_topdomain(uint8_t *d1, uint8_t *d2)
size_t dname_valid(uint8_t *dname, size_t len)
int dname_strict_subdomain_c(uint8_t *d1, uint8_t *d2)
unsigned char uint8_t
Definition: stdint.h:124
int dname_lab_startswith(uint8_t *label, char *prefix, char **endptr)
void dname_str(uint8_t *dname, char *str)
int dname_subdomain_c(uint8_t *d1, uint8_t *d2)
void dname_remove_label(uint8_t **dname, size_t *len)
void dname_remove_labels(uint8_t **dname, size_t *len, int n)
void pkt_dname_tolower(struct sldns_buffer *pkt, uint8_t *dname)
int dname_canonical_compare(uint8_t *d1, uint8_t *d2)
uint32_t hashvalue_type
Definition: lruhash.h:119
int dname_is_root(uint8_t *dname)
int dname_buffer_write(struct sldns_buffer *pkt, uint8_t *dname)
int dname_count_labels(uint8_t *dname)
void dname_pkt_copy(struct sldns_buffer *pkt, uint8_t *to, uint8_t *dname)
size_t pkt_dname_len(struct sldns_buffer *pkt)
void query_dname_tolower(uint8_t *dname)
size_t query_dname_len(struct sldns_buffer *query)
int dname_signame_label_count(uint8_t *dname)
int dname_is_wild(uint8_t *dname)
int dname_strict_subdomain(uint8_t *d1, int labs1, uint8_t *d2, int labs2)
int dname_lab_cmp(uint8_t *d1, int labs1, uint8_t *d2, int labs2, int *mlabs)
int dname_count_size_labels(uint8_t *dname, size_t *size)