00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 1999 - 2005, Digium, Inc. 00005 * 00006 * Kevin P. Fleming <kpfleming@digium.com> 00007 * 00008 * See http://www.asterisk.org for more information about 00009 * the Asterisk project. Please do not directly contact 00010 * any of the maintainers of this project for assistance; 00011 * the project provides a web site, mailing lists and IRC 00012 * channels for your use. 00013 * 00014 * This program is free software, distributed under the terms of 00015 * the GNU General Public License Version 2. See the LICENSE file 00016 * at the top of the source tree. 00017 */ 00018 00019 /*! \file 00020 * \brief Background DNS update manager 00021 */ 00022 00023 #ifndef _ASTERISK_DNSMGR_H 00024 #define _ASTERISK_DNSMGR_H 00025 00026 #if defined(__cplusplus) || defined(c_plusplus) 00027 extern "C" { 00028 #endif 00029 00030 #include "asterisk/netsock2.h" 00031 #include "asterisk/srv.h" 00032 00033 /*! 00034 * \brief A DNS manager entry 00035 * 00036 * This is an opaque type. 00037 */ 00038 struct ast_dnsmgr_entry; 00039 00040 /*! 00041 * \brief Allocate a new DNS manager entry 00042 * 00043 * \param name the hostname 00044 * \param result where the DNS manager should store the IP address as it refreshes it. 00045 * \param service 00046 * 00047 * This function allocates a new DNS manager entry object, and fills it with the 00048 * provided hostname and IP address. This function does not force an initial lookup 00049 * of the IP address. So, generally, this should be used when the initial address 00050 * is already known. 00051 * 00052 * \return a DNS manager entry 00053 * \version 1.6.1 result changed from struct in_addr to struct sockaddr_in to store port number 00054 * \version 1.8.0 result changed from struct ast_sockaddr_in to ast_sockaddr for IPv6 support 00055 */ 00056 struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service); 00057 00058 /*! 00059 * \brief Free a DNS manager entry 00060 * 00061 * \param entry the DNS manager entry to free 00062 * 00063 * \return nothing 00064 */ 00065 void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry); 00066 00067 /*! 00068 * \brief Allocate and initialize a DNS manager entry 00069 * 00070 * \param name the hostname 00071 * \param result where to store the IP address as the DNS manager refreshes it. 00072 * The address family is used as an input parameter to filter the returned addresses. 00073 * If it is 0, both IPv4 and IPv6 addresses can be returned. 00074 * \param dnsmgr Where to store the allocate DNS manager entry 00075 * \param service 00076 * 00077 * \note 00078 * This function allocates a new DNS manager entry object, and fills it with 00079 * the provided hostname and IP address. This function _does_ force an initial 00080 * lookup, so it may block for some period of time. 00081 * 00082 * \retval 0 success 00083 * \retval non-zero failure 00084 * \version 1.6.1 result changed from struct in_addr to struct aockaddr_in to store port number 00085 */ 00086 int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service); 00087 00088 /*! 00089 * \brief Force a refresh of a dnsmgr entry 00090 * 00091 * \retval non-zero if the result is different than the previous result 00092 * \retval zero if the result is the same as the previous result 00093 */ 00094 int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry); 00095 00096 /*! 00097 * \brief Check is see if a dnsmgr entry has changed 00098 * 00099 * \retval non-zero if the dnsmgr entry has changed since the last call to 00100 * this function 00101 * \retval zero if the dnsmgr entry has not changed since the last call to 00102 * this function 00103 */ 00104 int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry); 00105 00106 #if defined(__cplusplus) || defined(c_plusplus) 00107 } 00108 #endif /* c_plusplus */ 00109 00110 #endif /* ASTERISK_DNSMGR_H */