Mon Mar 12 2012 21:20:57

Asterisk developer's documentation


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 /*!
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  * \details
00048  * This function allocates a new DNS manager entry object, and fills it with the
00049  * provided hostname and IP address.  This function does not force an initial lookup
00050  * of the IP address.  So, generally, this should be used when the initial address
00051  * is already known.
00052  *
00053  * \return a DNS manager entry
00054  * \version 1.6.1 result changed from struct in_addr to struct sockaddr_in to store port number
00055  * \version 1.8.0 result changed from struct ast_sockaddr_in to ast_sockaddr for IPv6 support
00056  */
00057 struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service);
00058 
00059 /*!
00060  * \brief Allocate a new DNS manager entry
00061  *
00062  * \param name the hostname
00063  * \param result where the DNS manager should store the IP address as it refreshes it.
00064  * \param service
00065  * \param family Address family to filter DNS addresses.
00066  *
00067  * \details
00068  * This function allocates a new DNS manager entry object, and fills it with the
00069  * provided hostname and IP address.  This function does not force an initial lookup
00070  * of the IP address.  So, generally, this should be used when the initial address
00071  * is already known.
00072  *
00073  * \return a DNS manager entry
00074  */
00075 struct ast_dnsmgr_entry *ast_dnsmgr_get_family(const char *name, struct ast_sockaddr *result, const char *service, unsigned int family);
00076 
00077 /*!
00078  * \brief Free a DNS manager entry
00079  *
00080  * \param entry the DNS manager entry to free
00081  *
00082  * \return nothing
00083  */
00084 void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry);
00085 
00086 /*!
00087  * \brief Allocate and initialize a DNS manager entry
00088  *
00089  * \param name the hostname
00090  * \param result where to store the IP address as the DNS manager refreshes it.
00091  * The address family is used as an input parameter to filter the returned addresses.
00092  * If it is 0, both IPv4 and IPv6 addresses can be returned.
00093  * \param dnsmgr Where to store the allocate DNS manager entry
00094  * \param service
00095  *
00096  * \note
00097  * This function allocates a new DNS manager entry object, and fills it with
00098  * the provided hostname and IP address.  This function _does_ force an initial
00099  * lookup, so it may block for some period of time.
00100  *
00101  * \retval 0 success
00102  * \retval non-zero failure
00103  * \version 1.6.1 result changed from struct in_addr to struct aockaddr_in to store port number
00104  */
00105 int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service);
00106 
00107 /*!
00108  * \brief Force a refresh of a dnsmgr entry
00109  *
00110  * \retval non-zero if the result is different than the previous result
00111  * \retval zero if the result is the same as the previous result
00112  */
00113 int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry);
00114 
00115 /*!
00116  * \brief Check is see if a dnsmgr entry has changed
00117  *
00118  * \retval non-zero if the dnsmgr entry has changed since the last call to
00119  *                  this function
00120  * \retval zero     if the dnsmgr entry has not changed since the last call to
00121  *                  this function
00122  */
00123 int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry);
00124 
00125 #if defined(__cplusplus) || defined(c_plusplus)
00126 }
00127 #endif /* c_plusplus */
00128 
00129 #endif /* ASTERISK_DNSMGR_H */