make ozmod_sangoma_boost compile on Windows ... but not linking yet -_-

git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@915 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Moises Silva 2009-11-27 22:40:45 +00:00
parent 5bb2c0eb3f
commit 4778d58223
5 changed files with 297 additions and 63 deletions

View File

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ozmod_sangoma_boost"
ProjectGUID="{D021EF2A-460D-4827-A0F7-41FDECF46F1B}"
RootNamespace="ozmod_sangoma_boost"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<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="..\..\include;..\..\isdn\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OZMOD_SANGOMA_BOOST_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4100"
/>
<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="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="..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OZMOD_SANGOMA_BOOST_EXPORTS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4100"
/>
<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="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="ozmod_sangoma_boost.c"
>
</File>
<File
RelativePath="sangoma_boost_client.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="sangoma_boost_client.h"
>
</File>
<File
RelativePath="sangoma_boost_interface.h"
>
</File>
<File
RelativePath="sigboost.h"
>
</File>
<File
RelativePath="zap_sangoma_boost.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -38,6 +38,11 @@
*
*/
/* 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"
@ -194,11 +199,11 @@ static sangoma_boost_request_id_t __next_request_id(const char *func, int line)
*/
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;
@ -358,13 +363,13 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(sangoma_boost_channel_request)
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;
@ -1315,9 +1320,11 @@ static zap_status_t zap_boost_connection_open(zap_span_t *span)
*/
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) {
@ -1331,6 +1338,7 @@ static int zap_boost_wait_event(zap_span_t *span, int ms)
}
return 1;
}
#ifndef WIN32
mcon = &sangoma_boost_data->mcon;
pcon = &sangoma_boost_data->pcon;
@ -1352,6 +1360,8 @@ static int zap_boost_wait_event(zap_span_t *span, int ms)
}
return 1;
#endif
return 0;
}

View File

@ -109,6 +109,7 @@ static void sangomabc_print_event_short(sangomabc_connection_t *mcon, sangomabc_
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];
@ -174,12 +175,15 @@ static int create_conn_socket(sangomabc_connection_t *mcon, char *local_ip, int
}
}
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;
@ -195,7 +199,7 @@ int sangomabc_connection_close(sangomabc_connection_t *mcon)
}
memset(mcon, 0, sizeof(*mcon));
mcon->socket = -1;
#endif
return 0;
}
@ -206,8 +210,12 @@ int sangomabc_connection_open(sangomabc_connection_t *mcon, char *local_ip, int
/*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
}
@ -217,7 +225,7 @@ int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int
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;
@ -227,7 +235,7 @@ int sangomabc_exec_command(sangomabc_connection_t *mcon, int span, int chan, int
}
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) {
@ -250,10 +258,10 @@ int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, in
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) {
@ -271,7 +279,9 @@ int sangomabc_exec_commandp(sangomabc_connection_t *pcon, int span, int chan, in
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;
@ -283,11 +293,13 @@ sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int
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;
}
@ -365,16 +377,20 @@ sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int
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;
}
@ -405,14 +421,12 @@ sangomabc_event_t *__sangomabc_connection_readp(sangomabc_connection_t *mcon, in
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);
@ -448,16 +462,16 @@ int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t
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);
@ -471,15 +485,13 @@ int __sangomabc_connection_write(sangomabc_connection_t *mcon, sangomabc_event_t
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)) {
@ -492,15 +504,15 @@ int __sangomabc_connection_writep(sangomabc_connection_t *mcon, sangomabc_event_
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);
@ -519,15 +531,15 @@ void sangomabc_call_init(sangomabc_event_t *event, const char *calling, const ch
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;
}
@ -535,8 +547,8 @@ void sangomabc_event_init(sangomabc_short_event_t *event, sangomabc_event_id_t e
{
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)

View File

@ -38,26 +38,26 @@
#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)); \
@ -120,7 +120,7 @@ typedef struct sangomabc_queue_element {
} 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;
@ -134,10 +134,10 @@ sangomabc_event_t *__sangomabc_connection_read(sangomabc_connection_t *mcon, int
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);

View File

@ -142,7 +142,7 @@ typedef struct
#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:
@ -150,10 +150,9 @@ static inline int boost_full_event(int event_id)
case SIGBOOST_EVENT_CALL_PROGRESS:
return 1;
default:
return 0;
break;
}
return 0;
return 0;
}
#endif