Go to the source code of this file.
Data Structures | |
struct | ldns_schwartzian_compare_struct |
Structure to do a Schwartzian-like transformation, for instance when sorting. More... | |
struct | ldns_struct_lookup_table |
A general purpose lookup table. More... | |
Macros | |
#define | dprintf(X, Y) fprintf(stderr, (X), (Y)) |
#define | LDNS_VERSION "1.6.16" |
#define | LDNS_REVISION ((1<<16)|(6<<8)|(16)) |
#define | INLINE static inline |
splint static inline workaround More... | |
#define | LDNS_MALLOC(type) LDNS_XMALLOC(type, 1) |
Memory management macros. More... | |
#define | LDNS_XMALLOC(type, count) ((type *) malloc((count) * sizeof(type))) |
#define | LDNS_CALLOC(type, count) ((type *) calloc((count), sizeof(type))) |
#define | LDNS_REALLOC(ptr, type) LDNS_XREALLOC((ptr), type, 1) |
#define | LDNS_XREALLOC(ptr, type, count) ((type *) realloc((ptr), (count) * sizeof(type))) |
#define | LDNS_FREE(ptr) do { free((ptr)); (ptr) = NULL; } while (0) |
#define | LDNS_DEP printf("DEPRECATED FUNCTION!\n"); |
Typedefs | |
typedef struct ldns_struct_lookup_table | ldns_lookup_table |
Functions | |
ldns_lookup_table * | ldns_lookup_by_name (ldns_lookup_table table[], const char *name) |
Looks up the table entry by name, returns NULL if not found. More... | |
ldns_lookup_table * | ldns_lookup_by_id (ldns_lookup_table table[], int id) |
Looks up the table entry by id, returns NULL if not found. More... | |
int | ldns_get_bit (uint8_t bits[], size_t index) |
Returns the value of the specified bit The bits are counted from left to right, so bit #0 is the left most bit. More... | |
int | ldns_get_bit_r (uint8_t bits[], size_t index) |
Returns the value of the specified bit The bits are counted from right to left, so bit #0 is the right most bit. More... | |
void | ldns_set_bit (uint8_t *byte, int bit_nr, signed char value) |
sets the specified bit in the specified byte to 1 if value is true, 0 if false The bits are counted from right to left, so bit #0 is the right most bit. More... | |
int | ldns_hexdigit_to_int (char ch) |
Returns the int value of the given (hex) digit. More... | |
char | ldns_int_to_hexdigit (int ch) |
Returns the char (hex) representation of the given int. More... | |
int | ldns_hexstring_to_data (uint8_t *data, const char *str) |
Converts a hex string to binary data. More... | |
const char * | ldns_version (void) |
Show the internal library version. More... | |
time_t | ldns_mktime_from_utc (const struct tm *tm) |
Convert TM to seconds since epoch (midnight, January 1st, 1970). More... | |
time_t | mktime_from_utc (const struct tm *tm) |
struct tm * | ldns_serial_arithmitics_gmtime_r (int32_t time, time_t now, struct tm *result) |
The function interprets time as the number of seconds since epoch with respect to now using serial arithmitics (rfc1982). More... | |
int | ldns_init_random (FILE *fd, unsigned int size) |
Seed the random function. More... | |
uint16_t | ldns_get_random (void) |
Get random number. More... | |
char * | ldns_bubblebabble (uint8_t *data, size_t len) |
Encode data as BubbleBabble. More... | |
int | ldns_b32_ntop (uint8_t const *src, size_t srclength, char *target, size_t targsize) |
int | b32_ntop (uint8_t const *src, size_t srclength, char *target, size_t targsize) |
int | ldns_b32_ntop_extended_hex (uint8_t const *src, size_t srclength, char *target, size_t targsize) |
int | b32_ntop_extended_hex (uint8_t const *src, size_t srclength, char *target, size_t targsize) |
int | ldns_b32_pton (char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize) |
int | b32_pton (char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize) |
int | ldns_b32_pton_extended_hex (char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize) |
int | b32_pton_extended_hex (char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize) |
#define LDNS_MALLOC | ( | type) | LDNS_XMALLOC(type, 1) |
#define LDNS_XMALLOC | ( | type, | |
count | |||
) | ((type *) malloc((count) * sizeof(type))) |
#define LDNS_CALLOC | ( | type, | |
count | |||
) | ((type *) calloc((count), sizeof(type))) |
#define LDNS_REALLOC | ( | ptr, | |
type | |||
) | LDNS_XREALLOC((ptr), type, 1) |
#define LDNS_XREALLOC | ( | ptr, | |
type, | |||
count | |||
) | ((type *) realloc((ptr), (count) * sizeof(type))) |
#define LDNS_FREE | ( | ptr) | do { free((ptr)); (ptr) = NULL; } while (0) |
typedef struct ldns_struct_lookup_table ldns_lookup_table |
ldns_lookup_table* ldns_lookup_by_name | ( | ldns_lookup_table | table[], |
const char * | name | ||
) |
Looks up the table entry by name, returns NULL if not found.
[in] | table | the lookup table to search in |
[in] | name | what to search for |
ldns_lookup_table* ldns_lookup_by_id | ( | ldns_lookup_table | table[], |
int | id | ||
) |
Looks up the table entry by id, returns NULL if not found.
[in] | table | the lookup table to search in |
[in] | id | what to search for |
int ldns_get_bit | ( | uint8_t | bits[], |
size_t | index | ||
) |
int ldns_get_bit_r | ( | uint8_t | bits[], |
size_t | index | ||
) |
void ldns_set_bit | ( | uint8_t * | byte, |
int | bit_nr, | ||
signed char | value | ||
) |
sets the specified bit in the specified byte to 1 if value is true, 0 if false The bits are counted from right to left, so bit #0 is the right most bit.
[in] | byte | the bit to set the bit in |
[in] | bit_nr | the bit to set (0 <= n <= 7) |
[in] | value | whether to set the bit to 1 or 0 |
int ldns_hexdigit_to_int | ( | char | ch) |
char ldns_int_to_hexdigit | ( | int | ch) |
int ldns_hexstring_to_data | ( | uint8_t * | data, |
const char * | str | ||
) |
Converts a hex string to binary data.
[out] | data | The binary result is placed here. At least strlen(str)/2 bytes should be allocated |
[in] | str | The hex string to convert. This string should not contain spaces |
Definition at line 174 of file util.c.
References ldns_hexdigit_to_int().
const char* ldns_version | ( | void | ) |
Show the internal library version.
Definition at line 196 of file util.c.
References LDNS_VERSION.
time_t ldns_mktime_from_utc | ( | const struct tm * | tm) |
time_t mktime_from_utc | ( | const struct tm * | tm) |
Definition at line 255 of file util.c.
References ldns_mktime_from_utc().
struct tm* ldns_serial_arithmitics_gmtime_r | ( | int32_t | time, |
time_t | now, | ||
struct tm * | result | ||
) |
The function interprets time as the number of seconds since epoch with respect to now using serial arithmitics (rfc1982).
That number of seconds is then converted to broken-out time information. This is especially usefull when converting the inception and expiration fields of RRSIG records.
[in] | time | number of seconds since epoch (midnight, January 1st, 1970) to be intepreted as a serial arithmitics number relative to now. |
[in] | now | number of seconds since epoch (midnight, January 1st, 1970) to which the time value is compared to determine the final value. |
[out] | result | the struct with the broken-out time information |
int ldns_init_random | ( | FILE * | fd, |
unsigned int | size | ||
) |
Seed the random function.
If the file descriptor is specified, the random generator is seeded with data from that file. If not, /dev/urandom is used.
applications should call this if they need entropy data within ldns If openSSL is available, it is automatically seeded from /dev/urandom or /dev/random.
If you need more entropy, or have no openssl available, this function MUST be called at the start of the program
If openssl is available, this function just adds more entropy
[in] | fd | a file providing entropy data for the seed |
[in] | size | the number of bytes to use as entropy data. If this is 0, only the minimal amount is taken (usually 4 bytes) |
Seed the random function.
If you need more entropy, or have no openssl available, this function MUST be called at the start of the program
If openssl is available, this function just adds more entropy
Definition at line 363 of file util.c.
References LDNS_FREE, and LDNS_XMALLOC.
uint16_t ldns_get_random | ( | void | ) |
char* ldns_bubblebabble | ( | uint8_t * | data, |
size_t | len | ||
) |
Encode data as BubbleBabble.
[in] | data | a pointer to data to be encoded |
[in] | len | size the number of bytes of data |
Definition at line 454 of file util.c.
References LDNS_XMALLOC.
int ldns_b32_ntop | ( | uint8_t const * | src, |
size_t | srclength, | ||
char * | target, | ||
size_t | targsize | ||
) |
int b32_ntop | ( | uint8_t const * | src, |
size_t | srclength, | ||
char * | target, | ||
size_t | targsize | ||
) |
int ldns_b32_ntop_extended_hex | ( | uint8_t const * | src, |
size_t | srclength, | ||
char * | target, | ||
size_t | targsize | ||
) |
int b32_ntop_extended_hex | ( | uint8_t const * | src, |
size_t | srclength, | ||
char * | target, | ||
size_t | targsize | ||
) |
int ldns_b32_pton | ( | char const * | src, |
size_t | hashed_owner_str_len, | ||
uint8_t * | target, | ||
size_t | targsize | ||
) |
int b32_pton | ( | char const * | src, |
size_t | hashed_owner_str_len, | ||
uint8_t * | target, | ||
size_t | targsize | ||
) |
int ldns_b32_pton_extended_hex | ( | char const * | src, |
size_t | hashed_owner_str_len, | ||
uint8_t * | target, | ||
size_t | targsize | ||
) |
int b32_pton_extended_hex | ( | char const * | src, |
size_t | hashed_owner_str_len, | ||
uint8_t * | target, | ||
size_t | targsize | ||
) |