summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/res_sip.h178
-rw-r--r--include/asterisk/res_sip_exten_state.h94
-rw-r--r--include/asterisk/res_sip_pubsub.h17
-rw-r--r--include/asterisk/res_sip_session.h42
-rw-r--r--include/asterisk/sdp_srtp.h125
5 files changed, 452 insertions, 4 deletions
diff --git a/include/asterisk/res_sip.h b/include/asterisk/res_sip.h
index b48ed9f82..7c486aa68 100644
--- a/include/asterisk/res_sip.h
+++ b/include/asterisk/res_sip.h
@@ -139,6 +139,47 @@ struct ast_sip_contact {
);
/*! Absolute time that this contact is no longer valid after */
struct timeval expiration_time;
+ /*! Frequency to send OPTIONS requests to contact. 0 is disabled. */
+ unsigned int qualify_frequency;
+ /*! If true authenticate the qualify if needed */
+ int authenticate_qualify;
+};
+
+#define CONTACT_STATUS "contact_status"
+
+/*!
+ * \brief Status type for a contact.
+ */
+enum ast_sip_contact_status_type {
+ UNAVAILABLE,
+ AVAILABLE
+};
+
+/*!
+ * \brief A contact's status.
+ *
+ * \detail Maintains a contact's current status and round trip time
+ * if available.
+ */
+struct ast_sip_contact_status {
+ SORCERY_OBJECT(details);
+ /*! Current status for a contact (default - unavailable) */
+ enum ast_sip_contact_status_type status;
+ /*! The round trip start time set before sending a qualify request */
+ struct timeval rtt_start;
+ /*! The round trip time in microseconds */
+ int64_t rtt;
+};
+
+/*!
+ * \brief A transport to be used for messages to a contact
+ */
+struct ast_sip_contact_transport {
+ AST_DECLARE_STRING_FIELDS(
+ /*! Full URI of the contact */
+ AST_STRING_FIELD(uri);
+ );
+ pjsip_transport *transport;
};
/*!
@@ -157,6 +198,10 @@ struct ast_sip_aor {
unsigned int maximum_expiration;
/*! Default contact expiration if one is not provided in the contact */
unsigned int default_expiration;
+ /*! Frequency to send OPTIONS requests to AOR contacts. 0 is disabled. */
+ unsigned int qualify_frequency;
+ /*! If true authenticate the qualify if needed */
+ int authenticate_qualify;
/*! Maximum number of external contacts, 0 to disable */
unsigned int max_contacts;
/*! Whether to remove any existing contacts not related to an incoming REGISTER when it comes in */
@@ -245,6 +290,17 @@ enum ast_sip_direct_media_glare_mitigation {
AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING,
};
+enum ast_sip_session_media_encryption {
+ /*! Invalid media encryption configuration */
+ AST_SIP_MEDIA_TRANSPORT_INVALID = 0,
+ /*! Do not allow any encryption of session media */
+ AST_SIP_MEDIA_ENCRYPT_NONE,
+ /*! Offer SDES-encrypted session media */
+ AST_SIP_MEDIA_ENCRYPT_SDES,
+ /*! Offer encrypted session media with datagram TLS key exchange */
+ AST_SIP_MEDIA_ENCRYPT_DTLS,
+};
+
/*!
* \brief An entity with which Asterisk communicates
*/
@@ -306,14 +362,14 @@ struct ast_sip_endpoint {
unsigned int sess_expires;
/*! List of outbound registrations */
AST_LIST_HEAD_NOLOCK(, ast_sip_registration) registrations;
- /*! Frequency to send OPTIONS requests to endpoint. 0 is disabled. */
- unsigned int qualify_frequency;
/*! Method(s) by which the endpoint should be identified. */
enum ast_sip_endpoint_identifier_type ident_method;
/*! Boolean indicating if direct_media is permissible */
unsigned int direct_media;
/*! When using direct media, which method should be used */
enum ast_sip_session_refresh_method direct_media_method;
+ /*! When performing connected line update, which method should be used */
+ enum ast_sip_session_refresh_method connected_line_method;
/*! Take steps to mitigate glare for direct media */
enum ast_sip_direct_media_glare_mitigation direct_media_glare_mitigation;
/*! Do not attempt direct media session refreshes if a media NAT is detected */
@@ -326,8 +382,26 @@ struct ast_sip_endpoint {
unsigned int send_pai;
/*! Do we send Remote-Party-ID headers to this endpoint? */
unsigned int send_rpid;
+ /*! Do we add Diversion headers to applicable outgoing requests/responses? */
+ unsigned int send_diversion;
/*! Should unsolicited MWI be aggregated into a single NOTIFY? */
unsigned int aggregate_mwi;
+ /*! Do we use media encryption? what type? */
+ enum ast_sip_session_media_encryption media_encryption;
+ /*! Do we use AVPF exclusively for this endpoint? */
+ unsigned int use_avpf;
+ /*! Is one-touch recording permitted? */
+ unsigned int one_touch_recording;
+ /*! Boolean indicating if ringing should be sent as inband progress */
+ unsigned int inband_progress;
+ /*! Call group */
+ ast_group_t callgroup;
+ /*! Pickup group */
+ ast_group_t pickupgroup;
+ /*! Named call group */
+ struct ast_namedgroups *named_callgroups;
+ /*! Named pickup group */
+ struct ast_namedgroups *named_pickupgroups;
/*! Pointer to the persistent Asterisk endpoint */
struct ast_endpoint *persistent;
/*! The number of channels at which busy device state is returned */
@@ -553,6 +627,16 @@ struct ast_sorcery *ast_sip_get_sorcery(void);
int ast_sip_initialize_sorcery_transport(struct ast_sorcery *sorcery);
/*!
+ * \brief Initialize qualify support on a sorcery instance
+ *
+ * \param sorcery The sorcery instance
+ *
+ * \retval -1 failure
+ * \retval 0 success
+ */
+int ast_sip_initialize_sorcery_qualify(struct ast_sorcery *sorcery);
+
+/*!
* \brief Initialize location support on a sorcery instance
*
* \param sorcery The sorcery instance
@@ -611,6 +695,37 @@ struct ast_sip_contact *ast_sip_location_retrieve_contact_from_aor_list(const ch
struct ast_sip_contact *ast_sip_location_retrieve_contact(const char *contact_name);
/*!
+ * \brief Add a transport for a contact to use
+ */
+
+void ast_sip_location_add_contact_transport(struct ast_sip_contact_transport *ct);
+
+/*!
+ * \brief Delete a transport for a contact that went away
+ */
+void ast_sip_location_delete_contact_transport(struct ast_sip_contact_transport *ct);
+
+/*!
+ * \brief Retrieve a contact_transport, by URI
+ *
+ * \param contact_uri URI of the contact
+ *
+ * \retval NULL if not found
+ * \retval non-NULL if found
+ */
+struct ast_sip_contact_transport *ast_sip_location_retrieve_contact_transport_by_uri(const char *contact_uri);
+
+/*!
+ * \brief Retrieve a contact_transport, by transport
+ *
+ * \param transport transport the contact uses
+ *
+ * \retval NULL if not found
+ * \retval non-NULL if found
+ */
+struct ast_sip_contact_transport *ast_sip_location_retrieve_contact_transport_by_transport(pjsip_transport *transport);
+
+/*!
* \brief Add a new contact to an AOR
*
* \param aor Pointer to the AOR
@@ -1045,7 +1160,7 @@ int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text);
* \param src The pj_str_t to copy
* \param size The size of the destination buffer.
*/
-void ast_copy_pj_str(char *dest, pj_str_t *src, size_t size);
+void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size);
/*!
* \brief Get the looked-up endpoint on an out-of dialog request or response
@@ -1085,4 +1200,61 @@ int ast_sip_retrieve_auths(const char *auth_names[], size_t num_auths, struct as
*/
void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths);
+/*!
+ * \brief Checks if the given content type matches type/subtype.
+ *
+ * Compares the pjsip_media_type with the passed type and subtype and
+ * returns the result of that comparison. The media type parameters are
+ * ignored.
+ *
+ * \param content_type The pjsip_media_type structure to compare
+ * \param type The media type to compare
+ * \param subtype The media subtype to compare
+ * \retval 0 No match
+ * \retval -1 Match
+ */
+int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype);
+
+/*!
+ * \brief Send a security event notification for when an invalid endpoint is requested
+ *
+ * \param name Name of the endpoint requested
+ * \param rdata Received message
+ */
+void ast_sip_report_invalid_endpoint(const char *name, pjsip_rx_data *rdata);
+
+/*!
+ * \brief Send a security event notification for when an ACL check fails
+ *
+ * \param endpoint Pointer to the endpoint in use
+ * \param rdata Received message
+ * \param name Name of the ACL
+ */
+void ast_sip_report_failed_acl(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *name);
+
+/*!
+ * \brief Send a security event notification for when a challenge response has failed
+ *
+ * \param endpoint Pointer to the endpoint in use
+ * \param rdata Received message
+ */
+void ast_sip_report_auth_failed_challenge_response(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
+
+/*!
+ * \brief Send a security event notification for when authentication succeeds
+ *
+ * \param endpoint Pointer to the endpoint in use
+ * \param rdata Received message
+ */
+void ast_sip_report_auth_success(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
+
+/*!
+ * \brief Send a security event notification for when an authentication challenge is sent
+ *
+ * \param endpoint Pointer to the endpoint in use
+ * \param rdata Received message
+ * \param tdata Sent message
+ */
+void ast_sip_report_auth_challenge_sent(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata);
+
#endif /* _RES_SIP_H */
diff --git a/include/asterisk/res_sip_exten_state.h b/include/asterisk/res_sip_exten_state.h
new file mode 100644
index 000000000..62662f930
--- /dev/null
+++ b/include/asterisk/res_sip_exten_state.h
@@ -0,0 +1,94 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * Kevin Harwell <kharwell@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+#ifndef _RES_SIP_EXTEN_STATE_H
+#define _RES_SIP_EXTEN_STATE_H
+
+#include "asterisk/stringfields.h"
+#include "asterisk/linkedlists.h"
+
+#include "asterisk/pbx.h"
+#include "asterisk/presencestate.h"
+
+
+/*!
+ * \brief Contains information pertaining to extension/device state changes.
+ */
+struct ast_sip_exten_state_data {
+ /*! The extension of the current state change */
+ const char *exten;
+ /*! The extension state of the change */
+ enum ast_extension_states exten_state;
+ /*! The presence state of the change */
+ enum ast_presence_state presence_state;
+ /*! Current device state information */
+ struct ao2_container *device_state_info;
+};
+
+/*!
+ * \brief Extension state provider.
+ */
+struct ast_sip_exten_state_provider {
+ /*! The name of the event this provider registers for */
+ const char *event_name;
+ /*! Type of the body, ex: "application" */
+ const char *type;
+ /*! Subtype of the body, ex: "pidf+xml" */
+ const char *subtype;
+ /*! Type/Subtype together - ex: application/pidf+xml */
+ const char *body_type;
+ /*! Subscription handler to be used and associated with provider */
+ struct ast_sip_subscription_handler *handler;
+
+ /*!
+ * \brief Create the body text of a NOTIFY request.
+ *
+ * Implementors use this to create body information within the given
+ * ast_str. That information is then added to the NOTIFY request.
+ *
+ * \param data Current extension state changes
+ * \param local URI of the dialog's local party, e.g. 'from'
+ * \param remote URI of the dialog's remote party, e.g. 'to'
+ * \param body_text Out parameter used to populate the NOTIFY msg body
+ * \retval 0 Successfully created the body's text
+ * \retval -1 Failed to create the body's text
+ */
+ int (*create_body)(struct ast_sip_exten_state_data *data, const char *local,
+ const char *remote, struct ast_str **body_text);
+
+ /*! Next item in the list */
+ AST_LIST_ENTRY(ast_sip_exten_state_provider) next;
+};
+
+/*!
+ * \brief Registers an extension state provider.
+ *
+ * \param obj An extension state provider
+ * \retval 0 Successfully registered the extension state provider
+ * \retval -1 Failed to register the extension state provider
+ */
+int ast_sip_register_exten_state_provider(struct ast_sip_exten_state_provider *obj);
+
+/*!
+ * \brief Unregisters an extension state provider.
+ *
+ * \param obj An extension state provider
+ */
+void ast_sip_unregister_exten_state_provider(struct ast_sip_exten_state_provider *obj);
+
+#endif
diff --git a/include/asterisk/res_sip_pubsub.h b/include/asterisk/res_sip_pubsub.h
index 33614b285..be443299c 100644
--- a/include/asterisk/res_sip_pubsub.h
+++ b/include/asterisk/res_sip_pubsub.h
@@ -261,7 +261,22 @@ struct ast_taskprocessor *ast_sip_subscription_get_serializer(struct ast_sip_sub
* \retval non-NULL The underlying pjsip_evsub
*/
pjsip_evsub *ast_sip_subscription_get_evsub(struct ast_sip_subscription *sub);
-
+
+/*!
+ * \brief Get the underlying PJSIP dialog structure
+ *
+ * Call this function when information needs to be retrieved from the
+ * underlying pjsip dialog.
+ *
+ * This function, as well as all methods called on the pjsip_evsub should
+ * be done in a SIP servant thread.
+ *
+ * \param sub The subscription
+ * \retval NULL Failure
+ * \retval non-NULL The underlying pjsip_dialog
+ */
+pjsip_dialog *ast_sip_subscription_get_dlg(struct ast_sip_subscription *sub);
+
/*!
* \brief Send a request created via a PJSIP evsub method
*
diff --git a/include/asterisk/res_sip_session.h b/include/asterisk/res_sip_session.h
index cbed52621..e4b05f7c3 100644
--- a/include/asterisk/res_sip_session.h
+++ b/include/asterisk/res_sip_session.h
@@ -26,6 +26,8 @@
#include "asterisk/channel.h"
/* Needed for ast_sockaddr struct */
#include "asterisk/netsock.h"
+/* Neeed for ast_sdp_srtp struct */
+#include "asterisk/sdp_srtp.h"
/* Forward declarations */
struct ast_sip_endpoint;
@@ -41,6 +43,7 @@ struct ast_party_id;
struct pjmedia_sdp_media;
struct pjmedia_sdp_session;
struct ast_rtp_instance;
+struct ast_dsp;
struct ast_sip_session_sdp_handler;
@@ -54,6 +57,8 @@ struct ast_sip_session_media {
struct ast_sockaddr direct_media_addr;
/*! \brief SDP handler that setup the RTP */
struct ast_sip_session_sdp_handler *handler;
+ /*! \brief Holds SRTP information */
+ struct ast_sdp_srtp *srtp;
/*! \brief Stream is on hold */
unsigned int held:1;
/*! \brief Stream type this session media handles */
@@ -97,10 +102,18 @@ struct ast_sip_session {
pj_timer_entry rescheduled_reinvite;
/* Format capabilities pertaining to direct media */
struct ast_format_cap *direct_media_cap;
+ /* When we need to forcefully end the session */
+ pj_timer_entry scheduled_termination;
/* Identity of endpoint this session deals with */
struct ast_party_id id;
/* Requested capabilities */
struct ast_format_cap *req_caps;
+ /* Codecs overriden by dialplan on an outgoing request */
+ struct ast_codec_pref override_prefs;
+ /* Optional DSP, used only for inband DTMF detection if configured */
+ struct ast_dsp *dsp;
+ /* Whether the termination of the session should be deferred */
+ unsigned int defer_terminate:1;
};
typedef int (*ast_sip_session_request_creation_cb)(struct ast_sip_session *session, pjsip_tx_data *tdata);
@@ -289,6 +302,13 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint,
struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, const char *location, const char *request_user, struct ast_format_cap *req_caps);
/*!
+ * \brief Defer local termination of a session until remote side terminates, or an amount of time passes
+ *
+ * \param session The session to defer termination on
+ */
+void ast_sip_session_defer_termination(struct ast_sip_session *session);
+
+/*!
* \brief Register an SDP handler
*
* An SDP handler is responsible for parsing incoming SDP streams and ensuring that
@@ -452,6 +472,14 @@ void ast_sip_session_send_response(struct ast_sip_session *session, pjsip_tx_dat
void ast_sip_session_send_request(struct ast_sip_session *session, pjsip_tx_data *tdata);
/*!
+ * \brief Creates an INVITE request.
+ *
+ * \param session Starting session for the INVITE
+ * \param tdata The created request.
+ */
+int ast_sip_session_create_invite(struct ast_sip_session *session, pjsip_tx_data **tdata);
+
+/*!
* \brief Send a SIP request and get called back when a response is received
*
* This will send the request out exactly the same as ast_sip_send_request() does.
@@ -465,4 +493,18 @@ void ast_sip_session_send_request(struct ast_sip_session *session, pjsip_tx_data
void ast_sip_session_send_request_with_cb(struct ast_sip_session *session, pjsip_tx_data *tdata,
ast_sip_session_response_cb on_response);
+/*!
+ * \brief Retrieves a session from a dialog
+ *
+ * \param dlg The dialog to retrieve the session from
+ *
+ * \retval non-NULL if session exists
+ * \retval NULL if no session
+ *
+ * \note The reference count of the session is increased when returned
+ *
+ * \note This function *must* be called with the dialog locked
+ */
+struct ast_sip_session *ast_sip_dialog_get_session(pjsip_dialog *dlg);
+
#endif /* _RES_SIP_SESSION_H */
diff --git a/include/asterisk/sdp_srtp.h b/include/asterisk/sdp_srtp.h
new file mode 100644
index 000000000..9b92e0e3f
--- /dev/null
+++ b/include/asterisk/sdp_srtp.h
@@ -0,0 +1,125 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2006 - 2007, Mikael Magnusson
+ *
+ * Mikael Magnusson <mikma@users.sourceforge.net>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file sdp_srtp.h
+ *
+ * \brief SRTP and SDP Security descriptions
+ *
+ * Specified in RFC 4568
+ * Specified in RFC 3711
+ *
+ * \author Mikael Magnusson <mikma@users.sourceforge.net>
+ */
+
+#ifndef _SDP_SRTP_H
+#define _SDP_SRTP_H
+
+#include <asterisk/rtp_engine.h>
+
+struct ast_sdp_crypto;
+
+/*! \brief structure for secure RTP audio */
+struct ast_sdp_srtp {
+ unsigned int flags;
+ struct ast_sdp_crypto *crypto;
+};
+
+/* SRTP flags */
+#define AST_SRTP_CRYPTO_OFFER_OK (1 << 1)
+#define AST_SRTP_CRYPTO_TAG_32 (1 << 2)
+#define AST_SRTP_CRYPTO_TAG_80 (1 << 3)
+
+/*!
+ * \brief allocate a ast_sdp_srtp structure
+ * \retval a new malloc'd ast_sdp_srtp structure on success
+ * \retval NULL on failure
+*/
+struct ast_sdp_srtp *ast_sdp_srtp_alloc(void);
+
+/*!
+ * \brief free a ast_sdp_srtp structure
+ * \param srtp a ast_sdp_srtp structure
+*/
+void ast_sdp_srtp_destroy(struct ast_sdp_srtp *srtp);
+
+/*! \brief Initialize an return an ast_sdp_crypto struct
+ *
+ * \details
+ * This function allocates a new ast_sdp_crypto struct and initializes its values
+ *
+ * \retval NULL on failure
+ * \retval a pointer to a new ast_sdp_crypto structure
+ */
+struct ast_sdp_crypto *ast_sdp_crypto_alloc(void);
+
+/*! \brief Destroy a previously allocated ast_sdp_crypto struct */
+void ast_sdp_crypto_destroy(struct ast_sdp_crypto *crypto);
+
+/*! \brief Parse the a=crypto line from SDP and set appropriate values on the
+ * ast_sdp_crypto struct.
+ *
+ * The attribute line should already have "a=crypto:" removed.
+ *
+ * \param p A valid ast_sdp_crypto struct
+ * \param attr the a:crypto line from SDP
+ * \param rtp The rtp instance associated with the SDP being parsed
+ * \param srtp SRTP structure
+ *
+ * \retval 0 success
+ * \retval nonzero failure
+ */
+int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *srtp, const char *attr);
+
+/*! \brief Generate an SRTP a=crypto offer
+ *
+ * \details
+ * The offer is stored on the ast_sdp_crypto struct in a_crypto
+ *
+ * \param p A valid ast_sdp_crypto struct
+ * \param taglen Length
+ *
+ * \retval 0 success
+ * \retval nonzero failure
+ */
+int ast_sdp_crypto_build_offer(struct ast_sdp_crypto *p, int taglen);
+
+
+/*! \brief Get the crypto attribute line for the srtp structure
+ *
+ * The attribute line does not contain the initial "a=crypto:" and does
+ * not terminate with "\r\n".
+ *
+ * \param srtp The ast_sdp_srtp structure for which to get an attribute line
+ * \param dtls_enabled Whether this connection is encrypted with datagram TLS
+ * \param default_taglen_32 Whether to default to a tag length of 32 instead of 80
+ *
+ * \retval An attribute line containing cryptographic information
+ * \retval NULL if the srtp structure does not require an attribute line containing crypto information
+ */
+const char *ast_sdp_srtp_get_attrib(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32);
+
+/*! \brief Get the RTP profile in use by a media session
+ *
+ * \param sdes_active Whether the media session is using SDES-SRTP
+ * \param instance The RTP instance associated with this media session
+ * \param using_avpf Whether the media session is using early feedback (AVPF)
+ *
+ * \retval A non-allocated string describing the profile in use (does not need to be freed)
+ */
+char *ast_sdp_get_rtp_profile(unsigned int sdes_active, struct ast_rtp_instance *instance, unsigned int using_avpf);
+#endif /* _SDP_CRYPTO_H */