mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 06:34:19 +00:00
Merge branch 'master' of git://git.freeswitch.org/freeswitch
Conflicts: conf/autoload_configs/modules.conf.xml libs/freetdm/src/ftdm_sched.c libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c
This commit is contained in:
commit
8d66f38212
232 files changed
+57975
-3495
No files matched your search
File diff suppressed because it is too large.
Load diff
+22
-13
@@ -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
|
||||
@@ -1176,6 +1176,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