--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+ ProjectType="Visual C++"\r
+ Version="9.00"\r
+ Name="ozmod_sangoma_boost"\r
+ ProjectGUID="{D021EF2A-460D-4827-A0F7-41FDECF46F1B}"\r
+ RootNamespace="ozmod_sangoma_boost"\r
+ Keyword="Win32Proj"\r
+ TargetFrameworkVersion="196613"\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
+ CharacterSet="1"\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;..\..\isdn\include"\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OZMOD_SANGOMA_BOOST_EXPORTS"\r
+ MinimalRebuild="true"\r
+ BasicRuntimeChecks="3"\r
+ RuntimeLibrary="3"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="4"\r
+ WarnAsError="true"\r
+ DebugInformationFormat="4"\r
+ DisableSpecificWarnings="4100"\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
+ 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
+ CharacterSet="1"\r
+ WholeProgramOptimization="1"\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="2"\r
+ EnableIntrinsicFunctions="true"\r
+ AdditionalIncludeDirectories="..\..\include"\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OZMOD_SANGOMA_BOOST_EXPORTS"\r
+ RuntimeLibrary="2"\r
+ EnableFunctionLevelLinking="true"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="4"\r
+ WarnAsError="true"\r
+ DebugInformationFormat="3"\r
+ DisableSpecificWarnings="4100"\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="1"\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="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="ozmod_sangoma_boost.c"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="sangoma_boost_client.c"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="Header Files"\r
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+ >\r
+ <File\r
+ RelativePath="sangoma_boost_client.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="sangoma_boost_interface.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="sigboost.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zap_sangoma_boost.h"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ </Files>\r
+ <Globals>\r
+ </Globals>\r
+</VisualStudioProject>\r
*
*/
+/* NOTE:
+On WIN32 platform this code works with sigmod ONLY, don't try to make sense of any socket code for win32
+I basically ifdef out everything that the compiler complained about
+*/
+
#include "openzap.h"
#include "sangoma_boost_client.h"
#include "zap_sangoma_boost.h"
*/
static zap_channel_t *find_zchan(zap_span_t *span, sangomabc_short_event_t *event, int force)
{
- int i;
+ uint32_t i;
zap_channel_t *zchan = NULL;
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
- int targetspan = event->span+1;
- int targetchan = event->chan+1;
+ uint32_t targetspan = event->span+1;
+ uint32_t targetchan = event->chan+1;
if (sangoma_boost_data->sigmod) {
/* span is not strictly needed here since we're supposed to get only events for our span */
targetspan = event->span;
zap_set_string(event.calling_name, caller_data->cid_name);
zap_set_string(event.isup_in_rdnis, caller_data->rdnis.digits);
if (strlen(caller_data->rdnis.digits)) {
- event.isup_in_rdnis_size = strlen(caller_data->rdnis.digits)+1;
+ event.isup_in_rdnis_size = (uint16_t)strlen(caller_data->rdnis.digits)+1;
}
event.calling_number_screening_ind = caller_data->screen;
event.calling_number_presentation = caller_data->pres;
if (sangoma_boost_data->sigmod) {
- event.span = span->channels[1]->physical_span_id;
+ event.span = (uint8_t)span->channels[1]->physical_span_id;
}
OUTBOUND_REQUESTS[r].status = BST_WAITING;
*/
static int zap_boost_wait_event(zap_span_t *span, int ms)
{
+#ifndef WIN32
struct timeval tv = { 0, ms * 1000 };
- int max, activity;
sangomabc_connection_t *mcon, *pcon;
+ int max, activity;
+#endif
zap_sangoma_boost_data_t *sangoma_boost_data = span->signal_data;
if (sangoma_boost_data->sigmod) {
}
return 1;
}
+#ifndef WIN32
mcon = &sangoma_boost_data->mcon;
pcon = &sangoma_boost_data->pcon;
}
return 1;
+#endif
+ return 0;
}
static int create_conn_socket(sangomabc_connection_t *mcon, char *local_ip, int local_port, char *ip, int port)
{
+#ifndef WIN32
int rc;
struct hostent *result, *local_result;
char buf[512], local_buf[512];
}
}
-
return mcon->socket;
+#else
+ return 0;
+#endif // ifndef WIN32
}
int sangomabc_connection_close(sangomabc_connection_t *mcon)
{
+#ifndef WIN32
if (mcon->sigmod) {
zap_log(ZAP_LOG_WARNING, "I should not be called on a sigmod-managed connection!\n");
return 0;
}
memset(mcon, 0, sizeof(*mcon));
mcon->socket = -1;
-
+#endif
return 0;
}
/*value of mcon->socket will be ignored in sigmod mode */
return 0;
}
+#ifndef WIN32
create_conn_socket(mcon, local_ip, local_port, ip, port);
return mcon->socket;
+#else
+ return 0;
+#endif
}
int retry = 5;
sangomabc_event_init(&oevent, cmd, chan, span);
- oevent.release_cause = cause;
+ oevent.release_cause = (uint8_t)cause;
if (cmd == SIGBOOST_EVENT_SYSTEM_RESTART || cmd == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
mcon->rxseq_reset = 1;
}
if (id >= 0) {
- oevent.call_setup_id = id;
+ oevent.call_setup_id = (uint16_t)id;
}
while (sangomabc_connection_write(mcon, (sangomabc_event_t*)&oevent) <= 0) {
int retry = 5;
sangomabc_event_init(&oevent, cmd, chan, span);
- oevent.release_cause = cause;
+ oevent.release_cause = (uint8_t)cause;
if (id >= 0) {
- oevent.call_setup_id = id;
+ oevent.call_setup_id = (uint16_t)id;
}
while (sangomabc_connection_writep(pcon, (sangomabc_event_t*)&oevent) <= 0) {
sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
{
+#ifndef WIN32
unsigned int fromlen = sizeof(struct sockaddr_in);
+#endif
int bytes = 0;
int msg_ok = 0;
sangomabc_queue_element_t *e = NULL;
memcpy(&mcon->event, e->boostmsg, bytes);
zap_safe_free(e);
}
- } else {
+ }
+#ifndef WIN32
+ else {
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
(struct sockaddr *) &mcon->local_addr, &fromlen);
}
-
+#endif
if (bytes <= 0) {
return NULL;
}
sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line)
{
+#ifndef WIN32
unsigned int fromlen = sizeof(struct sockaddr_in);
+#endif
int bytes = 0;
if (mcon->sigmod) {
/* priority stuff is handled just the same when there is a sigmod */
return sangomabc_connection_read(mcon, iteration);
- } else {
+ }
+#ifndef WIN32
+ else {
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT, (struct sockaddr *) &mcon->local_addr, &fromlen);
}
-
+#endif
if (bytes <= 0) {
return NULL;
}
int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
{
- int err;
+ int err = 0;
int event_size=MIN_SIZE_CALLSTART_MSG+event->isup_in_rdnis_size;
-
- if (!event || mcon->socket < 0 || !mcon->mutex) {
- zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n");
- return -EINVAL;
- abort();
- }
+
+ zap_assert_return(event != NULL, -1, "No event!");
+ zap_assert_return(mcon->socket >= 0, -1, "No mcon->socket!");
+ zap_assert_return(mcon->mutex != NULL, -1, "No mcon->mutex!");
if (event->span >= ZAP_MAX_PHYSICAL_SPANS_PER_LOGICAL_SPAN || event->chan >= ZAP_MAX_CHANNELS_PHYSICAL_SPAN ) {
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: TX Cmd=%s Invalid Span=%i Chan=%i\n", sangomabc_event_id_name(event->event_id), event->span, event->chan);
if (mcon->sigmod) {
mcon->sigmod->write_msg(mcon->span, event, event_size);
err = event_size;
- } else {
+ }
+#ifndef WIN32
+ else {
err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
}
+#endif
zap_mutex_unlock(mcon->mutex);
- if (err != event_size) {
- err = -1;
- abort();
- }
+ zap_assert_return(err == event_size, -1, "Failed to send the boost message completely!");
if (boost_full_event(event->event_id)) {
sangomabc_print_event_call(mcon, event, 0, 1, file, func, line);
int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line)
{
- int err;
+ int err = 0;
int event_size=sizeof(sangomabc_event_t);
if (!mcon->sigmod) {
- if (!event || mcon->socket < 0 || !mcon->mutex) {
- zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n");
- return -EINVAL;
- abort();
- }
+ zap_assert_return(event != NULL, -1, "No event!");
+ zap_assert_return(mcon->socket >= 0, -1, "No mcon->socket!");
+ zap_assert_return(mcon->mutex != NULL, -1, "No mcon->mutex!");
}
if (!boost_full_event(event->event_id)) {
mcon->sigmod->write_msg(mcon->span, event, event_size);
err = event_size;
- } else {
+ }
+#ifndef WIN32
+ else {
err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
}
+#endif
zap_mutex_unlock(mcon->mutex);
- if (err != event_size) {
- err = -1;
- abort();
- }
+ zap_assert_return(err == event_size, -1, "Failed to send boost message completely!");
if (boost_full_event(event->event_id)) {
sangomabc_print_event_call(mcon, event, 1, 1, file, func, line);
if (calling) {
strncpy((char*)event->calling_number_digits, calling, sizeof(event->calling_number_digits)-1);
- event->calling_number_digits_count = strlen(calling);
+ event->calling_number_digits_count = (uint8_t)strlen(calling);
}
if (called) {
strncpy((char*)event->called_number_digits, called, sizeof(event->called_number_digits)-1);
- event->called_number_digits_count = strlen(called);
+ event->called_number_digits_count = (uint8_t)strlen(called);
}
- event->call_setup_id = setup_id;
+ event->call_setup_id = (uint16_t)setup_id;
}
{
memset(event, 0, sizeof(sangomabc_short_event_t));
event->event_id = event_id;
- event->chan = chan;
- event->span = span;
+ event->chan = (uint8_t)chan;
+ event->span = (uint8_t)span;
}
const char *sangomabc_event_id_name(uint32_t event_id)
#include <ctype.h>
#include <string.h>
+#ifndef WIN32
#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifdef HAVE_NETINET_SCTP_H
#include <netinet/sctp.h>
#endif
#include <arpa/inet.h>
-#include <stdarg.h>
#include <netdb.h>
-#include <sigboost.h>
#include <sys/time.h>
+#endif
+#include <stdlib.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdarg.h>
+#include "sigboost.h"
-#define sangomabc_test_flag(p,flag) ({ \
- ((p)->flags & (flag)); \
- })
+#define sangomabc_test_flag(p,flag) ((p)->flags & (flag))
#define sangomabc_set_flag(p,flag) do { \
((p)->flags |= (flag)); \
} sangomabc_queue_element_t;
/* disable nagle's algorythm */
-static inline void sctp_no_nagle(int socket)
+static __inline__ void sctp_no_nagle(int socket)
{
#ifdef HAVE_NETINET_SCTP_H
int flag = 1;
sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, int iteration, const char *file, const char *func, int line);
int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_t *event, const char *file, const char *func, int line);
-#define sangomabc_connection_write(_m,_e) __sangomabc_connection_write(_m, _e, __FILE__, __func__, __LINE__)
-#define sangomabc_connection_writep(_m,_e) __sangomabc_connection_writep(_m, _e, __FILE__, __func__, __LINE__)
-#define sangomabc_connection_read(_m,_e) __sangomabc_connection_read(_m, _e, __FILE__, __func__, __LINE__)
-#define sangomabc_connection_readp(_m,_e) __sangomabc_connection_readp(_m, _e, __FILE__, __func__, __LINE__)
+#define sangomabc_connection_write(_m,_e) __sangomabc_connection_write(_m, _e, __FILE__, __FUNCTION__, __LINE__)
+#define sangomabc_connection_writep(_m,_e) __sangomabc_connection_writep(_m, _e, __FILE__, __FUNCTION__, __LINE__)
+#define sangomabc_connection_read(_m,_e) __sangomabc_connection_read(_m, _e, __FILE__, __FUNCTION__, __LINE__)
+#define sangomabc_connection_readp(_m,_e) __sangomabc_connection_readp(_m, _e, __FILE__, __FUNCTION__, __LINE__)
void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t event_id, int chan, int span);
void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const char *called, int setup_id);
const char *sangomabc_event_id_name(uint32_t event_id);
#pragma pack()
-static inline int boost_full_event(int event_id)
+static __inline__ int boost_full_event(int event_id)
{
switch (event_id) {
case SIGBOOST_EVENT_CALL_START:
case SIGBOOST_EVENT_CALL_PROGRESS:
return 1;
default:
- return 0;
+ break;
}
-
- return 0;
+ return 0;
}
#endif