20 #ifdef HAVE_NETINET_IN_H
21 #include <netinet/in.h>
23 #ifdef HAVE_SYS_SOCKET_H
24 #include <sys/socket.h>
29 #ifdef HAVE_ARPA_INET_H
30 #include <arpa/inet.h>
38 ldns_dname_last_label_is_root_label(
const ldns_rdf* dname)
43 for (src_pos = 0; src_pos <
ldns_rdf_size(dname); src_pos += len + 1) {
48 return src_pos > 0 && len == 0;
68 if (ldns_dname_last_label_is_root_label(rd1)) {
105 if (ldns_dname_last_label_is_root_label(rd1)) {
147 if (ldns_dname_last_label_is_root_label(dname)) {
148 buf[rd_size - 1] = 0;
151 for (src_pos = 0; src_pos < rd_size; src_pos += len + 1) {
153 memcpy(&buf[rd_size - src_pos - len - 1],
175 label_size = data[0] + 1;
177 if (data_size < label_size) {
181 data_size -= label_size;
238 while ((len > 0) && src_pos < r_size) {
323 if (sub_lab < par_lab) {
330 for (i = par_lab -1; i >= 0; i--) {
333 if (!tmp_sub || !tmp_par) {
361 size_t lc1, lc2, lc1f, lc2f;
370 if (!dname1 && !dname2) {
373 if (!dname1 || !dname2) {
386 if (lc1 == 0 && lc2 == 0) {
416 for (i = 1; i < (size_t)(*lp1 + 1); i++) {
437 if (lc1 == 0 && lc2 > 0) {
440 }
else if (lc1 > 0 && lc2 == 0) {
443 }
else if (lc1 == 0 && lc2 == 0) {
491 int prev_check, next_check;
502 if (next_check == 0) {
507 if ((prev_check == -1 || prev_check == 0) &&
521 if(dname_str && strcmp(dname_str,
".") == 0)
523 if(!dname_str || strlen(dname_str) < 2)
525 if(dname_str[strlen(dname_str) - 1] !=
'.')
527 if(dname_str[strlen(dname_str) - 2] !=
'\\')
530 for(s=dname_str; *s; s++) {
532 if(s[1] && s[2] && s[3]
533 && isdigit((
unsigned char)s[1])
534 && isdigit((
unsigned char)s[2])
535 && isdigit((
unsigned char)s[3]))
537 else if(!s[1] || isdigit((
unsigned char)s[1]))
541 else if(!*(s+1) && *s ==
'.')
578 while ((len > 0) && src_pos < s) {
579 if (labelcnt == labelpos) {
586 data[len + 2 - 1] = 0;
bool ldns_dname_str_absolute(const char *dname_str)
Checks whether the given dname string is absolute (i.e.
bool ldns_dname_absolute(const ldns_rdf *rdf)
Checks whether the given dname is absolute (i.e.
int ldns_dname_is_wildcard(const ldns_rdf *dname)
Check if dname is a wildcard, starts with *.
ldns_rdf * ldns_dname_cat_clone(const ldns_rdf *rd1, const ldns_rdf *rd2)
concatenates two dnames together
ldns_rdf * ldns_dname_new_frm_data(uint16_t size, const void *data)
Create a new dname rdf from data (the data is copied)
int ldns_dname_match_wildcard(const ldns_rdf *dname, const ldns_rdf *wildcard)
Checks whether the dname matches the given wildcard.
ldns_rdf * ldns_dname_clone_from(const ldns_rdf *d, uint16_t n)
Clones the given dname from the nth label on.
bool ldns_dname_is_subdomain(const ldns_rdf *sub, const ldns_rdf *parent)
test whether the name sub falls under parent (i.e.
int ldns_dname_compare(const ldns_rdf *dname1, const ldns_rdf *dname2)
Compares the two dname rdf's according to the algorithm for ordering in RFC4034 Section 6.
ldns_rdf * ldns_dname_reverse(const ldns_rdf *dname)
Returns a clone of the given dname with the labels reversed.
void ldns_dname2canonical(const ldns_rdf *rd)
Put a dname into canonical fmt - ie.
ldns_rdf * ldns_dname_left_chop(const ldns_rdf *d)
chop one label off the left side of a dname.
int ldns_dname_interval(const ldns_rdf *prev, const ldns_rdf *middle, const ldns_rdf *next)
check if middle lays in the interval defined by prev and next prev <= middle < next.
ldns_rdf * ldns_dname_new(uint16_t s, void *d)
Create a new dname rdf from a string.
uint8_t ldns_dname_label_count(const ldns_rdf *r)
count the number of labels inside a LDNS_RDF_DNAME type rdf.
ldns_status ldns_dname_cat(ldns_rdf *rd1, const ldns_rdf *rd2)
concatenates rd2 after rd1 (rd2 is copied, rd1 is modified)
ldns_rdf * ldns_dname_label(const ldns_rdf *rdf, uint8_t labelpos)
look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label.
ldns_rdf * ldns_dname_new_frm_str(const char *str)
creates a new dname rdf from a string.
#define LDNS_DNAME_NORMALIZE
enum ldns_enum_status ldns_status
char * ldns_rdf2str(const ldns_rdf *rdf)
Converts the data in the rdata field to presentation format and returns that as a char *.
Including this file will include all ldns files, and define some lookup tables.
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd)
returns the type of the rdf.
void ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type)
sets the size of the rdf.
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
ldns_rdf * ldns_rdf_new(ldns_rdf_type type, size_t size, void *data)
allocates a new rdf structure and fills it.
ldns_rdf * ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
creates a new rdf from a string.
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
void ldns_rdf_set_data(ldns_rdf *rd, void *data)
sets the size of the rdf.
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
void ldns_rdf_set_size(ldns_rdf *rd, size_t size)
sets the size of the rdf.
int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2)
compares two rdf's on their wire formats.
ldns_rdf * ldns_rdf_new_frm_data(ldns_rdf_type type, size_t size, const void *data)
allocates a new rdf structure and fills it.
@ LDNS_RDF_TYPE_DNAME
domain name
Resource record data field.
#define LDNS_MALLOC(type)
Memory management macros.
#define LDNS_XMALLOC(type, count)
#define LDNS_XREALLOC(ptr, type, count)