summaryrefslogtreecommitdiff
path: root/include/asterisk/srv.h
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2010-04-09 14:37:50 +0000
committerMark Michelson <mmichelson@digium.com>2010-04-09 14:37:50 +0000
commit6cad0f1602c1e07fcef98714281ae4d4cedb7e09 (patch)
treea4229d9951584abfc017622e1a74d2d358d9edf5 /include/asterisk/srv.h
parent0f01ace7af23550f05619ef5dc61f0537f93a564 (diff)
func_srv and explicit specification of a remote IP for SIP.
From Review Board: There are two interrelated changes here. First, there is the introduction of func_srv. This adds two new read-only dialplan functions, SRVQUERY and SRVRESULT. They work very similarly to the ENUMQUERY and ENUMRESULT functions, except that this allows one to query SRV records instead. In order to facilitate this work, I added a couple of new API calls to srv.h. ast_srv_get_record_count tells the number of records returned by an SRV lookup. This number is calculated at the time of the SRV lookup. ast_srv_get_nth_record allows one to get a numbered SRV record. Second, there is the modification to chan_sip that allows one to specify a hostname or IP address (along with a port) to send an outgoing INVITE to when dialing a SIP peer. This goes hand-in-hand with func_srv. You can query SRV records and then use the host and port from the results to dial via a specific host instead of what is configured in sip.conf. Review: https://reviewboard.asterisk.org/r/608 SWP-1200 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@256485 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/srv.h')
-rw-r--r--include/asterisk/srv.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/asterisk/srv.h b/include/asterisk/srv.h
index a3d2c7a6e..d98a1d0b9 100644
--- a/include/asterisk/srv.h
+++ b/include/asterisk/srv.h
@@ -61,4 +61,39 @@ void ast_srv_cleanup(struct srv_context **context);
*/
extern int ast_get_srv(struct ast_channel *chan, char *host, int hostlen, int *port, const char *service);
+/*!
+ * \brief Get the number of records for a given SRV context
+ *
+ * \details
+ * This is meant to be used after calling ast_srv_lookup, so that
+ * one may retrieve the number of records returned during a specific
+ * SRV lookup.
+ *
+ * \param context The context returned by ast_srv_lookup
+ * \return Number of records in context
+ */
+unsigned int ast_srv_get_record_count(struct srv_context *context);
+
+/*!
+ * \brief Retrieve details from a specific SRV record
+ *
+ * \details
+ * After calling ast_srv_lookup, the srv_context will contain
+ * the data from several records. You can retrieve the data
+ * of a specific one by asking for a specific record number. The
+ * records are sorted based on priority and secondarily based on
+ * weight. See RFC 2782 for the exact sorting rules.
+ *
+ * \param context The context returned by ast_srv_lookup
+ * \param record_num The 1-indexed record number to retrieve
+ * \param[out] host The host portion of the record
+ * \param[out] port The port portion of the record
+ * \param[out] priority The priority portion of the record
+ * \param[out] weight The weight portion of the record
+ * \retval -1 Failed to retrieve information. Likely due to an out of
+ * range record_num
+ * \retval 0 Success
+ */
+int ast_srv_get_nth_record(struct srv_context *context, int record_num, const char **host,
+ unsigned short *port, unsigned short *priority, unsigned short *weight);
#endif /* _ASTERISK_SRV_H */