FS-4539 please test this and post new logs if necessary

This commit is contained in:
Anthony Minessale 2012-08-16 11:56:55 -05:00
parent cd21b67c1d
commit 42bf44de51
15 changed files with 1836 additions and 2007 deletions

View File

@ -98,8 +98,7 @@ typedef enum {
SSF_READ_TRANSCODE = (1 << 5),
SSF_WRITE_TRANSCODE = (1 << 6),
SSF_READ_CODEC_RESET = (1 << 7),
SSF_WRITE_CODEC_RESET = (1 << 8),
SSF_DESTROYABLE = (1 << 9)
SSF_WRITE_CODEC_RESET = (1 << 8)
} switch_session_flag_t;

View File

@ -1,19 +1,7 @@
BASE=../../../..
PKG_DIR:=/usr/local/lib/pkgconfig
ifeq ($(PKG_CONFIG_PATH),)
export PKG_CONFIG_PATH:=$(PKG_DIR)
else
ifeq ($(findstring $(PKG_DIR),$(PKG_CONFIG_PATH)),)
export PKG_CONFIG_PATH:=$(PKG_CONFIG_PATH):$(PKG_DIR)
endif
endif
#DEBUG_SUFFIX:=--define-variable=suffix=_d
LOCAL_INSERT_CFLAGS= pkg-config opal $(DEBUG_SUFFIX) --cflags
LOCAL_CFLAGS+=-g -ggdb
LOCAL_INSERT_LDFLAGS= pkg-config opal $(DEBUG_SUFFIX) --libs
LOCAL_INSERT_CFLAGS= pkg-config opal --cflags
LOCAL_CFLAGS+=-g -ggdb -I.
LOCAL_INSERT_LDFLAGS= pkg-config opal --libs
include $(BASE)/build/modmake.rules

File diff suppressed because it is too large Load Diff

View File

@ -1,330 +1,270 @@
/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
* Soft-Switch Application
*
* Version: MPL 1.1
*
* Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
* Copyright (c) 2008-2012 Vox Lucida Pty. Ltd. (robertj@voxlucida.com.au)
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Contributor(s):
* Tuyan Ozipek (tuyanozipek@gmail.com)
* Lukasz Zwierko (lzwierko@gmail.com)
* Robert Jongbloed (robertj@voxlucida.com.au)
*
*/
#ifndef __FREESWITCH_MOD_OPAL__
#define __FREESWITCH_MOD_OPAL__
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
#pragma GCC visibility push(default)
#endif
#include <ptlib.h>
#include <opal/manager.h>
#include <opal/localep.h>
#include <h323/h323ep.h>
#include <iax2/iax2ep.h>
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
#pragma GCC visibility pop
#endif
#undef strcasecmp
#undef strncasecmp
#if _MSC_VER < 1600
/*The following insanity is because libteletone_generate.h defines int8_t in
a slightly different manner to most other cases (SDL, PCAP, Java V8, stdint.h
etc) and does not provide a mechanism to prevent it's inclusion. Then, to
cap it off, VS2008 barfs on the difference. VS2010 seems OK with it.
Sigh.
*/
#pragma include_alias(<libteletone.h>, <../../libs/libteletone/src/libteletone.h>)
#pragma include_alias(<libteletone_generate.h>, <../../libs/libteletone/src/libteletone_generate.h>)
#pragma include_alias(<libteletone_detect.h>, <../../libs/libteletone/src/libteletone_detect.h>)
#define int8_t signed int8_t
#include <libteletone_generate.h>
#undef int8_t
#endif // End of insanity
#define HAVE_APR
#define uint32_t uint32_t // Avoid conflict in stdint definitions
#include <switch.h>
#undef uint32_t
#include <switch_version.h>
#define MODNAME "mod_opal"
class FSEndPoint;
class FSManager;
class FSProcess : public PLibraryProcess
{
PCLASSINFO(FSProcess, PLibraryProcess);
public:
FSProcess();
~FSProcess();
bool Initialise(switch_loadable_module_interface_t *iface);
FSManager & GetManager() const
{
return *m_manager;
}
protected:
FSManager * m_manager;
};
struct FSListener
{
FSListener() : m_port(H323EndPoint::DefaultTcpSignalPort) { }
PString m_name;
PIPSocket::Address m_address;
uint16_t m_port;
};
class FSManager : public OpalManager
{
PCLASSINFO(FSManager, OpalManager);
public:
FSManager();
bool Initialise(switch_loadable_module_interface_t *iface);
switch_status_t ReadConfig(int reload);
switch_endpoint_interface_t *GetSwitchInterface() const { return m_FreeSwitch; }
const PString & GetContext() const { return m_context; }
const PString & GetDialPlan() const { return m_dialplan; }
const PString & GetCodecPrefs() const { return m_codecPrefs; }
bool GetDisableTranscoding() const { return m_disableTranscoding; }
private:
switch_endpoint_interface_t *m_FreeSwitch;
H323EndPoint *m_h323ep;
IAX2EndPoint *m_iaxep;
FSEndPoint *m_fsep;
PString m_context;
PString m_dialplan;
PString m_codecPrefs;
bool m_disableTranscoding;
PString m_gkAddress;
PString m_gkIdentifer;
PString m_gkInterface;
list <FSListener> m_listeners;
};
class FSEndPoint : public OpalLocalEndPoint
{
PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
public:
FSEndPoint(FSManager & manager);
virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
FSManager & GetManager() const { return m_manager; }
protected:
FSManager & m_manager;
};
class FSConnection;
class FSMediaStream : public OpalMediaStream
{
PCLASSINFO(FSMediaStream, OpalMediaStream);
public:
FSMediaStream(
FSConnection & conn,
const OpalMediaFormat & mediaFormat, ///< Media format for stream
unsigned sessionID, ///< Session number for stream
bool isSource ///< Is a source stream
);
virtual PBoolean Open();
virtual PBoolean IsSynchronous() const;
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
protected:
virtual void InternalClose();
int StartReadWrite(PatchPtr & mediaPatch) const;
private:
bool CheckPatchAndLock();
FSConnection &m_connection;
switch_timer_t *m_switchTimer;
switch_codec_t *m_switchCodec;
switch_frame_t m_readFrame;
RTP_DataFrame m_readRTP;
};
#define DECLARE_CALLBACK0(name) \
static switch_status_t name(switch_core_session_t *session) { \
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
return tech_pvt != NULL ? tech_pvt->name() : SWITCH_STATUS_FALSE; } \
switch_status_t name()
#define DECLARE_CALLBACK1(name, type1, name1) \
static switch_status_t name(switch_core_session_t *session, type1 name1) { \
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
return tech_pvt != NULL ? tech_pvt->name(name1) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1)
#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \
static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \
FSConnection *tech_pvt = (FSConnection *) switch_core_session_get_private(session); \
return tech_pvt != NULL ? tech_pvt->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1, type2 name2, type3 name3)
class FSConnection : public OpalLocalConnection
{
PCLASSINFO(FSConnection, OpalLocalConnection)
public:
struct outgoing_params {
switch_event_t *var_event;
switch_caller_profile_t *outbound_profile;
switch_core_session_t **new_session;
switch_memory_pool_t **pool;
switch_originate_flag_t flags;
switch_call_cause_t *cancel_cause;
switch_call_cause_t fail_cause;
};
FSConnection(OpalCall & call,
FSEndPoint & endpoint,
unsigned options,
OpalConnection::StringOptions * stringOptions,
outgoing_params * params);
virtual bool OnOutgoingSetUp();
virtual bool OnIncoming();
virtual void OnReleased();
virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
virtual void OnPatchMediaStream(PBoolean isSource, OpalMediaPatch & patch);
virtual OpalMediaFormatList GetMediaFormats() const;
virtual PBoolean SendUserInputTone(char tone, unsigned duration);
DECLARE_CALLBACK0(on_init);
DECLARE_CALLBACK0(on_destroy);
DECLARE_CALLBACK0(on_routing);
DECLARE_CALLBACK0(on_execute);
DECLARE_CALLBACK0(on_hangup);
DECLARE_CALLBACK0(on_exchange_media);
DECLARE_CALLBACK0(on_soft_execute);
DECLARE_CALLBACK1(kill_channel, int, sig);
DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
DECLARE_CALLBACK0(state_change);
DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
__inline switch_core_session_t *GetSession() const
{
return m_fsSession;
}
__inline switch_channel_t *GetChannel() const
{
return m_fsChannel;
}
bool IsChannelReady() const
{
return m_fsChannel != NULL && switch_channel_ready(m_fsChannel);
}
bool NeedFlushAudio()
{
if (!m_flushAudio)
return false;
m_flushAudio = false;
return true;
}
protected:
void SetCodecs();
bool WaitForMedia();
switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
private:
FSEndPoint &m_endpoint;
switch_core_session_t *m_fsSession;
switch_channel_t *m_fsChannel;
PSyncPoint m_rxAudioOpened;
PSyncPoint m_txAudioOpened;
OpalMediaFormatList m_switchMediaFormats;
// If FS ever supports more than one audio and one video, this needs to change
switch_timer_t m_read_timer;
switch_codec_t m_read_codec;
switch_codec_t m_write_codec;
switch_timer_t m_vid_read_timer;
switch_codec_t m_vid_read_codec;
switch_codec_t m_vid_write_codec;
bool m_flushAudio;
friend PBoolean FSMediaStream::Open();
};
#endif /* __FREESWITCH_MOD_OPAL__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:nil
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:s:
*/
/* Opal endpoint interface for Freeswitch Modular Media Switching Software Library /
* Soft-Switch Application
*
* Version: MPL 1.1
*
* Copyright (c) 2007 Tuyan Ozipek (tuyanozipek@gmail.com)
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Contributor(s):
* Tuyan Ozipek (tuyanozipek@gmail.com)
* Lukasz Zwierko (lzwierko@gmail.com)
* Robert Jongbloed (robertj@voxlucida.com.au)
*
*/
#ifndef __FREESWITCH_MOD_OPAL__
#define __FREESWITCH_MOD_OPAL__
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
#pragma GCC visibility push(default)
#endif
#include <ptlib.h>
#include <opal/manager.h>
#include <opal/localep.h>
#include <h323/h323ep.h>
#include <iax2/iax2ep.h>
#if defined(__GNUC__) && defined(HAVE_VISIBILITY)
#pragma GCC visibility pop
#endif
#undef strcasecmp
#undef strncasecmp
#define HAVE_APR
#include <switch.h>
#include <switch_version.h>
#define MODNAME "mod_opal"
class FSEndPoint;
class FSManager;
struct mod_opal_globals {
int trace_level;
char *codec_string;
char *context;
char *dialplan;
};
extern struct mod_opal_globals mod_opal_globals;
class FSProcess:public PLibraryProcess {
PCLASSINFO(FSProcess, PLibraryProcess);
public:
FSProcess();
~FSProcess();
bool Initialise(switch_loadable_module_interface_t *iface);
FSManager & GetManager() const {
return *m_manager;
} protected:
FSManager * m_manager;
};
struct FSListener {
FSListener() {
} PString name;
OpalTransportAddress listenAddress;
PString localUserName;
PString gatekeeper;
};
class FSCall:public OpalCall {
PCLASSINFO(FSCall, OpalCall);
public:
FSCall(OpalManager & manager);
virtual PBoolean OnSetUp(OpalConnection & connection);
};
class FSManager:public OpalManager {
PCLASSINFO(FSManager, OpalManager);
public:
FSManager();
bool Initialise(switch_loadable_module_interface_t *iface);
switch_status_t ReadConfig(int reload);
switch_endpoint_interface_t *GetSwitchInterface() const {
return m_FreeSwitch;
} virtual OpalCall *CreateCall(void *userData);
private:
switch_endpoint_interface_t *m_FreeSwitch;
H323EndPoint *m_h323ep;
IAX2EndPoint *m_iaxep;
FSEndPoint *m_fsep;
PString m_gkAddress;
PString m_gkIdentifer;
PString m_gkInterface;
list < FSListener > m_listeners;
};
class FSConnection;
typedef struct {
switch_timer_t read_timer;
switch_codec_t read_codec;
switch_codec_t write_codec;
switch_timer_t vid_read_timer;
switch_codec_t vid_read_codec;
switch_codec_t vid_write_codec;
FSConnection *me;
} opal_private_t;
class FSEndPoint:public OpalLocalEndPoint {
PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
public:
FSEndPoint(FSManager & manager);
virtual bool OnIncomingCall(OpalLocalConnection &);
virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
};
#define DECLARE_CALLBACK0(name) \
static switch_status_t name(switch_core_session_t *session) { \
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \
return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name() : SWITCH_STATUS_FALSE; } \
switch_status_t name()
#define DECLARE_CALLBACK1(name, type1, name1) \
static switch_status_t name(switch_core_session_t *session, type1 name1) { \
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \
return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1)
#define DECLARE_CALLBACK3(name, type1, name1, type2, name2, type3, name3) \
static switch_status_t name(switch_core_session_t *session, type1 name1, type2 name2, type3 name3) { \
opal_private_t *tech_pvt = (opal_private_t *) switch_core_session_get_private(session); \
return tech_pvt && tech_pvt->me != NULL ? tech_pvt->me->name(name1, name2, name3) : SWITCH_STATUS_FALSE; } \
switch_status_t name(type1 name1, type2 name2, type3 name3)
class FSConnection:public OpalLocalConnection {
PCLASSINFO(FSConnection, OpalLocalConnection)
public:
FSConnection(OpalCall & call,
FSEndPoint & endpoint,
void *userData,
unsigned options,
OpalConnection::StringOptions * stringOptions,
switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel);
virtual bool OnIncoming();
virtual void OnReleased();
virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
virtual void OnAlerting();
virtual void OnEstablished();
virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
virtual PBoolean OnOpenMediaStream(OpalMediaStream & stream);
virtual OpalMediaFormatList GetMediaFormats() const;
virtual PBoolean SendUserInputTone(char tone, unsigned duration);
virtual PBoolean SendUserInputString(const PString & value);
void SetCodecs();
DECLARE_CALLBACK0(on_init);
DECLARE_CALLBACK0(on_routing);
DECLARE_CALLBACK0(on_execute);
DECLARE_CALLBACK0(on_exchange_media);
DECLARE_CALLBACK0(on_soft_execute);
DECLARE_CALLBACK1(kill_channel, int, sig);
DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
DECLARE_CALLBACK0(state_change);
DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
switch_core_session_t *GetSession() const {
return m_fsSession;
} private:
FSEndPoint & m_endpoint;
switch_core_session_t *m_fsSession;
switch_channel_t *m_fsChannel;
PSyncPoint m_rxAudioOpened;
PSyncPoint m_txAudioOpened;
OpalMediaFormatList m_switchMediaFormats;
};
class FSMediaStream:public OpalMediaStream {
PCLASSINFO(FSMediaStream, OpalMediaStream);
public:
FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, ///< Media format for stream
unsigned sessionID, ///< Session number for stream
bool isSource ///< Is a source stream
);
virtual PBoolean Open();
virtual PBoolean Close();
virtual PBoolean IsSynchronous() const;
virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
private:
switch_core_session_t *m_fsSession;
switch_channel_t *m_fsChannel;
switch_timer_t *m_switchTimer;
switch_codec_t *m_switchCodec;
switch_frame_t m_readFrame;
unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
RTP_DataFrame m_readRTP;
bool m_callOnStart;
uint32_t m_timeStamp;
bool CheckPatchAndLock();
};
#endif /* __FREESWITCH_MOD_OPAL__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:nil
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:s:
*/

View File

@ -429,10 +429,6 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
gateway_ptr = sofia_reg_find_gateway(gateway_name);
}
if (!tech_pvt) {
return SWITCH_STATUS_SUCCESS;
}
switch_mutex_lock(tech_pvt->sofia_mutex);
rec = sofia_test_flag(tech_pvt, TFLAG_RECOVERING);

View File

@ -154,7 +154,6 @@ typedef struct sofia_dispatch_event_s {
int save;
switch_core_session_t *session;
switch_memory_pool_t *pool;
struct sofia_dispatch_event_s *next;
} sofia_dispatch_event_t;
struct sofia_private {
@ -167,7 +166,6 @@ struct sofia_private {
int is_call;
int is_static;
sofia_dispatch_event_t *de;
sofia_dispatch_event_t *deq;
};
#define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);}

View File

@ -969,25 +969,18 @@ static void our_sofia_event_callback(nua_event_t event,
int locked = 0;
int check_destroy = 1;
if (sofia_private && sofia_private->is_call) {
sofia_dispatch_event_t *qde = NULL;
if (sofia_private && sofia_private->is_call && sofia_private->de) {
sofia_dispatch_event_t *qde = sofia_private->de;
sofia_private->de = NULL;
switch_mutex_lock(profile->flag_mutex);
if (sofia_private->de) {
qde = sofia_private->de;
sofia_private->de = NULL;
}
switch_mutex_unlock(profile->flag_mutex);
if (qde) {
if (event == nua_i_cancel) {
nua_destroy_event(qde->event);
su_free(nh->nh_home, qde);
} else {
sofia_process_dispatch_event(&qde);
}
}
if (sofia_private && (sofia_private->destroy_me == 12)) {
return;
}
profile->last_sip_event = switch_time_now();
/* sofia_private will be == &mod_sofia_globals.keep_private whenever a request is done with a new handle that has to be
@ -1532,51 +1525,22 @@ void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep)
void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
{
sofia_dispatch_event_t *de = *dep, *deq = NULL;
sofia_dispatch_event_t *de = *dep;
nua_handle_t *nh = de->nh;
nua_t *nua = de->nua;
sofia_profile_t *profile = de->profile;
sofia_private_t *sofia_private = nua_handle_magic(de->nh);
*dep = NULL;
our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
de->nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags);
de->nh, nua_handle_magic(de->nh), de->sip, de, (tagi_t *) de->data->e_tags);
nua_destroy_event(de->event);
su_free(nh->nh_home, de);
switch_mutex_lock(profile->flag_mutex);
profile->queued_events--;
if (sofia_private && sofia_private->is_call && sofia_private->deq) {
deq = sofia_private->deq;
sofia_private->deq = NULL;
}
switch_mutex_unlock(profile->flag_mutex);
if (deq) {
for (;;) {
switch_mutex_lock(profile->flag_mutex);
if ((de = deq)) {
deq = deq->next;
de->next = NULL;
}
switch_mutex_unlock(profile->flag_mutex);
if (!de) {
break;
}
our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
de->nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags);
nua_destroy_event(de->event);
su_free(nh->nh_home, de);
nua_handle_unref(nh);
nua_stack_unref(nua);
}
}
nua_handle_unref(nh);
nua_stack_unref(nua);
@ -1720,6 +1684,8 @@ void sofia_event_callback(nua_event_t event,
return;
}
switch_mutex_lock(profile->flag_mutex);
profile->queued_events++;
switch_mutex_unlock(profile->flag_mutex);
@ -1741,9 +1707,7 @@ void sofia_event_callback(nua_event_t event,
memset(sofia_private, 0, sizeof(*sofia_private));
sofia_private->is_call++;
sofia_private->is_static++;
switch_mutex_lock(profile->flag_mutex);
sofia_private->de = de;
switch_mutex_unlock(profile->flag_mutex);
nua_handle_bind(nh, sofia_private);
return;
}
@ -1751,23 +1715,7 @@ void sofia_event_callback(nua_event_t event,
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
switch_core_session_t *session;
if (zstr(sofia_private->uuid)) {
if (sofia_private->is_call && !sofia_private->de) {
sofia_dispatch_event_t *dep;
switch_mutex_lock(profile->flag_mutex);
if (!sofia_private->deq) {
sofia_private->deq = de;
} else {
for (dep = sofia_private->deq; dep && dep->next; dep = dep->next);
dep->next = de;
}
switch_mutex_unlock(profile->flag_mutex);
return;
}
} else {
if (!zstr(sofia_private->uuid)) {
if ((session = switch_core_session_locate(sofia_private->uuid))) {
if (switch_core_session_running(session)) {
switch_core_session_queue_signal_data(session, de);
@ -1784,7 +1732,7 @@ void sofia_event_callback(nua_event_t event,
}
}
}
sofia_queue_message(de);
switch_os_yield();
}
@ -6092,9 +6040,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
}
// if (sofia_private) {
//sofia_private->destroy_me = 1;
//}
if (sofia_private) {
sofia_private->destroy_me = 1;
}
}
if (session) {
@ -8065,7 +8013,6 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
profile->ib_calls++;
if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING)) {
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
goto fail;
@ -8270,8 +8217,14 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
goto fail;
}
tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t));
if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END());
switch_core_session_destroy(&session);
goto fail;
}
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
@ -9078,10 +9031,6 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
}
switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
if (switch_core_session_running(session) || switch_core_session_started(session)) {
return;
}
if (sip && switch_core_session_thread_launch(session) == SWITCH_STATUS_SUCCESS) {
const char *dialog_from_user = "", *dialog_from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = "";
const char *user_agent = "", *call_id = "";
@ -9170,7 +9119,6 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting NAT mode based on %s\n", is_nat);
switch_channel_set_variable(channel, "sip_nat_detected", "true");
}
return;
}
@ -9192,12 +9140,10 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
switch_mutex_unlock(tech_pvt->profile->flag_mutex);
}
if (!switch_core_session_running(session)) {
nua_handle_bind(nh, NULL);
sofia_private_free(sofia_private);
switch_core_session_destroy(&session);
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
}
nua_handle_bind(nh, NULL);
sofia_private_free(sofia_private);
switch_core_session_destroy(&session);
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
return;
fail:

View File

@ -1,7 +1,7 @@
<include>
<extension name="auth" continue="true">
<condition field="${radius_auth_result}" expression="^$">
<condition>
<action application="radius_auth" inline="true"/>
</condition>
</extension>
@ -18,10 +18,5 @@
</condition>
</extension>
<extension name="originate_leg" continue="true">
<condition>
<action application="export" data="nolocal:h323-call-origin=originate"/>
</condition>
</extension>
</include>

View File

@ -34,7 +34,6 @@
static struct {
switch_memory_pool_t *pool;
switch_xml_t auth_invite_configs;
switch_xml_t auth_reg_configs;
switch_xml_t auth_app_configs;
switch_xml_t acct_start_configs;
switch_xml_t acct_end_configs;
@ -150,42 +149,7 @@ switch_status_t do_config()
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_invite' section in config file.\n");
}
serv = timeout = deadtime = retries = dict = seq = 0;
if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_reg"))) != NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
for (param = switch_xml_child(server, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
if ( strncmp(var, "authserver", 10) == 0 ) {
serv = 1;
} else if ( strncmp(var, "radius_timeout", 14) == 0 ) {
timeout = 1;
} else if ( strncmp(var, "radius_deadtime", 15) == 0 ) {
deadtime = 1;
} else if ( strncmp(var, "radius_retries", 14) == 0 ) {
retries = 1;
} else if ( strncmp(var, "dictionary", 10) == 0 ) {
dict = 1;
} else if ( strncmp(var, "seqfile", 7) == 0 ) {
seq = 1;
}
}
if ( serv && timeout && deadtime && retries && dict && seq ) {
globals.auth_reg_configs = tmp;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing a require section for radius connections\n");
goto err;
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_invite\n");
goto err;
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_invite' section in config file.\n");
}
serv = timeout = deadtime = retries = dict = seq = 0;
if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_app"))) != NULL ) {
if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_app"))) == NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
for (param = switch_xml_child(server, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
@ -218,8 +182,7 @@ switch_status_t do_config()
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_app' section in config file.\n");
}
serv = timeout = deadtime = retries = dict = seq = 0;
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_start"))) != NULL ) {
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_start"))) == NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
for (param = switch_xml_child(server, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
@ -252,8 +215,7 @@ switch_status_t do_config()
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_start' section in config file.\n");
}
serv = timeout = deadtime = retries = dict = seq = 0;
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_end"))) != NULL ) {
if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_end"))) == NULL ) {
if ( (server = switch_xml_child(tmp, "connection")) != NULL) {
for (param = switch_xml_child(server, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
@ -319,11 +281,8 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
char *var = (char *) switch_xml_attr(param, "name");
char *vend = (char *) switch_xml_attr(param, "vendor");
char *variable = (char *) switch_xml_attr(param, "variable");
char *variable_secondary = (char *) switch_xml_attr(param, "variable_secondary");
char *val_default = (char *) switch_xml_attr(param, "default");
char *format = (char *) switch_xml_attr(param, "format");
char *other_leg = (char *) switch_xml_attr(param, "other_leg");
attribute = rc_dict_findattr(handle, var);
if ( attribute == NULL ) {
@ -416,36 +375,8 @@ switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch
}
} else {
if ( format == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing format attribute for %s variable\n", variable);
goto err;
}
if ( attribute->type == 0 ) {
const char *val = NULL;
if ( other_leg ) {
val = switch_channel_get_variable_partner(channel, variable);
if ( val == NULL && variable_secondary != NULL) {
val = switch_channel_get_variable_partner(channel, variable_secondary);
}
} else {
val = switch_channel_get_variable(channel, variable);
if ( val == NULL && variable_secondary != NULL) {
val = switch_channel_get_variable(channel, variable_secondary);
}
}
if ( val == NULL && val_default != NULL) {
av_value = switch_mprintf(format, val_default);
} else {
av_value = switch_mprintf(format, val);
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value);
}
av_value = switch_mprintf(format, switch_channel_get_variable(channel, variable));
if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option with val '%s' to handle\n", (char *) av_value);
goto err;
@ -556,10 +487,7 @@ switch_xml_t mod_xml_radius_auth_invite(switch_event_t *params) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting invite authentication\n");
}
if ( mod_xml_radius_new_handle(&new_handle, globals.auth_invite_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle\n");
goto err;
}
mod_xml_radius_new_handle(&new_handle, globals.auth_invite_configs);
if ( new_handle == NULL ) {
goto err;
@ -637,100 +565,6 @@ switch_xml_t mod_xml_radius_auth_invite(switch_event_t *params) {
return NULL;
}
switch_xml_t mod_xml_radius_auth_reg(switch_event_t *params) {
int result = 0, param_idx = 0;
VALUE_PAIR *send = NULL, *recv = NULL, *service_vp = NULL;
char msg[512 * 10 + 1] = {0};
uint32_t service = PW_AUTHENTICATE_ONLY;
rc_handle *new_handle = NULL;
switch_xml_t fields, xml, dir, dom, usr, vars, var;
char name[512], value[512], *strtmp;
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting registration authentication\n");
}
if ( mod_xml_radius_new_handle(&new_handle, globals.auth_invite_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle\n");
goto err;
}
if ( new_handle == NULL ) {
goto err;
}
if ((fields = switch_xml_child(globals.auth_reg_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto err;
}
if ( mod_xml_radius_add_params(NULL, params, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto err;
}
if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto err;
}
result = rc_auth(new_handle, 0, send, &recv, msg);
if ( GLOBAL_DEBUG ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg);
}
if ( result != 0 ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate\n");
goto err;
}
xml = switch_xml_new("document");
switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
dir = switch_xml_add_child_d(xml, "section", 0);
switch_xml_set_attr_d(dir, "name", "directory");
dom = switch_xml_add_child_d(dir, "domain", 0);
switch_xml_set_attr_d(dom, "name", switch_event_get_header(params, "domain"));
usr = switch_xml_add_child_d(dom, "user", 0);
vars = switch_xml_add_child_d(usr, "variables", 0);
switch_xml_set_attr_d(usr, "id", switch_event_get_header(params, "user"));
service_vp = recv;
while (service_vp != NULL) {
rc_avpair_tostr(new_handle, service_vp, name, 512, value, 512);
if ( GLOBAL_DEBUG )
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\tattribute (%s)[%s] found in radius packet\n", name, value);
var = switch_xml_add_child_d(vars, "variable", param_idx++);
strtmp = strdup(name);
switch_xml_set_attr_d(var, "name", strtmp);
free(strtmp);
strtmp = strdup(value);
switch_xml_set_attr_d(var, "value", strtmp);
free(strtmp);
service_vp = service_vp->next;
}
if ( GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML: %s \n", switch_xml_toxml(xml, 1));
}
rc_avpair_free(recv);
rc_destroy(new_handle);
return xml;
err:
if ( recv ) {
rc_avpair_free(recv);
recv = NULL;
}
if ( new_handle ) {
rc_destroy(new_handle);
new_handle = NULL;
}
return NULL;
}
static switch_xml_t mod_xml_radius_directory_search(const char *section, const char *tag_name, const char *key_name, const char *key_value,
switch_event_t *params, void *user_data)
{
@ -750,11 +584,9 @@ static switch_xml_t mod_xml_radius_directory_search(const char *section, const c
if ( auth_method == NULL) {
return NULL;
}
if ( strncmp( "INVITE", auth_method, 6) == 0) {
xml = mod_xml_radius_auth_invite(params);
} else if ( strncmp( "REGISTER", auth_method, 8) == 0) {
xml = mod_xml_radius_auth_reg(params);
} else {
xml = NULL;
}
@ -790,7 +622,6 @@ switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switc
}
if ( switch_regex_match( switch_channel_get_variable(channel, channel_var), regex) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Didn't match: %s == %s \n", switch_channel_get_variable(channel, channel_var), regex);
all_matched = 0;
}
}
@ -812,7 +643,6 @@ switch_status_t mod_xml_radius_accounting_start(switch_core_session_t *session){
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting accounting start\n");
switch_core_session_execute_application(session, "info", NULL);
}
/* If there are conditions defined, and none of them pass, then skip this accounting */
@ -821,10 +651,7 @@ switch_status_t mod_xml_radius_accounting_start(switch_core_session_t *session){
goto end;
}
if ( mod_xml_radius_new_handle(&new_handle, globals.acct_start_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle\n");
goto end;
}
mod_xml_radius_new_handle(&new_handle, globals.acct_start_configs);
if ((fields = switch_xml_child(globals.acct_start_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
@ -873,10 +700,7 @@ switch_status_t mod_xml_radius_accounting_end(switch_core_session_t *session){
goto end;
}
if ( mod_xml_radius_new_handle(&new_handle, globals.acct_end_configs) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle\n");
goto end;
}
mod_xml_radius_new_handle(&new_handle, globals.acct_end_configs);
if ((fields = switch_xml_child(globals.acct_end_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
@ -900,10 +724,8 @@ switch_status_t mod_xml_radius_accounting_end(switch_core_session_t *session){
}
end:
if ( new_handle) {
rc_destroy(new_handle);
}
rc_destroy(new_handle);
return SWITCH_STATUS_SUCCESS;
}

View File

@ -22,48 +22,10 @@
<param vendor="Cisco" name="Cisco-AVPair" variable="ip" format="src-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" format="src-gw-name=%s"/>
<param vendor="Cisco" name="h323-conf-id" variable="Core-UUID" format="%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="ip" format="number"/>
<param name="Called-Station-Id" variable="sip_to_user" format="%s"/>
<param name="Calling-Station-Id" variable="sip_from_user" format="%s"/>
<param name="User-Name" variable="sip_from_user" format="%s"/>
<param name="Digest-Response" variable="sip_auth_response" format="%s"/>
<param name="Digest-Realm" variable="sip_auth_realm" format="%s"/>
<param name="Digest-Nonce" variable="sip_auth_nonce" format="%s"/>
<param name="Digest-Username" variable="sip_auth_username" format="%s"/>
<param name="Digest-URI" variable="sip_auth_uri" format="%s"/>
<param name="Digest-Method" variable="sip_auth_method" format="%s"/>
<param name="Digest-Algorithm" variable="sip_auth_method" format="MD5"/>
<param name="Digest-Qop" variable="sip_auth_qop" format="%s"/>
<param name="Digest-CNonce" variable="sip_auth_cnonce" format="%s"/>
<param name="Digest-Nonce-Count" variable="sip_auth_nc" format="%s"/>
</fields>
</auth_invite>
<auth_reg>
<connection name="testing">
<param name="authserver" value="127.0.0.1:1812:testing123"/>
<param name="radius_timeout" value="10"/>
<param name="radius_retries" value="2"/>
<param name="radius_deadtime" value="0"/>
<param name="dictionary" value="/usr/local/src/freeswitch/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary"/>
<param name="seqfile" value="/var/run/radius.seq"/>
</connection>
<fields>
<param vendor="Cisco" name="Cisco-AVPair" variable="ip" format="user"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="ip" format="src-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" format="src-gw-name=%s"/>
<param name="User-Name" variable="sip_from_user" format="%s"/>
<param name="Digest-Response" variable="sip_auth_response" format="%s"/>
<param name="Digest-Realm" variable="sip_auth_realm" format="%s"/>
<param name="Digest-Nonce" variable="sip_auth_nonce" format="%s"/>
<param name="Digest-Username" variable="sip_auth_username" format="%s"/>
<param name="Digest-URI" variable="sip_auth_uri" format="%s"/>
<param name="Digest-Method" variable="sip_auth_method" format="%s"/>
<param name="Digest-Algorithm" variable="sip_auth_method" format="MD5"/>
<param name="Digest-Qop" variable="sip_auth_qop" format="%s"/>
<param name="Digest-CNonce" variable="sip_auth_cnonce" format="%s"/>
<param name="Digest-Nonce-Count" variable="sip_auth_nc" format="%s"/>
</fields>
</auth_reg>
<auth_app>
<connection name="testing">
<param name="authserver" value="127.0.0.1:1812:testing123"/>
@ -74,7 +36,7 @@
<param name="seqfile" value="/var/run/radius.seq"/>
</connection>
<fields>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_host" format="src-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_network_ip" format="src-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" format="src-gw-name=%s"/>
<param vendor="Cisco" name="h323-conf-id" variable="Core-UUID" format="%s"/>
<param name="Called-Station-Id" variable="sip_to_user" format="%s"/>
@ -105,19 +67,18 @@
<fields>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_host" format="src-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" format="src-gw-name=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="h323-conf-id" variable_secondary="uuid" variable="originating_leg_uuid" format="%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="h323-conf-id" variable="uuid" format="%s"/>
<param vendor="Cisco" name="h323-setup-time"/>
<param vendor="Cisco" name="h323-connect-time"/>
<param vendor="Cisco" name="h323-call-origin" variable="h323-call-origin" default="answer" format="%s"/>
<param name="Called-Station-Id" variable="sip_to_user" format="%s"/>
<param name="Calling-Station-Id" variable="sip_from_user" format="%s"/>
</fields>
<!-- <conditions>
<conditions>
<condition>
<param var="direction" regex="^outbound$"/>
</condition>
</conditions> -->
<param var="direction" regex="inbound"/>
</condition>
</conditions>
</acct_start>
<acct_end>
<connection name="testing">
@ -131,23 +92,22 @@
<fields>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_host" format="src-gw-ip=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" format="src-gw-name=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="h323-conf-id" variable_secondary="uuid" variable="originating_leg_uuid" format="%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_host" format="dst-gw-ip=%s"/>
<param vendor="Cisco" name="h323-conf-id" variable="uuid" format="%s"/>
<param vendor="Cisco" name="h323-setup-time"/>
<param vendor="Cisco" name="h323-connect-time"/>
<param vendor="Cisco" name="h323-disconnect-time"/>
<param vendor="Cisco" name="h323-disconnect-cause"/>
<param vendor="Cisco" name="h323-call-origin" variable="h323-call-origin" format="%s" default="answer"/>
<param name="Called-Station-Id" variable="sip_to_user" format="%s"/>
<param name="Acct-Session-Time" variable="billsec" format="%s"/>
<param name="Calling-Station-Id" variable="sip_from_user" format="%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_from_user" format="src-number-out=%s"/>
<param vendor="Cisco" name="Cisco-AVPair" variable="sip_to_user" format="dst-number-out=%s"/>
</fields>
<!-- <conditions>
<conditions>
<condition>
<param var="direction" regex="^outbound$"/>
</condition>
</conditions> -->
<param var="direction" regex="inbound"/>
</condition>
</conditions>
</acct_end>
</configuration>

View File

@ -576,15 +576,10 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel)
while (switch_queue_trypop(channel->dtmf_log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
switch_safe_free(pop);
}
if (channel->private_hash) {
switch_core_hash_destroy(&channel->private_hash);
}
switch_core_hash_destroy(&channel->private_hash);
if (channel->app_flag_hash) {
switch_core_hash_destroy(&channel->app_flag_hash);
}
switch_mutex_lock(channel->profile_mutex);
switch_event_destroy(&channel->variables);
switch_event_destroy(&channel->api_list);

View File

@ -80,8 +80,8 @@ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(switch_core_session_t *
#ifdef DEBUG_ALLOC
if (memory > 500)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Session Allocate %s %d\n",
(void *) session->pool, (void *) session, apr_pool_tag(session->pool, NULL), (int) memory);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Session Allocate %s %d\n",
apr_pool_tag(session->pool, NULL), (int) memory);
#endif
ptr = apr_palloc(session->pool, memory);
@ -113,8 +113,8 @@ SWITCH_DECLARE(void *) switch_core_perform_permanent_alloc(switch_size_t memory,
#endif
#ifdef DEBUG_ALLOC
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Perm Allocate %s %d\n",
(void *)memory_manager.memory_pool, apr_pool_tag(memory_manager.memory_pool, NULL), (int) memory);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Perm Allocate %s %d\n",
apr_pool_tag(memory_manager.memory_pool, NULL), (int) memory);
#endif
ptr = apr_palloc(memory_manager.memory_pool, memory);
@ -155,8 +155,8 @@ SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(const char *todup, c
switch_assert(duped != NULL);
#ifdef DEBUG_ALLOC
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Perm Allocate %s %d\n",
(void *) memory_manager.memory_pool, apr_pool_tag(memory_manager.memory_pool, NULL), (int) len);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Perm Allocate %s %d\n",
apr_pool_tag(memory_manager.memory_pool, NULL), (int) len);
#endif
#ifdef LOCK_MORE
@ -248,8 +248,8 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
#ifdef DEBUG_ALLOC
len = strlen(todup);
if (len > 500)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p %p Sess Strdup Allocate %s %ld\n",
(void *) session->pool, (void *)session, apr_pool_tag(session->pool, NULL), strlen(todup));
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Sess Strdup Allocate %s %ld\n",
apr_pool_tag(session->pool, NULL), strlen(todup));
#endif
duped = apr_pstrdup(session->pool, todup);
@ -287,8 +287,8 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
#ifdef DEBUG_ALLOC
if (len > 500)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Strdup Allocate %s %d\n",
(void *) pool, apr_pool_tag(pool, NULL), (int)len);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Core Strdup Allocate %s %d\n",
apr_pool_tag(pool, NULL), (int)len);
#endif
duped = apr_pstrmemdup(pool, todup, len);
@ -400,7 +400,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_new_memory_pool(switch_memor
apr_pool_tag(*pool, tmp);
#ifdef DEBUG_ALLOC2
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p New Pool %s\n", (void *) *pool, apr_pool_tag(*pool, NULL));
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "New Pool %s\n", apr_pool_tag(*pool, NULL));
#endif
@ -416,7 +416,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_destroy_memory_pool(switch_m
switch_assert(pool != NULL);
#ifdef DEBUG_ALLOC2
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Free Pool %s\n", (void *) *pool, apr_pool_tag(*pool, NULL));
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Free Pool %s\n", apr_pool_tag(*pool, NULL));
#endif
#ifdef INSTANTLY_DESTROY_POOLS
@ -458,8 +458,8 @@ SWITCH_DECLARE(void *) switch_core_perform_alloc(switch_memory_pool_t *pool, swi
#ifdef DEBUG_ALLOC
if (memory > 500)
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Allocate %s %d\n",
(void *) pool, apr_pool_tag(pool, NULL), (int) memory);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Core Allocate %s %d\n",
apr_pool_tag(pool, NULL), (int) memory);
/*switch_assert(memory < 20000); */
#endif
@ -525,26 +525,16 @@ static void *SWITCH_THREAD_FUNC pool_thread(switch_thread_t *thread, void *obj)
#ifdef USE_MEM_LOCK
switch_mutex_lock(memory_manager.mem_lock);
#endif
#ifdef DEBUG_ALLOC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
#endif
apr_pool_destroy(pop);
#ifdef USE_MEM_LOCK
switch_mutex_unlock(memory_manager.mem_lock);
#endif
#else
apr_pool_mutex_set(pop, NULL);
#ifdef DEBUG_ALLOC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
#endif
apr_pool_clear(pop);
if (switch_queue_trypush(memory_manager.pool_recycle_queue, pop) != SWITCH_STATUS_SUCCESS) {
#ifdef USE_MEM_LOCK
switch_mutex_lock(memory_manager.mem_lock);
#endif
#ifdef DEBUG_ALLOC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%p DESTROY POOL\n", (void *) pop);
#endif
apr_pool_destroy(pop);
#ifdef USE_MEM_LOCK

View File

@ -1260,11 +1260,6 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t *
switch_endpoint_interface_t *endpoint_interface = (*session)->endpoint_interface;
int i;
if (switch_core_session_running(*session) && !switch_test_flag((*session), SSF_DESTROYABLE)) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(*session), SWITCH_LOG_ERROR,
"Cowardly ignoring an attempt to call destroy on a running session.\n");
}
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(*session), SWITCH_LOG_NOTICE, "Close Channel %s [%s]\n",
switch_channel_get_name((*session)->channel), switch_channel_state_name(switch_channel_get_state((*session)->channel)));
@ -1445,8 +1440,6 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thre
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Session %" SWITCH_SIZE_T_FMT " (%s) Ended\n",
session->id, switch_channel_get_name(session->channel));
switch_set_flag(session, SSF_DESTROYABLE);
switch_core_session_destroy(&session);
return NULL;
}
@ -1461,7 +1454,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_se
switch_threadattr_detach_set(thd_attr, 1);
if (switch_test_flag(session, SSF_THREAD_RUNNING) || switch_test_flag(session, SSF_THREAD_STARTED)) {
status = SWITCH_STATUS_INUSE;
goto end;
}

View File

@ -336,7 +336,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
const switch_state_handler_table_t *driver_state_handler = NULL;
const switch_state_handler_table_t *application_state_handler = NULL;
int silly = 0;
uint32_t new_loops = 5000;
uint32_t new_loops = 60000;
/*
Life of the channel. you have channel and pool in your session

View File

@ -761,7 +761,7 @@ static switch_status_t uuid_bridge_on_hibernate(switch_core_session_t *session)
static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_core_session_t *other_session;
switch_core_session_t *other_session = NULL;
const char *other_uuid = NULL;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CUSTOM SOFT_EXECUTE\n", switch_channel_get_name(channel));
@ -818,7 +818,6 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
if (switch_ivr_wait_for_answer(session, other_session) != SWITCH_STATUS_SUCCESS) {
switch_core_session_rwunlock(other_session);
if (switch_true(switch_channel_get_variable(channel, "uuid_bridge_continue_on_cancel"))) {
switch_channel_set_state(channel, CS_EXECUTE);
} else if (!switch_channel_test_flag(channel, CF_TRANSFER)) {
@ -843,7 +842,6 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
}
switch_core_session_rwunlock(other_session);
goto done;
}
@ -869,13 +867,17 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
!switch_channel_test_flag(channel, CF_REDIRECT) && state < CS_HANGUP && state != CS_ROUTING && state != CS_PARK) {
switch_channel_set_state(channel, CS_EXECUTE);
}
switch_core_session_rwunlock(other_session);
} else {
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
done:
if (other_session) {
switch_core_session_rwunlock(other_session);
other_session = NULL;
}
switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR);
return SWITCH_STATUS_FALSE;