[asterisk-commits] kharwell: branch kharwell/pimp_my_sip r384973 - in /team/kharwell/pimp_my_sip...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 8 12:11:27 CDT 2013


Author: kharwell
Date: Mon Apr  8 12:11:23 2013
New Revision: 384973

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384973
Log:
Review updates

Modified:
    team/kharwell/pimp_my_sip/channels/chan_gulp.c
    team/kharwell/pimp_my_sip/res/res_sip.c
    team/kharwell/pimp_my_sip/res/res_sip_messaging.c

Modified: team/kharwell/pimp_my_sip/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_my_sip/channels/chan_gulp.c?view=diff&rev=384973&r1=384972&r2=384973
==============================================================================
--- team/kharwell/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/kharwell/pimp_my_sip/channels/chan_gulp.c Mon Apr  8 12:11:23 2013
@@ -1128,7 +1128,7 @@
 	struct gulp_pvt *pvt = ast_channel_tech_pvt(ast);
 	struct sendtext_data *data = sendtext_data_create(pvt->session, text);
 
-	return ast_sip_push_task(NULL, sendtext, data);
+	return ast_sip_push_task(pvt->session->serializer, sendtext, data);
 }
 
 /*! \brief Convert SIP hangup causes to Asterisk hangup causes */

Modified: team/kharwell/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_my_sip/res/res_sip.c?view=diff&rev=384973&r1=384972&r2=384973
==============================================================================
--- team/kharwell/pimp_my_sip/res/res_sip.c (original)
+++ team/kharwell/pimp_my_sip/res/res_sip.c Mon Apr  8 12:11:23 2013
@@ -22,7 +22,6 @@
 /* Needed for SUBSCRIBE, NOTIFY, and PUBLISH method definitions */
 #include <pjsip_simple.h>
 #include <pjlib.h>
-#include "pjsua-lib/pjsua.h"
 
 #include "asterisk/res_sip.h"
 #include "res_sip/include/res_sip_private.h"

Modified: team/kharwell/pimp_my_sip/res/res_sip_messaging.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_my_sip/res/res_sip_messaging.c?view=diff&rev=384973&r1=384972&r2=384973
==============================================================================
--- team/kharwell/pimp_my_sip/res/res_sip_messaging.c (original)
+++ team/kharwell/pimp_my_sip/res/res_sip_messaging.c Mon Apr  8 12:11:23 2013
@@ -24,9 +24,6 @@
  ***/
 
 #include "asterisk.h"
-
-#undef bzero
-#define bzero bzero
 
 #include "pjsua-lib/pjsua.h"
 
@@ -141,7 +138,7 @@
 	const char *value;
 	int max_forwards;
 
-	struct ast_msg_var_iterator *i = ast_msg_var_iterator_init(msg);
+	RAII_VAR(struct ast_msg_var_iterator *, i, ast_msg_var_iterator_init(msg), ast_msg_var_iterator_destroy);
 	while (ast_msg_var_iterator_next(msg, i, &name, &value)) {
 		if (!strcasecmp(name, "Max-Forwards")) {
 			/* Decrement Max-Forwards for SIP loop prevention. */
@@ -157,7 +154,6 @@
 		}
 		ast_msg_var_unref_current(i);
 	}
-	ast_msg_var_iterator_destroy(i);
 	return PJSIP_SC_OK;
 }
 
@@ -229,12 +225,15 @@
  */
 static enum pjsip_status_code rx_data_to_ast_msg(pjsip_rx_data *rdata, struct ast_msg *msg)
 {
-	int res, size;
+
+#define CHECK_RES(z_) do { if (z_) { ast_msg_destroy(msg); \
+		return PJSIP_SC_INTERNAL_SERVER_ERROR; } } while (0)
+
+	int size;
 	char buf[MAX_BODY_SIZE];
-	pjsip_uri *uri;
+	pjsip_name_addr *name_addr;
 	const char *field;
 	pjsip_status_code code;
-	pj_str_t *display;
 	struct ast_sip_endpoint *endpt = ast_pjsip_rdata_get_endpoint(rdata);
 
 	/* make sure there is an appropriate context and extension*/
@@ -242,50 +241,45 @@
 		return code;
 	}
 
-	res = ast_msg_set_context(msg, "%s", endpt->context);
-	res |= ast_msg_set_exten(msg, "%s", buf);
+	CHECK_RES(ast_msg_set_context(msg, "%s", endpt->context));
+	CHECK_RES(ast_msg_set_exten(msg, "%s", buf));
 
 	/* to header */
-	uri = pjsip_uri_get_uri(rdata->msg_info.to->uri);
-	pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, uri, buf, sizeof(buf)-1);
-	res = ast_msg_set_to(msg, "%s", buf);
+	name_addr = (pjsip_name_addr *)rdata->msg_info.to->uri;
+	if ((size = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, name_addr, buf, sizeof(buf)-1)) > 0) {
+		buf[size] = '\0';
+		CHECK_RES(ast_msg_set_to(msg, "%s", buf));
+	}
 
 	/* from header */
-	uri = pjsip_uri_get_uri(rdata->msg_info.from->uri);
-	pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, uri, buf, sizeof(buf)-1);
-	display = &((pjsip_name_addr*)rdata->msg_info.from->uri)->display;
-	if (pj_strlen(display)) {
-		res |= ast_msg_set_from(msg, "\"%.*s\" <%s>", pj_strlen(display), pj_strbuf(display), buf);
-	} else {
-		res |= ast_msg_set_from(msg, "<%s>", buf);
+	name_addr = (pjsip_name_addr *)rdata->msg_info.from->uri;
+	if ((size = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, name_addr, buf, sizeof(buf)-1)) > 0) {
+		buf[size] = '\0';
+		CHECK_RES(ast_msg_set_from(msg, "%s", buf));
 	}
 
 	/* contact header */
 	if ((size = pjsip_hdr_print_on(pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL), buf, sizeof(buf)-1)) > 0) {
 		buf[size] = '\0';
-		res |= ast_msg_set_var(msg, "SIP_FULLCONTACT", buf);
+		CHECK_RES(ast_msg_set_var(msg, "SIP_FULLCONTACT", buf));
 	}
 
 	/* receive address */
 	field = pj_sockaddr_print(&rdata->pkt_info.src_addr, buf, sizeof(buf)-1, 1);
-	res |= ast_msg_set_var(msg, "SIP_RECVADDR", field);
+	CHECK_RES(ast_msg_set_var(msg, "SIP_RECVADDR", field));
 
 	/* body */
 	if (print_body(rdata, buf, sizeof(buf) - 1) > 0) {
-		res |= ast_msg_set_body(msg, "%s", buf);
+		CHECK_RES(ast_msg_set_body(msg, "%s", buf));
 	}
 
 	/* endpoint name */
 	if (endpt->id.name.valid) {
-		res |= ast_msg_set_var(msg, "SIP_PEERNAME", endpt->id.name.str);
-	}
-
-	res |= headers_to_vars(rdata, msg);
-
-	if (res) {
-		ast_msg_destroy(msg);
-		return PJSIP_SC_INTERNAL_SERVER_ERROR;
-	}
+		CHECK_RES(ast_msg_set_var(msg, "SIP_PEERNAME", endpt->id.name.str));
+	}
+
+	CHECK_RES(headers_to_vars(rdata, msg));
+
 	return PJSIP_SC_OK;
 }
 
@@ -299,13 +293,8 @@
 {
 	struct msg_data *mdata = obj;
 
-	if (mdata->from) {
-		free(mdata->from);
-	}
-
-	if (mdata->to) {
-		free(mdata->to);
-	}
+	ast_free(mdata->from);
+	ast_free(mdata->to);
 
 	ast_msg_destroy(mdata->msg);
 }
@@ -452,7 +441,7 @@
 	struct ast_frame f;
 
 	pjsip_dialog *dlg = session->inv_session->dlg;
-	pjsip_transaction *tsx = session->inv_session->invite_tsx;
+	pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
 
 	if ((code = check_content_type(rdata)) != PJSIP_SC_OK) {
 		send_response(rdata, code, dlg, tsx);
@@ -491,19 +480,20 @@
 static int load_module(void)
 {
 	if (ast_sip_register_service(&messaging_module) != PJ_SUCCESS) {
-		return AST_MODULE_LOAD_FAILURE;
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	if (pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(),
 				       NULL, PJSIP_H_ALLOW, NULL, 1,
 				       &pjsip_message_method.name) != PJ_SUCCESS) {
 
-		pjsip_endpt_unregister_module(ast_sip_get_pjsip_endpoint(), &messaging_module);
-		return AST_MODULE_LOAD_FAILURE;
+		ast_sip_unregister_service(&messaging_module);
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	if (ast_msg_tech_register(&msg_tech)) {
-		return AST_MODULE_LOAD_FAILURE;
+		ast_sip_unregister_service(&messaging_module);
+		return AST_MODULE_LOAD_DECLINE;
 	}
 
 	ast_sip_session_register_supplement(&messaging_supplement);




More information about the asterisk-commits mailing list