[svn-commits] file: branch group/pimp_my_sip r380412 - in /team/group/pimp_my_sip: channels...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jan 29 15:01:29 CST 2013


Author: file
Date: Tue Jan 29 15:01:26 2013
New Revision: 380412

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380412
Log:
Add 100rel and session timers support. This is configurable on a per-endpoint basis.

Modified:
    team/group/pimp_my_sip/channels/chan_gulp.c
    team/group/pimp_my_sip/configs/res_sip.conf.sample
    team/group/pimp_my_sip/include/asterisk/res_sip.h
    team/group/pimp_my_sip/res/res_sip/sip_configuration.c
    team/group/pimp_my_sip/res/res_sip_session.c

Modified: team/group/pimp_my_sip/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/channels/chan_gulp.c?view=diff&rev=380412&r1=380411&r2=380412
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Tue Jan 29 15:01:26 2013
@@ -509,8 +509,11 @@
 		return NULL;
 	}
 
+	/* TODO: This needs to actually grab a proper endpoint and such */
 	ast_string_field_set(endpoint, context, "default");
 	ast_parse_allow_disallow(&endpoint->prefs, endpoint->codecs, "ulaw", 1);
+	endpoint->min_se = 90;
+	endpoint->sess_expires = 1800;
 
 	pj_thread_register_check();
 

Modified: team/group/pimp_my_sip/configs/res_sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/configs/res_sip.conf.sample?view=diff&rev=380412&r1=380411&r2=380412
==============================================================================
--- team/group/pimp_my_sip/configs/res_sip.conf.sample (original)
+++ team/group/pimp_my_sip/configs/res_sip.conf.sample Tue Jan 29 15:01:26 2013
@@ -12,5 +12,9 @@
 context=default
 disallow=all
 allow=ulaw
-dtmfmode=rfc4733 ; Supported DTMF modes are rfc4733, inband, info, and none
-;transport=local ; Name of a specific transport to use when placing calls
+dtmfmode=rfc4733          ; Supported DTMF modes are rfc4733, inband, info, and none
+;transport=local          ; Name of a specific transport to use when placing calls
+;100rel=yes               ; Enable or disable 100rel support - valid options are: yes, no, required
+;timers=yes               ; Enable or disable session timers support - valid options are: yes, no, required, forced
+;timers_min_se=90         ; Minimum session timers expiration period, in seconds
+;timers_sess_expires=1800 ; Session timers expiration period, in seconds

Modified: team/group/pimp_my_sip/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip.h?view=diff&rev=380412&r1=380411&r2=380412
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip.h Tue Jan 29 15:01:26 2013
@@ -196,6 +196,12 @@
 	struct ast_format_cap *codecs;
 	/*! DTMF mode to use with this endpoint */
 	enum ast_sip_dtmf_mode dtmf;
+	/*! Enabled SIP extensions */
+	unsigned int extensions;
+	/*! Minimum session expiration period, in seconds */
+	unsigned min_se;
+	/*! Session expiration period, in seconds */
+	unsigned sess_expires;
 	/*! List of outbound registrations */
 	AST_LIST_HEAD_NOLOCK(, ast_sip_registration) registrations;
 	/*! Frequency to send OPTIONS requests to endpoint. 0 is disabled. */

Modified: team/group/pimp_my_sip/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip/sip_configuration.c?view=diff&rev=380412&r1=380411&r2=380412
==============================================================================
--- team/group/pimp_my_sip/res/res_sip/sip_configuration.c (original)
+++ team/group/pimp_my_sip/res/res_sip/sip_configuration.c Tue Jan 29 15:01:26 2013
@@ -10,6 +10,7 @@
 #undef bzero
 #define bzero bzero
 #include "pjsip.h"
+#include "pjsip_ua.h"
 
 #include "asterisk/res_sip.h"
 #include "include/res_sip_private.h"
@@ -156,6 +157,42 @@
 	return 0;
 }
 
+static int prack_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+	struct ast_sip_endpoint *endpoint = obj;
+
+	if (ast_true(var->value)) {
+		endpoint->extensions |= PJSIP_INV_SUPPORT_100REL;
+	} else if (ast_false(var->value)) {
+		endpoint->extensions &= PJSIP_INV_SUPPORT_100REL;
+	} else if (!strcasecmp(var->value, "required")) {
+		endpoint->extensions |= PJSIP_INV_REQUIRE_100REL;
+	} else {
+		return -1;
+	}
+
+	return 0;
+}
+
+static int timers_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
+{
+	struct ast_sip_endpoint *endpoint = obj;
+
+	if (ast_true(var->value)) {
+		endpoint->extensions |= PJSIP_INV_SUPPORT_TIMER;
+	} else if (ast_false(var->value)) {
+		endpoint->extensions &= PJSIP_INV_SUPPORT_TIMER;
+	} else if (!strcasecmp(var->value, "required")) {
+		endpoint->extensions |= PJSIP_INV_REQUIRE_TIMER;
+	} else if (!strcasecmp(var->value, "always")) {
+		endpoint->extensions |= PJSIP_INV_ALWAYS_USE_TIMER;
+	} else {
+		return -1;
+	}
+
+	return 0;
+}
+
 int ast_res_sip_initialize_configuration(void)
 {
 	if (ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands))) {
@@ -191,6 +228,10 @@
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "host", "", host_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtmfmode", "rfc4733", dtmf_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "transport", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, transport));
+	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "100rel", "yes", prack_handler, NULL, 0, 0);
+	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "timers", "yes", timers_handler, NULL, 0, 0);
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_min_se", "90", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, min_se));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "timers_sess_expires", "1800", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, sess_expires));
 
 	if (ast_sip_initialize_sorcery_transport(sip_sorcery)) {
 		ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");

Modified: team/group/pimp_my_sip/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_session.c?view=diff&rev=380412&r1=380411&r2=380412
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.c (original)
+++ team/group/pimp_my_sip/res/res_sip_session.c Tue Jan 29 15:01:26 2013
@@ -541,6 +541,7 @@
 	struct ast_sip_session *session = NULL;
 	pjmedia_sdp_session *offer = NULL;
 	pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
+	pjsip_timer_setting timer;
 
 	if (pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, NULL, &dlg) != PJ_SUCCESS) {
 		return NULL;
@@ -576,12 +577,17 @@
 	dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
 	dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL);
 
-	if (pjsip_inv_create_uac(dlg, NULL, 0, &inv_session) != PJ_SUCCESS) {
+	if (pjsip_inv_create_uac(dlg, NULL, endpoint->extensions, &inv_session) != PJ_SUCCESS) {
 		pjsip_dlg_terminate(dlg);
 		return NULL;
 	}
 
 	pjsip_dlg_set_transport(dlg, &selector);
+
+	pjsip_timer_setting_default(&timer);
+	timer.min_se = endpoint->min_se;
+	timer.sess_expires = endpoint->sess_expires;
+	pjsip_timer_init_session(inv_session, &timer);
 	
 	if (pjsip_dlg_add_usage(dlg, &session_module, NULL) != PJ_SUCCESS) {
 		pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
@@ -641,12 +647,12 @@
 	return SIP_GET_DEST_EXTEN_NOT_FOUND;
 }
 
-static pjsip_inv_session *pre_session_setup(pjsip_rx_data *rdata)
+static pjsip_inv_session *pre_session_setup(pjsip_rx_data *rdata, const struct ast_sip_endpoint *endpoint)
 {
 	pjsip_tx_data *tdata;
 	pjsip_dialog *dlg;
 	pjsip_inv_session *inv_session;
-	unsigned int options = 0;
+	unsigned int options = endpoint->extensions;
 
 	if (pjsip_inv_verify_request(rdata, &options, NULL, NULL, ast_sip_get_pjsip_endpoint(), &tdata) != PJ_SUCCESS) {
 		if (tdata) {
@@ -688,22 +694,19 @@
 	pjsip_inv_session *inv_session = NULL;
 	struct ast_sip_endpoint *endpoint = NULL;
 	struct ast_sip_session *session = NULL;
+	pjsip_timer_setting timer;
 	pjsip_rdata_sdp_info *sdp_info;
 	pjmedia_sdp_session *local = NULL;
 
-	inv_session = pre_session_setup(rdata);
+	endpoint = ast_sip_identify_endpoint(rdata);
+	if (!endpoint) {
+		pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 403, NULL, NULL, NULL);
+		return;
+	}
+
+	inv_session = pre_session_setup(rdata, endpoint);
 	if (!inv_session) {
 		/* pre_session_setup() returns a response on failure */
-		return;
-	}
-
-	endpoint = ast_sip_identify_endpoint(rdata);
-	if (!endpoint) {
-		if (pjsip_inv_initial_answer(inv_session, rdata, 403, NULL, NULL, &tdata) == PJ_SUCCESS) {
-			pjsip_inv_send_msg(inv_session, tdata);
-		} else  {
-			pjsip_inv_terminate(inv_session, 403, PJ_FALSE);
-		}
 		return;
 	}
 
@@ -792,6 +795,11 @@
 	} else {
 		pjsip_inv_set_local_sdp(inv_session, local);
 	}
+
+	pjsip_timer_setting_default(&timer);
+	timer.min_se = endpoint->min_se;
+	timer.sess_expires = endpoint->sess_expires;
+	pjsip_timer_init_session(inv_session, &timer);
 
 	/* At this point, we've verified what we can, so let's go ahead and send a 100 Trying out */
 	if (pjsip_inv_initial_answer(inv_session, rdata, 100, NULL, NULL, &tdata) != PJ_SUCCESS) {
@@ -1125,6 +1133,7 @@
 	pjsip_ua_init_module(endpt, NULL);
 	pjsip_inv_usage_init(endpt, &inv_callback);
 	pjsip_100rel_init_module(endpt);
+	pjsip_timer_init_module(endpt);
 	if (ast_sip_register_service(&session_module)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}




More information about the svn-commits mailing list