[asterisk-commits] mmichelson: branch group/pimp_my_sip r379916 - /team/group/pimp_my_sip/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 22 13:53:12 CST 2013


Author: mmichelson
Date: Tue Jan 22 13:53:09 2013
New Revision: 379916

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379916
Log:
Use common outgoing message handler in ast_sip_send_response.

The commit seems large because I changed the placement of functions.


Modified:
    team/group/pimp_my_sip/res/res_sip_session.c

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=379916&r1=379915&r2=379916
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_session.c (original)
+++ team/group/pimp_my_sip/res/res_sip_session.c Tue Jan 22 13:53:09 2013
@@ -36,6 +36,14 @@
 
 #define SDP_HANDLER_BUCKETS 11
 
+/* Some forward declarations */
+static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata);
+static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata);
+static void handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata);
+static void handle_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata);
+static void handle_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata);
+static void handle_outgoing(struct ast_sip_session *session, pjsip_tx_data *tdata);
+
 /*!
  * \brief Registered SDP stream handlers
  *
@@ -303,12 +311,7 @@
 
 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) {
-		if (supplement->outgoing_response) {
-			supplement->outgoing_response(session, tdata);
-		}
-	}
+	handle_outgoing_response(session, tdata);
 	pjsip_inv_send_msg(session->inv_session, tdata);
 	return;
 }
@@ -558,101 +561,6 @@
 		return NULL;
 	}
 	return inv_session;
-}
-
-static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
-{
-	struct ast_sip_session_supplement *supplement;
-	char method[16];
-	struct pjsip_request_line req = rdata->msg_info.msg->line.req;
-	pj_str_t *pj_method = &req.method.name;
-
-	ast_copy_pj_str(method, pj_method, sizeof(method));
-
-	ast_debug(3, "Method is %s\n", method);
-	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
-		if (supplement->incoming_request && (
-				!supplement->method || !strcmp(supplement->method, method))) {
-			supplement->incoming_request(session, rdata);
-		}
-	}
-}
-
-static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
-{
-	struct ast_sip_session_supplement *supplement;
-	struct pjsip_status_line status = rdata->msg_info.msg->line.status;
-
-	ast_debug(3, "Response is %d %.*s\n", status.code, (int) pj_strlen(&status.reason),
-			pj_strbuf(&status.reason));
-
-	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
-		/* XXX Not sure how to get the method from a response.
-		 * For now, just call supplements on all responses, no
-		 * matter the method. This is less than ideal
-		 */
-		if (supplement->incoming_response) {
-			supplement->incoming_response(session, rdata);
-		}
-	}
-}
-
-static void handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata)
-{
-	ast_debug(3, "Received %s\n", rdata->msg_info.msg->type == PJSIP_REQUEST_MSG ?
-			"request" : "response");
-	if (rdata->msg_info.msg->type == PJSIP_REQUEST_MSG) {
-		handle_incoming_request(session, rdata);
-	} else {
-		handle_incoming_response(session, rdata);
-	}
-}
-
-static void handle_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
-{
-	struct ast_sip_session_supplement *supplement;
-	char method[16];
-	struct pjsip_request_line req = tdata->msg->line.req;
-	pj_str_t *pj_method = &req.method.name;
-
-	ast_copy_pj_str(method, pj_method, sizeof(method));
-
-	ast_debug(3, "Method is %s\n", method);
-	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
-		if (supplement->outgoing_request && 
-				(!supplement->method || !strcmp(supplement->method, method))) {
-			supplement->outgoing_request(session, tdata);
-		}
-	}
-}
-
-static void handle_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
-{
-	struct ast_sip_session_supplement *supplement;
-	struct pjsip_status_line status = tdata->msg->line.status;
-	ast_debug(3, "Response is %d %.*s\n", status.code, (int) pj_strlen(&status.reason),
-			pj_strbuf(&status.reason));
-
-	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
-		/* XXX Not sure how to get the method from a response.
-		 * For now, just call supplements on all responses, no
-		 * matter the method. This is less than ideal
-		 */
-		if (supplement->outgoing_response) {
-			supplement->outgoing_response(session, tdata);
-		}
-	}
-}
-
-static void handle_outgoing(struct ast_sip_session *session, pjsip_tx_data *tdata)
-{
-	ast_debug(3, "Sending %s\n", tdata->msg->type == PJSIP_REQUEST_MSG ?
-			"request" : "response");
-	if (tdata->msg->type == PJSIP_REQUEST_MSG) {
-		handle_outgoing_request(session, tdata);
-	} else {
-		handle_outgoing_response(session, tdata);
-	}
 }
 
 static void handle_new_invite(pjsip_rx_data *rdata)
@@ -810,6 +718,101 @@
 static void session_on_tsx_state(pjsip_transaction *tsx, pjsip_event *event)
 {
 	/* XXX STUB */
+}
+
+static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
+{
+	struct ast_sip_session_supplement *supplement;
+	char method[16];
+	struct pjsip_request_line req = rdata->msg_info.msg->line.req;
+	pj_str_t *pj_method = &req.method.name;
+
+	ast_copy_pj_str(method, pj_method, sizeof(method));
+
+	ast_debug(3, "Method is %s\n", method);
+	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
+		if (supplement->incoming_request && (
+				!supplement->method || !strcmp(supplement->method, method))) {
+			supplement->incoming_request(session, rdata);
+		}
+	}
+}
+
+static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
+{
+	struct ast_sip_session_supplement *supplement;
+	struct pjsip_status_line status = rdata->msg_info.msg->line.status;
+
+	ast_debug(3, "Response is %d %.*s\n", status.code, (int) pj_strlen(&status.reason),
+			pj_strbuf(&status.reason));
+
+	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
+		/* XXX Not sure how to get the method from a response.
+		 * For now, just call supplements on all responses, no
+		 * matter the method. This is less than ideal
+		 */
+		if (supplement->incoming_response) {
+			supplement->incoming_response(session, rdata);
+		}
+	}
+}
+
+static void handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata)
+{
+	ast_debug(3, "Received %s\n", rdata->msg_info.msg->type == PJSIP_REQUEST_MSG ?
+			"request" : "response");
+	if (rdata->msg_info.msg->type == PJSIP_REQUEST_MSG) {
+		handle_incoming_request(session, rdata);
+	} else {
+		handle_incoming_response(session, rdata);
+	}
+}
+
+static void handle_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
+{
+	struct ast_sip_session_supplement *supplement;
+	char method[16];
+	struct pjsip_request_line req = tdata->msg->line.req;
+	pj_str_t *pj_method = &req.method.name;
+
+	ast_copy_pj_str(method, pj_method, sizeof(method));
+
+	ast_debug(3, "Method is %s\n", method);
+	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
+		if (supplement->outgoing_request && 
+				(!supplement->method || !strcmp(supplement->method, method))) {
+			supplement->outgoing_request(session, tdata);
+		}
+	}
+}
+
+static void handle_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
+{
+	struct ast_sip_session_supplement *supplement;
+	struct pjsip_status_line status = tdata->msg->line.status;
+	ast_debug(3, "Response is %d %.*s\n", status.code, (int) pj_strlen(&status.reason),
+			pj_strbuf(&status.reason));
+
+	AST_LIST_TRAVERSE(&session->supplements, supplement, next) {
+		/* XXX Not sure how to get the method from a response.
+		 * For now, just call supplements on all responses, no
+		 * matter the method. This is less than ideal
+		 */
+		if (supplement->outgoing_response) {
+			supplement->outgoing_response(session, tdata);
+		}
+	}
+}
+
+static void handle_outgoing(struct ast_sip_session *session, pjsip_tx_data *tdata)
+{
+	ast_debug(3, "Sending %s\n", tdata->msg->type == PJSIP_REQUEST_MSG ?
+			"request" : "response");
+	if (tdata->msg->type == PJSIP_REQUEST_MSG) {
+		handle_outgoing_request(session, tdata);
+	} else {
+		handle_outgoing_response(session, tdata);
+	}
 }
 
 static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)




More information about the asterisk-commits mailing list