move sig callback pointer to the span so it can be called from a function

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@1015 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale 2010-02-01 18:16:13 +00:00
parent f1140c352d
commit 000b7e78b2
14 changed files with 87 additions and 62 deletions

View File

@ -846,7 +846,6 @@ static switch_status_t channel_receive_message_b(switch_core_session_t *session,
return SWITCH_STATUS_FALSE;
}
zap_mutex_lock(tech_pvt->zchan->mutex);
if (tech_pvt->zchan->state == ZAP_CHANNEL_STATE_TERMINATING) {
zap_mutex_unlock(tech_pvt->zchan->mutex);
return SWITCH_STATUS_SUCCESS;
@ -902,7 +901,6 @@ static switch_status_t channel_receive_message_b(switch_core_session_t *session,
break;
}
zap_mutex_unlock(tech_pvt->zchan->mutex);
return SWITCH_STATUS_SUCCESS;
}
@ -992,12 +990,26 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
switch_status_t status;
switch_channel_t *channel;
const char *var;
zap_channel_t *zchan = NULL;
tech_pvt = (private_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
channel = switch_core_session_get_channel(session);
if (!(zchan = tech_pvt->zchan)) {
switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE);
return SWITCH_STATUS_FALSE;
}
zap_mutex_lock(zchan->mutex);
if (!tech_pvt->zchan) {
switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE);
status = SWITCH_STATUS_FALSE;
goto end;
}
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_PROGRESS:
case SWITCH_MESSAGE_INDICATE_ANSWER:
@ -1038,6 +1050,10 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
break;
}
end:
zap_mutex_unlock(zchan->mutex);
return status;
}

View File

@ -567,6 +567,7 @@ struct zap_span {
zap_analog_start_type_t start_type;
zap_signal_type_t signal_type;
void *signal_data;
zio_signal_cb_t signal_cb;
zap_event_t event_header;
char last_error[256];
char tone_map[ZAP_TONEMAP_INVALID+1][ZAP_TONEMAP_LEN];
@ -692,6 +693,7 @@ OZ_DECLARE(zap_status_t) zap_unload_modules(void);
OZ_DECLARE(zap_status_t) zap_configure_span(const char *type, zap_span_t *span, zio_signal_cb_t sig_cb, ...);
OZ_DECLARE(zap_status_t) zap_span_start(zap_span_t *span);
OZ_DECLARE(zap_status_t) zap_span_stop(zap_span_t *span);
OZ_DECLARE(zap_status_t) zap_span_send_signal(zap_span_t *span, zap_sigmsg_t *sigmsg);
OZ_DECLARE(int) zap_load_module(const char *name);
OZ_DECLARE(int) zap_load_module_assume(const char *name);
OZ_DECLARE(zap_status_t) zap_span_find_by_name(const char *name, zap_span_t **span);

View File

@ -176,7 +176,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_configure_span)
analog_data->flags = flags;
analog_data->digit_timeout = digit_timeout;
analog_data->max_dialstr = max_dialstr;
analog_data->sig_cb = sig_cb;
span->signal_cb = sig_cb;
strncpy(analog_data->hotline, hotline, sizeof(analog_data->hotline));
span->signal_type = ZAP_SIGTYPE_ANALOG;
span->signal_data = analog_data;
@ -481,7 +481,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
sig.event_id = ZAP_SIGEVENT_UP;
}
analog_data->sig_cb(&sig);
zap_span_send_signal(zchan->span, &sig);
continue;
}
break;
@ -501,14 +501,14 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
zap_set_string(zchan->caller_data.dnis.digits, dtmf);
}
analog_data->sig_cb(&sig);
zap_span_send_signal(zchan->span, &sig);
continue;
}
break;
case ZAP_CHANNEL_STATE_DOWN:
{
sig.event_id = ZAP_SIGEVENT_STOP;
analog_data->sig_cb(&sig);
zap_span_send_signal(zchan->span, &sig);
goto done;
}
break;
@ -549,7 +549,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
sig.span_id = zchan->span_id;
sig.channel = zchan;
sig.event_id = ZAP_SIGEVENT_PROGRESS;
analog_data->sig_cb(&sig);
zap_span_send_signal(zchan->span, &sig);
}
break;
@ -608,7 +608,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
last_digit = elapsed;
sig.event_id = ZAP_SIGEVENT_COLLECTED_DIGIT;
sig.raw_data = dtmf;
if (analog_data->sig_cb(&sig) == ZAP_BREAK) {
if (zap_span_send_signal(zchan->span, &sig) == ZAP_BREAK) {
collecting = 0;
}
}
@ -654,9 +654,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
if (zchan->detected_tones[i]) {
zap_log(ZAP_LOG_DEBUG, "Detected tone %s on %d:%d\n", zap_tonemap2str(i), zchan->span_id, zchan->chan_id);
sig.raw_data = &i;
if (analog_data->sig_cb) {
analog_data->sig_cb(&sig);
}
zap_span_send_signal(zchan->span, &sig);
}
}
@ -843,7 +841,7 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_UP);
} else {
sig.event_id = ZAP_SIGEVENT_FLASH;
analog_data->sig_cb(&sig);
zap_span_send_signal(span, &sig);
}
}
break;

View File

@ -48,7 +48,6 @@ struct zap_analog_data {
uint32_t max_dialstr;
uint32_t digit_timeout;
char hotline[ZAP_MAX_HOTLINE_STR];
zio_signal_cb_t sig_cb;
};

View File

@ -145,7 +145,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_analog_em_configure_span)
span->start = zap_analog_em_start;
analog_data->digit_timeout = digit_timeout;
analog_data->max_dialstr = max_dialstr;
analog_data->sig_cb = sig_cb;
span->signal_cb = sig_cb;
span->signal_type = ZAP_SIGTYPE_ANALOG;
span->signal_data = analog_data;
span->outgoing_call = analog_em_outgoing_call;
@ -349,7 +349,7 @@ static void *zap_analog_em_channel_run(zap_thread_t *me, void *obj)
sig.event_id = ZAP_SIGEVENT_UP;
analog_data->sig_cb(&sig);
zap_span_send_signal(zchan->span, &sig);
continue;
}
break;
@ -370,14 +370,14 @@ static void *zap_analog_em_channel_run(zap_thread_t *me, void *obj)
sig.event_id = ZAP_SIGEVENT_START;
analog_data->sig_cb(&sig);
zap_span_send_signal(zchan->span, &sig);
continue;
}
break;
case ZAP_CHANNEL_STATE_DOWN:
{
sig.event_id = ZAP_SIGEVENT_STOP;
analog_data->sig_cb(&sig);
zap_span_send_signal(zchan->span, &sig);
goto done;
}
break;
@ -440,7 +440,7 @@ static void *zap_analog_em_channel_run(zap_thread_t *me, void *obj)
last_digit = elapsed;
sig.event_id = ZAP_SIGEVENT_COLLECTED_DIGIT;
sig.raw_data = dtmf;
if (analog_data->sig_cb(&sig) == ZAP_BREAK) {
if (zap_span_send_signal(zchan->span, &sig) == ZAP_BREAK) {
collecting = 0;
}
}
@ -480,9 +480,7 @@ static void *zap_analog_em_channel_run(zap_thread_t *me, void *obj)
if (zchan->detected_tones[i]) {
zap_log(ZAP_LOG_DEBUG, "Detected tone %s on %d:%d\n", zap_tonemap2str(i), zchan->span_id, zchan->chan_id);
sig.raw_data = &i;
if (analog_data->sig_cb) {
analog_data->sig_cb(&sig);
}
zap_span_send_signal(zchan->span, &sig);
}
}

View File

@ -51,7 +51,6 @@ struct zap_analog_data {
uint32_t flags;
uint32_t max_dialstr;
uint32_t digit_timeout;
zio_signal_cb_t sig_cb;
};
static void *zap_analog_em_run(zap_thread_t *me, void *obj);

View File

@ -699,7 +699,7 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen)
sig.channel->caller_data.hangup_cause = (cause) ? cause->Value : ZAP_CAUSE_NORMAL_UNSPECIFIED;
sig.event_id = ZAP_SIGEVENT_STOP;
status = isdn_data->sig_cb(&sig);
status = zap_span_send_signal(zchan->span, &sig);
zap_log(ZAP_LOG_DEBUG, "Received %s in state %s, requested hangup for channel %d:%d\n", what, zap_channel_state2str(zchan->state), zchan->span_id, chan_id);
}
@ -1186,7 +1186,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_PROGRESS;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else {
@ -1230,7 +1230,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (!zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_START;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
}
@ -1240,7 +1240,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
zchan->caller_data.hangup_cause = ZAP_CAUSE_NORMAL_UNSPECIFIED;
sig.event_id = ZAP_SIGEVENT_RESTART;
status = isdn_data->sig_cb(&sig);
status = zap_span_send_signal(zchan->span, &sig);
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
}
break;
@ -1248,7 +1248,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_PROGRESS_MEDIA;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else {
@ -1268,7 +1268,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_UP;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else {
@ -1473,7 +1473,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
zap_log(ZAP_LOG_DEBUG, "Terminating: Direction %s\n", zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND) ? "Outbound" : "Inbound");
sig.event_id = ZAP_SIGEVENT_STOP;
status = isdn_data->sig_cb(&sig);
status = zap_span_send_signal(zchan->span, &sig);
gen->MesType = Q931mes_RELEASE;
gen->CRVFlag = zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND) ? 0 : 1;
Q931Rx43(&isdn_data->q931, (void *)gen, gen->Size);
@ -1513,7 +1513,6 @@ static __inline__ void check_state(zap_span_t *span)
static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *event)
{
zap_sigmsg_t sig;
zap_isdn_data_t *isdn_data = span->signal_data;
memset(&sig, 0, sizeof(sig));
sig.chan_id = event->channel->chan_id;
@ -1538,7 +1537,7 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
zap_channel_get_alarms(event->channel);
isdn_data->sig_cb(&sig);
zap_span_send_signal(span, &sig);
zap_log(ZAP_LOG_WARNING, "channel %d:%d (%d:%d) has alarms! [%s]\n",
event->channel->span_id, event->channel->chan_id,
event->channel->physical_span_id, event->channel->physical_chan_id,
@ -1554,7 +1553,7 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
sig.event_id = ZAP_OOB_ALARM_CLEAR;
zap_clear_flag(event->channel, ZAP_CHANNEL_SUSPENDED);
zap_channel_get_alarms(event->channel);
isdn_data->sig_cb(&sig);
zap_span_send_signal(span, &sig);
}
break;
}
@ -2355,7 +2354,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_isdn_configure_span)
span->start = zap_isdn_start;
span->stop = zap_isdn_stop;
isdn_data->sig_cb = sig_cb;
span->signal_cb = sig_cb;
isdn_data->dchans[0] = dchans[0];
isdn_data->dchans[1] = dchans[1];
isdn_data->dchan = isdn_data->dchans[0];

View File

@ -60,7 +60,6 @@ struct zap_isdn_data {
zap_channel_t *dchan;
zap_channel_t *dchans[2];
struct zap_sigmsg sigmsg;
zio_signal_cb_t sig_cb;
uint32_t flags;
int32_t mode;
int32_t digit_timeout;

View File

@ -454,7 +454,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_PROGRESS;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else if (call) {
@ -468,7 +468,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_PROGRESS_MEDIA;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else if (call) {
@ -484,7 +484,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
if (call) {
pri_acknowledge(isdn_data->spri.pri, call, zchan->chan_id, 0);
sig.event_id = ZAP_SIGEVENT_START;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else {
@ -497,7 +497,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
zchan->caller_data.hangup_cause = ZAP_CAUSE_NORMAL_UNSPECIFIED;
sig.event_id = ZAP_SIGEVENT_RESTART;
status = isdn_data->sig_cb(&sig);
status = zap_span_send_signal(zchan->span, &sig);
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
}
break;
@ -505,7 +505,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_UP;
if ((status = isdn_data->sig_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else if (call) {
@ -579,7 +579,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
case ZAP_CHANNEL_STATE_TERMINATING:
{
sig.event_id = ZAP_SIGEVENT_STOP;
status = isdn_data->sig_cb(&sig);
status = zap_span_send_signal(zchan->span, &sig);
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
}
@ -807,7 +807,6 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event
static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *event)
{
zap_sigmsg_t sig;
zap_libpri_data_t *isdn_data = span->signal_data;
memset(&sig, 0, sizeof(sig));
sig.chan_id = event->channel->chan_id;
@ -832,7 +831,7 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
zap_channel_get_alarms(event->channel);
isdn_data->sig_cb(&sig);
zap_span_send_signal(span, &sig);
zap_log(ZAP_LOG_WARNING, "channel %d:%d (%d:%d) has alarms! [%s]\n",
event->channel->span_id, event->channel->chan_id,
event->channel->physical_span_id, event->channel->physical_chan_id,
@ -848,7 +847,7 @@ static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *even
sig.event_id = ZAP_OOB_ALARM_CLEAR;
zap_clear_flag(event->channel, ZAP_CHANNEL_SUSPENDED);
zap_channel_get_alarms(event->channel);
isdn_data->sig_cb(&sig);
zap_span_send_signal(span, &sig);
}
break;
}
@ -1329,7 +1328,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_libpri_configure_span)
span->start = zap_libpri_start;
span->stop = zap_libpri_stop;
isdn_data->sig_cb = sig_cb;
span->signal_cb = sig_cb;
//isdn_data->dchans[0] = dchans[0];
//isdn_data->dchans[1] = dchans[1];
//isdn_data->dchan = isdn_data->dchans[0];

View File

@ -55,7 +55,6 @@ struct zap_libpri_data {
zap_channel_t *dchan;
zap_channel_t *dchans[2];
struct zap_sigmsg sigmsg;
zio_signal_cb_t sig_cb;
uint32_t flags;
int32_t mode;
zap_isdn_opts_t opts;

View File

@ -91,8 +91,6 @@ typedef struct oz_r2_conf_s {
/* r2 configuration stored in span->signal_data */
typedef struct zap_r2_data_s {
/* signaling callback */
zio_signal_cb_t sig_cb;
/* span flags */
zap_r2_flag_t flags;
/* openr2 handle for the R2 variant context */
@ -254,7 +252,7 @@ static void zap_r2_on_call_offered(openr2_chan_t *r2chan, const char *ani, const
sigev.channel = zchan;
sigev.event_id = ZAP_SIGEVENT_START;
if (r2data->sig_cb(&sigev) != ZAP_SUCCESS) {
if (zap_span_send_signal(zchan->span, &sigev) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_NOTICE, "Failed to handle call offered on chan %d\n", openr2_chan_get_number(r2chan));
openr2_chan_disconnect_call(r2chan, OR2_CAUSE_OUT_OF_ORDER);
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_CANCEL);
@ -324,7 +322,7 @@ static void zap_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disconn
sigev.event_id = ZAP_SIGEVENT_STOP;
r2data = zchan->span->signal_data;
r2data->sig_cb(&sigev);
zap_span_send_signal(zchan->span, &sigev);
}
static void zap_r2_on_call_end(openr2_chan_t *r2chan)
@ -378,7 +376,7 @@ static void zap_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_erro
sigev.event_id = ZAP_SIGEVENT_STOP;
r2data = zchan->span->signal_data;
r2data->sig_cb(&sigev);
zap_span_send_signal(zchan->span, &sigev);
}
static void zap_r2_on_line_blocked(openr2_chan_t *r2chan)
@ -461,7 +459,7 @@ static int zap_r2_on_dnis_digit_received(openr2_chan_t *r2chan, char digit)
sigev.channel = zchan;
sigev.event_id = ZAP_SIGEVENT_COLLECTED_DIGIT;
r2data = zchan->span->signal_data;
if (r2data->sig_cb(&sigev) == ZAP_BREAK) {
if (zap_span_send_signal(zchan->span, &sigev) == ZAP_BREAK) {
zap_log(ZAP_LOG_NOTICE, "Requested to stop getting DNIS. Current DNIS = %s on chan %d\n", zchan->caller_data.dnis.digits, openr2_chan_get_number(r2chan));
return OR2_STOP_DNIS_REQUEST;
}
@ -885,7 +883,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_r2_configure_span)
span->start = zap_r2_start;
r2data->flags = 0;
r2data->sig_cb = sig_cb;
span->signal_cb = sig_cb;
span->signal_type = ZAP_SIGTYPE_R2;
span->signal_data = r2data;
span->outgoing_call = r2_outgoing_call;
@ -1005,7 +1003,7 @@ static void *zap_r2_channel_run(zap_thread_t *me, void *obj)
} else {
zap_log(ZAP_LOG_DEBUG, "PROGRESS: Notifying progress in channel %d\n", zchan->physical_chan_id);
sigev.event_id = ZAP_SIGEVENT_PROGRESS;
if (r2data->sig_cb(&sigev) != ZAP_SUCCESS) {
if (zap_span_send_signal(zchan->span, &sigev) != ZAP_SUCCESS) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
}
@ -1028,7 +1026,7 @@ static void *zap_r2_channel_run(zap_thread_t *me, void *obj)
} else {
zap_log(ZAP_LOG_DEBUG, "UP: Notifying of call answered in channel %d\n", zchan->physical_chan_id);
sigev.event_id = ZAP_SIGEVENT_UP;
if (r2data->sig_cb(&sigev) != ZAP_SUCCESS) {
if (zap_span_send_signal(zchan->span, &sigev) != ZAP_SUCCESS) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
}

View File

@ -996,7 +996,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_PROGRESS_MEDIA;
if ((status = sangoma_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else {
@ -1017,7 +1017,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_PROGRESS;
if ((status = sangoma_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else {
@ -1042,7 +1042,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (!zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_START;
if ((status = sangoma_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
}
@ -1051,7 +1051,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
case ZAP_CHANNEL_STATE_RESTART:
{
sig.event_id = ZAP_SIGEVENT_RESTART;
status = sangoma_boost_data->signal_cb(&sig);
status = zap_span_send_signal(zchan->span, &sig);
zap_set_sflag_locked(zchan, SFLAG_SENT_FINAL_MSG);
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
}
@ -1060,7 +1060,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
if (zap_test_flag(zchan, ZAP_CHANNEL_OUTBOUND)) {
sig.event_id = ZAP_SIGEVENT_UP;
if ((status = sangoma_boost_data->signal_cb(&sig) != ZAP_SUCCESS)) {
if ((status = zap_span_send_signal(zchan->span, &sig) != ZAP_SUCCESS)) {
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
}
} else {
@ -1125,7 +1125,7 @@ static __inline__ void state_advance(zap_channel_t *zchan)
{
zap_set_sflag_locked(zchan, SFLAG_TERMINATING);
sig.event_id = ZAP_SIGEVENT_STOP;
status = sangoma_boost_data->signal_cb(&sig);
status = zap_span_send_signal(zchan->span, &sig);
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP_COMPLETE);
}
break;
@ -1593,7 +1593,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_sangoma_boost_configure_span)
sangoma_boost_data->mcon.cfg.local_port = local_port;
zap_set_string(sangoma_boost_data->mcon.cfg.remote_ip, remote_ip);
sangoma_boost_data->mcon.cfg.remote_port = remote_port;
sangoma_boost_data->signal_cb = sig_cb;
span->signal_cb = sig_cb;
span->start = zap_sangoma_boost_start;
span->signal_data = sangoma_boost_data;
span->signal_type = ZAP_SIGTYPE_SANGOMABOOST;

View File

@ -44,7 +44,6 @@ typedef enum {
typedef struct zap_sangoma_boost_data {
sangomabc_connection_t mcon;
sangomabc_connection_t pcon;
zio_signal_cb_t signal_cb;
uint32_t flags;
} zap_sangoma_boost_data_t;

View File

@ -2735,6 +2735,26 @@ OZ_DECLARE(zap_status_t) zap_span_start(zap_span_t *span)
return ZAP_FAIL;
}
OZ_DECLARE(zap_status_t) zap_span_send_signal(zap_span_t *span, zap_sigmsg_t *sigmsg)
{
zap_status_t status = ZAP_FAIL;
if (span->signal_cb) {
if (sigmsg->channel) {
zap_mutex_lock(sigmsg->channel->mutex);
}
status = span->signal_cb(sigmsg);
if (sigmsg->channel) {
zap_mutex_unlock(sigmsg->channel->mutex);
}
}
return status;
}
OZ_DECLARE(zap_status_t) zap_global_init(void)
{