|
Electroneum
|
#include "util/storage/lruhash.h"
Go to the source code of this file.
Macros | |
| #define | MAX_COMPRESS_PTRS 256 |
This file contains functions to deal with domain names (dnames).
Some of the functions deal with domain names as a wireformat buffer, with a length.
Definition in file dname.h.
| #define MAX_COMPRESS_PTRS 256 |
| int dname_buffer_write | ( | struct sldns_buffer * | pkt, |
| uint8_t * | dname | ||
| ) |
Copy over a valid dname to a packet.
| pkt | packet to copy to. |
| dname | dname to copy. |
Compare dnames, Canonical in rfc4034 sense, but by label. Such that zone contents follows zone apex.
| d1 | first dname. pointer to uncompressed wireformat. |
| labs1 | number of labels in first dname. |
| d2 | second dname. pointer to uncompressed wireformat. |
| labs2 | number of labels in second dname. |
| mlabs | number of labels that matched exactly (the shared topdomain). |
Canonical dname compare. Takes care of counting labels. Per rfc 4034 canonical order.
| d1 | first dname. pointer to uncompressed wireformat. |
| d2 | second dname. pointer to uncompressed wireformat. |
| int dname_count_labels | ( | uint8_t * | dname | ) |
Count the number of labels in an uncompressed dname in memory.
| dname | pointer to uncompressed dname. |
| int dname_count_size_labels | ( | uint8_t * | dname, |
| size_t * | size | ||
| ) |
Count labels and dname length both, for uncompressed dname in memory.
| dname | pointer to uncompressed dname. |
| size | length of dname, including root label. |
Get the shared topdomain between two names. Root "." or longer.
| d1 | first dname. pointer to uncompressed wireformat. |
| d2 | second dname. pointer to uncompressed wireformat. |
| int dname_is_root | ( | uint8_t * | dname | ) |
Returns true if the uncompressed wireformat dname is the root "."
| dname | the dname to check |
| int dname_is_wild | ( | uint8_t * | dname | ) |
Return true if the label is a wildcard, *.example.com.
| dname | valid uncompressed wireformat. |
Compare dnames, sorted not canonical, but by label. Such that zone contents follows zone apex.
| d1 | first dname. pointer to uncompressed wireformat. |
| labs1 | number of labels in first dname. |
| d2 | second dname. pointer to uncompressed wireformat. |
| labs2 | number of labels in second dname. |
| mlabs | number of labels that matched exactly (the shared topdomain). |
| int dname_lab_startswith | ( | uint8_t * | label, |
| char * | prefix, | ||
| char ** | endptr | ||
| ) |
Check if labels starts with given prefix
| label | dname label |
| prefix | the string to match label with, null terminated. |
| endptr | pointer to location in label after prefix, only if return value is 1. NULL if nothing in the label after the prefix, i.e. prefix and label are the same. |
| int dname_pkt_compare | ( | struct sldns_buffer * | pkt, |
| uint8_t * | d1, | ||
| uint8_t * | d2 | ||
| ) |
Compare dnames in packet (compressed). Dnames must be valid. routine performs lowercasing, so the packet casing is preserved.
| pkt | packet, used to resolve compression pointers. |
| d1 | dname to compare |
| d2 | dname to compare |
| void dname_pkt_copy | ( | struct sldns_buffer * | pkt, |
| uint8_t * | to, | ||
| uint8_t * | dname | ||
| ) |
Copy over a valid dname and decompress it.
| pkt | packet to resolve compression pointers. |
| to | buffer of size from pkt_len function to hold result. |
| dname | pointer into packet where dname starts. |
| hashvalue_type dname_pkt_hash | ( | struct sldns_buffer * | pkt, |
| uint8_t * | dname, | ||
| hashvalue_type | h | ||
| ) |
Hash dname, label by label, lowercasing, into hashvalue. Dname in pkt format (compressed).
| pkt | packet, for resolving compression pointers. |
| dname | dname to hash, pointer to the pkt buffer. Must be valid format. No loops, etc. |
| h | initial hash value. |
| void dname_print | ( | FILE * | out, |
| struct sldns_buffer * | pkt, | ||
| uint8_t * | dname | ||
| ) |
Debug helper. Print wireformat dname to output.
| out | like stdout or a file. |
| pkt | if not NULL, the packet for resolving compression ptrs. |
| dname | pointer to (start of) dname. |
| hashvalue_type dname_query_hash | ( | uint8_t * | dname, |
| hashvalue_type | h | ||
| ) |
Hash dname, label by label, lowercasing, into hashvalue. Dname in query format (not compressed).
| dname | dname to hash. |
| h | initial hash value. |
| void dname_remove_label | ( | uint8_t ** | dname, |
| size_t * | len | ||
| ) |
Snip off first label from a dname, returning the parent zone.
| dname | from what to strip off. uncompressed wireformat. |
| len | length, adjusted to become less. |
| void dname_remove_labels | ( | uint8_t ** | dname, |
| size_t * | len, | ||
| int | n | ||
| ) |
Snip off first N labels from a dname, returning the parent zone.
| dname | from what to strip off. uncompressed wireformat. |
| len | length, adjusted to become less. |
| n | number of labels to strip off (from the left). if 0, nothing happens. |
| int dname_signame_label_count | ( | uint8_t * | dname | ) |
Count labels for the RRSIG signature label field. Like a normal labelcount, but "*" wildcard and "." root are not counted.
| dname | valid uncompressed wireformat. |
| void dname_str | ( | uint8_t * | dname, |
| char * | str | ||
| ) |
Debug helper. Print dname to given string buffer (string buffer must be at least 255 chars + 1 for the 0, in printable form. This may lose information (? for nonprintable characters, or & if the name is too long, # for a bad label length).
| dname | uncompressed wireformat. |
| str | buffer of 255+1 length. |
See if domain name d1 is a strict subdomain of d2. That is a subdomain, but not equal.
| d1 | domain name, uncompressed wireformat |
| labs1 | number of labels in d1, including root label. |
| d2 | domain name, uncompressed wireformat |
| labs2 | number of labels in d2, including root label. |
Like dname_strict_subdomain but counts labels
| d1 | domain name, uncompressed wireformat |
| d2 | domain name, uncompressed wireformat |
Counts labels. Tests is d1 is a subdomain of d2.
| d1 | domain name, uncompressed wireformat |
| d2 | domain name, uncompressed wireformat |
| size_t dname_valid | ( | uint8_t * | dname, |
| size_t | len | ||
| ) |
Determine if dname in memory is correct. no compression ptrs allowed.
| dname | where dname starts in memory. |
| len | dname is not allowed to exceed this length (i.e. of allocation). |
| size_t pkt_dname_len | ( | struct sldns_buffer * | pkt | ) |
Determine correct, compressed, dname present in packet. Checks for parse errors.
| pkt | packet to read from (from current start position). |
| void pkt_dname_tolower | ( | struct sldns_buffer * | pkt, |
| uint8_t * | dname | ||
| ) |
lowercase pkt dname (follows compression pointers)
| pkt | the packet, used to follow compression pointers. Position is unchanged. |
| dname | start of dname in packet. |
Compare query dnames (uncompressed storage). The Dnames passed do not have to be lowercased, comparison routine does this.
This routine is special, in that the comparison that it does corresponds with the canonical comparison needed when comparing dnames inside rdata for RR types that need canonicalization. That means that the first byte that is smaller (possibly after lowercasing) makes an RR smaller, or the shortest name makes an RR smaller.
This routine does not compute the canonical order needed for NSEC processing.
Dnames have to be valid format.
| d1 | dname to compare |
| d2 | dname to compare |
| size_t query_dname_len | ( | struct sldns_buffer * | query | ) |
Determine length of dname in buffer, no compression ptrs allowed,
| query | the ldns buffer, current position at start of dname. at end, position is at end of the dname. |
| void query_dname_tolower | ( | uint8_t * | dname | ) |
lowercase query dname