Asterisk - The Open Source Telephony Project GIT-master-f36a736
dnsmgr.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999 - 2005, Digium, Inc.
5 *
6 * Kevin P. Fleming <kpfleming@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*! \file
20 * \brief Background DNS update manager
21 */
22
23#ifndef _ASTERISK_DNSMGR_H
24#define _ASTERISK_DNSMGR_H
25
26#if defined(__cplusplus) || defined(c_plusplus)
27extern "C" {
28#endif
29
30#include "asterisk/netsock2.h"
31#include "asterisk/srv.h"
32
33/*!
34 * \brief A DNS manager entry
35 *
36 * This is an opaque type.
37 */
38struct ast_dnsmgr_entry;
39
40typedef void (*dns_update_func)(struct ast_sockaddr *old_addr, struct ast_sockaddr *new_addr, void *data);
41
42/*!
43 * \brief Allocate a new DNS manager entry
44 *
45 * \param name the hostname
46 * \param result where the DNS manager should store the IP address as it refreshes it.
47 * \param service
48 *
49 * \details
50 * This function allocates a new DNS manager entry object, and fills it with the
51 * provided hostname and IP address. This function does not force an initial lookup
52 * of the IP address. So, generally, this should be used when the initial address
53 * is already known.
54 *
55 * \return a DNS manager entry
56 * \version 1.6.1 result changed from struct in_addr to struct sockaddr_in to store port number
57 * \version 1.8.0 result changed from struct ast_sockaddr_in to ast_sockaddr for IPv6 support
58 */
59struct ast_dnsmgr_entry *ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service);
60
61/*!
62 * \brief Allocate a new DNS manager entry
63 *
64 * \param name the hostname
65 * \param result where the DNS manager should store the IP address as it refreshes it.
66 * \param service
67 * \param family Address family to filter DNS addresses.
68 *
69 * \details
70 * This function allocates a new DNS manager entry object, and fills it with the
71 * provided hostname and IP address. This function does not force an initial lookup
72 * of the IP address. So, generally, this should be used when the initial address
73 * is already known.
74 *
75 * \return a DNS manager entry
76 */
77struct ast_dnsmgr_entry *ast_dnsmgr_get_family(const char *name, struct ast_sockaddr *result, const char *service, unsigned int family);
78
79/*!
80 * \brief Free a DNS manager entry
81 *
82 * \param entry the DNS manager entry to free
83 */
85
86/*!
87 * \brief Allocate and initialize a DNS manager entry
88 *
89 * \param name the hostname
90 * \param result where to store the IP address as the DNS manager refreshes it.
91 * The address family is used as an input parameter to filter the returned addresses.
92 * If it is 0, both IPv4 and IPv6 addresses can be returned.
93 * \param dnsmgr Where to store the allocate DNS manager entry
94 * \param service
95 *
96 * \note
97 * This function allocates a new DNS manager entry object, and fills it with
98 * the provided hostname and IP address. This function _does_ force an initial
99 * lookup, so it may block for some period of time.
100 *
101 * \retval 0 success
102 * \retval non-zero failure
103 * \version 1.6.1 result changed from struct in_addr to struct aockaddr_in to store port number
104 */
105int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service);
106
107/*!
108 * \brief Allocate and initialize a DNS manager entry, with update callback
109 *
110 * \param name the hostname
111 * \param result The addr which is intended to be updated in the update callback when DNS manager calls it on refresh.
112 * The address family is used as an input parameter to filter the returned addresses.
113 * If it is 0, both IPv4 and IPv6 addresses can be returned.
114 * \param dnsmgr Where to store the allocate DNS manager entry
115 * \param service
116 * \param func The update callback function
117 * The update callback will be called when DNS manager detects that an IP address has been changed.
118 * Instead of updating the addr itself, DNS manager will call this callback function with the old
119 * and new addresses. It is the responsibility of the callback to perform any updates
120 * \param data A pointer to data that will be passed through to the callback function
121 *
122 * \note
123 * This function allocates a new DNS manager entry object, and fills it with
124 * the provided hostname and IP address. This function _does_ force an initial
125 * lookup, so it may block for some period of time.
126 *
127 * \retval 0 success
128 * \retval non-zero failure
129 */
130int 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);
131
132/*!
133 * \brief Force a refresh of a dnsmgr entry
134 *
135 * \retval non-zero if the result is different than the previous result
136 * \retval zero if the result is the same as the previous result
137 */
139
140/*!
141 * \brief Check is see if a dnsmgr entry has changed
142 *
143 * \retval non-zero if the dnsmgr entry has changed since the last call to
144 * this function
145 * \retval zero if the dnsmgr entry has not changed since the last call to
146 * this function
147 */
149
150#if defined(__cplusplus) || defined(c_plusplus)
151}
152#endif /* c_plusplus */
153
154#endif /* ASTERISK_DNSMGR_H */
enum ast_cc_service_type service
Definition: ccss.c:383
static PGresult * result
Definition: cel_pgsql.c:84
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
Definition: dnsmgr.c:136
struct ast_dnsmgr_entry * ast_dnsmgr_get_family(const char *name, struct ast_sockaddr *result, const char *service, unsigned int family)
Allocate a new DNS manager entry.
Definition: dnsmgr.c:106
struct ast_dnsmgr_entry * ast_dnsmgr_get(const char *name, struct ast_sockaddr *result, const char *service)
Allocate a new DNS manager entry.
Definition: dnsmgr.c:131
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)
Allocate and initialize a DNS manager entry, with update callback.
Definition: dnsmgr.c:196
int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
Allocate and initialize a DNS manager entry.
Definition: dnsmgr.c:191
void(* dns_update_func)(struct ast_sockaddr *old_addr, struct ast_sockaddr *new_addr, void *data)
Definition: dnsmgr.h:40
int ast_dnsmgr_changed(struct ast_dnsmgr_entry *entry)
Check is see if a dnsmgr entry has changed.
Definition: dnsmgr.c:247
int ast_dnsmgr_refresh(struct ast_dnsmgr_entry *entry)
Force a refresh of a dnsmgr entry.
Definition: dnsmgr.c:239
static const char name[]
Definition: format_mp3.c:68
Network socket handling.
Support for DNS SRV records, used in to locate SIP services.
Definition: dnsmgr.c:66
unsigned int family
Definition: dnsmgr.c:72
void * data
Definition: dnsmgr.c:76
Socket address structure.
Definition: netsock2.h:97
Definition: search.h:40