Revision f70f4528

View differences:

configure.ac
531 531
                  [libre],
532 532
                  [
533 533
                    AS_IF([test "x$enable_plugin_sipre" = "xmaybe"],
534
                          [enable_plugin_sipre=yes])
534
                          [
535
                           enable_plugin_sipre=yes
536
                           AC_CHECK_LIB([re],
537
                                        [sip_set_trace],
538
                                        [AC_DEFINE(HAVE_LIBRE_SIPTRACE)],
539
                                        [AC_MSG_NOTICE([libre version does not have sip_set_trace])]
540
                                       )
541
                          ])
535 542
                  ],
536 543
                  [
537 544
                    AS_IF([test "x$enable_plugin_sipre" = "xyes"],
plugins/janus_sipre.c
798 798
}
799 799

  
800 800

  
801
#ifdef HAVE_LIBRE_SIPTRACE
802
/* libre SIP logger function: when the Event Handlers mechanism is enabled,
803
 * we use this to intercept SIP messages sent and received by the stack */
804
static void janus_sipre_msg_logger(bool tx, enum sip_transp tp, const struct sa *src, const struct sa *dst,
805
		const uint8_t *pkt, size_t len, void *arg) {
806
	/* Access the session this message refers to */
807
	janus_sipre_session *session = (janus_sipre_session *)arg;
808
	/* Print the SIP message */
809
	char sip_msg[2048];
810
	g_snprintf(sip_msg, sizeof(sip_msg), "%.*s", (int)len, (char *)pkt);
811
	/* Shoot the event */
812
	json_t *info = json_object();
813
	json_object_set_new(info, "event", json_string(tx ? "sip-out" : "sip-in"));
814
	json_object_set_new(info, "sip", json_string(sip_msg));
815
	gateway->notify_event(&janus_sipre_plugin, session->handle, info);
816
}
817
#endif
818

  
819

  
801 820
/* Plugin implementation */
802 821
int janus_sipre_init(janus_callbacks *callback, const char *config_path) {
803 822
	if(g_atomic_int_get(&stopping)) {
......
931 950
		return -1;
932 951
	}
933 952

  
953
#ifndef HAVE_LIBRE_SIPTRACE
954
	JANUS_LOG(LOG_WARN, "sip_set_trace() was not found in libre... "
955
		"The tracing of SIP incoming/outgoing SIP messages when using the SIPre plugin will not be available to Event Handlers. "
956
		"In case you're interested in that, apply this patch on your libre installation and recompile the plugin: "
957
		"https://raw.githubusercontent.com/alfredh/patches/master/re-sip-trace.patch\n");
958
#endif
959

  
934 960
	JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_SIPRE_NAME);
935 961
	return 0;
936 962
}
......
3507 3533
				g_free(payload);
3508 3534
				return;
3509 3535
			}
3536
#ifdef HAVE_LIBRE_SIPTRACE
3537
			if(gateway->events_is_enabled()) {
3538
				/* Trace incoming/outgoing SIP messages */
3539
				sip_set_trace(session->stack.sipstack, janus_sipre_msg_logger);
3540
			}
3541
#endif
3510 3542
			mem_deref(session->stack.tls);
3511 3543
			g_free(payload);
3512 3544
			break;

Also available in: Unified diff