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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 23 16:54:20 CST 2013


Author: mmichelson
Date: Wed Jan 23 16:54:17 2013
New Revision: 380024

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380024
Log:
Add a SIP logging module.

This way I can see on my CLI the SIP traffic Asterisk sees. This
way I am not relying on tools like tcpdump to see the traffic.

Right now, there's no configuration to enable or disable the logging.
You either load the module or don't load it. If loaded, you get debug,
if not loaded, you don't get debug.


Added:
    team/group/pimp_my_sip/res/res_sip_logger.c   (with props)
Modified:
    team/group/pimp_my_sip/res/Makefile

Modified: team/group/pimp_my_sip/res/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/Makefile?view=diff&rev=380024&r1=380023&r2=380024
==============================================================================
--- team/group/pimp_my_sip/res/Makefile (original)
+++ team/group/pimp_my_sip/res/Makefile Wed Jan 23 16:54:17 2013
@@ -95,3 +95,4 @@
 res_sip_session.o: _ASTCFLAGS+=$(PJ_CFLAGS)
 res_sip_sdp_audio.o: _ASTCFLAGS+=$(PJ_CFLAGS)
 res_sip_endpoint_identifier_constant.o: _ASTCFLAGS+=$(PJ_CFLAGS)
+res_sip_logger.o: _ASTCFLAGS+=$(PJ_CFLAGS)

Added: team/group/pimp_my_sip/res/res_sip_logger.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_logger.c?view=auto&rev=380024
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_logger.c (added)
+++ team/group/pimp_my_sip/res/res_sip_logger.c Wed Jan 23 16:54:17 2013
@@ -1,0 +1,77 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson at digium.com>
+ *
+ * Includes code and algorithms from the Zapata library.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*** MODULEINFO
+	<support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+#undef bzero
+#define bzero bzero
+#include <pjsip.h>
+
+#include "asterisk/res_sip.h"
+#include "asterisk/module.h"
+#include "asterisk/logger.h"
+
+static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
+{
+	ast_verbose("<--- Transmitting SIP %s to %.*s --->\n%.*s\n",
+			tdata->msg->type == PJSIP_REQUEST_MSG ? "request" : "response",
+			(int) pj_strlen(&tdata->dest_info.name), pj_strbuf(&tdata->dest_info.name),
+			(int) (tdata->buf.end - tdata->buf.start), tdata->buf.start);
+	return PJ_SUCCESS;
+}
+
+static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata)
+{
+	ast_verbose("<--- Received SIP %s from %s --->\n%s\n",
+			rdata->msg_info.msg->type == PJSIP_REQUEST_MSG ? "request" : "response",
+			rdata->pkt_info.src_name, rdata->pkt_info.packet);
+	return PJ_FALSE;
+}
+
+static pjsip_module logging_module = {
+	.name = { "Logging Module", 14 },
+	.priority = 0,
+	.on_rx_request = logging_on_rx_msg,
+	.on_rx_response = logging_on_rx_msg,
+	.on_tx_request = logging_on_tx_msg,
+	.on_tx_response = logging_on_tx_msg,
+};
+
+static int load_module(void)
+{
+	ast_sip_register_service(&logging_module);
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+static int unload_module(void)
+{
+	ast_sip_unregister_service(&logging_module);
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ADSI Resource",
+		.load = load_module,
+		.unload = unload_module,
+		.load_pri = AST_MODPRI_APP_DEPEND,
+	       );

Propchange: team/group/pimp_my_sip/res/res_sip_logger.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/group/pimp_my_sip/res/res_sip_logger.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/group/pimp_my_sip/res/res_sip_logger.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list