--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<VisualStudioProject\r
+ ProjectType="Visual C++"\r
+ Version="9.00"\r
+ Name="ftmod_r2"\r
+ ProjectGUID="{08C3EA27-A51D-47F8-B47D-B189C649CF30}"\r
+ Keyword="Win32Proj"\r
+ TargetFrameworkVersion="131072"\r
+ >\r
+ <Platforms>\r
+ <Platform\r
+ Name="Win32"\r
+ />\r
+ </Platforms>\r
+ <ToolFiles>\r
+ </ToolFiles>\r
+ <Configurations>\r
+ <Configuration\r
+ Name="Debug|Win32"\r
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+ IntermediateDirectory="$(ConfigurationName)"\r
+ ConfigurationType="2"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ AdditionalIncludeDirectories="..\..\include;"c:\Program Files\openr2\include\openr2";"C:\Program Files\openr2\include""\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FTMOD_R2_EXPORTS;"\r
+ MinimalRebuild="true"\r
+ BasicRuntimeChecks="3"\r
+ RuntimeLibrary="3"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="4"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="freetdm.lib openr2.lib"\r
+ LinkIncremental="2"\r
+ AdditionalLibraryDirectories=""C:\Program Files\openr2\lib";"$(OutDir)""\r
+ GenerateDebugInformation="true"\r
+ SubSystem="2"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ <Configuration\r
+ Name="Release|Win32"\r
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+ IntermediateDirectory="$(ConfigurationName)"\r
+ ConfigurationType="2"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ AdditionalIncludeDirectories="..\..\include;C:\Program Files\openr2\include"\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FTMOD_R2_EXPORTS;"\r
+ RuntimeLibrary="2"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="3"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ LinkIncremental="2"\r
+ GenerateDebugInformation="true"\r
+ SubSystem="2"\r
+ OptimizeReferences="2"\r
+ EnableCOMDATFolding="2"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ </Configurations>\r
+ <References>\r
+ </References>\r
+ <Files>\r
+ <Filter\r
+ Name="Header Files"\r
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+ >\r
+ </Filter>\r
+ <Filter\r
+ Name="Resource Files"\r
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"\r
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+ >\r
+ </Filter>\r
+ <Filter\r
+ Name="Source Files"\r
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+ >\r
+ <File\r
+ RelativePath=".\ftmod_r2.c"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ </Files>\r
+ <Globals>\r
+ </Globals>\r
+</VisualStudioProject>\r
static int ftdm_r2_state_advance(ftdm_channel_t *ftdmchan);
+
+/* functions not available on windows */
+#ifdef WIN32
+#include <mmsystem.h>
+
+static __inline int gettimeofday(struct timeval *tp, void *nothing)
+{
+#ifdef WITHOUT_MM_LIB
+ SYSTEMTIME st;
+ time_t tt;
+ struct tm tmtm;
+ /* mktime converts local to UTC */
+ GetLocalTime (&st);
+ tmtm.tm_sec = st.wSecond;
+ tmtm.tm_min = st.wMinute;
+ tmtm.tm_hour = st.wHour;
+ tmtm.tm_mday = st.wDay;
+ tmtm.tm_mon = st.wMonth - 1;
+ tmtm.tm_year = st.wYear - 1900; tmtm.tm_isdst = -1;
+ tt = mktime (&tmtm);
+ tp->tv_sec = tt;
+ tp->tv_usec = st.wMilliseconds * 1000;
+#else
+ /**
+ ** The earlier time calculations using GetLocalTime
+ ** had a time resolution of 10ms.The timeGetTime, part
+ ** of multimedia apis offer a better time resolution
+ ** of 1ms.Need to link against winmm.lib for this
+ **/
+ unsigned long Ticks = 0;
+ unsigned long Sec =0;
+ unsigned long Usec = 0;
+ Ticks = timeGetTime();
+
+ Sec = Ticks/1000;
+ Usec = (Ticks - (Sec*1000))*1000;
+ tp->tv_sec = Sec;
+ tp->tv_usec = Usec;
+#endif /* WITHOUT_MM_LIB */
+ (void)nothing;
+ return 0;
+}
+
+static char *strsep(char **stringp, const char *delim)
+{
+ char *start = *stringp;
+ char *ptr;
+
+ if (!start)
+ return NULL;
+
+ if (!*delim)
+ ptr = start + strlen(start);
+ else {
+ ptr = strpbrk(start, delim);
+ if (!ptr) {
+ *stringp = NULL;
+ return start;
+ }
+ }
+
+ *ptr = '\0';
+ *stringp = ptr + 1;
+
+ return start;
+}
+#endif /* WIN32 */
+
static ftdm_call_cause_t ftdm_r2_cause_to_ftdm_cause(ftdm_channel_t *fchan, openr2_call_disconnect_cause_t cause)
{
switch (cause) {
}
static openr2_event_interface_t ftdm_r2_event_iface = {
- .on_call_init = ftdm_r2_on_call_init,
- .on_call_offered = ftdm_r2_on_call_offered,
- .on_call_accepted = ftdm_r2_on_call_accepted,
- .on_call_answered = ftdm_r2_on_call_answered,
- .on_call_disconnect = ftdm_r2_on_call_disconnect,
- .on_call_end = ftdm_r2_on_call_end,
- .on_call_read = ftdm_r2_on_call_read,
- .on_hardware_alarm = ftdm_r2_on_hardware_alarm,
- .on_os_error = ftdm_r2_on_os_error,
- .on_protocol_error = ftdm_r2_on_protocol_error,
- .on_line_blocked = ftdm_r2_on_line_blocked,
- .on_line_idle = ftdm_r2_on_line_idle,
+ /* .on_call_init */ ftdm_r2_on_call_init,
+ /* .on_call_offered */ ftdm_r2_on_call_offered,
+ /* .on_call_accepted */ ftdm_r2_on_call_accepted,
+ /* .on_call_answered */ ftdm_r2_on_call_answered,
+ /* .on_call_disconnect */ ftdm_r2_on_call_disconnect,
+ /* .on_call_end */ ftdm_r2_on_call_end,
+ /* .on_call_read */ ftdm_r2_on_call_read,
+ /* .on_hardware_alarm */ ftdm_r2_on_hardware_alarm,
+ /* .on_os_error */ ftdm_r2_on_os_error,
+ /* .on_protocol_error */ ftdm_r2_on_protocol_error,
+ /* .on_line_blocked */ ftdm_r2_on_line_blocked,
+ /* .on_line_idle */ ftdm_r2_on_line_idle,
+
/* cast seems to be needed to get rid of the annoying warning regarding format attribute */
- .on_context_log = (openr2_handle_context_logging_func)ftdm_r2_on_context_log,
- .on_dnis_digit_received = ftdm_r2_on_dnis_digit_received,
- .on_ani_digit_received = ftdm_r2_on_ani_digit_received,
+ /* .on_context_log */ (openr2_handle_context_logging_func)ftdm_r2_on_context_log,
+ /* .on_dnis_digit_received */ ftdm_r2_on_dnis_digit_received,
+ /* .on_ani_digit_received */ ftdm_r2_on_ani_digit_received,
+
/* so far we do nothing with billing pulses */
- .on_billing_pulse_received = NULL,
+ /* .on_billing_pulse_received */ NULL,
};
static int ftdm_r2_io_set_cas(openr2_chan_t *r2chan, int cas)
}
static openr2_io_interface_t ftdm_r2_io_iface = {
- .open = ftdm_r2_io_open, /* never called */
- .close = ftdm_r2_io_close, /* never called */
- .set_cas = ftdm_r2_io_set_cas,
- .get_cas = ftdm_r2_io_get_cas,
- .flush_write_buffers = ftdm_r2_io_flush_write_buffers,
- .write = ftdm_r2_io_write,
- .read = ftdm_r2_io_read,
- .setup = ftdm_r2_io_setup, /* never called */
- .wait = ftdm_r2_io_wait,
- .get_oob_event = ftdm_r2_io_get_oob_event /* never called */
+ /* .open */ ftdm_r2_io_open, /* never called */
+ /* .close */ ftdm_r2_io_close, /* never called */
+ /* .set_cas */ ftdm_r2_io_set_cas,
+ /* .get_cas */ ftdm_r2_io_get_cas,
+ /* .flush_write_buffers */ ftdm_r2_io_flush_write_buffers,
+ /* .write */ ftdm_r2_io_write,
+ /* .read */ ftdm_r2_io_read,
+ /* .setup */ ftdm_r2_io_setup, /* never called */
+ /* .wait */ ftdm_r2_io_wait,
+ /* .get_oob_event */ ftdm_r2_io_get_oob_event /* never called */
};
static FIO_SIG_CONFIGURE_FUNCTION(ftdm_r2_configure_span)
ftdm_r2_span_pvt_t *spanpvt = NULL;
ftdm_r2_call_t *r2call = NULL;
openr2_chan_t *r2chan = NULL;
-
- assert(sig_cb != NULL);
+ openr2_log_level_t tmplevel;
+ char *clevel;
+ char *logval = NULL;
ft_r2_conf_t r2conf =
{
- .variant = OR2_VAR_ITU,
- .category = OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER,
- .loglevel = OR2_LOG_ERROR | OR2_LOG_WARNING,
- .max_ani = 10,
- .max_dnis = 4,
- .mfback_timeout = -1,
- .metering_pulse_timeout = -1,
- .allow_collect_calls = -1,
- .immediate_accept = -1,
- .skip_category = -1,
- .forced_release = -1,
- .charge_calls = -1,
- .get_ani_first = -1,
- .call_files = 0,
- .mf_files = 0,
- .logdir = NULL,
- .advanced_protocol_file = NULL
+ /* .variant */ OR2_VAR_ITU,
+ /* .category */ OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER,
+ /* .loglevel */ OR2_LOG_ERROR | OR2_LOG_WARNING,
+ /* .max_ani */ 10,
+ /* .max_dnis */ 4,
+ /* .mfback_timeout */ -1,
+ /* .metering_pulse_timeout */ -1,
+ /* .allow_collect_calls */ -1,
+ /* .immediate_accept */ -1,
+ /* .skip_category */ -1,
+ /* .forced_release */ -1,
+ /* .charge_calls */ -1,
+ /* .get_ani_first */ -1,
+ /* .call_files */ 0,
+ /* .mf_files */ 0,
+ /* .logdir */ NULL,
+ /* .advanced_protocol_file */ NULL
};
+ assert(sig_cb != NULL);
if (span->signal_type) {
snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling.");
ftdm_log(FTDM_LOG_NOTICE, "Ignoring empty R2 logging parameter\n");
continue;
}
- openr2_log_level_t tmplevel;
- char *clevel;
- char *logval = ftdm_malloc(strlen(val)+1); /* alloca man page scared me, so better to use good ol' malloc */
+ logval = ftdm_malloc(strlen(val)+1); /* alloca man page scared me, so better to use good ol' malloc */
if (!logval) {
ftdm_log(FTDM_LOG_WARNING, "Ignoring R2 logging parameter: '%s', failed to alloc memory\n", val);
continue;
}
}
+#ifndef WIN32
/* figure out what event to poll each channel for. POLLPRI when the channel is down,
* POLLPRI|POLLIN|POLLOUT otherwise.
*/
}
status = ftdm_span_poll_event(span, waitms, poll_events);
+#else
+ status = ftdm_span_poll_event(span, waitms, NULL);
+#endif
res = gettimeofday(&start, NULL);
if (res) {
int span_id = 0;
int chan_id = 0;
int i = 0;
+ ftdm_r2_data_t *r2data = NULL;
+ openr2_chan_t *r2chan = NULL;
+ openr2_context_t *r2context = NULL;
+ openr2_variant_t r2variant;
if (data) {
mycmd = ftdm_strdup(data);
if (!strcasecmp(argv[0], "status")) {
//openr2_chan_stats_t stats;
span_id = atoi(argv[1]);
- ftdm_r2_data_t *r2data = NULL;
- openr2_chan_t *r2chan = NULL;
- openr2_context_t *r2context = NULL;
if (ftdm_span_find_by_name(argv[1], &span) == FTDM_SUCCESS || ftdm_span_find(span_id, &span) == FTDM_SUCCESS) {
if (span->start != ftdm_r2_start) {
goto done;
}
r2context = r2data->r2context;
- openr2_variant_t r2variant = openr2_context_get_variant(r2context);
+ r2variant = openr2_context_get_variant(r2context);
stream->write_function(stream,
"Variant: %s\n"
"Max ANI: %d\n"