[asterisk-commits] file: branch group/pimp_my_sip r379225 - /team/group/pimp_my_sip/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 16 11:13:49 CST 2013


Author: file
Date: Wed Jan 16 11:13:46 2013
New Revision: 379225

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379225
Log:
Use the user portion of the request URI as the dialed extension.

Modified:
    team/group/pimp_my_sip/channels/chan_gulp.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=379225&r1=379224&r2=379225
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Wed Jan 16 11:13:46 2013
@@ -448,6 +448,8 @@
 /*! \brief Function called when a request is received on the session */
 static int gulp_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
 {
+	pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
+	char exten[AST_MAX_EXTENSION] = "";
 	int res = AST_PBX_FAILED;
 
 	/* We only care about new sessions */
@@ -456,7 +458,21 @@
 		return 0;
 	}
 
-	if (!(session->channel = gulp_new(session, AST_STATE_DOWN, NULL, NULL, NULL, NULL))) {
+	if (PJSIP_URI_SCHEME_IS_SIP(ruri) || PJSIP_URI_SCHEME_IS_SIPS(ruri)) {
+		pjsip_sip_uri *sipRuri = pjsip_uri_get_uri(ruri);
+
+		snprintf(exten, sizeof(exten), "%.*s", (int) pj_strlen(&sipRuri->user), pj_strbuf(&sipRuri->user));
+	} else {
+		pjsip_tx_data *packet = NULL;
+
+		if (pjsip_inv_end_session(session->inv_session, 416, NULL, &packet) == PJ_SUCCESS) {
+			pjsip_inv_send_msg(session->inv_session, packet);
+		}
+
+		return -1;
+	}
+
+	if (!(session->channel = gulp_new(session, AST_STATE_DOWN, exten, NULL, NULL, NULL))) {
 		pjsip_tx_data *packet = NULL;
 
 		if (pjsip_inv_end_session(session->inv_session, 503, NULL, &packet) == PJ_SUCCESS) {




More information about the asterisk-commits mailing list