[Pkg-voip-commits] [janus] 62/282: Send incoming/outgoing SIP messages to event handlers when using SIPre plugin, if sip_set_trace is available in libre
Jonas Smedegaard
dr at jones.dk
Wed Dec 20 21:53:27 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/0.2.6-1
in repository janus.
commit f70f4528ac883899f2d5207771f6031a652fd8a4
Author: Lorenzo Miniero <lminiero at gmail.com>
Date: Thu Jun 1 16:57:34 2017 +0200
Send incoming/outgoing SIP messages to event handlers when using SIPre plugin, if sip_set_trace is available in libre
---
configure.ac | 9 ++++++++-
plugins/janus_sipre.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 4e8aea1..addfd02 100644
--- a/configure.ac
+++ b/configure.ac
@@ -531,7 +531,14 @@ PKG_CHECK_MODULES([LIBRE],
[libre],
[
AS_IF([test "x$enable_plugin_sipre" = "xmaybe"],
- [enable_plugin_sipre=yes])
+ [
+ enable_plugin_sipre=yes
+ AC_CHECK_LIB([re],
+ [sip_set_trace],
+ [AC_DEFINE(HAVE_LIBRE_SIPTRACE)],
+ [AC_MSG_NOTICE([libre version does not have sip_set_trace])]
+ )
+ ])
],
[
AS_IF([test "x$enable_plugin_sipre" = "xyes"],
diff --git a/plugins/janus_sipre.c b/plugins/janus_sipre.c
index a9818e8..783df4a 100644
--- a/plugins/janus_sipre.c
+++ b/plugins/janus_sipre.c
@@ -798,6 +798,25 @@ static void janus_sipre_random_string(int length, char *buffer) {
}
+#ifdef HAVE_LIBRE_SIPTRACE
+/* libre SIP logger function: when the Event Handlers mechanism is enabled,
+ * we use this to intercept SIP messages sent and received by the stack */
+static void janus_sipre_msg_logger(bool tx, enum sip_transp tp, const struct sa *src, const struct sa *dst,
+ const uint8_t *pkt, size_t len, void *arg) {
+ /* Access the session this message refers to */
+ janus_sipre_session *session = (janus_sipre_session *)arg;
+ /* Print the SIP message */
+ char sip_msg[2048];
+ g_snprintf(sip_msg, sizeof(sip_msg), "%.*s", (int)len, (char *)pkt);
+ /* Shoot the event */
+ json_t *info = json_object();
+ json_object_set_new(info, "event", json_string(tx ? "sip-out" : "sip-in"));
+ json_object_set_new(info, "sip", json_string(sip_msg));
+ gateway->notify_event(&janus_sipre_plugin, session->handle, info);
+}
+#endif
+
+
/* Plugin implementation */
int janus_sipre_init(janus_callbacks *callback, const char *config_path) {
if(g_atomic_int_get(&stopping)) {
@@ -931,6 +950,13 @@ int janus_sipre_init(janus_callbacks *callback, const char *config_path) {
return -1;
}
+#ifndef HAVE_LIBRE_SIPTRACE
+ JANUS_LOG(LOG_WARN, "sip_set_trace() was not found in libre... "
+ "The tracing of SIP incoming/outgoing SIP messages when using the SIPre plugin will not be available to Event Handlers. "
+ "In case you're interested in that, apply this patch on your libre installation and recompile the plugin: "
+ "https://raw.githubusercontent.com/alfredh/patches/master/re-sip-trace.patch\n");
+#endif
+
JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_SIPRE_NAME);
return 0;
}
@@ -3507,6 +3533,12 @@ void janus_sipre_mqueue_handler(int id, void *data, void *arg) {
g_free(payload);
return;
}
+#ifdef HAVE_LIBRE_SIPTRACE
+ if(gateway->events_is_enabled()) {
+ /* Trace incoming/outgoing SIP messages */
+ sip_set_trace(session->stack.sipstack, janus_sipre_msg_logger);
+ }
+#endif
mem_deref(session->stack.tls);
g_free(payload);
break;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git
More information about the Pkg-voip-commits
mailing list