mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 09:36:46 +00:00
Merge branch 'master' of git.sangoma.com:smg_freeswitch
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Anthony Minessale II
|
||||
* 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 original author; nor the names of any 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 FOR
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#ifndef FTDM_ISDN_H
|
||||
#define FTDM_ISDN_H
|
||||
#include "freetdm.h"
|
||||
|
||||
#define DEFAULT_DIGIT_TIMEOUT 10000 /* default overlap timeout: 10 seconds */
|
||||
|
||||
@@ -42,17 +41,23 @@ typedef enum {
|
||||
FTDM_ISDN_OPT_NONE = 0,
|
||||
FTDM_ISDN_OPT_SUGGEST_CHANNEL = (1 << 0),
|
||||
FTDM_ISDN_OPT_OMIT_DISPLAY_IE = (1 << 1), /*!< Do not send Caller name in outgoing SETUP message (= Display IE) */
|
||||
FTDM_ISDN_OPT_DISABLE_TONES = (1 << 2), /*!< Disable tone generating thread (NT mode) */
|
||||
FTDM_ISDN_OPT_DISABLE_TONES = (1 << 2), /*!< Disable tone generating thread (NT mode) */
|
||||
|
||||
FTDM_ISDN_OPT_MAX = (2 << 0)
|
||||
} ftdm_isdn_opts_t;
|
||||
|
||||
typedef enum {
|
||||
FTDM_ISDN_RUNNING = (1 << 0),
|
||||
FTDM_ISDN_TONES_RUNNING = (1 << 1),
|
||||
FTDM_ISDN_STOP = (1 << 2)
|
||||
FTDM_ISDN_RUNNING = (1 << 0),
|
||||
FTDM_ISDN_TONES_RUNNING = (1 << 1),
|
||||
FTDM_ISDN_STOP = (1 << 2),
|
||||
|
||||
FTDM_ISDN_CAPTURE = (1 << 3),
|
||||
FTDM_ISDN_CAPTURE_L3ONLY = (1 << 4)
|
||||
} ftdm_isdn_flag_t;
|
||||
|
||||
#ifdef HAVE_PCAP
|
||||
struct pcap_context;
|
||||
#endif
|
||||
|
||||
struct ftdm_isdn_data {
|
||||
Q921Data_t q921;
|
||||
@@ -60,6 +65,7 @@ struct ftdm_isdn_data {
|
||||
ftdm_channel_t *dchan;
|
||||
ftdm_channel_t *dchans[2];
|
||||
struct ftdm_sigmsg sigmsg;
|
||||
fio_signal_cb_t sig_cb;
|
||||
uint32_t flags;
|
||||
int32_t mode;
|
||||
int32_t digit_timeout;
|
||||
@@ -67,6 +73,9 @@ struct ftdm_isdn_data {
|
||||
ftdm_caller_data_t *outbound_crv[32768];
|
||||
ftdm_channel_t *channels_local_crv[32768];
|
||||
ftdm_channel_t *channels_remote_crv[32768];
|
||||
#ifdef HAVE_PCAP
|
||||
struct pcap_context *pcap;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct ftdm_isdn_data ftdm_isdn_data_t;
|
||||
@@ -75,7 +84,7 @@ typedef struct ftdm_isdn_data ftdm_isdn_data_t;
|
||||
/* b-channel private data */
|
||||
struct ftdm_isdn_bchan_data
|
||||
{
|
||||
L2ULONG digit_timeout;
|
||||
int32_t digit_timeout;
|
||||
};
|
||||
|
||||
typedef struct ftdm_isdn_bchan_data ftdm_isdn_bchan_data_t;
|
||||
@@ -91,6 +100,6 @@ typedef struct ftdm_isdn_bchan_data ftdm_isdn_bchan_data_t;
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
|
||||
*/
|
||||
|
@@ -1,316 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="ftmod_isdn"
|
||||
ProjectGUID="{729344A5-D5E9-434D-8EE8-AF8C6C795D15}"
|
||||
RootNamespace="ftmod_isdn"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\isdn\include;..\..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_ISDN_EXPORTS;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
WarnAsError="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="..\..\isdn\include;..\..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_ISDN_EXPORTS;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
WarnAsError="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\isdn\5ESSmes.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\5ESSStateNT.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\5ESSStateTE.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\DMSmes.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\DMSStateNT.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\DMSStateTE.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\EuroISDNStateNT.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\EuroISDNStateTE.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\mfifo.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\nationalmes.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\nationalStateNT.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\nationalStateTE.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ftmod_isdn.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q921.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q931.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q931api.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q931ie.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q931mes.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q931StateNT.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q931StateTE.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\Q932mes.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\5ESS.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\DMS.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\mfifo.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\national.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\Q921.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\Q921priv.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\Q931.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\Q931ie.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\isdn\include\Q932.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ftdm_isdn.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
File diff suppressed because it is too large
Load Diff
@@ -42,8 +42,9 @@ typedef enum {
|
||||
FTMOD_LIBPRI_OPT_SUGGEST_CHANNEL = (1 << 0),
|
||||
FTMOD_LIBPRI_OPT_OMIT_DISPLAY_IE = (1 << 1),
|
||||
FTMOD_LIBPRI_OPT_OMIT_REDIRECTING_NUMBER_IE = (1 << 2),
|
||||
|
||||
FTMOD_LIBPRI_OPT_MAX = (1 << 3)
|
||||
FTMOD_LIBPRI_OPT_FACILITY_AOC = (1 << 3),
|
||||
|
||||
FTMOD_LIBPRI_OPT_MAX = (1 << 4)
|
||||
} ftdm_isdn_opts_t;
|
||||
|
||||
typedef enum {
|
||||
|
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Anthony Minessale II
|
||||
* 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 original author; nor the names of any 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 FOR
|
||||
@@ -35,8 +35,8 @@
|
||||
|
||||
#include "private/ftdm_core.h"
|
||||
#include "lpwrap_pri.h"
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
#ifdef WIN32
|
||||
#include <mmsystem.h>
|
||||
|
||||
@@ -92,7 +92,7 @@ static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[] = {
|
||||
{8, LPWRAP_PRI_EVENT_ANSWER, "ANSWER"},
|
||||
{9, LPWRAP_PRI_EVENT_HANGUP_ACK, "HANGUP_ACK"},
|
||||
{10, LPWRAP_PRI_EVENT_RESTART_ACK, "RESTART_ACK"},
|
||||
{11, LPWRAP_PRI_EVENT_FACNAME, "FACNAME"},
|
||||
{11, LPWRAP_PRI_EVENT_FACILITY, "FACILITY"},
|
||||
{12, LPWRAP_PRI_EVENT_INFO_RECEIVED, "INFO_RECEIVED"},
|
||||
{13, LPWRAP_PRI_EVENT_PROCEEDING, "PROCEEDING"},
|
||||
{14, LPWRAP_PRI_EVENT_SETUP_ACK, "SETUP_ACK"},
|
||||
@@ -106,7 +106,10 @@ static struct lpwrap_pri_event_list LPWRAP_PRI_EVENT_LIST[] = {
|
||||
#define LINE "--------------------------------------------------------------------------------"
|
||||
|
||||
const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id)
|
||||
{
|
||||
{
|
||||
if (event_id < 0 || event_id >= LPWRAP_PRI_EVENT_MAX)
|
||||
return "";
|
||||
|
||||
return LPWRAP_PRI_EVENT_LIST[event_id].name;
|
||||
}
|
||||
|
||||
@@ -114,8 +117,8 @@ static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen)
|
||||
{
|
||||
struct lpwrap_pri *spri = (struct lpwrap_pri *) pri_get_userdata(pri);
|
||||
ftdm_size_t len = buflen;
|
||||
int res;
|
||||
ftdm_status_t zst;
|
||||
int res;
|
||||
|
||||
if ((zst = ftdm_channel_read(spri->dchan, buf, &len)) != FTDM_SUCCESS) {
|
||||
if (zst == FTDM_FAIL) {
|
||||
@@ -124,31 +127,31 @@ static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen)
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_CRIT, "span %d D-READ TIMEOUT\n", spri->span->span_id);
|
||||
}
|
||||
|
||||
|
||||
ftdm_clear_flag(spri, LPWRAP_PRI_READY);
|
||||
return -1;
|
||||
}
|
||||
spri->errs = 0;
|
||||
res = (int)len;
|
||||
memset(&((unsigned char*)buf)[res],0,2);
|
||||
res+=2;
|
||||
|
||||
memset(&((unsigned char*)buf)[res], 0, 2);
|
||||
res += 2;
|
||||
|
||||
#ifdef IODEBUG
|
||||
{
|
||||
char bb[2048] = { 0 };
|
||||
|
||||
print_hex_bytes(buf, res - 2, bb, sizeof(bb));
|
||||
ftdm_log(FTDM_LOG_DEBUG, "READ %d\n", res-2);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "READ %d\n", res - 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int __pri_lpwrap_write(struct pri *pri, void *buf, int buflen)
|
||||
{
|
||||
struct lpwrap_pri *spri = (struct lpwrap_pri *) pri_get_userdata(pri);
|
||||
ftdm_size_t len = buflen -2;
|
||||
ftdm_size_t len = buflen - 2;
|
||||
|
||||
if (ftdm_channel_write(spri->dchan, buf, buflen, &len) != FTDM_SUCCESS) {
|
||||
ftdm_log(FTDM_LOG_CRIT, "span %d D-WRITE FAIL! [%s]\n", spri->span->span_id, spri->dchan->last_error);
|
||||
@@ -161,11 +164,10 @@ static int __pri_lpwrap_write(struct pri *pri, void *buf, int buflen)
|
||||
char bb[2048] = { 0 };
|
||||
|
||||
print_hex_bytes(buf, buflen - 2, bb, sizeof(bb));
|
||||
ftdm_log(FTDM_LOG_DEBUG, "WRITE %d\n", (int)buflen-2);
|
||||
ftdm_log(FTDM_LOG_DEBUG, "WRITE %d\n", (int)buflen - 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (int) buflen;
|
||||
return (int)buflen;
|
||||
}
|
||||
|
||||
int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug)
|
||||
@@ -173,21 +175,63 @@ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *
|
||||
int ret = -1;
|
||||
|
||||
memset(spri, 0, sizeof(struct lpwrap_pri));
|
||||
|
||||
spri->dchan = dchan;
|
||||
spri->span = span;
|
||||
spri->span = span;
|
||||
|
||||
if (spri->dchan && (spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))){
|
||||
unsigned char buf[4] = { 0 };
|
||||
size_t buflen = sizeof(buf), len = 0;
|
||||
pri_set_debug(spri->pri, debug);
|
||||
ret = 0;
|
||||
|
||||
ftdm_channel_write(spri->dchan, buf, buflen, &len);
|
||||
} else {
|
||||
fprintf(stderr, "Unable to create PRI\n");
|
||||
if (!spri->dchan) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create PRI\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))) {
|
||||
unsigned char buf[4] = { 0 };
|
||||
size_t buflen = sizeof(buf), len = 0;
|
||||
|
||||
pri_set_debug(spri->pri, debug);
|
||||
#ifdef HAVE_LIBPRI_AOC
|
||||
pri_aoc_events_enable(spri->pri, 1);
|
||||
#endif
|
||||
ftdm_channel_write(spri->dchan, buf, buflen, &len);
|
||||
|
||||
ret = 0;
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Unable to create PRI\n");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int ptp, int debug)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
#ifdef HAVE_LIBPRI_BRI
|
||||
memset(spri, 0, sizeof(struct lpwrap_pri));
|
||||
spri->dchan = dchan;
|
||||
spri->span = span;
|
||||
|
||||
if (!spri->dchan) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "No D-Channel available, unable to create BRI\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((spri->pri = pri_new_bri_cb(spri->dchan->sockfd, ptp, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))) {
|
||||
unsigned char buf[4] = { 0 };
|
||||
size_t buflen = sizeof(buf), len = 0;
|
||||
|
||||
pri_set_debug(spri->pri, debug);
|
||||
#ifdef HAVE_LIBPRI_AOC
|
||||
pri_aoc_events_enable(spri->pri, 1);
|
||||
#endif
|
||||
ftdm_channel_write(spri->dchan, buf, buflen, &len);
|
||||
|
||||
ret = 0;
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_ERROR, "Unable to create BRI\n");
|
||||
}
|
||||
#else
|
||||
ftdm_log(FTDM_LOG_ERROR, "Installed libpri version (%s) has no BRI support\n",
|
||||
pri_get_version());
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -195,11 +239,11 @@ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *
|
||||
int lpwrap_one_loop(struct lpwrap_pri *spri)
|
||||
{
|
||||
fd_set rfds, efds;
|
||||
struct timeval now = {0,0}, *next;
|
||||
pri_event *event;
|
||||
struct timeval now = {0,0}, *next = NULL;
|
||||
pri_event *event = NULL;
|
||||
event_handler handler;
|
||||
int sel;
|
||||
|
||||
int sel;
|
||||
|
||||
if (spri->on_loop) {
|
||||
if ((sel = spri->on_loop(spri)) < 0) {
|
||||
return sel;
|
||||
@@ -231,9 +275,6 @@ int lpwrap_one_loop(struct lpwrap_pri *spri)
|
||||
now.tv_usec = 100000;
|
||||
|
||||
sel = select(pri_fd(spri->pri) + 1, &rfds, NULL, &efds, &now);
|
||||
|
||||
event = NULL;
|
||||
|
||||
if (!sel) {
|
||||
if ((next = pri_schedule_next(spri->pri))) {
|
||||
gettimeofday(&now, NULL);
|
||||
@@ -248,46 +289,40 @@ int lpwrap_one_loop(struct lpwrap_pri *spri)
|
||||
|
||||
if (event) {
|
||||
/* 0 is catchall event handler */
|
||||
if ((handler = spri->eventmap[event->e] ? spri->eventmap[event->e] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
if (event->e < 0 || event->e >= LPWRAP_PRI_EVENT_MAX) {
|
||||
handler = spri->eventmap[0];
|
||||
} else if (spri->eventmap[event->e]) {
|
||||
handler = spri->eventmap[event->e];
|
||||
} else {
|
||||
handler = spri->eventmap[0];
|
||||
}
|
||||
|
||||
if (handler) {
|
||||
handler(spri, event->e, event);
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_CRIT, "No event handler found for event %d.\n", event->e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return sel;
|
||||
|
||||
|
||||
if ((handler = spri->eventmap[LPWRAP_PRI_EVENT_IO_FAIL] ? spri->eventmap[LPWRAP_PRI_EVENT_IO_FAIL] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
|
||||
handler(spri, LPWRAP_PRI_EVENT_IO_FAIL, NULL);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int lpwrap_run_pri(struct lpwrap_pri *spri)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
for (;;){
|
||||
ret = lpwrap_one_loop(spri);
|
||||
|
||||
if (ret < 0) {
|
||||
|
||||
for (;;) {
|
||||
if ((ret = lpwrap_one_loop(spri)) < 0) {
|
||||
#ifndef WIN32 //This needs to be adressed fror WIN32 still
|
||||
if (errno == EINTR){
|
||||
/* Igonore an interrupted system call */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
ftdm_log(FTDM_LOG_CRIT, "Error = %i [%s]\n", ret, strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/* For Emacs:
|
||||
@@ -300,4 +335,3 @@ int lpwrap_run_pri(struct lpwrap_pri *spri)
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
|
||||
*/
|
||||
|
||||
|
@@ -51,7 +51,11 @@ typedef enum {
|
||||
LPWRAP_PRI_EVENT_ANSWER = PRI_EVENT_ANSWER,
|
||||
LPWRAP_PRI_EVENT_HANGUP_ACK = PRI_EVENT_HANGUP_ACK,
|
||||
LPWRAP_PRI_EVENT_RESTART_ACK = PRI_EVENT_RESTART_ACK,
|
||||
LPWRAP_PRI_EVENT_FACNAME = PRI_EVENT_FACNAME,
|
||||
#ifdef PRI_EVENT_FACILITY
|
||||
LPWRAP_PRI_EVENT_FACILITY = PRI_EVENT_FACILITY,
|
||||
#else
|
||||
LPWRAP_PRI_EVENT_FACILITY = PRI_EVENT_FACNAME,
|
||||
#endif
|
||||
LPWRAP_PRI_EVENT_INFO_RECEIVED = PRI_EVENT_INFO_RECEIVED,
|
||||
LPWRAP_PRI_EVENT_PROCEEDING = PRI_EVENT_PROCEEDING,
|
||||
LPWRAP_PRI_EVENT_SETUP_ACK = PRI_EVENT_SETUP_ACK,
|
||||
@@ -121,6 +125,8 @@ struct lpwrap_pri_event_list {
|
||||
const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id);
|
||||
int lpwrap_one_loop(struct lpwrap_pri *spri);
|
||||
int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug);
|
||||
int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int ptp, int debug);
|
||||
int lpwrap_run_pri(struct lpwrap_pri *spri);
|
||||
#define lpwrap_run_bri(x) lpwrap_run_pri(x)
|
||||
|
||||
#endif
|
||||
|
@@ -403,6 +403,7 @@ static void ftdm_r2_on_call_init(openr2_chan_t *r2chan)
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) {
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Cannot start call when channel is in use (state = %s)\n", ftdm_channel_state2str(ftdmchan->state));
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ftdmchan->state != FTDM_CHANNEL_STATE_DOWN) {
|
||||
@@ -436,9 +437,6 @@ static void ftdm_r2_on_call_init(openr2_chan_t *r2chan)
|
||||
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_COLLECT);
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Span is not threaded, not launching thread for this call\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* only called for incoming calls when the ANI, DNIS etc is complete and the user has to decide either to accept or reject the call */
|
||||
@@ -447,9 +445,7 @@ static void ftdm_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, cons
|
||||
ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan);
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Call offered with ANI = %s, DNIS = %s, Priority = (%d)\n", ani, dnis, category);
|
||||
//ftdmchan->caller_data.priority = category;
|
||||
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING);
|
||||
|
||||
}
|
||||
|
||||
static void ftdm_r2_on_call_accepted(openr2_chan_t *r2chan, openr2_call_mode_t mode)
|
||||
@@ -602,8 +598,8 @@ static void ftdm_r2_on_line_idle(openr2_chan_t *r2chan)
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Far end unblocked in state %s\n", ftdm_channel_state2str(ftdmchan->state));
|
||||
ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED);
|
||||
|
||||
/* XXX when should we set/unset this flag? XXX */
|
||||
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SIG_UP);
|
||||
/* XXX when should we set/unset this flag? XXX */
|
||||
ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SIG_UP);
|
||||
}
|
||||
|
||||
static void ftdm_r2_write_log(openr2_log_level_t level, const char *file, const char *function, int line, const char *message)
|
||||
@@ -1116,7 +1112,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_r2_configure_span)
|
||||
memset(r2call, 0, sizeof(*r2call));
|
||||
openr2_chan_set_logging_func(r2chan, ftdm_r2_on_chan_log);
|
||||
openr2_chan_set_client_data(r2chan, span->channels[i]);
|
||||
r2call->r2chan = r2chan;
|
||||
r2call->r2chan = r2chan;
|
||||
span->channels[i]->call_data = r2call;
|
||||
/* value and key are the same so just free one of them */
|
||||
snprintf(r2call->name, sizeof(r2call->name), "chancall%d", i);
|
||||
@@ -1331,8 +1327,8 @@ static int ftdm_r2_state_advance(ftdm_channel_t *ftdmchan)
|
||||
static void *ftdm_r2_run(ftdm_thread_t *me, void *obj)
|
||||
{
|
||||
openr2_chan_t *r2chan;
|
||||
ftdm_r2_call_t *r2call = NULL;
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
ftdm_r2_call_t *r2call = NULL;
|
||||
ftdm_channel_t *ftdmchan = NULL;
|
||||
ftdm_status_t status;
|
||||
ftdm_span_t *span = (ftdm_span_t *) obj;
|
||||
ftdm_r2_data_t *r2data = span->signal_data;
|
||||
@@ -1368,16 +1364,14 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj)
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
/* figure out what event to poll each channel for. POLLPRI when the channel is down,
|
||||
* POLLPRI|POLLIN|POLLOUT otherwise.
|
||||
*/
|
||||
memset(poll_events, 0, sizeof(short)*span->chan_count);
|
||||
for (i = 0; i < span->chan_count; i++) {
|
||||
r2chan = R2CALL(span->channels[(i+1)])->r2chan;
|
||||
ftdmchan = openr2_chan_get_client_data(r2chan);
|
||||
|
||||
poll_events[i] = ftdmchan->state == FTDM_CHANNEL_STATE_DOWN ? POLLPRI : (POLLPRI | POLLIN | POLLOUT);
|
||||
}
|
||||
/* figure out what event to poll each channel for. POLLPRI when the channel is down,
|
||||
* POLLPRI|POLLIN|POLLOUT otherwise */
|
||||
memset(poll_events, 0, sizeof(short)*span->chan_count);
|
||||
for (i = 0; i < span->chan_count; i++) {
|
||||
r2chan = R2CALL(span->channels[(i+1)])->r2chan;
|
||||
ftdmchan = openr2_chan_get_client_data(r2chan);
|
||||
poll_events[i] = ftdmchan->state == FTDM_CHANNEL_STATE_DOWN ? POLLPRI : (POLLPRI | POLLIN | POLLOUT);
|
||||
}
|
||||
|
||||
status = ftdm_span_poll_event(span, waitms, poll_events);
|
||||
#else
|
||||
@@ -1394,62 +1388,61 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FTDM_SUCCESS == status) {
|
||||
if (FTDM_SUCCESS == status) {
|
||||
ftdm_event_t *event;
|
||||
while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) {
|
||||
if (event->enum_id == FTDM_OOB_CAS_BITS_CHANGE) {
|
||||
r2call = R2CALL(event->channel);
|
||||
r2chan = r2call->r2chan;
|
||||
r2call = R2CALL(event->channel);
|
||||
r2chan = r2call->r2chan;
|
||||
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Handling CAS on channel %d.\n", openr2_chan_get_number(r2chan));
|
||||
// we only expect CAS and other OOB events on this thread/loop, once a call is started
|
||||
// the MF events (in-band signaling) are handled in the call thread
|
||||
openr2_chan_process_cas_signaling(r2chan);
|
||||
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Ignoring event %d on channel %d.\n", event->enum_id, openr2_chan_get_number(r2chan));
|
||||
// XXX TODO: handle alarms here XXX
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX
|
||||
* when ftdm_span_poll_event() returns FTDM_SUCCESS, means there are events pending on the span.
|
||||
* is it possible to know on which channels those events are pending, without trasvering the span?
|
||||
* XXX
|
||||
*/
|
||||
for (i = 1; i <= span->chan_count; i++) {
|
||||
r2chan = R2CALL(span->channels[i])->r2chan;
|
||||
ftdmchan = openr2_chan_get_client_data(r2chan);
|
||||
r2call = R2CALL(ftdmchan);
|
||||
/* XXX
|
||||
* when ftdm_span_poll_event() returns FTDM_SUCCESS, means there are events pending on the span.
|
||||
* is it possible to know on which channels those events are pending, without traversing the span?
|
||||
* XXX */
|
||||
for (i = 1; i <= span->chan_count; i++) {
|
||||
r2chan = R2CALL(span->channels[i])->r2chan;
|
||||
ftdmchan = openr2_chan_get_client_data(r2chan);
|
||||
r2call = R2CALL(ftdmchan);
|
||||
|
||||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
ftdm_set_flag(r2call, FTDM_R2_PROCESSING);
|
||||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
ftdm_set_flag(r2call, FTDM_R2_PROCESSING);
|
||||
|
||||
if (ftdm_r2_state_advance(ftdmchan)) {
|
||||
ftdm_clear_flag(r2call, FTDM_R2_PROCESSING);
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
continue;
|
||||
}
|
||||
if (ftdm_r2_state_advance(ftdmchan)) {
|
||||
ftdm_clear_flag(r2call, FTDM_R2_PROCESSING);
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* handle timeout events first if any */
|
||||
openr2_chan_run_schedule(r2chan);
|
||||
/* handle timeout events first if any */
|
||||
openr2_chan_run_schedule(r2chan);
|
||||
|
||||
/* process mf tones, if any */
|
||||
if (openr2_chan_get_read_enabled(r2chan))
|
||||
openr2_chan_process_mf_signaling(r2chan);
|
||||
/* process mf tones, if any */
|
||||
if (openr2_chan_get_read_enabled(r2chan)) {
|
||||
openr2_chan_process_mf_signaling(r2chan);
|
||||
}
|
||||
|
||||
if (ftdm_r2_state_advance(ftdmchan)) {
|
||||
ftdm_clear_flag(r2call, FTDM_R2_PROCESSING);
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
continue;
|
||||
}
|
||||
if (ftdm_r2_state_advance(ftdmchan)) {
|
||||
ftdm_clear_flag(r2call, FTDM_R2_PROCESSING);
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
continue;
|
||||
}
|
||||
|
||||
ftdm_clear_flag(r2call, FTDM_R2_PROCESSING);
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
}
|
||||
ftdm_clear_flag(r2call, FTDM_R2_PROCESSING);
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
}
|
||||
} else if (status != FTDM_TIMEOUT) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "ftdm_span_poll_event returned %d.\n", status);
|
||||
}
|
||||
}
|
||||
ftdm_sleep(20);
|
||||
}
|
||||
|
||||
|
@@ -1179,6 +1179,11 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event)
|
||||
char tmp_dtmf[2] = { tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_dtmf_digit, 0 };
|
||||
event_id = FTDM_OOB_NOOP;
|
||||
|
||||
if (tmp_dtmf[0] == 'f') {
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Ignoring wanpipe DTMF: %c, fax tones will be passed through!\n", tmp_dtmf[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_dtmf_type == WAN_EC_TONE_PRESENT) {
|
||||
ftdm_set_flag_locked(ftdmchan, FTDM_CHANNEL_MUTE);
|
||||
}
|
||||
|
@@ -867,7 +867,7 @@ static FIO_WAIT_FUNCTION(zt_wait)
|
||||
{
|
||||
int32_t inflags = 0;
|
||||
int result;
|
||||
struct pollfd pfds[1];
|
||||
struct pollfd pfds[1];
|
||||
|
||||
if (*flags & FTDM_READ) {
|
||||
inflags |= POLLIN;
|
||||
@@ -882,13 +882,14 @@ static FIO_WAIT_FUNCTION(zt_wait)
|
||||
}
|
||||
|
||||
|
||||
memset(&pfds[0], 0, sizeof(pfds[0]));
|
||||
pfds[0].fd = ftdmchan->sockfd;
|
||||
pfds[0].events = inflags;
|
||||
result = poll(pfds, 1, to);
|
||||
memset(&pfds[0], 0, sizeof(pfds[0]));
|
||||
pfds[0].fd = ftdmchan->sockfd;
|
||||
pfds[0].events = inflags;
|
||||
result = poll(pfds, 1, to);
|
||||
*flags = 0;
|
||||
|
||||
if (pfds[0].revents & POLLERR) {
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_ERROR, "DAHDI device got POLLERR\n");
|
||||
result = -1;
|
||||
}
|
||||
|
||||
@@ -900,6 +901,7 @@ static FIO_WAIT_FUNCTION(zt_wait)
|
||||
|
||||
if (result < 0){
|
||||
snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "Poll failed");
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to poll DAHDI device: %s\n", strerror(errno));
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user