TT#59805 add dtmf-log-dest option

Change-Id: Id6f7ce7fa627b138e0b0ea3d410b8af53532b290
changes/24/30424/2
Richard Fuchs 7 years ago
parent 166aaa0c71
commit fcb08df0ae

@ -3,9 +3,20 @@
#include "log.h"
#include "call.h"
#include "dtmflib.h"
#include "main.h"
static socket_t dtmf_log_sock;
void dtmf_init(void) {
if (rtpe_config.dtmf_udp_ep.port) {
if (connect_socket(&dtmf_log_sock, SOCK_DGRAM, &rtpe_config.dtmf_udp_ep))
ilog(LOG_ERR, "Failed to open/connect DTMF logging socket: %s", strerror(errno));
}
}
static GString *dtmf_json_print(struct media_packet *mp,
struct telephone_event_payload *dtmf, int clockrate)
{
@ -61,12 +72,18 @@ int dtmf_event(struct media_packet *mp, str *payload, int clockrate) {
int ret = 0;
if (_log_facility_dtmf) {
GString *buf = dtmf_json_print(mp, dtmf, clockrate);
if (buf) {
GString *buf = NULL;
if (_log_facility_dtmf || dtmf_log_sock.family)
buf = dtmf_json_print(mp, dtmf, clockrate);
if (buf) {
if (_log_facility_dtmf)
dtmflog(buf);
ret = 1; // END event
}
if (dtmf_log_sock.family)
send(dtmf_log_sock.fd, buf->str, buf->len, 0);
ret = 1; // END event
}
return ret;

@ -306,6 +306,7 @@ static void options(int *argc, char ***argv) {
int codecs = 0;
double max_load = 0;
double max_cpu = 0;
char *dtmf_udp_ep = NULL;
GOptionEntry e[] = {
{ "table", 't', 0, G_OPTION_ARG_INT, &rtpe_config.kernel_table, "Kernel table to use", "INT" },
@ -341,6 +342,7 @@ static void options(int *argc, char ***argv) {
{ "log-facility-rtcp",0, 0, G_OPTION_ARG_STRING, &log_facility_rtcp_s, "Syslog facility to use for logging RTCP", "daemon|local0|...|local7"},
{ "log-facility-dtmf",0, 0, G_OPTION_ARG_STRING, &log_facility_dtmf_s, "Syslog facility to use for logging DTMF", "daemon|local0|...|local7"},
{ "log-format", 0, 0, G_OPTION_ARG_STRING, &log_format, "Log prefix format", "default|parsable"},
{ "dtmf-log-dest", 0,0, G_OPTION_ARG_STRING, &dtmf_udp_ep, "Destination address for DTMF logging via UDP", "IP46|HOSTNAME:PORT" },
{ "xmlrpc-format",'x', 0, G_OPTION_ARG_INT, &rtpe_config.fmt, "XMLRPC timeout request format to use. 0: SEMS DI, 1: call-id only, 2: Kamailio", "INT" },
{ "num-threads", 0, 0, G_OPTION_ARG_INT, &rtpe_config.num_threads, "Number of worker threads to create", "INT" },
{ "media-num-threads", 0, 0, G_OPTION_ARG_INT, &rtpe_config.media_num_threads, "Number of worker threads for media playback", "INT" },
@ -518,6 +520,11 @@ static void options(int *argc, char ***argv) {
die("Invalid --log-format option");
}
if (dtmf_udp_ep) {
if (endpoint_parse_any_getaddrinfo_full(&rtpe_config.dtmf_udp_ep, dtmf_udp_ep))
die("Invalid IP or port '%s' (--dtmf-log-dest)", dtmf_udp_ep);
}
if (!sip_source)
trust_address_def = 1;
@ -643,6 +650,7 @@ static void init_everything(void) {
statistics_init();
codeclib_init(0);
media_player_init();
dtmf_init();
}

@ -235,6 +235,13 @@ The B<parsable> output style is similar, but makes the ID easier to
parse by enclosing it in quotes, such as B<[ID="CALLID"]>
or B<[ID="CALLID" port="12345"]>.
=item B<--dtmf-log-dest=>I<IP46>:I<PORT>
Configures a target address for logging detected DTMF event. Similar
to the feature enabled by B<--log-facilty-dtmf>, but instead of writing
detected DTMF events to syslog, this sends the JSON payload to the
given address as UDP packets.
=item B<--log-srtp-keys>
Write SRTP keys to error log instead of debug log.

@ -14,6 +14,7 @@ struct dtmf_event {
uint64_t ts;
};
void dtmf_init(void);
int dtmf_event(struct media_packet *, str *, int);
int dtmf_event_payload(str *, uint64_t *, uint64_t, struct dtmf_event *, GQueue *);
void dtmf_event_free(void *);

@ -83,6 +83,7 @@ struct rtpengine_config {
char *mysql_user;
char *mysql_pass;
char *mysql_query;
endpoint_t dtmf_udp_ep;
};

Loading…
Cancel
Save