mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-13 04:57:05 +00:00
FS-9785: upgrade libsrtp to 2.1
This commit is contained in:
1 parent
19e8621682
commit
3bcf5b7ff8
129 files changed
+21084
-21652
No files matched your search
+60
-102
@@ -7,26 +7,26 @@
|
||||
* Cisco Systems, Inc.
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Copyright(c) 2001-2006 Cisco Systems, Inc.
|
||||
*
|
||||
* Copyright(c) 2001-2017 Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* Neither the name of the Cisco Systems, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
@@ -42,107 +42,65 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "err.h"
|
||||
#include "datatypes.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef ERR_REPORTING_SYSLOG
|
||||
# ifdef HAVE_SYSLOG_H
|
||||
# include <syslog.h>
|
||||
# endif
|
||||
#endif
|
||||
/* srtp_err_file is the FILE to which errors are reported */
|
||||
|
||||
static FILE *srtp_err_file = NULL;
|
||||
|
||||
/* err_level reflects the level of errors that are reported */
|
||||
|
||||
err_reporting_level_t err_level = err_level_none;
|
||||
|
||||
#ifdef SRTP_KERNEL_LINUX
|
||||
err_status_t
|
||||
err_reporting_init(char *ident) {
|
||||
|
||||
return err_status_ok;
|
||||
}
|
||||
|
||||
#else /* SRTP_KERNEL_LINUX */
|
||||
|
||||
/* err_file is the FILE to which errors are reported */
|
||||
|
||||
static FILE *err_file = NULL;
|
||||
|
||||
err_status_t
|
||||
err_reporting_init(char *ident) {
|
||||
#ifdef ERR_REPORTING_SYSLOG
|
||||
openlog(ident, LOG_PID, LOG_AUTHPRIV);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Believe it or not, openlog doesn't return an error on failure.
|
||||
* But then, neither does the syslog() call...
|
||||
*/
|
||||
|
||||
srtp_err_status_t srtp_err_reporting_init ()
|
||||
{
|
||||
#ifdef ERR_REPORTING_STDOUT
|
||||
err_file = stdout;
|
||||
#elif defined(USE_ERR_REPORTING_FILE)
|
||||
/* open file for error reporting */
|
||||
err_file = fopen(ERR_REPORTING_FILE, "w");
|
||||
if (err_file == NULL)
|
||||
return err_status_init_fail;
|
||||
#endif
|
||||
|
||||
return err_status_ok;
|
||||
}
|
||||
|
||||
void
|
||||
err_report(int priority, char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (priority <= err_level) {
|
||||
|
||||
va_start(args, format);
|
||||
if (err_file != NULL) {
|
||||
vfprintf(err_file, format, args);
|
||||
/* fprintf(err_file, "\n"); */
|
||||
srtp_err_file = stdout;
|
||||
#elif defined(ERR_REPORTING_FILE)
|
||||
/* open file for error reporting */
|
||||
srtp_err_file = fopen(ERR_REPORTING_FILE, "w");
|
||||
if (srtp_err_file == NULL) {
|
||||
return srtp_err_status_init_fail;
|
||||
}
|
||||
#ifdef ERR_REPORTING_SYSLOG
|
||||
if (1) { /* FIXME: Make this a runtime option. */
|
||||
int syslogpri;
|
||||
|
||||
switch (priority) {
|
||||
case err_level_emergency:
|
||||
syslogpri = LOG_EMERG;
|
||||
break;
|
||||
case err_level_alert:
|
||||
syslogpri = LOG_ALERT;
|
||||
break;
|
||||
case err_level_critical:
|
||||
syslogpri = LOG_CRIT;
|
||||
break;
|
||||
case err_level_error:
|
||||
syslogpri = LOG_ERR;
|
||||
break;
|
||||
case err_level_warning:
|
||||
syslogpri = LOG_WARNING;
|
||||
break;
|
||||
case err_level_notice:
|
||||
syslogpri = LOG_NOTICE;
|
||||
break;
|
||||
case err_level_info:
|
||||
syslogpri = LOG_INFO;
|
||||
break;
|
||||
case err_level_debug:
|
||||
case err_level_none:
|
||||
default:
|
||||
syslogpri = LOG_DEBUG;
|
||||
break;
|
||||
}
|
||||
|
||||
vsyslog(syslogpri, format, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
#endif /* SRTP_KERNEL_LINUX */
|
||||
|
||||
void
|
||||
err_reporting_set_level(err_reporting_level_t lvl) {
|
||||
err_level = lvl;
|
||||
return srtp_err_status_ok;
|
||||
}
|
||||
|
||||
static srtp_err_report_handler_func_t * srtp_err_report_handler = NULL;
|
||||
|
||||
srtp_err_status_t srtp_install_err_report_handler(srtp_err_report_handler_func_t func)
|
||||
{
|
||||
srtp_err_report_handler = func;
|
||||
return srtp_err_status_ok;
|
||||
}
|
||||
|
||||
void srtp_err_report (srtp_err_reporting_level_t level, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
if (srtp_err_file != NULL) {
|
||||
va_start(args, format);
|
||||
vfprintf(srtp_err_file, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
if (srtp_err_report_handler != NULL) {
|
||||
va_start(args, format);
|
||||
char msg[512];
|
||||
if (vsnprintf(msg, sizeof(msg), format, args) > 0) {
|
||||
/* strip trailing \n, callback should not have one */
|
||||
size_t l = strlen(msg);
|
||||
if (l && msg[l-1] == '\n') {
|
||||
msg[l-1] = '\0';
|
||||
}
|
||||
srtp_err_report_handler(level, msg);
|
||||
/*
|
||||
* NOTE, need to be carefull, there is a potential that octet_string_set_to_zero() could
|
||||
* call srtp_err_report() in the future, leading to recursion
|
||||
*/
|
||||
octet_string_set_to_zero(msg, sizeof(msg));
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user