Add module to write traces to Diva trace driver. Restore compilation with version 1.2
parent
08db9b6db3
commit
578b7005c7
12
Makefile
12
Makefile
|
@ -20,6 +20,7 @@ OSNAME=${shell uname}
|
|||
|
||||
DIVA_STREAMING=0
|
||||
DIVA_STATUS=0
|
||||
DIVA_VERBOSE=0
|
||||
|
||||
USE_OWN_LIBCAPI=yes
|
||||
|
||||
|
@ -89,6 +90,8 @@ ifeq (${DIVA_STATUS},1)
|
|||
INCLUDE += -I./divastatus -I./divastatus/..
|
||||
endif
|
||||
|
||||
INCLUDE += -I./divaverbose
|
||||
|
||||
DEBUG=-g #-pg
|
||||
INCLUDE+= -I$(ASTERISK_HEADER_DIR)
|
||||
ifndef C4B
|
||||
|
@ -121,6 +124,10 @@ CFLAGS+=$(shell echo '\#include <sys/inotify.h>' > /tmp/test.c 2>/dev/null && \
|
|||
echo 'int main(int argc,char**argv){if(inotify_init()>=0)return 0; return 1;}' >> /tmp/test.c 2>/dev/null && \
|
||||
$(CC) /tmp/test.c -o /tmp/test && /tmp/test >/dev/null 2>&1 && echo '-DCC_USE_INOTIFY=1'; rm -f /tmp/test.c /tmp/test)
|
||||
endif
|
||||
ifeq (${DIVA_VERBOSE},1)
|
||||
CFLAGS += -DDIVA_VERBOSE=1
|
||||
endif
|
||||
|
||||
|
||||
LIBS=-ldl -lpthread -lm
|
||||
CC=gcc
|
||||
|
@ -152,6 +159,10 @@ ifeq (${DIVA_STATUS},1)
|
|||
OBJECTS += divastatus/divastatus.o
|
||||
endif
|
||||
|
||||
ifeq (${DIVA_VERBOSE},1)
|
||||
OBJECTS += divaverbose/divaverbose.o
|
||||
endif
|
||||
|
||||
CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
|
||||
|
||||
CFLAGS+=-DCRYPTO
|
||||
|
@ -170,6 +181,7 @@ clean:
|
|||
rm -f libcapi20/*.o
|
||||
rm -f divastreaming/*.o
|
||||
rm -f divastatus/*.o
|
||||
rm -f divaverbose/*.o
|
||||
|
||||
config.h:
|
||||
./create_config.sh "$(ASTERISK_HEADER_DIR)"
|
||||
|
|
11
chan_capi.c
11
chan_capi.c
|
@ -58,6 +58,7 @@ struct _diva_streaming_vector* vind;
|
|||
#include "chan_capi_cli.h"
|
||||
#include "chan_capi_ami.h"
|
||||
#include "chan_capi_devstate.h"
|
||||
#include "divaverbose.h"
|
||||
|
||||
/* #define CC_VERSION "x.y.z" */
|
||||
#define CC_VERSION "$Revision$"
|
||||
|
@ -4482,8 +4483,10 @@ static int pbx_capi_get_samples(struct capi_pvt *i, int length)
|
|||
case AST_FORMAT_SLINEAR16:
|
||||
#endif
|
||||
return (length/2);
|
||||
#if defined(AST_FORMAT_G722)
|
||||
case AST_FORMAT_G722:
|
||||
return (length*2);
|
||||
#endif
|
||||
#if defined(AST_FORMAT_SIREN7)
|
||||
case AST_FORMAT_SIREN7:
|
||||
return (length * (320 / 80));
|
||||
|
@ -8791,6 +8794,8 @@ int unload_module(void)
|
|||
ast_channel_unregister(&capi_tech);
|
||||
|
||||
cleanup_ccbsnr();
|
||||
|
||||
diva_verbose_unload();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -8810,6 +8815,8 @@ int load_module(void)
|
|||
struct ast_flags config_flags = { 0 };
|
||||
#endif
|
||||
|
||||
diva_verbose_load();
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
cfg = ast_config_load(config, config_flags);
|
||||
#else
|
||||
|
@ -8819,16 +8826,19 @@ int load_module(void)
|
|||
/* We *must* have a config file otherwise stop immediately, well no */
|
||||
if (!cfg) {
|
||||
cc_log(LOG_ERROR, "Unable to load config %s, chan_capi disabled\n", config);
|
||||
diva_verbose_unload();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cc_mutex_lock(&iflock)) {
|
||||
cc_log(LOG_ERROR, "Unable to lock interface list???\n");
|
||||
diva_verbose_unload();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((res = cc_init_capi()) != 0) {
|
||||
cc_mutex_unlock(&iflock);
|
||||
diva_verbose_unload();
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
@ -8837,6 +8847,7 @@ int load_module(void)
|
|||
|
||||
if (res != 0) {
|
||||
cc_mutex_unlock(&iflock);
|
||||
diva_verbose_unload();
|
||||
return(res);
|
||||
}
|
||||
|
||||
|
|
12
chan_capi.h
12
chan_capi.h
|
@ -839,4 +839,16 @@ int pbx_capi_streaming_supported (struct capi_pvt *i);
|
|||
#define _DI_DSP_CTRL 0x0003
|
||||
#define _DI_OPTIONS_REQUEST 0x0009
|
||||
|
||||
#if (!defined(CC_AST_HAS_VERSION_1_4) && !defined(CC_AST_HAS_VERSION_1_6) && !defined(CC_AST_HAS_VERSION_1_8))
|
||||
|
||||
#define ast_malloc(__x__) malloc((__x__))
|
||||
#define ast_free(__x__) free((__x__))
|
||||
#define ast_strdup(__x__) strdup((__x__))
|
||||
#define ast_channel_trylock(__x__) ast_mutex_trylock(&(__x__)->lock)
|
||||
#define ast_channel_unlock(__x__) ast_mutex_unlock(&(__x__)->lock)
|
||||
#define ast_devstate_prov_add(__a__,__b__) (-1)
|
||||
#define ast_devstate_prov_del(__x__) do{}while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* Based on apps/app_meetme.c
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "chan_capi_platform.h"
|
||||
#include "chan_capi20.h"
|
||||
#include "chan_capi.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* This program is free software and may be modified and
|
||||
* distributed under the terms of the GNU Public License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "chan_capi_platform.h"
|
||||
#include "chan_capi20.h"
|
||||
#include "chan_capi.h"
|
||||
|
@ -29,6 +29,9 @@
|
|||
#ifdef DIVA_STATUS
|
||||
#include "divastatus_ifc.h"
|
||||
#endif
|
||||
#ifdef DIVA_VERBOSE
|
||||
#include "divaverbose.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* usages
|
||||
|
@ -502,7 +505,7 @@ static int pbxcli_capi_do_debug(int fd, int argc, char *argv[])
|
|||
|
||||
capidebug = 1;
|
||||
ast_cli(fd, CC_MESSAGE_BIGNAME " Message Debugging Enabled\n");
|
||||
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
return CLI_SUCCESS;
|
||||
#else
|
||||
|
@ -738,6 +741,10 @@ static struct ast_cli_entry cc_cli_cmd[] = {
|
|||
AST_CLI_DEFINE(pbxcli_capi_chatinfo, CC_CLI_TEXT_CHATINFO),
|
||||
#ifdef DIVA_STATUS
|
||||
AST_CLI_DEFINE(pbxcli_capi_ifc_status, CC_CLI_TEXT_IFC_STATUSINFO),
|
||||
#endif
|
||||
#ifdef DIVA_VERBOSE
|
||||
AST_CLI_DEFINE(pbxcli_capi_do_verbose, CC_CLI_TEXT_CAPI_DO_VERBOSE),
|
||||
AST_CLI_DEFINE(pbxcli_capi_no_verbose, CC_CLI_TEXT_CAPI_NO_VERBOSE),
|
||||
#endif
|
||||
AST_CLI_DEFINE(pbxcli_capi_show_resources, CC_CLI_TEXT_SHOW_RESOURCES),
|
||||
AST_CLI_DEFINE(pbxcli_capi_exec_capicommand, CC_CLI_TEXT_EXEC_CAPICOMMAND),
|
||||
|
@ -763,6 +770,12 @@ static struct ast_cli_entry cli_chatinfo =
|
|||
static struct ast_cli_entry cli_ifcstate =
|
||||
{ { CC_MESSAGE_NAME, "ifcstate", NULL }, pbxcli_capi_ifc_status, CC_CLI_TEXT_IFC_STATUSINFO, diva_status_ifc_state_usage };
|
||||
#endif
|
||||
#ifdef DIVA_VERBOSE
|
||||
static struct ast_cli_entry cli_verbose =
|
||||
{ { CC_MESSAGE_NAME, "verbose", NULL }, pbxcli_capi_do_verbose, CC_CLI_TEXT_CAPI_DO_VERBOSE, capi_do_verbose_usage };
|
||||
static struct ast_cli_entry cli_no_verbose =
|
||||
{ { CC_MESSAGE_NAME, "no", "verbose", NULL }, pbxcli_capi_no_verbose, CC_CLI_TEXT_CAPI_NO_VERBOSE, capi_no_verbose_usage };
|
||||
#endif
|
||||
static struct ast_cli_entry cli_show_resources =
|
||||
{ { CC_MESSAGE_NAME, "show", "resources", NULL }, pbxcli_capi_show_resources, CC_CLI_TEXT_SHOW_RESOURCES, show_resources_usage };
|
||||
static struct ast_cli_entry cli_exec_capicommand =
|
||||
|
@ -789,6 +802,10 @@ void pbx_capi_cli_register(void)
|
|||
ast_cli_register(&cli_chatinfo);
|
||||
#ifdef DIVA_STATUS
|
||||
ast_cli_register(&cli_ifcstate);
|
||||
#endif
|
||||
#ifdef DIVA_VERBOSE
|
||||
ast_cli_register(&cli_verbose);
|
||||
ast_cli_register(&cli_no_verbose);
|
||||
#endif
|
||||
ast_cli_register(&cli_show_resources);
|
||||
ast_cli_register(&cli_exec_capicommand);
|
||||
|
@ -811,6 +828,10 @@ void pbx_capi_cli_unregister(void)
|
|||
ast_cli_unregister(&cli_chatinfo);
|
||||
#ifdef DIVA_STATUS
|
||||
ast_cli_unregister(&cli_ifcstate);
|
||||
#endif
|
||||
#ifdef DIVA_VERBOSE
|
||||
ast_cli_unregister(&cli_verbose);
|
||||
ast_cli_unregister(&cli_no_verbose);
|
||||
#endif
|
||||
ast_cli_unregister(&cli_show_resources);
|
||||
ast_cli_unregister(&cli_exec_capicommand);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "chan_capi_platform.h"
|
||||
#include "chan_capi20.h"
|
||||
#include "chan_capi.h"
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "chan_capi_platform.h"
|
||||
#include "chan_capi20.h"
|
||||
#include "chan_capi.h"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "chan_capi_platform.h"
|
||||
#include "chan_capi20.h"
|
||||
#include "chan_capi.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include "chan_capi_platform.h"
|
||||
#include "xlaw.h"
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
* it CVS file format.
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "divastreaming/platform.h"
|
||||
#include "chan_capi_platform.h"
|
||||
#include "chan_capi20.h"
|
||||
#include "chan_capi.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
|
@ -0,0 +1,184 @@
|
|||
#include <stdio.h>
|
||||
#include "chan_capi20.h"
|
||||
#include "chan_capi.h"
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_4
|
||||
#include <asterisk.h>
|
||||
#endif
|
||||
|
||||
#include <asterisk/logger.h>
|
||||
#include <asterisk/module.h>
|
||||
#include <asterisk/cli.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "divaverbose.h"
|
||||
|
||||
static int verbose_registered;
|
||||
AST_MUTEX_DEFINE_STATIC(dbgIfcLock);
|
||||
static volatile int divaDbgIfc = -1;
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
static
|
||||
#endif
|
||||
char capi_do_verbose_usage[] =
|
||||
"Usage: " CC_MESSAGE_NAME " verbose\n"
|
||||
" Connect to debug driver.\n";
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
static
|
||||
#endif
|
||||
char capi_no_verbose_usage[] =
|
||||
"Usage: " CC_MESSAGE_NAME " no verbose\n"
|
||||
" Disconnect from debug driver.\n";
|
||||
|
||||
static void open_diva_mnt(void)
|
||||
{
|
||||
cc_mutex_lock(&dbgIfcLock);
|
||||
if (divaDbgIfc < 0) {
|
||||
divaDbgIfc = open("/dev/DivasDBGIFC", O_WRONLY);
|
||||
}
|
||||
cc_mutex_unlock(&dbgIfcLock);
|
||||
}
|
||||
|
||||
#if (!defined(CC_AST_HAS_VERSION_1_4) && !defined(CC_AST_HAS_VERSION_1_6) && !defined(CC_AST_HAS_VERSION_1_8))
|
||||
static void diva_verbose_write (const char *info, int opos, int replacelast, int complete)
|
||||
#else
|
||||
static void diva_verbose_write (const char *info)
|
||||
#endif
|
||||
{
|
||||
if (divaDbgIfc < 0) {
|
||||
open_diva_mnt();
|
||||
}
|
||||
if (divaDbgIfc >= 0) {
|
||||
write (divaDbgIfc, info, strlen(info));
|
||||
}
|
||||
}
|
||||
|
||||
static int diva_verbose_start(void)
|
||||
{
|
||||
if (verbose_registered == 0) {
|
||||
verbose_registered = (ast_register_verbose(diva_verbose_write) == 0);
|
||||
}
|
||||
|
||||
return ((verbose_registered != 0) ? 0 : -1);
|
||||
}
|
||||
|
||||
static int diva_verbose_stop(void)
|
||||
{
|
||||
if (verbose_registered != 0) {
|
||||
verbose_registered = !(ast_unregister_verbose(diva_verbose_write) == 0);
|
||||
}
|
||||
if ((verbose_registered == 0) && (divaDbgIfc >= 0)) {
|
||||
close(divaDbgIfc);
|
||||
divaDbgIfc = -1;
|
||||
}
|
||||
|
||||
return ((verbose_registered == 0) ? 0 : -1);
|
||||
}
|
||||
|
||||
/*
|
||||
* enable debugging
|
||||
*/
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
char *pbxcli_capi_do_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||
#else
|
||||
int pbxcli_capi_do_verbose(int fd, int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
int ret;
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
int fd = a->fd;
|
||||
|
||||
if (cmd == CLI_INIT) {
|
||||
e->command = CC_MESSAGE_NAME " verbose";
|
||||
e->usage = capi_do_verbose_usage;
|
||||
return NULL;
|
||||
} else if (cmd == CLI_GENERATE)
|
||||
return NULL;
|
||||
if (a->argc != e->args)
|
||||
return CLI_SHOWUSAGE;
|
||||
#else
|
||||
if (argc != 2)
|
||||
return RESULT_SHOWUSAGE;
|
||||
#endif
|
||||
|
||||
ret = diva_verbose_start();
|
||||
if (ret == 0) {
|
||||
ast_cli(fd, CC_MESSAGE_BIGNAME " Message Verboser Enabled\n");
|
||||
} else {
|
||||
ast_cli(fd, CC_MESSAGE_BIGNAME " Failed to enable Message Verboser\n");
|
||||
}
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
return ((ret == 0) ? CLI_SUCCESS : CLI_FAILURE);
|
||||
#else
|
||||
return ((ret == 0) ? RESULT_SUCCESS : RESULT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* disable debugging
|
||||
*/
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
char *pbxcli_capi_no_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||
#else
|
||||
int pbxcli_capi_no_verbose(int fd, int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
int ret;
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
int fd = a->fd;
|
||||
|
||||
if (cmd == CLI_INIT) {
|
||||
e->command = CC_MESSAGE_NAME " no verbose";
|
||||
e->usage = capi_no_verbose_usage;
|
||||
return NULL;
|
||||
} else if (cmd == CLI_GENERATE)
|
||||
return NULL;
|
||||
if (a->argc != e->args)
|
||||
return CLI_SHOWUSAGE;
|
||||
#else
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
#endif
|
||||
|
||||
|
||||
ret = diva_verbose_stop();
|
||||
if (ret == 0) {
|
||||
ast_cli(fd, CC_MESSAGE_BIGNAME " Message Verboser Disabled\n");
|
||||
} else {
|
||||
ast_cli(fd, CC_MESSAGE_BIGNAME " Failed to disable Message Verboser\n");
|
||||
}
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
return ((ret == 0) ? CLI_SUCCESS : CLI_FAILURE);
|
||||
#else
|
||||
return ((ret == 0) ? RESULT_SUCCESS : RESULT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void diva_verbose_load(void)
|
||||
{
|
||||
divaDbgIfc = -1;
|
||||
open_diva_mnt();
|
||||
if (divaDbgIfc >= 0) {
|
||||
diva_verbose_start();
|
||||
}
|
||||
}
|
||||
|
||||
void diva_verbose_unload(void)
|
||||
{
|
||||
if (verbose_registered != 0) {
|
||||
verbose_registered = !(ast_unregister_verbose(diva_verbose_write) == 0);
|
||||
}
|
||||
if (verbose_registered != 0)
|
||||
cc_mutex_lock(&dbgIfcLock);
|
||||
if (divaDbgIfc >= 0) {
|
||||
close(divaDbgIfc);
|
||||
divaDbgIfc = -1;
|
||||
}
|
||||
if (verbose_registered != 0)
|
||||
cc_mutex_unlock(&dbgIfcLock);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef __DIVA_VERBOSER_H__
|
||||
#define __DIVA_VERBOSER_H__
|
||||
|
||||
#ifdef DIVA_VERBOSE
|
||||
|
||||
void diva_verbose_load(void);
|
||||
void diva_verbose_unload(void);
|
||||
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
char *pbxcli_capi_do_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
|
||||
char *pbxcli_capi_no_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
|
||||
#else
|
||||
int pbxcli_capi_do_verbose(int fd, int argc, char *argv[]);
|
||||
int pbxcli_capi_no_verbose(int fd, int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
#define CC_CLI_TEXT_CAPI_DO_VERBOSE "Connect " CC_MESSAGE_BIGNAME " to debug driver"
|
||||
#define CC_CLI_TEXT_CAPI_NO_VERBOSE "Disconnect " CC_MESSAGE_BIGNAME " from debug driver"
|
||||
|
||||
|
||||
#ifndef CC_AST_HAS_VERSION_1_6
|
||||
extern char capi_do_verbose_usage[];
|
||||
extern char capi_no_verbose_usage[];
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define diva_verbose_load() do{}while(0)
|
||||
#define diva_verbose_unload() do{}while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue