michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * @section DNS APIS michael@0: * This module contains method definitions to be implemented by the platform. michael@0: * SIP Stack uses these methods to perform DNS queries michael@0: */ michael@0: michael@0: michael@0: #ifndef _DNS_UTIL_H_ michael@0: #define _DNS_UTIL_H_ michael@0: michael@0: #include "cc_constants.h" michael@0: #include "cpr_types.h" michael@0: michael@0: /** michael@0: * Defines the return values for DNS query. michael@0: */ michael@0: #define CC_DNS_OK 0 michael@0: #define CC_DNS_ERR_NOBUF 1 michael@0: #define CC_DNS_ERR_INUSE 2 michael@0: #define CC_DNS_ERR_TIMEOUT 3 michael@0: #define CC_DNS_ERR_NOHOST 4 michael@0: #define CC_DNS_ERR_HOST_UNAVAIL 5 michael@0: michael@0: typedef void *srv_handle_t; michael@0: michael@0: /** michael@0: * Perform an DNS lookup of the name specified michael@0: * michael@0: * @param[in] hname host name michael@0: * @param[out] ipaddr_ptr the ip address returned by DNS for host with name hname. michael@0: * @param[in] timeout the timeout for the query michael@0: * @param[in] retries the retry times for the query michael@0: * michael@0: * @return CC_DNS_OK or CC_DNS_ERR_NOHOST michael@0: */ michael@0: cc_int32_t dnsGetHostByName(const char *hname, michael@0: cpr_ip_addr_t *ipaddr_ptr, michael@0: cc_int32_t timeout, michael@0: cc_int32_t retries); michael@0: michael@0: /** michael@0: * This function calls the dns api to perform a dns srv query. michael@0: * michael@0: * @param[in] service the service name, e.g. "sip" michael@0: * @param[in] protocol the protocol name, e.g. "udp" michael@0: * @param[in] domain the domain name michael@0: * @param[out] ipaddr_ptr the returned ip address michael@0: * @param[out] port the port michael@0: * @param[in] timeout the timeout for the query michael@0: * @param[in] retries the number of retries for the query michael@0: * @param[in,out] psrv_handle the handle for this query michael@0: * michael@0: * @note if handle is NULL an new query needs to be made and the michael@0: * first response needs to be returned along with a valid handle. michael@0: * Subsequent calls should return the next result if a valid handle has been provided. michael@0: * michael@0: * @returns CC_DNS_OK for success or michael@0: * CC_DNS_ERR_NOHOST, CC_DNS_ERR_HOST_UNAVAIL michael@0: */ michael@0: cc_int32_t dnsGetHostBySRV(cc_int8_t *service, michael@0: cc_int8_t *protocol, michael@0: cc_int8_t *domain, michael@0: cpr_ip_addr_t *ipaddr_ptr, michael@0: cc_uint16_t *port, michael@0: cc_int32_t timeout, michael@0: cc_int32_t retries, michael@0: srv_handle_t *psrv_handle); michael@0: michael@0: /** michael@0: * Free the srvhandle allocated in dnsGetHostBySRV. michael@0: * michael@0: * @param[in] srv_handle handle to be freed. michael@0: * michael@0: */ michael@0: michael@0: void dnsFreeSrvHandle(srv_handle_t srv_handle); michael@0: michael@0: #endif /* _DNS_UTIL_H_ */