dnsmgr.h

Go to the documentation of this file.
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 typedef void (*dns_update_func)(struct ast_sockaddr *old_addr, struct ast_sockaddr *new_addr, void *data);
00041 
00042 /*!
00043  * \brief Allocate a new DNS manager entry
00044  *
00045  * \param name the hostname
00046  * \param result where the DNS manager should store the IP address as it refreshes it.
00047  * \param service
00048  *
00049  * \details
00050  * This function allocates a new DNS manager entry object, and fills it with the
00051  * provided hostname and IP address.  This function does not force an initial lookup
00052  * of the IP address.  So, generally, this should be used when the initial address
00053  * is already known.
00054  *
00055  * \return a DNS manager entry
00056  * \version 1.6.1 result changed from struct in_addr to struct sockaddr_in to store port number
00057  * \version 1.8.0 result changed from struct ast_sockaddr_in to ast_sockaddr for IPv6 support
00058  */
00059 struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service);
00060 
00061 /*!
00062  * \brief Allocate a new DNS manager entry
00063  *
00064  * \param name the hostname
00065  * \param result where the DNS manager should store the IP address as it refreshes it.
00066  * \param service
00067  * \param family Address family to filter DNS addresses.
00068  *
00069  * \details
00070  * This function allocates a new DNS manager entry object, and fills it with the
00071  * provided hostname and IP address.  This function does not force an initial lookup
00072  * of the IP address.  So, generally, this should be used when the initial address
00073  * is already known.
00074  *
00075  * \return a DNS manager entry
00076  */
00077 struct ast_dnsmgr_entry *ast_dnsmgr_get_family(const char *name, struct ast_sockaddr *result, const char *service, unsigned int family);
00078 
00079 /*!
00080  * \brief Free a DNS manager entry
00081  *
00082  * \param entry the DNS manager entry to free
00083  *
00084  * \return nothing
00085  */
00086 void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry);
00087 
00088 /*!
00089  * \brief Allocate and initialize a DNS manager entry
00090  *
00091  * \param name the hostname
00092  * \param result where to store the IP address as the DNS manager refreshes it.
00093  * The address family is used as an input parameter to filter the returned addresses.
00094  * If it is 0, both IPv4 and IPv6 addresses can be returned.
00095  * \param dnsmgr Where to store the allocate DNS manager entry
00096  * \param service
00097  *
00098  * \note
00099  * This function allocates a new DNS manager entry object, and fills it with
00100  * the provided hostname and IP address.  This function _does_ force an initial
00101  * lookup, so it may block for some period of time.
00102  *
00103  * \retval 0 success
00104  * \retval non-zero failure
00105  * \version 1.6.1 result changed from struct in_addr to struct aockaddr_in to store port number
00106  */
00107 int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service);
00108 
00109 /*!
00110  * \brief Allocate and initialize a DNS manager entry, with update callback
00111  *
00112  * \param name the hostname
00113  * \param result The addr which is intended to be updated in the update callback when DNS manager calls it on refresh.
00114  * The address family is used as an input parameter to filter the returned addresses.
00115  * If it is 0, both IPv4 and IPv6 addresses can be returned.
00116  * \param dnsmgr Where to store the allocate DNS manager entry
00117  * \param service
00118  * \param func The update callback function
00119  * The update callback will be called when DNS manager detects that an IP address has been changed.
00120  * Instead of updating the addr itself, DNS manager will call this callback function with the old
00121  * and new addresses. It is the responsibility of the callback to perform any updates
00122  * \param data A pointer to data that will be passed through to the callback function
00123  *
00124  * \note
00125  * This function allocates a new DNS manager entry object, and fills it with
00126  * the provided hostname and IP address.  This function _does_ force an initial
00127  * lookup, so it may block for some period of time.
00128  *
00129  * \retval 0 success
00130  * \retval non-zero failure
00131  */
00132 int ast_dnsmgr_lookup_cb(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service, dns_update_func func, void *data);
00133 
00134 /*!
00135  * \brief Force a refresh of a dnsmgr entry
00136  *
00137  * \retval non-zero if the result is different than the previous result
00138  * \retval zero if the result is the same as the previous result
00139  */
00140 int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry);
00141 
00142 /*!
00143  * \brief Check is see if a dnsmgr entry has changed
00144  *
00145  * \retval non-zero if the dnsmgr entry has changed since the last call to
00146  *                  this function
00147  * \retval zero     if the dnsmgr entry has not changed since the last call to
00148  *                  this function
00149  */
00150 int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry);
00151 
00152 #if defined(__cplusplus) || defined(c_plusplus)
00153 }
00154 #endif /* c_plusplus */
00155 
00156 #endif /* ASTERISK_DNSMGR_H */

Generated on Thu Apr 16 06:27:33 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6