dname isroot and dellabel

git-svn-id: file:///svn/unbound/trunk@492 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards
2007-08-06 11:06:00 +00:00
parent 44560e40ea
commit 4eaa855db9
6 changed files with 77 additions and 7 deletions
+24
View File
@@ -571,3 +571,27 @@ dname_subdomain_c(uint8_t* d1, uint8_t* d2)
}
return (m == labs2);
}
int
dname_is_root(uint8_t* dname)
{
uint8_t len;
log_assert(dname);
len = dname[0];
log_assert(!LABEL_IS_PTR(len));
return (len == 0);
}
void
dname_remove_label(uint8_t** dname, size_t* len)
{
size_t lablen;
log_assert(dname && *dname && len);
lablen = (*dname)[0];
log_assert(!LABEL_IS_PTR(lablen));
log_assert(*len > lablen);
if(lablen == 0)
return; /* do not modify root label */
*len -= lablen+1;
*dname += lablen+1;
}
+15
View File
@@ -207,4 +207,19 @@ void dname_print(FILE* out, ldns_buffer* pkt, uint8_t* dname);
*/
void dname_str(uint8_t* dname, char* str);
/**
* Returns true if the uncompressed wireformat dname is the root "."
* @param dname: the dname to check
* @return true if ".", false if not.
*/
int dname_is_root(uint8_t* dname);
/**
* Snip off first label from a dname, returning the parent zone.
* @param dname: from what to strip off. uncompressed wireformat.
* @param len: length, adjusted to become less.
* @return stripped off, or "." if input was ".".
*/
void dname_remove_label(uint8_t** dname, size_t* len);
#endif /* UTIL_DATA_DNAME_H */