/usr/include/ldns/net.h is in libldns-dev 1.6.17-1ubuntu0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | /*
* 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>
#include <sys/socket.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LDNS_DEFAULT_TIMEOUT_SEC 5
#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 *unused*, was 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 connect attempt
* \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 connect attempt
* \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 *unused*, was 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
* \param[in] timeout the time allowed between packets.
* \return the data read
*/
uint8_t *ldns_tcp_read_wire_timeout(int sockfd, size_t *size, struct timeval timeout);
/**
* This routine may block. Use ldns_tcp_read_wire_timeout, it checks timeouts.
* 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);
#ifdef __cplusplus
}
#endif
#endif /* LDNS_NET_H */
|