[asterisk-commits] file: branch group/pimp_my_sip r380159 - /team/group/pimp_my_sip/res/res_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 27 07:04:09 CST 2013


Author: file
Date: Sun Jan 27 07:04:04 2013
New Revision: 380159

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380159
Log:
Add a module with last priority that sends a 501 response on unhandled requests.

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

Modified: team/group/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.c?view=diff&rev=380159&r1=380158&r2=380159
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.c (original)
+++ team/group/pimp_my_sip/res/res_sip.c Sun Jan 27 07:04:04 2013
@@ -668,6 +668,21 @@
 	pj_thread_join(monitor_thread);
 }
 
+static pj_bool_t unhandled_on_rx_request(pjsip_rx_data *rdata)
+{
+	if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_ack_method)) {
+		pjsip_endpt_respond_stateless(ast_pjsip_endpoint, rdata, 501, NULL, NULL, NULL);
+	}
+
+	return PJ_TRUE;
+}
+
+static pjsip_module unhandled_module = {
+	.name = { "Unhandled", 9 },
+	.priority = PJSIP_MOD_PRIORITY_APPLICATION + 32,
+	.on_rx_request = unhandled_on_rx_request,
+};
+
 static int load_module(void)
 {
     /* The third parameter is just copied from
@@ -718,6 +733,11 @@
 		goto error;
 	}
 
+	if (ast_sip_register_service(&unhandled_module)) {
+		ast_log(LOG_ERROR, "Failed to register unhandled request module. Aborting load\n");
+		goto error;
+	}
+
 	if (sip_initialize_sorcery()) {
 		ast_log(LOG_ERROR, "Failed to initialize SIP sorcery. Aborting load\n");
 		goto error;




More information about the asterisk-commits mailing list