提交 85602f9b authored 作者: Jeff Lenk's avatar Jeff Lenk

add win ldns project for vs2010

上级 294b0779
差异被折叠。
差异被折叠。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\ldns\compat\b32_ntop.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\b32_pton.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\b64_ntop.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\b64_pton.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\buffer.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\ctime_r.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\dname.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\dnssec.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\dnssec_sign.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\dnssec_verify.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\dnssec_zone.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\error.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\fake-rfc2553.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\gettimeofday.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\gmtime_r.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\higher.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\host2str.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\host2wire.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\inet_aton.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\inet_ntop.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\inet_pton.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\isblank.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\keys.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\linktest.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\malloc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\memmove.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\net.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\packet.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\parse.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\rbtree.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\rdata.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\realloc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\resolver.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\rr.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\rr_functions.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\sha1.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\sha2.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\snprintf.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\str2host.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\strlcpy.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\compat\timegm.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\tsig.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\update.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\util.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\wire2host.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ldns\zone.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\ldns\compat\fake-rfc2553.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\compat\gettimeofday.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\buffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\dname.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\dnssec.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\dnssec_sign.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\dnssec_verify.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\dnssec_zone.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\error.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\higher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\host2str.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\host2wire.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\keys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\ldns.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\net.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\packet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\parse.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\rbtree.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\rdata.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\resolver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\rr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\rr_functions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\sha1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\sha2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\str2host.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\tsig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\update.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\util.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\ldns\ldns\zone.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ldns\util.h.in">
<Filter>Header Files</Filter>
</None>
<None Include="ldns\readme.txt" />
</ItemGroup>
</Project>
\ No newline at end of file
/*
* net.h
*
* DNS Resolver definitions
*
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2005-2006
*
* See the file LICENSE for the license
*/
#ifndef LDNS_NET_H
#define LDNS_NET_H
#include <ldns/ldns.h>
#ifdef _MSC_VER
#include <winsock2.h>
#define socklen_t int
#define in_port_t USHORT
#define in_addr_t UINT
#else
#include <sys/socket.h>
#include <netdb.h>
#endif
#define LDNS_DEFAULT_TIMEOUT_SEC 2
#define LDNS_DEFAULT_TIMEOUT_USEC 0
/**
* \file
*
* Contains functions to send and receive packets over a network.
*/
/**
* Sends a buffer to an ip using udp and return the respons as a ldns_pkt
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout the timeout value for the network
* \param[out] answersize size of the packet
* \param[out] result packet with the answer
* \return status
*/
ldns_status ldns_udp_send(uint8_t **result, ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout, size_t *answersize);
/**
* Send an udp query and don't wait for an answer but return
* the socket
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout the timeout value for the network
* \return the socket used
*/
int ldns_udp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
/**
* Send an tcp query and don't wait for an answer but return
* the socket
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout the timeout value for the network
* \return the socket used
*/
int ldns_tcp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
/**
* Sends a buffer to an ip using tcp and return the respons as a ldns_pkt
* \param[in] qbin the ldns_buffer to be send
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout the timeout value for the network
* \param[out] answersize size of the packet
* \param[out] result packet with the answer
* \return status
*/
ldns_status ldns_tcp_send(uint8_t **result, ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout, size_t *answersize);
/**
* Sends ptk to the nameserver at the resolver object. Returns the data
* as a ldns_pkt
*
* \param[out] pkt packet received from the nameserver
* \param[in] r the resolver to use
* \param[in] query_pkt the query to send
* \return status
*/
ldns_status ldns_send(ldns_pkt **pkt, ldns_resolver *r, const ldns_pkt *query_pkt);
/**
* Sends and ldns_buffer (presumably containing a packet to the nameserver at the resolver object. Returns the data
* as a ldns_pkt
*
* \param[out] pkt packet received from the nameserver
* \param[in] r the resolver to use
* \param[in] qb the buffer to send
* \param[in] tsig_mac the tsig MAC to authenticate the response with (NULL to do no TSIG authentication)
* \return status
*/
ldns_status ldns_send_buffer(ldns_pkt **pkt, ldns_resolver *r, ldns_buffer *qb, ldns_rdf *tsig_mac);
/**
* Create a tcp socket to the specified address
* \param[in] to ip and family
* \param[in] tolen length of to
* \param[in] timeout timeout for the socket
* \return a socket descriptor
*/
int ldns_tcp_connect(const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
/**
* Create a udp socket to the specified address
* \param[in] to ip and family
* \param[in] timeout timeout for the socket
* \return a socket descriptor
*/
int ldns_udp_connect(const struct sockaddr_storage *to, struct timeval timeout);
/**
* send a query via tcp to a server. Don't want for the answer
*
* \param[in] qbin the buffer to send
* \param[in] sockfd the socket to use
* \param[in] to which ip to send it
* \param[in] tolen socketlen
* \return number of bytes sent
*/
ssize_t ldns_tcp_send_query(ldns_buffer *qbin, int sockfd, const struct sockaddr_storage *to, socklen_t tolen);
/**
* send a query via udp to a server. Don;t want for the answer
*
* \param[in] qbin the buffer to send
* \param[in] sockfd the socket to use
* \param[in] to which ip to send it
* \param[in] tolen socketlen
* \return number of bytes sent
*/
ssize_t ldns_udp_send_query(ldns_buffer *qbin, int sockfd, const struct sockaddr_storage *to, socklen_t tolen);
/**
* Gives back a raw packet from the wire and reads the header data from the given
* socket. Allocates the data (of size size) itself, so don't forget to free
*
* \param[in] sockfd the socket to read from
* \param[out] size the number of bytes that are read
* \return the data read
*/
uint8_t *ldns_tcp_read_wire(int sockfd, size_t *size);
/**
* Gives back a raw packet from the wire and reads the header data from the given
* socket. Allocates the data (of size size) itself, so don't forget to free
*
* \param[in] sockfd the socket to read from
* \param[in] fr the address of the client (if applicable)
* \param[in] *frlen the lenght of the client's addr (if applicable)
* \param[out] size the number of bytes that are read
* \return the data read
*/
uint8_t *ldns_udp_read_wire(int sockfd, size_t *size, struct sockaddr_storage *fr, socklen_t *frlen);
/**
* returns the native sockaddr representation from the rdf.
* \param[in] rd the ldns_rdf to operate on
* \param[in] port what port to use. 0 means; use default (53)
* \param[out] size what is the size of the sockaddr_storage
* \return struct sockaddr* the address in the format so other
* functions can use it (sendto)
*/
struct sockaddr_storage * ldns_rdf2native_sockaddr_storage(const ldns_rdf *rd, uint16_t port, size_t *size);
/**
* returns an rdf with the sockaddr info. works for ip4 and ip6
* \param[in] sock the struct sockaddr_storage to convert
* \param[in] port what port was used. When NULL this is not set
* \return ldns_rdf* wth the address
*/
ldns_rdf * ldns_sockaddr_storage2rdf(struct sockaddr_storage *sock, uint16_t *port);
/**
* Prepares the resolver for an axfr query
* The query is sent and the answers can be read with ldns_axfr_next
* \param[in] resolver the resolver to use
* \param[in] domain the domain to exfr
* \param[in] c the class to use
* \return ldns_status the status of the transfer
*/
ldns_status ldns_axfr_start(ldns_resolver *resolver, ldns_rdf *domain, ldns_rr_class c);
#endif /* LDNS_NET_H */
/*
* util.h
*
* helper function header file
*
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2004
*
* See the file LICENSE for the license
*/
#ifndef _UTIL_H
#define _UTIL_H
//@include_inttypes_h@
#include <ldns/common.h>
#include <time.h>
#include <stdio.h>
#define dprintf(X,Y) fprintf(stderr, (X), (Y))
/* #define dprintf(X, Y) */
#define LDNS_VERSION "@PACKAGE_VERSION@"
/**
* splint static inline workaround
*/
#ifdef S_SPLINT_S
#define INLINE
#else
#define INLINE static inline
#endif
/**
* Memory management macros
*/
#define LDNS_MALLOC(type) LDNS_XMALLOC(type, 1)
#define LDNS_XMALLOC(type, count) ((type *) malloc((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");
/*
* Copy data allowing for unaligned accesses in network byte order
* (big endian).
*/
INLINE uint16_t
ldns_read_uint16(const void *src)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
return ntohs(*(uint16_t *) src);
#else
uint8_t *p = (uint8_t *) src;
return ((uint16_t) p[0] << 8) | (uint16_t) p[1];
#endif
}
INLINE uint32_t
ldns_read_uint32(const void *src)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
return ntohl(*(uint32_t *) src);
#else
uint8_t *p = (uint8_t *) src;
return ( ((uint32_t) p[0] << 24)
| ((uint32_t) p[1] << 16)
| ((uint32_t) p[2] << 8)
| (uint32_t) p[3]);
#endif
}
/*
* Copy data allowing for unaligned accesses in network byte order
* (big endian).
*/
INLINE void
ldns_write_uint16(void *dst, uint16_t data)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
* (uint16_t *) dst = htons(data);
#else
uint8_t *p = (uint8_t *) dst;
p[0] = (uint8_t) ((data >> 8) & 0xff);
p[1] = (uint8_t) (data & 0xff);
#endif
}
INLINE void
ldns_write_uint32(void *dst, uint32_t data)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
* (uint32_t *) dst = htonl(data);
#else
uint8_t *p = (uint8_t *) dst;
p[0] = (uint8_t) ((data >> 24) & 0xff);
p[1] = (uint8_t) ((data >> 16) & 0xff);
p[2] = (uint8_t) ((data >> 8) & 0xff);
p[3] = (uint8_t) (data & 0xff);
#endif
}
/* warning. */
INLINE void
ldns_write_uint64_as_uint48(void *dst, uint64_t data)
{
uint8_t *p = (uint8_t *) dst;
p[0] = (uint8_t) ((data >> 40) & 0xff);
p[1] = (uint8_t) ((data >> 32) & 0xff);
p[2] = (uint8_t) ((data >> 24) & 0xff);
p[3] = (uint8_t) ((data >> 16) & 0xff);
p[4] = (uint8_t) ((data >> 8) & 0xff);
p[5] = (uint8_t) (data & 0xff);
}
/**
* Structure to do a Schwartzian-like transformation, for instance when
* sorting. If you need a transformation on the objects that are sorted,
* you can sue this to store the transformed values, so you do not
* need to do the transformation again for each comparison
*/
struct ldns_schwartzian_compare_struct {
void *original_object;
void *transformed_object;
};
/** A general purpose lookup table
*
* Lookup tables are arrays of (id, name) pairs,
* So you can for instance lookup the RCODE 3, which is "NXDOMAIN",
* and vice versa. The lookup tables themselves are defined wherever needed,
* for instance in \ref host2str.c
*/
struct ldns_struct_lookup_table {
int id;
const char *name;
};
typedef struct ldns_struct_lookup_table ldns_lookup_table;
/**
* Looks up the table entry by name, returns NULL if not found.
* \param[in] table the lookup table to search in
* \param[in] name what to search for
* \return the item found
*/
ldns_lookup_table *ldns_lookup_by_name(ldns_lookup_table table[],
const char *name);
/**
* Looks up the table entry by id, returns NULL if not found.
* \param[in] table the lookup table to search in
* \param[in] id what to search for
* \return the item found
*/
ldns_lookup_table *ldns_lookup_by_id(ldns_lookup_table table[], int id);
/**
* Returns the value of the specified bit
* The bits are counted from left to right, so bit #0 is the
* left most bit.
* \param[in] bits array holding the bits
* \param[in] index to the wanted bit
* \return
*/
int ldns_get_bit(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.
* \param[in] bits array holding the bits
* \param[in] index to the wanted bit
* \return 1 or 0 depending no the bit state
*/
int ldns_get_bit_r(uint8_t bits[], size_t index);
/**
* 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.
* \param[in] byte the bit to set the bit in
* \param[in] bit_nr the bit to set (0 <= n <= 7)
* \param[in] value whether to set the bit to 1 or 0
* \return 1 or 0 depending no the bit state
*/
void ldns_set_bit(uint8_t *byte, int bit_nr, bool value);
/**
* Returns the value of a to the power of b
* (or 1 of b < 1)
*/
/*@unused@*/
INLINE long
ldns_power(long a, long b) {
long result = 1;
while (b > 0) {
if (b & 1) {
result *= a;
if (b == 1) {
return result;
}
}
a *= a;
b /= 2;
}
return result;
}
/**
* Returns the int value of the given (hex) digit
* \param[in] ch the hex char to convert
* \return the converted decimal value
*/
int ldns_hexdigit_to_int(char ch);
/**
* Returns the char (hex) representation of the given int
* \param[in] ch the int to convert
* \return the converted hex char
*/
char ldns_int_to_hexdigit(int ch);
/**
* Converts a hex string to binary data
*
* \param[out] data The binary result is placed here.
* At least strlen(str)/2 bytes should be allocated
* \param[in] str The hex string to convert.
* This string should not contain spaces
* \return The number of bytes of converted data, or -1 if one of the arguments * is NULL, or -2 if the string length is not an even number
*/
int
ldns_hexstring_to_data(uint8_t *data, const char *str);
/**
* Show the internal library version
* \return a string with the version in it
*/
const char * ldns_version(void);
/**
* Convert TM to seconds since epoch (midnight, January 1st, 1970).
* Like timegm(3), which is not always available.
* \param[in] tm a struct tm* with the date
* \return the seconds since epoch
*/
time_t mktime_from_utc(const struct tm *tm);
/**
* 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
*
* \param[in] fd a file providing entropy data for the seed
* \param[in] size the number of bytes to use as entropy data. If this is 0,
* only the minimal amount is taken (usually 4 bytes)
* \return 0 if seeding succeeds, 1 if it fails
*/
int ldns_init_random(FILE *fd, unsigned int size);
/**
* Encode data as BubbleBabble
*
* \param[in] data a pointer to data to be encoded
* \param[in] len size the number of bytes of data
* \return a string of BubbleBabble
*/
char *ldns_bubblebabble(uint8_t *data, size_t len);
#ifndef B32_NTOP
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);
/**
* calculates the size needed to store the result of b32_ntop
*/
/*@unused@*/
static inline size_t ldns_b32_ntop_calculate_size(size_t srcsize)
{
size_t result = ((((srcsize / 5) * 8) - 2) + 2);
return result;
}
#endif /* !B32_NTOP */
#ifndef B32_PTON
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);
/**
* calculates the size needed to store the result of b32_pton
*/
/*@unused@*/
static inline size_t ldns_b32_pton_calculate_size(size_t srcsize)
{
size_t result = ((((srcsize) / 8) * 5));
return result;
}
#endif /* !B32_PTON */
#endif /* !_UTIL_H */
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论