[asterisk-commits] mmichelson: branch group/pimp_my_sip r379390 - in /team/group/pimp_my_sip: ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 17 17:43:46 CST 2013


Author: mmichelson
Date: Thu Jan 17 17:43:42 2013
New Revision: 379390

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379390
Log:
Edit ast_sip_session_send_response() to take a pjsip_tx_data

I also edited all response-sending functions to use this instead
of pjsip_inv_send_msg(). This way, session supplements get called
when we send our responses.


Modified:
    team/group/pimp_my_sip/channels/chan_gulp.c
    team/group/pimp_my_sip/include/asterisk/res_sip_session.h
    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=379390&r1=379389&r2=379390
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Thu Jan 17 17:43:42 2013
@@ -176,7 +176,7 @@
 	ast_setstate(ast, AST_STATE_UP);
 
 	if ((status = pjsip_inv_answer(session->inv_session, 200, NULL, NULL, &packet)) == PJ_SUCCESS) {
-		pjsip_inv_send_msg(session->inv_session, packet);
+		ast_sip_session_send_response(session, packet);
 	}
 
 	return (status == PJ_SUCCESS) ? 0 : -1;
@@ -308,7 +308,7 @@
 	case AST_CONTROL_VIDUPDATE:
 	case AST_CONTROL_UPDATE_RTP_PEER:
 	case AST_CONTROL_PVT_CAUSE_CODE:
-                break;
+		break;
 	case AST_CONTROL_HOLD:
 		ast_moh_start(ast, data, NULL);
 		break;
@@ -329,7 +329,7 @@
 	}
 
 	if (packet && (status == PJ_SUCCESS)) {
-		pjsip_inv_send_msg(session->inv_session, packet);
+		ast_sip_session_send_response(session, packet);
 	}
 
 	return res;
@@ -427,7 +427,11 @@
 	int cause = hangup_cause2sip(ast_channel_hangupcause(session->channel));
 
 	if (((status = pjsip_inv_end_session(session->inv_session, cause ? cause : 603, NULL, &packet)) == PJ_SUCCESS) && packet) {
-		pjsip_inv_send_msg(session->inv_session, packet);
+		if (packet->msg->type == PJSIP_RESPONSE_MSG) {
+			ast_sip_session_send_response(session, packet);
+		} else {
+			pjsip_inv_send_msg(session->inv_session, packet);
+		}
 	}
 
 	session->channel = NULL;
@@ -478,7 +482,7 @@
 		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);
+			ast_sip_session_send_response(session, packet);
 		}
 
 		return -1;
@@ -488,7 +492,7 @@
 		pjsip_tx_data *packet = NULL;
 
 		if (pjsip_inv_end_session(session->inv_session, 503, NULL, &packet) == PJ_SUCCESS) {
-			pjsip_inv_send_msg(session->inv_session, packet);
+			ast_sip_session_send_response(session, packet);
 		}
 
 		return -1;

Modified: team/group/pimp_my_sip/include/asterisk/res_sip_session.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip_session.h?view=diff&rev=379390&r1=379389&r2=379390
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip_session.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip_session.h Thu Jan 17 17:43:42 2013
@@ -270,13 +270,12 @@
 /*!
  * \brief Send a SIP response
  *
- * This will send a SIP response to the request specified in rdata. This will
+ * This will send the SIP response specified in tdata and
  * call into any registered supplements' outgoing_response callback.
  *
  * \param session The session to which the current transaction belongs
- * \param response_code The response code to send for this response
- * \param rdata The response to which the response is being sent
- */
-int ast_sip_session_send_response(struct ast_sip_session *session, int response_code, struct pjsip_rx_data *rdata);
+ * \param tdata The response to send
+ */
+void ast_sip_session_send_response(struct ast_sip_session *session, pjsip_tx_data *tdata);
 
 #endif /* _RES_SIP_SESSION_H */

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=379390&r1=379389&r2=379390
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.c (original)
+++ team/group/pimp_my_sip/res/res_sip_session.c Thu Jan 17 17:43:42 2013
@@ -311,10 +311,14 @@
 	return 0;
 }
 
-int ast_sip_session_send_response(struct ast_sip_session *session, int response_code, struct pjsip_rx_data *rdata)
-{
-	/* XXX STUB */
-	return 0;
+void ast_sip_session_send_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
+{
+	struct ast_sip_session_supplement *supplement;
+	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
+		supplement->outgoing_response(session, tdata);
+	}
+	pjsip_inv_send_msg(session->inv_session, tdata);
+	return;
 }
 
 static pj_status_t session_load(pjsip_endpoint *endpt);
@@ -573,8 +577,7 @@
 	session = ast_sip_session_alloc(endpoint, inv_session);
 	if (!session) {
         if (pjsip_inv_end_session(inv_session, 403, NULL, &tdata) == PJ_SUCCESS) {
-			/*XXX Should replace this with res_sip or res_sip_session call */
-			pjsip_inv_send_msg(inv_session, tdata);
+			ast_sip_session_send_response(session, tdata);
 		} else {
 			/*XXX Should replace this with res_sip or res_sip_session call */
 			pjsip_inv_terminate(inv_session, 403, PJ_FALSE);
@@ -588,8 +591,7 @@
 		break;
 	case SIP_GET_DEST_UNSUPPORTED_URI:
         if (pjsip_inv_end_session(inv_session, 416, NULL, &tdata) == PJ_SUCCESS) {
-			/*XXX Should replace this with res_sip or res_sip_session call */
-			pjsip_inv_send_msg(inv_session, tdata);
+			ast_sip_session_send_response(session, tdata);
 		} else {
 			/*XXX Should replace this with res_sip or res_sip_session call */
 			pjsip_inv_terminate(inv_session, 416, PJ_FALSE);
@@ -598,9 +600,9 @@
 	case SIP_GET_DEST_EXTEN_NOT_FOUND:
 	case SIP_GET_DEST_EXTEN_PARTIAL:
 	default:
-      if (pjsip_inv_end_session(inv_session, 404, NULL, &tdata) == PJ_SUCCESS) {
-			/*XXX Should replace this with res_sip or res_sip_session call */
-			pjsip_inv_send_msg(inv_session, tdata);
+		if (pjsip_inv_end_session(inv_session, 404, NULL, &tdata) == PJ_SUCCESS) {
+			/*XXX Should replace this with res_sip or res_sip_session call */
+			ast_sip_session_send_response(session, tdata);
 		} else {
 			/*XXX Should replace this with res_sip or res_sip_session call */
 			pjsip_inv_terminate(inv_session, 404, PJ_FALSE);
@@ -616,8 +618,7 @@
 	if (handle_sdp(session, rdata)) {
 		/* Dangit. After all that, we have to reject the call */
 		if (pjsip_inv_end_session(inv_session, 488, NULL, &tdata) == PJ_SUCCESS) {
-			/*XXX Should replace this with res_sip or res_sip_session call */
-			pjsip_inv_send_msg(inv_session, tdata);
+			ast_sip_session_send_response(session, tdata);
 		} else {
 			/*XXX Should replace this with res_sip or res_sip_session call */
 			pjsip_inv_terminate(inv_session, 488, PJ_FALSE);




More information about the asterisk-commits mailing list