Changeset View
Changeset View
Standalone View
Standalone View
contrib/ldns/ldns/net.h.in
Show All 24 Lines | |||||
/** | /** | ||||
* \file | * \file | ||||
* | * | ||||
* Contains functions to send and receive packets over a network. | * 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 | * Sends a buffer to an ip using udp and return the response 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] to the ip addr to send to | ||||
* \param[in] tolen length of the ip addr | * \param[in] tolen length of the ip addr | ||||
* \param[in] timeout the timeout value for the network | * \param[in] timeout the timeout value for the network | ||||
* \param[out] answersize size of the packet | * \param[out] answersize size of the packet | ||||
* \param[out] result packet with the answer | * \param[out] result packet with the answer | ||||
* \return status | * \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); | 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 | * Send an udp query and don't wait for an answer but return | ||||
* the socket | * the socket | ||||
* \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] to the ip addr to send to | ||||
* \param[in] tolen length of the ip addr | * \param[in] tolen length of the ip addr | ||||
* \param[in] timeout *unused*, was the timeout value for the network | * \param[in] timeout *unused*, was the timeout value for the network | ||||
* \return the socket used | * \return the socket used or -1 on failure | ||||
*/ | */ | ||||
int ldns_udp_bgsend2(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout); | |||||
/** | |||||
* Send an udp query and don't wait for an answer but return | |||||
* the socket | |||||
* This function has the flaw that it returns 0 on failure, but 0 could be a | |||||
* valid socket. Please use ldns_udp_bgsend2 instead of this function. | |||||
* \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 or 0 on failure | |||||
*/ | |||||
int ldns_udp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout); | 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 | * Send an tcp query and don't wait for an answer but return | ||||
* the socket | * the socket | ||||
* \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] to the ip addr to send to | ||||
* \param[in] tolen length of the ip addr | * \param[in] tolen length of the ip addr | ||||
* \param[in] timeout the timeout value for the connect attempt | * \param[in] timeout the timeout value for the connect attempt | ||||
* \return the socket used | * \return the socket used or -1 on failure | ||||
*/ | */ | ||||
int ldns_tcp_bgsend2(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 | |||||
* This function has the flaw that it returns 0 on failure, but 0 could be a | |||||
* valid socket. Please use ldns_tcp_bgsend2 instead of this function. | |||||
* \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 or 0 on failure | |||||
*/ | |||||
int ldns_tcp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout); | 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 | * Sends a buffer to an ip using tcp and return the response as a ldns_pkt | ||||
* \param[in] qbin the ldns_buffer to be send | * \param[in] qbin the ldns_buffer to be send | ||||
* \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] to the ip addr to send to | ||||
* \param[in] tolen length of the ip addr | * \param[in] tolen length of the ip addr | ||||
* \param[in] timeout the timeout value for the network | * \param[in] timeout the timeout value for the network | ||||
* \param[out] answersize size of the packet | * \param[out] answersize size of the packet | ||||
* \param[out] result packet with the answer | * \param[out] result packet with the answer | ||||
* \return status | * \return status | ||||
Show All 23 Lines | |||||
*/ | */ | ||||
ldns_status ldns_send_buffer(ldns_pkt **pkt, ldns_resolver *r, ldns_buffer *qb, ldns_rdf *tsig_mac); | 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 | * Create a tcp socket to the specified address | ||||
* \param[in] to ip and family | * \param[in] to ip and family | ||||
* \param[in] tolen length of to | * \param[in] tolen length of to | ||||
* \param[in] timeout timeout for the connect attempt | * \param[in] timeout timeout for the connect attempt | ||||
* \return a socket descriptor | * \return a socket descriptor or -1 on failure | ||||
*/ | */ | ||||
int ldns_tcp_connect2(const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout); | |||||
/** | |||||
* Create a tcp socket to the specified address | |||||
* This function has the flaw that it returns 0 on failure, but 0 could be a | |||||
* valid socket. Please use ldns_tcp_connect2 instead of this function. | |||||
* \param[in] to ip and family | |||||
* \param[in] tolen length of to | |||||
* \param[in] timeout timeout for the connect attempt | |||||
* \return a socket descriptor or 0 on failure | |||||
*/ | |||||
int ldns_tcp_connect(const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout); | int ldns_tcp_connect(const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout); | ||||
/** | /** | ||||
* Create a udp socket to the specified address | * Create a udp socket to the specified address | ||||
* \param[in] to ip and family | * \param[in] to ip and family | ||||
* \param[in] timeout *unused*, was timeout for the socket | * \param[in] timeout *unused*, was timeout for the socket | ||||
* \return a socket descriptor | * \return a socket descriptor or -1 on failure | ||||
*/ | */ | ||||
int ldns_udp_connect2(const struct sockaddr_storage *to, struct timeval timeout); | |||||
/** | |||||
* Create a udp socket to the specified address | |||||
* This function has the flaw that it returns 0 on failure, but 0 could be a | |||||
* valid socket. Please use ldns_udp_connect2 instead of this function. | |||||
* \param[in] to ip and family | |||||
* \param[in] timeout *unused*, was timeout for the socket | |||||
* \return a socket descriptor or 0 on failure | |||||
*/ | |||||
int ldns_udp_connect(const struct sockaddr_storage *to, struct timeval timeout); | 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 | * send a query via tcp to a server. Don't want for the answer | ||||
* | * | ||||
* \param[in] qbin the buffer to send | * \param[in] qbin the buffer to send | ||||
* \param[in] sockfd the socket to use | * \param[in] sockfd the socket to use | ||||
* \param[in] to which ip to send it | * \param[in] to which ip to send it | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
* functions can use it (sendto) | * functions can use it (sendto) | ||||
*/ | */ | ||||
struct sockaddr_storage * ldns_rdf2native_sockaddr_storage(const ldns_rdf *rd, uint16_t port, size_t *size); | 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 | * returns an rdf with the sockaddr info. works for ip4 and ip6 | ||||
* \param[in] sock the struct sockaddr_storage to convert | * \param[in] sock the struct sockaddr_storage to convert | ||||
* \param[in] port what port was used. When NULL this is not set | * \param[in] port what port was used. When NULL this is not set | ||||
* \return ldns_rdf* wth the address | * \return ldns_rdf* with the address | ||||
*/ | */ | ||||
ldns_rdf * ldns_sockaddr_storage2rdf(const struct sockaddr_storage *sock, uint16_t *port); | ldns_rdf * ldns_sockaddr_storage2rdf(const struct sockaddr_storage *sock, uint16_t *port); | ||||
/** | /** | ||||
* Prepares the resolver for an axfr query | * Prepares the resolver for an axfr query | ||||
* The query is sent and the answers can be read with ldns_axfr_next | * The query is sent and the answers can be read with ldns_axfr_next | ||||
* \param[in] resolver the resolver to use | * \param[in] resolver the resolver to use | ||||
* \param[in] domain the domain to exfr | * \param[in] domain the domain to axfr | ||||
* \param[in] c the class to use | * \param[in] c the class to use | ||||
* \return ldns_status the status of the transfer | * \return ldns_status the status of the transfer | ||||
*/ | */ | ||||
ldns_status ldns_axfr_start(ldns_resolver *resolver, const ldns_rdf *domain, ldns_rr_class c); | ldns_status ldns_axfr_start(ldns_resolver *resolver, const ldns_rdf *domain, ldns_rr_class c); | ||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } | ||||
#endif | #endif | ||||
#endif /* LDNS_NET_H */ | #endif /* LDNS_NET_H */ |