Fri Aug 17 00:17:20 2018

Asterisk developer's documentation


srv.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  * Mark Spencer <markster@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 /*
00020  * DNS SRV record support
00021  */
00022 
00023 #ifndef _ASTERISK_SRV_H
00024 #define _ASTERISK_SRV_H
00025 
00026 /*!
00027   \file srv.h
00028   \brief Support for DNS SRV records, used in to locate SIP services.
00029   \note Note: This SRV record support will respect the priority and
00030         weight elements of the records that are returned, but there are
00031    no provisions for retrying or failover between records.
00032 */
00033 
00034 /*!\brief An opaque type, for lookup usage */
00035 struct srv_context;
00036 
00037 /*!\brief Retrieve set of SRV lookups, in order
00038  * \param[in] context A pointer in which to hold the result
00039  * \param[in] service The service name to look up
00040  * \param[out] host Result host
00041  * \param[out] port Associated TCP portnum
00042  * \retval -1 Query failed
00043  * \retval 0 Result exists in host and port
00044  * \retval 1 No more results
00045  */
00046 extern int ast_srv_lookup(struct srv_context **context, const char *service, const char **host, unsigned short *port);
00047 
00048 /*!\brief Cleanup resources associated with ast_srv_lookup
00049  * \param context Pointer passed into ast_srv_lookup
00050  */
00051 void ast_srv_cleanup(struct srv_context **context);
00052 
00053 /*! Lookup entry in SRV records Returns 1 if found, 0 if not found, -1 on hangup 
00054    Only do SRV record lookup if you get a domain without a port. If you get a port #, it's a DNS host name.
00055 */
00056 /*!   \param   chan Ast channel
00057    \param   host host name (return value)
00058    \param   hostlen Length of string "host"
00059    \param   port Port number (return value)
00060    \param service Service tag for SRV lookup (like "_sip._udp" or "_stun._udp"
00061 */
00062 extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service);
00063 
00064 /*!
00065  * \brief Get the number of records for a given SRV context
00066  *
00067  * \details
00068  * This is meant to be used after calling ast_srv_lookup, so that
00069  * one may retrieve the number of records returned during a specific
00070  * SRV lookup.
00071  *
00072  * \param context The context returned by ast_srv_lookup
00073  * \return Number of records in context
00074  */
00075 unsigned int ast_srv_get_record_count(struct srv_context *context);
00076 
00077 /*!
00078  * \brief Retrieve details from a specific SRV record
00079  *
00080  * \details
00081  * After calling ast_srv_lookup, the srv_context will contain
00082  * the data from several records. You can retrieve the data
00083  * of a specific one by asking for a specific record number. The
00084  * records are sorted based on priority and secondarily based on
00085  * weight. See RFC 2782 for the exact sorting rules.
00086  *
00087  * \param context The context returned by ast_srv_lookup
00088  * \param record_num The 1-indexed record number to retrieve
00089  * \param[out] host The host portion of the record
00090  * \param[out] port The port portion of the record
00091  * \param[out] priority The priority portion of the record
00092  * \param[out] weight The weight portion of the record
00093  * \retval -1 Failed to retrieve information. Likely due to an out of
00094  * range record_num
00095  * \retval 0 Success
00096  */
00097 int ast_srv_get_nth_record(struct srv_context *context, int record_num, const char **host,
00098       unsigned short *port, unsigned short *priority, unsigned short *weight);
00099 #endif /* _ASTERISK_SRV_H */

Generated on 17 Aug 2018 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1