From 6cbf8a0167d9a3d79ff3846e14bc90dbf4fe7371 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 10 Nov 2010 19:03:15 -0500 Subject: [PATCH 01/55] freetdm: ISDN - Changes to used ftdm IO for d-channel --- .../freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c | 1 - .../ftmod_sangoma_boost/ftmod_sangoma_boost.c | 8 +- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 168 ++++++++++++++---- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 51 +++--- .../ftmod_sangoma_isdn_cfg.c | 33 ++-- .../ftmod_sangoma_isdn_stack_cfg.c | 107 +++++------ .../ftmod_sangoma_isdn_stack_cntrl.c | 83 ++++++--- .../ftmod_sangoma_isdn_stack_hndl.c | 2 +- .../ftmod_sangoma_isdn_stack_out.c | 11 ++ .../ftmod_sangoma_isdn_stack_rcv.c | 24 ++- .../ftmod_sangoma_isdn_support.c | 35 +++- libs/freetdm/src/include/private/ftdm_core.h | 2 + libs/freetdm/src/include/private/ftdm_types.h | 3 +- 13 files changed, 369 insertions(+), 159 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c index 65c9dfc11f..d64e711e73 100644 --- a/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_isdn/ftmod_isdn.c @@ -53,7 +53,6 @@ //#define IODEBUG /* helper macros */ -#define FTDM_SPAN_IS_BRI(x) ((x)->trunk_type == FTDM_TRUNK_BRI || (x)->trunk_type == FTDM_TRUNK_BRI_PTMP) #define FTDM_SPAN_IS_NT(x) (((ftdm_isdn_data_t *)(x)->signal_data)->mode == Q921_NT) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c index a975204b62..c9691e232b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c @@ -1557,11 +1557,11 @@ static __inline__ ftdm_status_t state_advance(ftdm_channel_t *ftdmchan) ftdm_set_string(event.calling_name, ftdmchan->caller_data.cid_name); ftdm_set_string(event.rdnis.digits, ftdmchan->caller_data.rdnis.digits); if (strlen(ftdmchan->caller_data.rdnis.digits)) { - event.rdnis.digits_count = (uint8_t)strlen(ftdmchan->caller_data.rdnis.digits)+1; - event.rdnis.ton = ftdmchan->caller_data.rdnis.type; - event.rdnis.npi = ftdmchan->caller_data.rdnis.plan; + event.rdnis.digits_count = (uint8_t)strlen(ftdmchan->caller_data.rdnis.digits)+1; + event.rdnis.ton = ftdmchan->caller_data.rdnis.type; + event.rdnis.npi = ftdmchan->caller_data.rdnis.plan; } - + event.calling.screening_ind = ftdmchan->caller_data.screen; event.calling.presentation_ind = ftdmchan->caller_data.pres; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 22c89cb920..04c3b86c5e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -47,6 +47,8 @@ static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span); ftdm_channel_t* ftdm_sangoma_isdn_process_event_states(ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event); static void ftdm_sangoma_isdn_advance_chan_states(ftdm_channel_t *ftdmchan); +static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span); +static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event); static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan); static void ftdm_sangoma_isdn_process_stack_event (ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event); @@ -56,7 +58,7 @@ static sng_isdn_event_interface_t g_sngisdn_event_interface; ftdm_sngisdn_data_t g_sngisdn_data; -extern ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); +extern ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); extern ftdm_status_t sngisdn_check_free_ids(void); ftdm_state_map_t sangoma_isdn_state_map = { @@ -238,6 +240,106 @@ static __inline__ void ftdm_sangoma_isdn_advance_chan_states(ftdm_channel_t *ftd } } +static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event) +{ + + switch (event) { + /* Check if the span woke up from power-saving mode */ + case FTDM_OOB_ALARM_CLEAR: + sngisdn_snd_event(span, SNG_L1EVENT_ALARM_OFF); + if (FTDM_SPAN_IS_BRI(span)) { + ftdm_channel_t *ftdmchan; + ftdm_iterator_t *chaniter = NULL; + ftdm_iterator_t *curr = NULL; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; + + chaniter = ftdm_span_get_chan_iterator(span, NULL); + for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { + ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); + sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; + + if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)) { + ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); + + ftdm_sched_timer(signal_data->sched, "delayed_setup", 1, sngisdn_delayed_setup, (void*) ftdmchan->call_data, NULL); + } + } + ftdm_iterator_free(chaniter); + } + break; + case FTDM_OOB_ALARM_TRAP: + sngisdn_snd_event(span, SNG_L1EVENT_ALARM_ON); + break; + default: + /* Ignore other events for now */ + break; + } +} + +static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span) +{ + ftdm_status_t ret_status; + ret_status = ftdm_span_poll_event(span, 0, NULL); + switch(ret_status) { + case FTDM_SUCCESS: + { + ftdm_event_t *event; + while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS) { + ftdm_sangoma_isdn_process_phy_events(span, event->enum_id); + } + } + break; + case FTDM_TIMEOUT: + /* No events pending */ + break; + default: + ftdm_log(FTDM_LOG_WARNING, "%s:Failed to poll span event\n", span->name); + } +} + +static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj) +{ + uint8_t data[1000]; + ftdm_status_t status = FTDM_SUCCESS; + ftdm_wait_flag_t wflags = FTDM_READ; + ftdm_span_t *span = (ftdm_span_t*) obj; + ftdm_channel_t *dchan = ((sngisdn_span_data_t*)span->signal_data)->dchan; + ftdm_size_t len = 0; + + + ftdm_assert(dchan, "Span does not have a dchannel"); + ftdm_channel_open_chan(dchan); + + while (ftdm_running() && !(ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD))) { + wflags = FTDM_READ; + status = ftdm_channel_wait(dchan, &wflags, 0); + switch(status) { + case FTDM_FAIL: + ftdm_log_chan_msg(dchan, FTDM_LOG_CRIT, "Failed to wait for d-channel\n"); + break; + case FTDM_TIMEOUT: + break; + case FTDM_SUCCESS: + if ((wflags & FTDM_READ)) { + len = 1000; + status = ftdm_channel_read(dchan, data, &len); + if (status == FTDM_SUCCESS) { + sngisdn_snd_data(span, data, len); + } else { + ftdm_log_chan_msg(dchan, FTDM_LOG_WARNING, "Failed to read from channel \n"); + } + } else { + ftdm_log_chan_msg(dchan, FTDM_LOG_CRIT, "Failed to poll for d-channel\n"); + } + break; + default: + ftdm_log_chan_msg(dchan, FTDM_LOG_CRIT, "Unhandled IO event\n"); + } + } + ftdm_channel_close(&dchan); + return NULL; +} + static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) { ftdm_interrupt_t *ftdm_sangoma_isdn_int[2]; @@ -300,21 +402,8 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) } /* Poll for events, e.g HW DTMF */ - ret_status = ftdm_span_poll_event(span, 0, NULL); - switch(ret_status) { - case FTDM_SUCCESS: - { - ftdm_event_t *event; - while (ftdm_span_next_event(span, &event) == FTDM_SUCCESS); - } - break; - case FTDM_TIMEOUT: - /* No events pending */ - break; - default: - ftdm_log(FTDM_LOG_WARNING, "%s:Failed to poll span event\n", span->name); - } - + ftdm_sangoma_isdn_poll_events(span); + if (ftdm_sched_get_time_to_next_timer(signal_data->sched, &sleep) == FTDM_SUCCESS) { if (sleep < 0 || sleep > SNGISDN_EVENT_POLL_RATE) { sleep = SNGISDN_EVENT_POLL_RATE; @@ -498,8 +587,20 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) } break; case FTDM_CHANNEL_STATE_DIALING: /* outgoing call request */ - { - sngisdn_snd_setup(ftdmchan); + { + if (FTDM_SPAN_IS_BRI(ftdmchan->span) && + ftdm_test_flag(ftdmchan, FTDM_CHANNEL_IN_ALARM) && + ftdm_test_flag(ftdmchan->span, FTDM_SPAN_PWR_SAVING)) { + + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Requesting Line activation\n"); + sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); + sngisdn_wake_up_phy(ftdmchan->span); + ftdm_sched_timer(signal_data->sched, "timer_t3", signal_data->timer_t3*1000, sngisdn_t3_timeout, (void*) sngisdn_info, NULL); + } else { + sngisdn_snd_setup(ftdmchan); + } } break; case FTDM_CHANNEL_STATE_PROGRESS: @@ -592,7 +693,7 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) sngisdn_snd_release(ftdmchan, 0); if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - sng_isdn_set_avail_rate(ftdmchan->span, SNGISDN_AVAIL_DOWN); + sngisdn_set_avail_rate(ftdmchan->span, SNGISDN_AVAIL_DOWN); } } else { sngisdn_snd_disconnect(ftdmchan); @@ -747,7 +848,7 @@ static FIO_SPAN_SET_SIG_STATUS_FUNCTION(ftdm_sangoma_isdn_set_span_sig_status) static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span) { ftdm_log(FTDM_LOG_INFO,"Starting span %s:%u.\n",span->name,span->span_id); - if (sng_isdn_stack_start(span) != FTDM_SUCCESS) { + if (sngisdn_stack_start(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed to start span %s\n", span->name); return FTDM_FAIL; } @@ -761,6 +862,12 @@ static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span) return FTDM_FAIL; } + /*start the dchan monitor thread*/ + if (ftdm_thread_create_detached(ftdm_sangoma_isdn_dchan_run, span) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_CRIT,"Failed to start Sangoma ISDN d-channel Monitor Thread!\n"); + return FTDM_FAIL; + } + ftdm_log(FTDM_LOG_DEBUG,"Finished starting span %s\n", span->name); return FTDM_SUCCESS; } @@ -782,7 +889,7 @@ static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span) ftdm_sleep(10); } - if (sng_isdn_stack_stop(span) != FTDM_SUCCESS) { + if (sngisdn_stack_stop(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed to stop span %s\n", span->name); } @@ -834,7 +941,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) return FTDM_FAIL; } - if (sng_isdn_stack_cfg(span) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Sangoma ISDN Stack configuration failed\n"); return FTDM_FAIL; } @@ -856,9 +963,8 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) if (span->trunk_type == FTDM_TRUNK_BRI_PTMP || span->trunk_type == FTDM_TRUNK_BRI) { - - ftdm_set_flag(span, FTDM_SPAN_USE_AV_RATE); - sng_isdn_set_avail_rate(span, SNGISDN_AVAIL_PWR_SAVING); + + sngisdn_set_avail_rate(span, SNGISDN_AVAIL_PWR_SAVING); } /* Initialize scheduling context */ @@ -906,7 +1012,9 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_isdn_init) g_sngisdn_event_interface.sta.sng_q921_trc_ind = sngisdn_rcv_q921_trace; g_sngisdn_event_interface.sta.sng_q931_sta_ind = sngisdn_rcv_q931_ind; g_sngisdn_event_interface.sta.sng_q931_trc_ind = sngisdn_rcv_q931_trace; - g_sngisdn_event_interface.sta.sng_cc_sta_ind = sngisdn_rcv_cc_ind; + g_sngisdn_event_interface.sta.sng_cc_sta_ind = sngisdn_rcv_cc_ind; + + g_sngisdn_event_interface.io.sng_data_req = sngisdn_rcv_data_req; for(i=1;i<=MAX_VARIANTS;i++) { ftdm_mutex_create(&g_sngisdn_data.ccs[i].mutex); @@ -914,7 +1022,7 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_isdn_init) /* initalize sng_isdn library */ - ftdm_assert_return(!sng_isdn_init(&g_sngisdn_event_interface), FTDM_FAIL, "Failed to initialize stack\n"); + ftdm_assert_return(!sng_isdn_init(&g_sngisdn_event_interface), FTDM_FAIL, "Failed to initialize stack\n"); return FTDM_SUCCESS; } @@ -968,11 +1076,11 @@ static FIO_API_FUNCTION(ftdm_sangoma_isdn_api) goto done; } if (!strcasecmp(trace_opt, "q921")) { - sng_isdn_activate_trace(span, SNGISDN_TRACE_Q921); + sngisdn_activate_trace(span, SNGISDN_TRACE_Q921); } else if (!strcasecmp(trace_opt, "q931")) { - sng_isdn_activate_trace(span, SNGISDN_TRACE_Q931); + sngisdn_activate_trace(span, SNGISDN_TRACE_Q931); } else if (!strcasecmp(trace_opt, "disable")) { - sng_isdn_activate_trace(span, SNGISDN_TRACE_DISABLE); + sngisdn_activate_trace(span, SNGISDN_TRACE_DISABLE); } else { stream->write_function(stream, "-ERR invalid trace option \n"); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index e84392e22a..75262c9627 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -74,6 +74,7 @@ typedef enum { FLAG_DELAYED_REL = (1 << 7), FLAG_SENT_PROCEED = (1 << 8), FLAG_SEND_DISC = (1 << 9), + FLAG_ACTIVATING = (1 << 10), /* Used for BRI only, flag is set after we request line CONNECTED */ } sngisdn_flag_t; @@ -167,6 +168,7 @@ typedef struct sngisdn_chan_data { /* Span specific data */ typedef struct sngisdn_span_data { ftdm_span_t *ftdm_span; + ftdm_channel_t *dchan; uint8_t link_id; uint8_t switchtype; uint8_t signalling; /* SNGISDN_SIGNALING_CPE or SNGISDN_SIGNALING_NET */ @@ -181,6 +183,7 @@ typedef struct sngisdn_span_data { uint8_t facility; int8_t facility_timeout; uint8_t num_local_numbers; + uint8_t timer_t3; char* local_numbers[SNGISDN_NUM_LOCAL_NUMBERS]; ftdm_sched_t *sched; ftdm_queue_t *event_queue; @@ -275,7 +278,7 @@ void stack_hdr_init(Header *hdr); void stack_pst_init(Pst *pst); FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data); FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data); -FT_DECLARE_INLINE(ftdm_status_t) sng_isdn_set_avail_rate(ftdm_span_t *ftdmspan, sngisdn_avail_t avail); +FT_DECLARE_INLINE(ftdm_status_t) sngisdn_set_avail_rate(ftdm_span_t *ftdmspan, sngisdn_avail_t avail); /* Outbound Call Control functions */ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan); @@ -290,25 +293,28 @@ void sngisdn_snd_reset(ftdm_channel_t *ftdmchan); void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan); void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan); void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan); +void sngisdn_snd_data(ftdm_span_t *span, uint8_t *data, ftdm_size_t len); +void sngisdn_snd_event(ftdm_span_t *span, sng_isdn_l1_event_t l1_event); /* Inbound Call Control functions */ -void sngisdn_rcv_con_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_con_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_cnst_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, uint8_t evntType, int16_t dChan, uint8_t ces); -void sngisdn_rcv_disc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, DiscEvnt *discEvnt); -void sngisdn_rcv_rel_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, RelEvnt *relEvnt); -void sngisdn_rcv_dat_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, InfoEvnt *infoEvnt); -void sngisdn_rcv_sshl_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action); -void sngisdn_rcv_sshl_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action); -void sngisdn_rcv_rmrt_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action); -void sngisdn_rcv_rmrt_cfm (int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action); -void sngisdn_rcv_flc_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt); -void sngisdn_rcv_fac_ind (int16_t suId, uint32_t suInstId, uint32_t spInstId, FacEvnt *facEvnt, uint8_t evntType, int16_t dChan, uint8_t ces); -void sngisdn_rcv_sta_cfm ( int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt); -void sngisdn_rcv_srv_ind ( int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_srv_cfm ( int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); -void sngisdn_rcv_rst_cfm ( int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); -void sngisdn_rcv_rst_ind ( int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); +void sngisdn_rcv_con_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces); +void sngisdn_rcv_con_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, int16_t dChan, uint8_t ces); +void sngisdn_rcv_cnst_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, CnStEvnt *cnStEvnt, uint8_t evntType, int16_t dChan, uint8_t ces); +void sngisdn_rcv_disc_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, DiscEvnt *discEvnt); +void sngisdn_rcv_rel_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, RelEvnt *relEvnt); +void sngisdn_rcv_dat_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, InfoEvnt *infoEvnt); +void sngisdn_rcv_sshl_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action); +void sngisdn_rcv_sshl_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, SsHlEvnt *ssHlEvnt, uint8_t action); +void sngisdn_rcv_rmrt_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action); +void sngisdn_rcv_rmrt_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, RmRtEvnt *rmRtEvnt, uint8_t action); +void sngisdn_rcv_flc_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt); +void sngisdn_rcv_fac_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, FacEvnt *facEvnt, uint8_t evntType, int16_t dChan, uint8_t ces); +void sngisdn_rcv_sta_cfm(int16_t suId, uint32_t suInstId, uint32_t spInstId, StaEvnt *staEvnt); +void sngisdn_rcv_srv_ind(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); +void sngisdn_rcv_srv_cfm(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); +void sngisdn_rcv_rst_cfm(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); +void sngisdn_rcv_rst_ind(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); +int16_t sngisdn_rcv_data_req(uint16_t spId, uint8_t *buff, uint32_t length); void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event); void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event); @@ -364,15 +370,18 @@ static __inline__ void sngisdn_set_flag(sngisdn_chan_data_t *sngisdn_info, sngis void handle_sng_log(uint8_t level, char *fmt,...); void sngisdn_set_span_sig_status(ftdm_span_t *ftdmspan, ftdm_signaling_status_t status); +void sngisdn_delayed_setup(void* p_sngisdn_info); void sngisdn_delayed_release(void* p_sngisdn_info); void sngisdn_delayed_connect(void* p_sngisdn_info); void sngisdn_delayed_disconnect(void* p_sngisdn_info); void sngisdn_facility_timeout(void* p_sngisdn_info); +void sngisdn_t3_timeout(void* p_sngisdn_info); /* Stack management functions */ -ftdm_status_t sng_isdn_stack_cfg(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_start(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_start(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span); +ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span); void sngisdn_print_phy_stats(ftdm_stream_handle_t *stream, ftdm_span_t *span); void sngisdn_print_spans(ftdm_stream_handle_t *stream); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index 64d7a2403f..43e35b6dfd 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -56,9 +56,11 @@ ftdm_status_t add_local_number(const char* val, ftdm_span_t *span) ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span) { unsigned i; - + ftdm_iterator_t *chaniter = NULL; + ftdm_iterator_t *curr = NULL; sngisdn_dchan_data_t *dchan_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; + switch(span->trunk_type) { case FTDM_TRUNK_T1: if (!strcasecmp(switch_name, "ni2") || @@ -122,9 +124,9 @@ ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span) /* add this span to its ent_cc */ signal_data->cc_id = i; - /* create a new dchan */ /* for NFAS - no-dchan on b-channels only links */ + /* create a new dchan */ /* for NFAS - no-dchan on b-channels-only links */ g_sngisdn_data.num_dchan++; - signal_data->dchan_id = g_sngisdn_data.num_dchan; + signal_data->dchan_id = g_sngisdn_data.num_dchan; dchan_data = &g_sngisdn_data.dchans[signal_data->dchan_id]; dchan_data->num_spans++; @@ -136,16 +138,23 @@ ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span) ftdm_log(FTDM_LOG_DEBUG, "%s: cc_id:%d dchan_id:%d span_id:%d\n", span->name, signal_data->cc_id, signal_data->dchan_id, signal_data->span_id); - /* Add the channels to the span */ - for (i=1;i<=span->chan_count;i++) { - unsigned chan_id; - ftdm_channel_t *ftdmchan = span->channels[i]; - /* NFAS is not supported on E1, so span_id will always be 1 for E1 so this will work for E1 as well */ - chan_id = ((signal_data->span_id-1)*NUM_T1_CHANNELS_PER_SPAN)+ftdmchan->physical_chan_id; - dchan_data->channels[chan_id] = (sngisdn_chan_data_t*)ftdmchan->call_data; - dchan_data->num_chans++; + + chaniter = ftdm_span_get_chan_iterator(span, NULL); + for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { + int32_t chan_id; + ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); + if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { + /* set the d-channel */ + signal_data->dchan = ftdmchan; + } else { + /* Add the channels to the span */ + /* NFAS is not supported on E1, so span_id will always be 1 for E1 so this will work for E1 as well */ + chan_id = ((signal_data->span_id-1)*NUM_T1_CHANNELS_PER_SPAN)+ftdmchan->physical_chan_id; + dchan_data->channels[chan_id] = (sngisdn_chan_data_t*)ftdmchan->call_data; + dchan_data->num_chans++; + } } - + ftdm_iterator_free(chaniter); return FTDM_SUCCESS; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c index bb46fb7fba..eabaa7affc 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c @@ -38,52 +38,52 @@ extern ftdm_sngisdn_data_t g_sngisdn_data; uint8_t sng_isdn_stack_switchtype(sngisdn_switchtype_t switchtype); -ftdm_status_t sng_isdn_cfg_phy(ftdm_span_t *span); -ftdm_status_t sng_isdn_cfg_q921(ftdm_span_t *span); -ftdm_status_t sng_isdn_cfg_q931(ftdm_span_t *span); -ftdm_status_t sng_isdn_cfg_cc(ftdm_span_t *span); +ftdm_status_t sngisdn_cfg_phy(ftdm_span_t *span); +ftdm_status_t sngisdn_cfg_q921(ftdm_span_t *span); +ftdm_status_t sngisdn_cfg_q931(ftdm_span_t *span); +ftdm_status_t sngisdn_cfg_cc(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_cfg_phy_gen(void); -ftdm_status_t sng_isdn_stack_cfg_q921_gen(void); -ftdm_status_t sng_isdn_stack_cfg_q931_gen(void); -ftdm_status_t sng_isdn_stack_cfg_cc_gen(void); +ftdm_status_t sngisdn_stack_cfg_phy_gen(void); +ftdm_status_t sngisdn_stack_cfg_q921_gen(void); +ftdm_status_t sngisdn_stack_cfg_q931_gen(void); +ftdm_status_t sngisdn_stack_cfg_cc_gen(void); -ftdm_status_t sng_isdn_stack_cfg_phy_psap(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_cfg_q921_msap(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management); -ftdm_status_t sng_isdn_stack_cfg_q931_tsap(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_cfg_q931_dlsap(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_cfg_q931_lce(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management); +ftdm_status_t sngisdn_stack_cfg_q931_tsap(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_cfg_cc_sap(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_cfg_cc_sap(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_cfg(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; if (!g_sngisdn_data.gen_config_done) { g_sngisdn_data.gen_config_done = 1; ftdm_log(FTDM_LOG_DEBUG, "Starting general stack configuration\n"); - if(sng_isdn_stack_cfg_phy_gen()!= FTDM_SUCCESS) { + if(sngisdn_stack_cfg_phy_gen()!= FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed general physical configuration\n"); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "General stack physical done\n"); - if(sng_isdn_stack_cfg_q921_gen()!= FTDM_SUCCESS) { + if(sngisdn_stack_cfg_q921_gen()!= FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed general q921 configuration\n"); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "General stack q921 done\n"); - if(sng_isdn_stack_cfg_q931_gen()!= FTDM_SUCCESS) { + if(sngisdn_stack_cfg_q931_gen()!= FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed general q921 configuration\n"); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "General stack q931 done\n"); - if(sng_isdn_stack_cfg_cc_gen()!= FTDM_SUCCESS) { + if(sngisdn_stack_cfg_cc_gen()!= FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "Failed general CC configuration\n"); return FTDM_FAIL; } @@ -92,26 +92,26 @@ ftdm_status_t sng_isdn_stack_cfg(ftdm_span_t *span) } /* TODO: for NFAS, should only call these function for spans with d-chans */ - if (sng_isdn_stack_cfg_phy_psap(span) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_phy_psap(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:phy_psap configuration failed\n", span->name); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "%s:phy_psap configuration done\n", span->name); - if (sng_isdn_stack_cfg_q921_msap(span) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_q921_msap(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:q921_msap configuration failed\n", span->name); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "%s:q921_msap configuration done\n", span->name); - if (sng_isdn_stack_cfg_q921_dlsap(span, 0) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_q921_dlsap(span, 0) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap configuration failed\n", span->name); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "%s:q921_dlsap configuration done\n", span->name); if (span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - if (sng_isdn_stack_cfg_q921_dlsap(span, 1) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_q921_dlsap(span, 1) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:q921_dlsap management configuration failed\n", span->name); return FTDM_FAIL; } @@ -119,13 +119,13 @@ ftdm_status_t sng_isdn_stack_cfg(ftdm_span_t *span) } - if (sng_isdn_stack_cfg_q931_dlsap(span) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_q931_dlsap(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:q931_dlsap configuration failed\n", span->name); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "%s:q931_dlsap configuration done\n", span->name); - if (sng_isdn_stack_cfg_q931_lce(span) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_q931_lce(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:q931_lce configuration failed\n", span->name); return FTDM_FAIL; } @@ -134,13 +134,13 @@ ftdm_status_t sng_isdn_stack_cfg(ftdm_span_t *span) if (!g_sngisdn_data.ccs[signal_data->cc_id].config_done) { g_sngisdn_data.ccs[signal_data->cc_id].config_done = 1; /* if BRI, need to configure dlsap_mgmt */ - if (sng_isdn_stack_cfg_q931_tsap(span) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_q931_tsap(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:q931_tsap configuration failed\n", span->name); return FTDM_FAIL; } ftdm_log(FTDM_LOG_DEBUG, "%s:q931_tsap configuration done\n", span->name); - if (sng_isdn_stack_cfg_cc_sap(span) != FTDM_SUCCESS) { + if (sngisdn_stack_cfg_cc_sap(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "%s:cc_sap configuration failed\n", span->name); return FTDM_FAIL; } @@ -153,7 +153,7 @@ ftdm_status_t sng_isdn_stack_cfg(ftdm_span_t *span) -ftdm_status_t sng_isdn_stack_cfg_phy_gen(void) +ftdm_status_t sngisdn_stack_cfg_phy_gen(void) { /*local variables*/ L1Mngmt cfg; /*configuration structure*/ @@ -191,14 +191,11 @@ ftdm_status_t sng_isdn_stack_cfg_phy_gen(void) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_stack_cfg_phy_psap(ftdm_span_t *span) -{ - ftdm_iterator_t *chaniter; - ftdm_iterator_t *curr; +ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span) +{ L1Mngmt cfg; Pst pst; - int32_t d_channel_fd = -1; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; /* initalize the post structure */ @@ -220,25 +217,13 @@ ftdm_status_t sng_isdn_stack_cfg_phy_psap(ftdm_span_t *span) cfg.hdr.elmId.elmnt = STPSAP; cfg.hdr.elmId.elmntInst1 = signal_data->link_id; - - - /* Find the d-channel */ - chaniter = ftdm_span_get_chan_iterator(span, NULL); - for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { - ftdm_channel_t *ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921) { - d_channel_fd = (int32_t)ftdmchan->sockfd; - break; - } - } - ftdm_iterator_free(chaniter); - - if(d_channel_fd < 0) { + + if (!signal_data->dchan) { ftdm_log(FTDM_LOG_ERROR, "%s:No d-channels specified\n", span->name); return FTDM_FAIL; - } - - cfg.t.cfg.s.l1PSAP.sockfd = d_channel_fd; + } + + cfg.t.cfg.s.l1PSAP.sockfd = (int32_t)signal_data->dchan->sockfd; switch(span->trunk_type) { case FTDM_TRUNK_E1: @@ -257,7 +242,7 @@ ftdm_status_t sng_isdn_stack_cfg_phy_psap(ftdm_span_t *span) return FTDM_FAIL; } cfg.t.cfg.s.l1PSAP.spId = signal_data->link_id; - + if (sng_isdn_phy_config(&pst, &cfg)) { return FTDM_FAIL; } @@ -265,7 +250,7 @@ ftdm_status_t sng_isdn_stack_cfg_phy_psap(ftdm_span_t *span) } -ftdm_status_t sng_isdn_stack_cfg_q921_gen(void) +ftdm_status_t sngisdn_stack_cfg_q921_gen(void) { BdMngmt cfg; Pst pst; @@ -308,7 +293,7 @@ ftdm_status_t sng_isdn_stack_cfg_q921_gen(void) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_stack_cfg_q921_msap(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span) { BdMngmt cfg; Pst pst; @@ -401,7 +386,7 @@ ftdm_status_t sng_isdn_stack_cfg_q921_msap(ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management) +ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management) { BdMngmt cfg; Pst pst; @@ -483,7 +468,7 @@ ftdm_status_t sng_isdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t managemen return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_stack_cfg_q931_gen(void) +ftdm_status_t sngisdn_stack_cfg_q931_gen(void) { InMngmt cfg; Pst pst; @@ -538,7 +523,7 @@ ftdm_status_t sng_isdn_stack_cfg_q931_gen(void) } /* Link between CC and q931 */ -ftdm_status_t sng_isdn_stack_cfg_q931_tsap(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_cfg_q931_tsap(ftdm_span_t *span) { InMngmt cfg; Pst pst; @@ -601,7 +586,7 @@ ftdm_status_t sng_isdn_stack_cfg_q931_tsap(ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_stack_cfg_q931_dlsap(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) { InMngmt cfg; Pst pst; @@ -851,7 +836,7 @@ ftdm_status_t sng_isdn_stack_cfg_q931_dlsap(ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_stack_cfg_q931_lce(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) { InMngmt cfg; Pst pst; @@ -927,7 +912,7 @@ ftdm_status_t sng_isdn_stack_cfg_q931_lce(ftdm_span_t *span) } -ftdm_status_t sng_isdn_stack_cfg_cc_gen(void) +ftdm_status_t sngisdn_stack_cfg_cc_gen(void) { CcMngmt cfg; Pst pst; @@ -966,7 +951,7 @@ ftdm_status_t sng_isdn_stack_cfg_cc_gen(void) } -ftdm_status_t sng_isdn_stack_cfg_cc_sap(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_cfg_cc_sap(ftdm_span_t *span) { CcMngmt cfg; Pst pst; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c index 27c16c2a51..d8e6c8e00d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c @@ -37,27 +37,27 @@ void stack_resp_hdr_init(Header *hdr); -ftdm_status_t sng_isdn_activate_phy(ftdm_span_t *span); -ftdm_status_t sng_isdn_deactivate_phy(ftdm_span_t *span); +ftdm_status_t sngisdn_activate_phy(ftdm_span_t *span); +ftdm_status_t sngisdn_deactivate_phy(ftdm_span_t *span); -ftdm_status_t sng_isdn_activate_cc(ftdm_span_t *span); -ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); +ftdm_status_t sngisdn_activate_cc(ftdm_span_t *span); +ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); -ftdm_status_t sng_isdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t subaction); -ftdm_status_t sng_isdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t subaction); +ftdm_status_t sngisdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t subaction); +ftdm_status_t sngisdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t subaction); extern ftdm_sngisdn_data_t g_sngisdn_data; -ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span); +ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span); -ftdm_status_t sng_isdn_stack_start(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_start(ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - if (sng_isdn_cntrl_q921(span, ABND_ENA, NOTUSED) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q921(span, ABND_ENA, NOTUSED) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q921\n", span->name); return FTDM_FAIL; } @@ -72,7 +72,7 @@ ftdm_status_t sng_isdn_stack_start(ftdm_span_t *span) ftdm_log(FTDM_LOG_DEBUG, "%s:Stack q921 activated\n", span->name); if (!g_sngisdn_data.ccs[signal_data->cc_id].activation_done) { g_sngisdn_data.ccs[signal_data->cc_id].activation_done = 1; - if (sng_isdn_activate_cc(span) != FTDM_SUCCESS) { + if (sngisdn_activate_cc(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack CC\n", span->name); return FTDM_FAIL; } @@ -80,7 +80,7 @@ ftdm_status_t sng_isdn_stack_start(ftdm_span_t *span) } - if (sng_isdn_cntrl_q931(span, ABND_ENA, SAELMNT) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q931(span, ABND_ENA, SAELMNT) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to activate stack q931\n", span->name); return FTDM_FAIL; } @@ -90,20 +90,20 @@ ftdm_status_t sng_isdn_stack_start(ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span) +ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span) { /* Stop L1 first, so we do not receive any more frames */ - if (sng_isdn_deactivate_phy(span) != FTDM_SUCCESS) { + if (sngisdn_deactivate_phy(span) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack phy\n", span->name); return FTDM_FAIL; } - if (sng_isdn_cntrl_q931(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q931(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack q931\n", span->name); return FTDM_FAIL; } - if (sng_isdn_cntrl_q921(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q921(span, AUBND_DIS, SAELMNT) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to deactivate stack q921\n", span->name); return FTDM_FAIL; } @@ -113,7 +113,7 @@ ftdm_status_t sng_isdn_stack_stop(ftdm_span_t *span) } -ftdm_status_t sng_isdn_activate_phy(ftdm_span_t *span) +ftdm_status_t sngisdn_activate_phy(ftdm_span_t *span) { /* There is no need to start phy, as it will Q921 will send a activate request to phy when it starts */ @@ -121,7 +121,7 @@ ftdm_status_t sng_isdn_activate_phy(ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_deactivate_phy(ftdm_span_t *span) +ftdm_status_t sngisdn_deactivate_phy(ftdm_span_t *span) { L1Mngmt cntrl; Pst pst; @@ -155,8 +155,41 @@ ftdm_status_t sng_isdn_deactivate_phy(ftdm_span_t *span) return FTDM_SUCCESS; } +ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span) +{ + L1Mngmt cntrl; + Pst pst; -ftdm_status_t sng_isdn_activate_cc(ftdm_span_t *span) + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; + + /* initalize the post structure */ + stack_pst_init(&pst); + + /* insert the destination Entity */ + pst.dstEnt = ENTL1; + + /* initalize the control structure */ + memset(&cntrl, 0, sizeof(cntrl)); + + /* initalize the control header */ + stack_hdr_init(&cntrl.hdr); + + cntrl.hdr.msgType = TCNTRL; /* configuration */ + cntrl.hdr.entId.ent = ENTL1; /* entity */ + cntrl.hdr.entId.inst = S_INST; /* instance */ + cntrl.hdr.elmId.elmnt = STTSAP; /* SAP Specific cntrl */ + + cntrl.t.cntrl.action = AENA; + cntrl.t.cntrl.subAction = SAELMNT; + cntrl.t.cntrl.sapId = signal_data->link_id; + + if (sng_isdn_phy_cntrl(&pst, &cntrl)) { + return FTDM_FAIL; + } + return FTDM_SUCCESS; +} + +ftdm_status_t sngisdn_activate_cc(ftdm_span_t *span) { CcMngmt cntrl; Pst pst; @@ -190,7 +223,7 @@ ftdm_status_t sng_isdn_activate_cc(ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt) +ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; switch (trace_opt) { @@ -199,7 +232,7 @@ ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t tra ftdm_log(FTDM_LOG_INFO, "s%d Disabling q921 trace\n", signal_data->link_id); sngisdn_clear_trace_flag(signal_data, SNGISDN_TRACE_Q921); - if (sng_isdn_cntrl_q921(span, ADISIMM, SATRC) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q921(span, ADISIMM, SATRC) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "s%d Failed to disable q921 trace\n"); } } @@ -207,7 +240,7 @@ ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t tra ftdm_log(FTDM_LOG_INFO, "s%d Disabling q931 trace\n", signal_data->link_id); sngisdn_clear_trace_flag(signal_data, SNGISDN_TRACE_Q931); - if (sng_isdn_cntrl_q931(span, ADISIMM, SATRC) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q931(span, ADISIMM, SATRC) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "s%d Failed to disable q931 trace\n"); } } @@ -217,7 +250,7 @@ ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t tra ftdm_log(FTDM_LOG_INFO, "s%d Enabling q921 trace\n", signal_data->link_id); sngisdn_set_trace_flag(signal_data, SNGISDN_TRACE_Q921); - if (sng_isdn_cntrl_q921(span, AENA, SATRC) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q921(span, AENA, SATRC) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "s%d Failed to enable q921 trace\n"); } } @@ -227,7 +260,7 @@ ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t tra ftdm_log(FTDM_LOG_INFO, "s%d Enabling q931 trace\n", signal_data->link_id); sngisdn_set_trace_flag(signal_data, SNGISDN_TRACE_Q931); - if (sng_isdn_cntrl_q931(span, AENA, SATRC) != FTDM_SUCCESS) { + if (sngisdn_cntrl_q931(span, AENA, SATRC) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "s%d Failed to enable q931 trace\n"); } } @@ -237,7 +270,7 @@ ftdm_status_t sng_isdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t tra } -ftdm_status_t sng_isdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t subaction) +ftdm_status_t sngisdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t subaction) { InMngmt cntrl; Pst pst; @@ -276,7 +309,7 @@ ftdm_status_t sng_isdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t sub } -ftdm_status_t sng_isdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t subaction) +ftdm_status_t sngisdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t subaction) { BdMngmt cntrl; Pst pst; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 7ca408538a..37613cc33d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -539,7 +539,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) case FTDM_CHANNEL_STATE_DIALING: /* Remote side rejected our SETUP message on outbound call */ if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { - sng_isdn_set_avail_rate(ftdmchan->span, SNGISDN_AVAIL_DOWN); + sngisdn_set_avail_rate(ftdmchan->span, SNGISDN_AVAIL_DOWN); } /* fall-through */ case FTDM_CHANNEL_STATE_PROGRESS: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 3284d54165..bf44cb2e0a 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -600,6 +600,17 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) return; } +void sngisdn_snd_data(ftdm_span_t *span, uint8_t *data, ftdm_size_t len) +{ + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; + sng_isdn_data_ind(signal_data->link_id, data, len); +} + +void sngisdn_snd_event(ftdm_span_t *span, sng_isdn_l1_event_t l1_event) +{ + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; + sng_isdn_event_ind(signal_data->link_id, l1_event); +} /* For Emacs: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index 5580f3a950..e7ebc8f20b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -736,7 +736,7 @@ void sngisdn_rcv_q931_ind(InMngmt *status) DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_UP); - sng_isdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_UP); + sngisdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_UP); } else { ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n", status->t.usta.suId, @@ -745,7 +745,7 @@ void sngisdn_rcv_q931_ind(InMngmt *status) DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause); sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN); - sng_isdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING); + sngisdn_set_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING); } } break; @@ -866,6 +866,26 @@ end_of_trace: return; } +int16_t sngisdn_rcv_data_req(uint16_t spId, uint8_t *buff, uint32_t length) +{ + ftdm_status_t status; + ftdm_wait_flag_t flags = FTDM_WRITE; + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; + ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); + + status = signal_data->dchan->fio->wait(signal_data->dchan, &flags, 10); + if (status != FTDM_SUCCESS) { + ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_WARNING, "transmit timed-out\n"); + return -1; + } + status = signal_data->dchan->fio->write(signal_data->dchan, buff, (ftdm_size_t*)&length); + if (status != FTDM_SUCCESS) { + ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_CRIT, "Failed to transmit frame\n"); + return -1; + } + return 0; +} + void sngisdn_rcv_sng_assert(char *message) { ftdm_assert(0, message); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index f54f7db61c..a418103bed 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -137,7 +137,7 @@ FT_DECLARE_INLINE(ftdm_status_t) get_ftdmchan_by_spInstId(int16_t cc_id, uint32_ return FTDM_SUCCESS; } -ftdm_status_t sng_isdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail) +ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail) { if (span->trunk_type == FTDM_TRUNK_BRI || @@ -382,6 +382,39 @@ ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmc return FTDM_SUCCESS; } +void sngisdn_t3_timeout(void* p_sngisdn_info) +{ + sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; + ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Timer T3 expired (suId:%d suInstId:%u spInstId:%u)\n", + signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); + ftdm_mutex_lock(ftdmchan->mutex); + if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)){ + /* PHY layer timed-out, need to clear the call */ + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Failed to Wake-Up line (suId:%d suInstId:%u spInstId:%u)\n", + signal_data->cc_id, sngisdn_info->glare.spInstId, sngisdn_info->glare.suInstId); + + ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NO_ROUTE_DESTINATION; + ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); + ftdm_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); + } + ftdm_mutex_unlock(ftdmchan->mutex); +} + +void sngisdn_delayed_setup(void* p_sngisdn_info) +{ + sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; + ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; + + ftdm_mutex_lock(ftdmchan->mutex); + sngisdn_snd_setup(ftdmchan); + ftdm_mutex_unlock(ftdmchan->mutex); + return; +} + void sngisdn_delayed_release(void* p_sngisdn_info) { sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h index 8bdbdd60f8..239eb4a3d9 100644 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ b/libs/freetdm/src/include/private/ftdm_core.h @@ -222,6 +222,8 @@ extern "C" { #define ftdm_is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119) +#define FTDM_SPAN_IS_BRI(x) ((x)->trunk_type == FTDM_TRUNK_BRI || (x)->trunk_type == FTDM_TRUNK_BRI_PTMP) + /*! \brief Copy flags from one arbitrary object to another \command dest the object to copy the flags to diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index bddefd9be6..78ac8f63eb 100644 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ b/libs/freetdm/src/include/private/ftdm_types.h @@ -176,10 +176,11 @@ typedef enum { FTDM_SPAN_USE_CHAN_QUEUE = (1 << 6), FTDM_SPAN_SUGGEST_CHAN_ID = (1 << 7), FTDM_SPAN_USE_AV_RATE = (1 << 8), + FTDM_SPAN_PWR_SAVING = (1 << 9), /* If you use this flag, you MUST call ftdm_span_trigger_signals to deliver the user signals * after having called ftdm_send_span_signal(), which with this flag it will just enqueue the signal * for later delivery */ - FTDM_SPAN_USE_SIGNALS_QUEUE = (1 << 9), + FTDM_SPAN_USE_SIGNALS_QUEUE = (1 << 10), } ftdm_span_flag_t; /*! \brief Channel supported features */ From 93aa30076b01be366f8f1c487b7b561f5bd7e074 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 10 Nov 2010 19:23:48 -0500 Subject: [PATCH 02/55] Fixed conflicts --- .../ftmod_sangoma_isdn_stack_cntrl.c | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c index 1714ac185c..d8e6c8e00d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c @@ -113,40 +113,6 @@ ftdm_status_t sngisdn_stack_stop(ftdm_span_t *span) } -ftdm_status_t sngisdn_wake_up_phy(ftdm_span_t *span) -{ - L1Mngmt cntrl; - Pst pst; - - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - - /* initalize the post structure */ - stack_pst_init(&pst); - - /* insert the destination Entity */ - pst.dstEnt = ENTL1; - - /* initalize the control structure */ - memset(&cntrl, 0, sizeof(cntrl)); - - /* initalize the control header */ - stack_hdr_init(&cntrl.hdr); - - cntrl.hdr.msgType = TCNTRL; /* configuration */ - cntrl.hdr.entId.ent = ENTL1; /* entity */ - cntrl.hdr.entId.inst = S_INST; /* instance */ - cntrl.hdr.elmId.elmnt = STTSAP; /* SAP Specific cntrl */ - - cntrl.t.cntrl.action = AENA; - cntrl.t.cntrl.subAction = SAELMNT; - cntrl.t.cntrl.sapId = signal_data->link_id; - - if (sng_isdn_phy_cntrl(&pst, &cntrl)) { - return FTDM_FAIL; - } - return FTDM_SUCCESS; -} - ftdm_status_t sngisdn_activate_phy(ftdm_span_t *span) { From d0b6117325ded66fdbcb8a8c3630386e671675f9 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 11 Nov 2010 18:43:53 -0500 Subject: [PATCH 03/55] FIX for windows IO --- libs/freetdm/cyginstall.sh | 4 +-- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 22 ++++++------ .../ftmod_sangoma_isdn_stack_out.c | 1 + .../ftmod_sangoma_isdn_stack_rcv.c | 34 +++++++++++++------ .../src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 3 +- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/libs/freetdm/cyginstall.sh b/libs/freetdm/cyginstall.sh index 9d486b7dce..311df939af 100644 --- a/libs/freetdm/cyginstall.sh +++ b/libs/freetdm/cyginstall.sh @@ -5,8 +5,8 @@ fsdir=../.. set -x cp Debug/mod/*.dll $fsdir/Debug/mod/ cp mod_freetdm/Debug/*.pdb $fsdir/Debug/mod/ -cp Debug/*.dll $fsdir/Debug/ -cp Debug/*.pdb $fsdir/Debug/ +cp Debug/*.dll $fsdir/Debug/mod/ +cp Debug/*.pdb $fsdir/Debug/mod/ #cp Debug/testsangomaboost.exe $fsdir/Debug/ echo "FRIENDLY REMINDER: RECOMPILE ftmod_wanpipe WHENEVER YOU INSTALL NEW DRIVERS" set +x diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 69743115fe..98b09e9305 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -52,10 +52,10 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan); static void ftdm_sangoma_isdn_process_stack_event (ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event); -static ftdm_io_interface_t g_sngisdn_io_interface; -static sng_isdn_event_interface_t g_sngisdn_event_interface; +static ftdm_io_interface_t g_sngisdn_io_interface; +static sng_isdn_event_interface_t g_sngisdn_event_interface; -ftdm_sngisdn_data_t g_sngisdn_data; +ftdm_sngisdn_data_t g_sngisdn_data; extern ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); extern ftdm_status_t sngisdn_check_free_ids(void); @@ -248,6 +248,7 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve sngisdn_snd_event(span, SNG_L1EVENT_ALARM_OFF); if (FTDM_SPAN_IS_BRI(span)) { ftdm_channel_t *ftdmchan; + sngisdn_chan_data_t *sngisdn_info; ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; @@ -255,7 +256,7 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve chaniter = ftdm_span_get_chan_iterator(span, NULL); for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); - sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; + sngisdn_info = (sngisdn_chan_data_t*)ftdmchan->call_data; if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)) { ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); @@ -277,8 +278,7 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span) { - ftdm_status_t ret_status; - ftdm_channel_t *ftdmchan; + ftdm_status_t ret_status; ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; @@ -315,7 +315,7 @@ static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj) while (ftdm_running() && !(ftdm_test_flag(span, FTDM_SPAN_STOP_THREAD))) { wflags = FTDM_READ; - status = ftdm_channel_wait(dchan, &wflags, 0); + status = ftdm_channel_wait(dchan, &wflags, 10000); switch(status) { case FTDM_FAIL: ftdm_log_chan_msg(dchan, FTDM_LOG_CRIT, "Failed to wait for d-channel\n"); @@ -331,8 +331,10 @@ static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj) } else { ftdm_log_chan_msg(dchan, FTDM_LOG_WARNING, "Failed to read from channel \n"); } +#ifndef WIN32 /* It is valid on WIN32 for poll to return without errors, but no flags set */ } else { ftdm_log_chan_msg(dchan, FTDM_LOG_CRIT, "Failed to poll for d-channel\n"); +#endif } break; default: @@ -986,7 +988,7 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_isdn_init) ftdm_log(FTDM_LOG_INFO, "Loading ftmod_sangoma_isdn...\n"); memset(&g_sngisdn_data, 0, sizeof(g_sngisdn_data)); - + memset(&g_sngisdn_event_interface, 0, sizeof(g_sngisdn_event_interface)); /* set callbacks */ g_sngisdn_event_interface.cc.sng_con_ind = sngisdn_rcv_con_ind; g_sngisdn_event_interface.cc.sng_con_cfm = sngisdn_rcv_con_cfm; @@ -1017,8 +1019,8 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_isdn_init) g_sngisdn_event_interface.sta.sng_q931_trc_ind = sngisdn_rcv_q931_trace; g_sngisdn_event_interface.sta.sng_cc_sta_ind = sngisdn_rcv_cc_ind; - g_sngisdn_event_interface.io.sng_data_req = sngisdn_rcv_data_req; - + g_sngisdn_event_interface.io.sng_data_req = sngisdn_rcv_data_req; + for(i=1;i<=MAX_VARIANTS;i++) { ftdm_mutex_create(&g_sngisdn_data.ccs[i].mutex); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 163265177f..c0ee11d980 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -37,6 +37,7 @@ extern ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm); extern ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm); extern ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan); +extern ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm); void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index e7ebc8f20b..940006451a 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -873,16 +873,30 @@ int16_t sngisdn_rcv_data_req(uint16_t spId, uint8_t *buff, uint32_t length) sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); - status = signal_data->dchan->fio->wait(signal_data->dchan, &flags, 10); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_WARNING, "transmit timed-out\n"); - return -1; - } - status = signal_data->dchan->fio->write(signal_data->dchan, buff, (ftdm_size_t*)&length); - if (status != FTDM_SUCCESS) { - ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_CRIT, "Failed to transmit frame\n"); - return -1; - } + do { + flags = FTDM_WRITE; + status = signal_data->dchan->fio->wait(signal_data->dchan, &flags, 1000); + if (status != FTDM_SUCCESS) { + ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_WARNING, "transmit timed-out\n"); + return -1; + } + + + if ((flags & FTDM_WRITE)) { + status = signal_data->dchan->fio->write(signal_data->dchan, buff, (ftdm_size_t*)&length); + if (status != FTDM_SUCCESS) { + ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_CRIT, "Failed to transmit frame\n"); + return -1; + } + break; + /* On WIN32, it is possible for poll to return without FTDM_WRITE flag set, so we try to retransmit */ +#ifndef WIN32 + } else { + ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_WARNING, "Failed to poll for d-channel\n"); + return -1; +#endif + } + } while(1); return 0; } diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index 896b8eebd8..f40f2b20c7 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -115,7 +115,7 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(wanpipe_next_event); static __inline__ int tdmv_api_wait_socket(ftdm_channel_t *ftdmchan, int timeout, int *flags) { -#ifdef LIBSANGOMA_VERSION +#ifdef LIBSANGOMA_VERSION int err; uint32_t inflags = *flags; uint32_t outflags = 0; @@ -130,6 +130,7 @@ static __inline__ int tdmv_api_wait_socket(ftdm_channel_t *ftdmchan, int timeout if (err == SANG_STATUS_APIPOLL_TIMEOUT) { err = 0; } + return err; #else struct pollfd pfds[1]; From caacb24500b1294a93cea6fa5345bd9605492c99 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 15 Nov 2010 14:13:01 -0500 Subject: [PATCH 04/55] freetdm: Changes for FTDM IO commands --- libs/freetdm/src/ftdm_io.c | 3 + .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 10 +- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 8 +- .../ftmod_sangoma_isdn_stack_cfg.c | 347 +++++++++--------- .../ftmod_sangoma_isdn_stack_out.c | 63 +++- .../src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 51 ++- libs/freetdm/src/include/private/ftdm_core.h | 40 ++ 7 files changed, 329 insertions(+), 193 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 1ede703a41..15e853236d 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -56,6 +56,9 @@ #define FTDM_READ_TRACE_INDEX 0 #define FTDM_WRITE_TRACE_INDEX 1 +ftdm_time_t time_last_throttle_log = 0; +ftdm_time_t time_current_throttle_log = 0; + static int time_is_init = 0; static void time_init(void) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 98b09e9305..5142de5211 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -242,10 +242,10 @@ static __inline__ void ftdm_sangoma_isdn_advance_chan_states(ftdm_channel_t *ftd static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event) { + sngisdn_snd_event(span, event); switch (event) { /* Check if the span woke up from power-saving mode */ case FTDM_OOB_ALARM_CLEAR: - sngisdn_snd_event(span, SNG_L1EVENT_ALARM_OFF); if (FTDM_SPAN_IS_BRI(span)) { ftdm_channel_t *ftdmchan; sngisdn_chan_data_t *sngisdn_info; @@ -267,9 +267,6 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve ftdm_iterator_free(chaniter); } break; - case FTDM_OOB_ALARM_TRAP: - sngisdn_snd_event(span, SNG_L1EVENT_ALARM_ON); - break; default: /* Ignore other events for now */ break; @@ -327,7 +324,7 @@ static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj) len = 1000; status = ftdm_channel_read(dchan, data, &len); if (status == FTDM_SUCCESS) { - sngisdn_snd_data(span, data, len); + sngisdn_snd_data(dchan, data, len); } else { ftdm_log_chan_msg(dchan, FTDM_LOG_WARNING, "Failed to read from channel \n"); } @@ -1019,7 +1016,8 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_isdn_init) g_sngisdn_event_interface.sta.sng_q931_trc_ind = sngisdn_rcv_q931_trace; g_sngisdn_event_interface.sta.sng_cc_sta_ind = sngisdn_rcv_cc_ind; - g_sngisdn_event_interface.io.sng_data_req = sngisdn_rcv_data_req; + g_sngisdn_event_interface.io.sng_l1_data_req = sngisdn_rcv_l1_data_req; + g_sngisdn_event_interface.io.sng_l1_cmd_req = sngisdn_rcv_l1_cmd_req; for(i=1;i<=MAX_VARIANTS;i++) { ftdm_mutex_create(&g_sngisdn_data.ccs[i].mutex); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 75262c9627..7c66c38acf 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -293,8 +293,8 @@ void sngisdn_snd_reset(ftdm_channel_t *ftdmchan); void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan); void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan); void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan); -void sngisdn_snd_data(ftdm_span_t *span, uint8_t *data, ftdm_size_t len); -void sngisdn_snd_event(ftdm_span_t *span, sng_isdn_l1_event_t l1_event); +void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len); +void sngisdn_snd_event(ftdm_channel_t *span, sng_isdn_l1_event_t l1_event); /* Inbound Call Control functions */ void sngisdn_rcv_con_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces); @@ -314,7 +314,9 @@ void sngisdn_rcv_srv_ind(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces) void sngisdn_rcv_srv_cfm(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); void sngisdn_rcv_rst_cfm(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); void sngisdn_rcv_rst_ind(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); -int16_t sngisdn_rcv_data_req(uint16_t spId, uint8_t *buff, uint32_t length); +int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_isdn_l1_frame_t *l1_frame); +int16_t sngisdn_rcv_l1_cmd_req(uint16_t spId, sng_l1_cmd_t *l1_cmd); + void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event); void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c index eabaa7affc..6c75fb3a81 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c @@ -156,34 +156,34 @@ ftdm_status_t sngisdn_stack_cfg(ftdm_span_t *span) ftdm_status_t sngisdn_stack_cfg_phy_gen(void) { /*local variables*/ - L1Mngmt cfg; /*configuration structure*/ - Pst pst; /*post structure*/ + L1Mngmt cfg; /*configuration structure*/ + Pst pst; /*post structure*/ - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTL1; + /* insert the destination Entity */ + pst.dstEnt = ENTL1; - /*clear the configuration structure*/ + /*clear the configuration structure*/ memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + /*fill in some general sections of the header*/ + stack_hdr_init(&cfg.hdr); - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTL1; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; + /*fill in the specific fields of the header*/ + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTL1; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STGEN; - stack_pst_init(&cfg.t.cfg.s.l1Gen.sm ); - cfg.t.cfg.s.l1Gen.sm.srcEnt = ENTL1; - cfg.t.cfg.s.l1Gen.sm.dstEnt = ENTSM; + stack_pst_init(&cfg.t.cfg.s.l1Gen.sm ); + cfg.t.cfg.s.l1Gen.sm.srcEnt = ENTL1; + cfg.t.cfg.s.l1Gen.sm.dstEnt = ENTSM; - cfg.t.cfg.s.l1Gen.nmbLnks = MAX_L1_LINKS+1; - cfg.t.cfg.s.l1Gen.poolTrUpper = POOL_UP_TR; /* upper pool threshold */ - cfg.t.cfg.s.l1Gen.poolTrLower = POOL_LW_TR; /* lower pool threshold */ + cfg.t.cfg.s.l1Gen.nmbLnks = MAX_L1_LINKS; + cfg.t.cfg.s.l1Gen.poolTrUpper = POOL_UP_TR; /* upper pool threshold */ + cfg.t.cfg.s.l1Gen.poolTrLower = POOL_LW_TR; /* lower pool threshold */ if (sng_isdn_phy_config(&pst, &cfg)) { return FTDM_FAIL; @@ -193,38 +193,38 @@ ftdm_status_t sngisdn_stack_cfg_phy_gen(void) ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span) { - L1Mngmt cfg; - Pst pst; + L1Mngmt cfg; + Pst pst; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTL1; + /* insert the destination Entity */ + pst.dstEnt = ENTL1; - /*clear the configuration structure*/ + /*clear the configuration structure*/ memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + /*fill in some general sections of the header*/ + stack_hdr_init(&cfg.hdr); - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTL1; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STPSAP; + /*fill in the specific fields of the header*/ + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTL1; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STPSAP; cfg.hdr.elmId.elmntInst1 = signal_data->link_id; - + if (!signal_data->dchan) { ftdm_log(FTDM_LOG_ERROR, "%s:No d-channels specified\n", span->name); return FTDM_FAIL; - } + } cfg.t.cfg.s.l1PSAP.sockfd = (int32_t)signal_data->dchan->sockfd; - + switch(span->trunk_type) { case FTDM_TRUNK_E1: cfg.t.cfg.s.l1PSAP.type = SNG_L1_TYPE_PRI; @@ -240,9 +240,9 @@ ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span) default: ftdm_log(FTDM_LOG_ERROR, "%s:Unsupported trunk type %d\n", span->name, span->trunk_type); return FTDM_FAIL; - } - cfg.t.cfg.s.l1PSAP.spId = signal_data->link_id; - + } + cfg.t.cfg.s.l1PSAP.spId = signal_data->link_id; + if (sng_isdn_phy_config(&pst, &cfg)) { return FTDM_FAIL; } @@ -253,25 +253,25 @@ ftdm_status_t sngisdn_stack_cfg_phy_psap(ftdm_span_t *span) ftdm_status_t sngisdn_stack_cfg_q921_gen(void) { BdMngmt cfg; - Pst pst; + Pst pst; - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); /* insert the destination Entity */ - pst.dstEnt = ENTLD; + pst.dstEnt = ENTLD; - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); + /*clear the configuration structure*/ + memset(&cfg, 0, sizeof(cfg)); /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); - - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTLD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; - /* fill in the Gen Conf structures internal pst struct */ + stack_hdr_init(&cfg.hdr); - stack_pst_init(&cfg.t.cfg.s.bdGen.sm); + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTLD; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STGEN; + /* fill in the Gen Conf structures internal pst struct */ + + stack_pst_init(&cfg.t.cfg.s.bdGen.sm); cfg.t.cfg.s.bdGen.sm.dstEnt = ENTSM; /* entity */ @@ -284,8 +284,8 @@ ftdm_status_t sngisdn_stack_cfg_q921_gen(void) #ifdef LAPD_3_4 cfg.t.cfg.s.bdGen.timeRes = 100; /* timer resolution = 1 sec */ #endif - cfg.t.cfg.s.bdGen.poolTrUpper = 2; /* upper pool threshold */ - cfg.t.cfg.s.bdGen.poolTrLower = 1; /* lower pool threshold */ + cfg.t.cfg.s.bdGen.poolTrUpper = 2; /* upper pool threshold */ + cfg.t.cfg.s.bdGen.poolTrLower = 1; /* lower pool threshold */ if (sng_isdn_q921_config(&pst, &cfg)) { return FTDM_FAIL; @@ -296,27 +296,27 @@ ftdm_status_t sngisdn_stack_cfg_q921_gen(void) ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span) { BdMngmt cfg; - Pst pst; + Pst pst; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); /* insert the destination Entity */ - pst.dstEnt = ENTLD; + pst.dstEnt = ENTLD; - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); + /*clear the configuration structure*/ + memset(&cfg, 0, sizeof(cfg)); /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + stack_hdr_init(&cfg.hdr); cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTLD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STMSAP; + cfg.hdr.entId.ent = ENTLD; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STMSAP; cfg.t.cfg.s.bdMSAP.lnkNmb = signal_data->link_id; - + cfg.t.cfg.s.bdMSAP.maxOutsFrms = 24; /* MAC window */ cfg.t.cfg.s.bdMSAP.tQUpperTrs = 32; /* Tx Queue Upper Threshold */ cfg.t.cfg.s.bdMSAP.tQLowerTrs = 24; /* Tx Queue Lower Threshold */ @@ -328,7 +328,7 @@ ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span) cfg.t.cfg.s.bdMSAP.route = RTESPEC; /* Route */ cfg.t.cfg.s.bdMSAP.dstProcId = SFndProcId(); /* destination proc id */ cfg.t.cfg.s.bdMSAP.dstEnt = ENTL1; /* entity */ - cfg.t.cfg.s.bdMSAP.dstInst = S_INST; /* instance */ + cfg.t.cfg.s.bdMSAP.dstInst = S_INST; /* instance */ cfg.t.cfg.s.bdMSAP.t201Tmr = 1; /* T201 - should be equal to t200Tmr */ cfg.t.cfg.s.bdMSAP.t202Tmr = 2; /* T202 */ cfg.t.cfg.s.bdMSAP.bndRetryCnt = 2; /* bind retry counter */ @@ -377,7 +377,7 @@ ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span) if (signal_data->setup_arb == SNGISDN_OPT_TRUE) { cfg.t.cfg.s.bdMSAP.setUpArb = ACTIVE; } else if (signal_data->setup_arb == SNGISDN_OPT_FALSE) { - cfg.t.cfg.s.bdMSAP.setUpArb = PASSIVE; + cfg.t.cfg.s.bdMSAP.setUpArb = PASSIVE; } if (sng_isdn_q921_config(&pst, &cfg)) { @@ -389,24 +389,24 @@ ftdm_status_t sngisdn_stack_cfg_q921_msap(ftdm_span_t *span) ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management) { BdMngmt cfg; - Pst pst; + Pst pst; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); /* insert the destination Entity */ - pst.dstEnt = ENTLD; + pst.dstEnt = ENTLD; - /*clear the configuration structure*/ - memset(&cfg, 0, sizeof(cfg)); + /*clear the configuration structure*/ + memset(&cfg, 0, sizeof(cfg)); /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + stack_hdr_init(&cfg.hdr); /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTLD; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLSAP; + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTLD; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STDLSAP; cfg.t.cfg.s.bdDLSAP.lnkNmb = signal_data->link_id; @@ -418,10 +418,10 @@ ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management } else { cfg.t.cfg.s.bdDLSAP.k = 7; /* k */ } - + cfg.t.cfg.s.bdDLSAP.n200 = 3; /* n200 */ cfg.t.cfg.s.bdDLSAP.congTmr = 300; /* congestion timer */ - cfg.t.cfg.s.bdDLSAP.t200Tmr = 1; /* t1 changed from 25 */ + cfg.t.cfg.s.bdDLSAP.t200Tmr = 1; /* t1 changed from 25 */ cfg.t.cfg.s.bdDLSAP.t203Tmr = 10; /* t3 changed from 50 */ cfg.t.cfg.s.bdDLSAP.mod = 128; /* modulo */ cfg.t.cfg.s.bdDLSAP.selector = 0; /* Selector 0 */ @@ -471,28 +471,28 @@ ftdm_status_t sngisdn_stack_cfg_q921_dlsap(ftdm_span_t *span, uint8_t management ftdm_status_t sngisdn_stack_cfg_q931_gen(void) { InMngmt cfg; - Pst pst; + Pst pst; - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTIN; + /* insert the destination Entity */ + pst.dstEnt = ENTIN; - /*clear the configuration structure*/ + /*clear the configuration structure*/ memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + /*fill in some general sections of the header*/ + stack_hdr_init(&cfg.hdr); - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STGEN; + /*fill in the specific fields of the header*/ + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTIN; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STGEN; - /* fill in the Gen Conf structures internal pst struct */ - stack_pst_init(&cfg.t.cfg.s.inGen.sm); + /* fill in the Gen Conf structures internal pst struct */ + stack_pst_init(&cfg.t.cfg.s.inGen.sm); cfg.t.cfg.s.inGen.nmbSaps = MAX_VARIANTS+1; /* Total number of variants supported */ @@ -526,26 +526,26 @@ ftdm_status_t sngisdn_stack_cfg_q931_gen(void) ftdm_status_t sngisdn_stack_cfg_q931_tsap(ftdm_span_t *span) { InMngmt cfg; - Pst pst; + Pst pst; unsigned i; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTIN; + /* insert the destination Entity */ + pst.dstEnt = ENTIN; - /*clear the configuration structure*/ + /*clear the configuration structure*/ memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + /*fill in some general sections of the header*/ + stack_hdr_init(&cfg.hdr); - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STTSAP; + /*fill in the specific fields of the header*/ + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTIN; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STTSAP; cfg.t.cfg.s.inTSAP.sapId = signal_data->cc_id; @@ -589,31 +589,31 @@ ftdm_status_t sngisdn_stack_cfg_q931_tsap(ftdm_span_t *span) ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) { InMngmt cfg; - Pst pst; + Pst pst; unsigned i; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTIN; + /* insert the destination Entity */ + pst.dstEnt = ENTIN; - /*clear the configuration structure*/ + /*clear the configuration structure*/ memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + /*fill in some general sections of the header*/ + stack_hdr_init(&cfg.hdr); + + /*fill in the specific fields of the header*/ + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTIN; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STDLSAP; - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLSAP; - cfg.hdr.response.selector=0; - + cfg.t.cfg.s.inDLSAP.sapId = signal_data->link_id; cfg.t.cfg.s.inDLSAP.spId = signal_data->link_id; cfg.t.cfg.s.inDLSAP.swtch = sng_isdn_stack_switchtype(signal_data->switchtype); @@ -659,7 +659,7 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) cfg.t.cfg.s.inDLSAP.ctldInt[1] = 1; } - cfg.t.cfg.s.inDLSAP.numRstInd = 255; + cfg.t.cfg.s.inDLSAP.numRstInd = 255; cfg.t.cfg.s.inDLSAP.relOpt = TRUE; #ifdef ISDN_SRV cfg.t.cfg.s.inDLSAP.bcas = FALSE; @@ -839,36 +839,36 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) { InMngmt cfg; - Pst pst; + Pst pst; uint8_t i; - uint8_t numCes=1; + uint8_t numCes=1; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*)span->signal_data; if (span->trunk_type == FTDM_TRUNK_BRI_PTMP && signal_data->signalling == SNGISDN_SIGNALING_NET) { numCes = 8; } - /* initalize the post structure */ - stack_pst_init(&pst); + /* initalize the post structure */ + stack_pst_init(&pst); - /* insert the destination Entity */ - pst.dstEnt = ENTIN; + /* insert the destination Entity */ + pst.dstEnt = ENTIN; - /*clear the configuration structure*/ + /*clear the configuration structure*/ memset(&cfg, 0, sizeof(cfg)); - /*fill in some general sections of the header*/ - stack_hdr_init(&cfg.hdr); + /*fill in some general sections of the header*/ + stack_hdr_init(&cfg.hdr); - /*fill in the specific fields of the header*/ - cfg.hdr.msgType = TCFG; - cfg.hdr.entId.ent = ENTIN; - cfg.hdr.entId.inst = S_INST; - cfg.hdr.elmId.elmnt = STDLC; + /*fill in the specific fields of the header*/ + cfg.hdr.msgType = TCFG; + cfg.hdr.entId.ent = ENTIN; + cfg.hdr.entId.inst = S_INST; + cfg.hdr.elmId.elmnt = STDLC; cfg.hdr.response.selector=0; cfg.t.cfg.s.inLCe.sapId = signal_data->link_id; - + cfg.t.cfg.s.inLCe.lnkUpDwnInd = TRUE; cfg.t.cfg.s.inLCe.tCon.enb = TRUE; @@ -877,7 +877,7 @@ ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) cfg.t.cfg.s.inLCe.tDisc.val = 35; cfg.t.cfg.s.inLCe.t314.enb = FALSE; /* if segmentation enabled, set to TRUE */ cfg.t.cfg.s.inLCe.t314.val = 35; - + cfg.t.cfg.s.inLCe.t332i.enb = FALSE; /* set to TRUE for NFAS */ #ifdef NFAS @@ -897,7 +897,6 @@ ftdm_status_t sngisdn_stack_cfg_q931_lce(ftdm_span_t *span) cfg.t.cfg.s.inLCe.tRstAck.enb = TRUE; cfg.t.cfg.s.inLCe.tRstAck.val = 10; - cfg.t.cfg.s.inLCe.usid = 0; cfg.t.cfg.s.inLCe.tid = 0; @@ -983,11 +982,11 @@ ftdm_status_t sngisdn_stack_cfg_cc_sap(ftdm_span_t *span) cfg.t.cfg.s.ccISAP.pst.dstInst = S_INST; cfg.t.cfg.s.ccISAP.pst.dstProcId = SFndProcId(); - cfg.t.cfg.s.ccISAP.pst.prior = PRIOR0; - cfg.t.cfg.s.ccISAP.pst.route = RTESPEC; - cfg.t.cfg.s.ccISAP.pst.region = S_REG; - cfg.t.cfg.s.ccISAP.pst.pool = S_POOL; - cfg.t.cfg.s.ccISAP.pst.selector = 0; + cfg.t.cfg.s.ccISAP.pst.prior = PRIOR0; + cfg.t.cfg.s.ccISAP.pst.route = RTESPEC; + cfg.t.cfg.s.ccISAP.pst.region = S_REG; + cfg.t.cfg.s.ccISAP.pst.pool = S_POOL; + cfg.t.cfg.s.ccISAP.pst.selector = 0; cfg.t.cfg.s.ccISAP.suId = signal_data->cc_id; cfg.t.cfg.s.ccISAP.spId = signal_data->cc_id; @@ -1005,19 +1004,19 @@ ftdm_status_t sngisdn_stack_cfg_cc_sap(ftdm_span_t *span) void stack_pst_init(Pst *pst) { memset(pst, 0, sizeof(Pst)); - /*fill in the post structure*/ - pst->dstProcId = SFndProcId(); - pst->dstInst = S_INST; + /*fill in the post structure*/ + pst->dstProcId = SFndProcId(); + pst->dstInst = S_INST; - pst->srcProcId = SFndProcId(); - pst->srcEnt = ENTSM; - pst->srcInst = S_INST; + pst->srcProcId = SFndProcId(); + pst->srcEnt = ENTSM; + pst->srcInst = S_INST; - pst->prior = PRIOR0; - pst->route = RTESPEC; - pst->region = S_REG; - pst->pool = S_POOL; - pst->selector = 0; + pst->prior = PRIOR0; + pst->route = RTESPEC; + pst->region = S_REG; + pst->pool = S_POOL; + pst->selector = 0; return; } @@ -1026,21 +1025,21 @@ void stack_pst_init(Pst *pst) void stack_hdr_init(Header *hdr) { hdr->msgType = 0; - hdr->msgLen = 0; - hdr->entId.ent = 0; - hdr->entId.inst = 0; - hdr->elmId.elmnt = 0; - hdr->elmId.elmntInst1 = 0; - hdr->elmId.elmntInst2 = 0; - hdr->elmId.elmntInst3 = 0; - hdr->seqNmb = 0; - hdr->version = 0; - hdr->response.prior = PRIOR0; - hdr->response.route = RTESPEC; - hdr->response.mem.region = S_REG; - hdr->response.mem.pool = S_POOL; - hdr->transId = 0; - hdr->response.selector = 0; + hdr->msgLen = 0; + hdr->entId.ent = 0; + hdr->entId.inst = 0; + hdr->elmId.elmnt = 0; + hdr->elmId.elmntInst1 = 0; + hdr->elmId.elmntInst2 = 0; + hdr->elmId.elmntInst3 = 0; + hdr->seqNmb = 0; + hdr->version = 0; + hdr->response.prior = PRIOR0; + hdr->response.route = RTESPEC; + hdr->response.mem.region = S_REG; + hdr->response.mem.pool = S_POOL; + hdr->transId = 0; + hdr->response.selector = 0; return; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index c0ee11d980..94bd6e23e1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -595,16 +595,65 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) return; } -void sngisdn_snd_data(ftdm_span_t *span, uint8_t *data, ftdm_size_t len) +/* We received an incoming frame on the d-channel, send data to the stack */ +void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) { - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - sng_isdn_data_ind(signal_data->link_id, data, len); + l1_frame_t l1_frame; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; + + memset(&l1_frame, 0, sizeof(l1_frame)); + l1_frame.len = len; + + memcpy(&l1_frame.data, data, len); + + if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_CRC)) { + l1_frame.flags |= SNG_L1FRAME_ERROR_CRC; + } + + if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_FRAME)) { + l1_frame.flags |= SNG_L1FRAME_ERROR_FRAME; + } + + if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_ABORT)) { + l1_frame.flags |= SNG_L1FRAME_ERROR_ABORT; + } + + if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_FIFO)) { + l1_frame.flags |= SNG_L1FRAME_ERROR_FIFO; + } + + if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_DMA)) { + l1_frame.flags |= SNG_L1FRAME_ERROR_DMA; + } + + if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_QUEUE_THRES)) { + /* Should we trigger congestion here? */ + l1_frame.flags |= SNG_L1FRAME_QUEUE_THRES; + } + + if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_QUEUE_FULL)) { + /* Should we trigger congestion here? */ + l1_frame.flags |= SNG_L1FRAME_QUEUE_FULL; + } + + sng_isdn_data_ind(signal_data->link_id, &l1_frame); } -void sngisdn_snd_event(ftdm_span_t *span, sng_isdn_l1_event_t l1_event) -{ - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - sng_isdn_event_ind(signal_data->link_id, l1_event); +void sngisdn_snd_event(ftdm_channel_t *dchan, ftdm_oob_event_t event) +{ + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; + switch(event) { + case FTDM_OOB_ALARM_CLEAR: + sng_isdn_event_ind(signal_data->link_id, SNG_L1EVENT_ALARM_OFF); + break; + case FTDM_OOB_ALARM_TRAP: + sng_isdn_event_ind(signal_data->link_id, SNG_L1EVENT_ALARM_ON); + break; + default: + /* We do not care about the other OOB events for now */ + return; + } + return; } diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index f40f2b20c7..d6573ac2de 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -170,7 +170,7 @@ static __inline__ sng_fd_t tdmv_api_open_span_chan(int span, int chan) static __inline__ sng_fd_t __tdmv_api_open_span_chan(int span, int chan) { return __sangoma_open_tdmapi_span_chan(span, chan); -} +} #endif static ftdm_io_interface_t wanpipe_interface; @@ -759,6 +759,49 @@ static FIO_COMMAND_FUNCTION(wanpipe_command) return FTDM_SUCCESS; } +static void wanpipe_read_stats(ftdmchan, wp_tdm_api_rx_hdr_t *rx_stats) +{ + ftdmchan->iostats.s.rx.error_flags = 0; + if (rx_stats->rx_hdr_errors) { + wanpipe_reset_stats(ftdmchan); + ftdm_log_chan_msg_throttle(ftdmchan, "IO errors\n"); + } + + ftdmchan->iostats.s.rx_queue_size = rx_stats->rx_h.rx_h.max_rx_queue_length; + ftdmchan->iostats.s.rx_queue_len = rx_stats->rx_h.current_number_of_frames_in_rx_queue; + + if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_ABORT); + } + if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_DMA); + } + if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_FIFO); + } + if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_CRC); + } + if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_FRAME); + } + + if (ftdmchan->iostats.s.rx_queue_len >= (0.8*ftdmchan->iostats.s.rx_queue_size)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Rx Queue length exceeded threshold (%d/%d)\n", + ftdmchan->iostats.s.rx_queue_len, ftdmchan->iostats.s.rx_queue_size); + + ftdm_set_flag(&(ftdmchan->iostats.s.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); + } + + if (ftdmchan->iostats.s.rx_queue_len >= ftdmchan->iostats.s.rx_queue_size) { + ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Rx Queue Full (%d/%d)\n", + ftdmchan->iostats.s.rx_queue_len, ftdmchan->iostats.s.rx_queue_size); + + ftdm_set_flag(&(ftdmchan->iostats.s.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); + } + return; +} + /** * \brief Reads data from a Wanpipe channel * \param ftdmchan Channel to read from @@ -787,9 +830,11 @@ static FIO_READ_FUNCTION(wanpipe_read) snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "%s", strerror(errno)); ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Failed to read from sangoma device: %s (%d)\n", strerror(errno), rx_len); return FTDM_FAIL; - } - + } + if (ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS)) { + wanpipe_read_stats(ftdmchan, &hdrframe); + } return FTDM_SUCCESS; } diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h index c5f3c4b821..6cbf589044 100644 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ b/libs/freetdm/src/include/private/ftdm_core.h @@ -357,6 +357,7 @@ typedef struct { } ftdm_dtmf_debug_t; #endif + typedef struct { const char *file; const char *func; @@ -366,6 +367,33 @@ typedef struct { ftdm_time_t time; } ftdm_channel_history_entry_t; +typedef enum { + FTDM_IOSTATS_ERROR_CRC = (1<<0), + FTDM_IOSTATS_ERROR_FRAME = (1<<1), + FTDM_IOSTATS_ERROR_ABORT = (1<<2), + FTDM_IOSTATS_ERROR_FIFO = (1<<3), + FTDM_IOSTATS_ERROR_DMA = (1<<4), + FTDM_IOSTATS_ERROR_QUEUE_THRES = (1<<5), /* Queue reached high threshold */ + FTDM_IOSTATS_ERROR_QUEUE_FULL = (1<<6), /* Queue is full */ +} ftdm_iostats_error_type_t; + +typedef struct { + union { + struct { + uint32_t errors; + uint16_t flags; + uint8_t rx_queue_size; /* max queue size configured */ + uint8_t rx_queue_len; /* Current number of elements in queue */ + } rx; + struct { + uint32_t errors; + uint16_t flags; + uint8_t tx_queue_size; /* max queue size configured */ + uint8_t tx_queue_len; /* Current number of elements in queue */ + } tx; + } s; +} ftdm_channel_iostats_t; + /* 2^8 table size, one for each byte (sample) value */ #define FTDM_GAINS_TABLE_SIZE 256 struct ftdm_channel { @@ -438,6 +466,7 @@ struct ftdm_channel { int availability_rate; void *user_private; ftdm_timer_id_t hangup_timer; + ftdm_channel_iostats_t iostats; #ifdef FTDM_DEBUG_DTMF ftdm_dtmf_debug_t dtmfdbg; #endif @@ -632,10 +661,21 @@ FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan); #define ftdm_channel_lock(chan) ftdm_mutex_lock(chan->mutex) #define ftdm_channel_unlock(chan) ftdm_mutex_unlock(chan->mutex) + +#define ftdm_log_throttle(level, ...) \ + time_current_throttle_log = ftdm_current_time_in_ms(); \ + if (time_current_throttle_log - time_last_throttle_log > FTDM_THROTTLE_LOG_INTERVAL) {\ + ftdm_log(level, __VA_ARGS__); \ + time_last_throttle_log = time_current_throttle_log; \ + } + #define ftdm_log_chan_ex(fchan, file, func, line, level, format, ...) ftdm_log(file, func, line, level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) #define ftdm_log_chan(fchan, level, format, ...) ftdm_log(level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) #define ftdm_log_chan_msg(fchan, level, msg) ftdm_log(level, "[s%dc%d][%d:%d] " msg, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id) +#define ftdm_log_chan_throttle(fchan, level, format, ...) ftdm_log_throttle(level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) +#define ftdm_log_chan_msg_throttle(fchan, level, format, ...) ftdm_log_throttle(level, "[s%dc%d][%d:%d] " format, fchan->span_id, fchan->chan_id, fchan->physical_span_id, fchan->physical_chan_id, __VA_ARGS__) + #define ftdm_span_lock(span) ftdm_mutex_lock(span->mutex) #define ftdm_span_unlock(span) ftdm_mutex_unlock(span->mutex) From a2add139638907d3c36ee935c2f0b51db7821fd0 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Mon, 15 Nov 2010 19:16:09 -0500 Subject: [PATCH 05/55] freetdm:Changes for shared IO --- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 51 +++++++++++--- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 5 +- .../ftmod_sangoma_isdn_stack_out.c | 28 +++++--- .../ftmod_sangoma_isdn_stack_rcv.c | 47 ++++++++++++- .../src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 67 ++++++++++++------- libs/freetdm/src/include/freetdm.h | 5 +- libs/freetdm/src/include/private/ftdm_core.h | 2 +- libs/freetdm/src/include/private/ftdm_types.h | 1 + 8 files changed, 153 insertions(+), 53 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 5142de5211..674fea21c5 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -51,6 +51,8 @@ static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span); static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event); static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan); static void ftdm_sangoma_isdn_process_stack_event (ftdm_span_t *span, sngisdn_event_data_t *sngisdn_event); +static void ftdm_sangoma_isdn_wakeup_phy(ftdm_channel_t *dchan); +static void ftdm_sangoma_isdn_dchan_set_queue_size(ftdm_channel_t *ftdmchan); static ftdm_io_interface_t g_sngisdn_io_interface; static sng_isdn_event_interface_t g_sngisdn_event_interface; @@ -241,8 +243,9 @@ static __inline__ void ftdm_sangoma_isdn_advance_chan_states(ftdm_channel_t *ftd static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_event_t event) { - - sngisdn_snd_event(span, event); + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; + sngisdn_snd_event(signal_data->dchan, event); + switch (event) { /* Check if the span woke up from power-saving mode */ case FTDM_OOB_ALARM_CLEAR: @@ -251,8 +254,7 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve sngisdn_chan_data_t *sngisdn_info; ftdm_iterator_t *chaniter = NULL; ftdm_iterator_t *curr = NULL; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; - + chaniter = ftdm_span_get_chan_iterator(span, NULL); for (curr = chaniter; curr; curr = ftdm_iterator_next(curr)) { ftdmchan = (ftdm_channel_t*)ftdm_iterator_current(curr); @@ -261,7 +263,7 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve if (ftdm_test_flag(sngisdn_info, FLAG_ACTIVATING)) { ftdm_clear_flag(sngisdn_info, FLAG_ACTIVATING); - ftdm_sched_timer(signal_data->sched, "delayed_setup", 1, sngisdn_delayed_setup, (void*) ftdmchan->call_data, NULL); + ftdm_sched_timer(signal_data->sched, "delayed_setup", 1000, sngisdn_delayed_setup, (void*) ftdmchan->call_data, NULL); } } ftdm_iterator_free(chaniter); @@ -276,9 +278,7 @@ static void ftdm_sangoma_isdn_process_phy_events(ftdm_span_t *span, ftdm_oob_eve static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span) { ftdm_status_t ret_status; - ftdm_iterator_t *chaniter = NULL; - ftdm_iterator_t *curr = NULL; - + ret_status = ftdm_span_poll_event(span, 0, NULL); switch(ret_status) { case FTDM_SUCCESS: @@ -297,6 +297,33 @@ static void ftdm_sangoma_isdn_poll_events(ftdm_span_t *span) } } +static void ftdm_sangoma_isdn_dchan_set_queue_size(ftdm_channel_t *dchan) +{ + ftdm_status_t ret_status; + uint32_t queue_size; + + queue_size = SNGISDN_DCHAN_QUEUE_LEN; + ret_status = ftdm_channel_command(dchan, FTDM_COMMAND_SET_RX_QUEUE_SIZE, &queue_size); + ftdm_assert(ret_status == FTDM_SUCCESS, "Failed to set Rx Queue size"); + + queue_size = SNGISDN_DCHAN_QUEUE_LEN; + ret_status = ftdm_channel_command(dchan, FTDM_COMMAND_SET_TX_QUEUE_SIZE, &queue_size); + ftdm_assert(ret_status == FTDM_SUCCESS, "Failed to set Tx Queue size"); + + RETVOID; +} + +static void ftdm_sangoma_isdn_wakeup_phy(ftdm_channel_t *dchan) +{ + ftdm_status_t ret_status; + ftdm_channel_hw_link_status_t status = FTDM_HW_LINK_CONNECTED; + ret_status = ftdm_channel_command(dchan, FTDM_COMMAND_SET_LINK_STATUS, &status); + if (ret_status != FTDM_SUCCESS) { + ftdm_log_chan_msg(dchan, FTDM_LOG_WARNING, "Failed to wake-up link\n"); + } + return; +} + static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj) { uint8_t data[1000]; @@ -306,7 +333,9 @@ static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj) ftdm_channel_t *dchan = ((sngisdn_span_data_t*)span->signal_data)->dchan; ftdm_size_t len = 0; - + ftdm_channel_set_feature(dchan, FTDM_CHANNEL_FEATURE_IO_STATS); + ftdm_sangoma_isdn_dchan_set_queue_size(dchan); + ftdm_assert(dchan, "Span does not have a dchannel"); ftdm_channel_open_chan(dchan); @@ -597,8 +626,8 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Requesting Line activation\n"); - sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); - sngisdn_wake_up_phy(ftdmchan->span); + sngisdn_set_flag(sngisdn_info, FLAG_ACTIVATING); + ftdm_sangoma_isdn_wakeup_phy(ftdmchan); ftdm_sched_timer(signal_data->sched, "timer_t3", signal_data->timer_t3*1000, sngisdn_t3_timeout, (void*) sngisdn_info, NULL); } else { sngisdn_snd_setup(ftdmchan); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 7c66c38acf..8208aa14bd 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -60,6 +60,7 @@ #define SNGISDN_EVENT_QUEUE_SIZE 100 #define SNGISDN_EVENT_POLL_RATE 100 #define SNGISDN_NUM_LOCAL_NUMBERS 8 +#define SNGISDN_DCHAN_QUEUE_LEN 200 /* TODO: rename all *_cc_* to *_an_* */ @@ -294,7 +295,7 @@ void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan); void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan); void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan); void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len); -void sngisdn_snd_event(ftdm_channel_t *span, sng_isdn_l1_event_t l1_event); +void sngisdn_snd_event(ftdm_channel_t *dchan, ftdm_oob_event_t event); /* Inbound Call Control functions */ void sngisdn_rcv_con_ind(int16_t suId, uint32_t suInstId, uint32_t spInstId, ConEvnt *conEvnt, int16_t dChan, uint8_t ces); @@ -314,7 +315,7 @@ void sngisdn_rcv_srv_ind(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces) void sngisdn_rcv_srv_cfm(int16_t suId, Srv *srvEvnt, int16_t dChan, uint8_t ces); void sngisdn_rcv_rst_cfm(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); void sngisdn_rcv_rst_ind(int16_t suId, Rst *rstEvnt, int16_t dChan, uint8_t ces, uint8_t evntType); -int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_isdn_l1_frame_t *l1_frame); +int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_l1_frame_t *l1_frame); int16_t sngisdn_rcv_l1_cmd_req(uint16_t spId, sng_l1_cmd_t *l1_cmd); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 94bd6e23e1..8842ef5934 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -598,7 +598,7 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) /* We received an incoming frame on the d-channel, send data to the stack */ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) { - l1_frame_t l1_frame; + sng_l1_frame_t l1_frame; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; memset(&l1_frame, 0, sizeof(l1_frame)); @@ -606,32 +606,32 @@ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) memcpy(&l1_frame.data, data, len); - if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_CRC)) { + if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_CRC)) { l1_frame.flags |= SNG_L1FRAME_ERROR_CRC; } - if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_FRAME)) { + if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_FRAME)) { l1_frame.flags |= SNG_L1FRAME_ERROR_FRAME; } - if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_ABORT)) { + if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_ABORT)) { l1_frame.flags |= SNG_L1FRAME_ERROR_ABORT; } - if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_FIFO)) { + if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_FIFO)) { l1_frame.flags |= SNG_L1FRAME_ERROR_FIFO; } - if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_ERROR_DMA)) { + if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_DMA)) { l1_frame.flags |= SNG_L1FRAME_ERROR_DMA; } - if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_QUEUE_THRES)) { + if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES)) { /* Should we trigger congestion here? */ l1_frame.flags |= SNG_L1FRAME_QUEUE_THRES; } - if (ftdm_test_flag(&(dchan->iostats.s.rx), FTDM_IOSTATS_QUEUE_FULL)) { + if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL)) { /* Should we trigger congestion here? */ l1_frame.flags |= SNG_L1FRAME_QUEUE_FULL; } @@ -640,14 +640,20 @@ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) } void sngisdn_snd_event(ftdm_channel_t *dchan, ftdm_oob_event_t event) -{ +{ + sng_l1_event_t l1_event; + memset(&l1_event, 0, sizeof(l1_event)); + + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; switch(event) { case FTDM_OOB_ALARM_CLEAR: - sng_isdn_event_ind(signal_data->link_id, SNG_L1EVENT_ALARM_OFF); + l1_event.type = SNG_L1EVENT_ALARM_OFF; + sng_isdn_event_ind(signal_data->link_id, &l1_event); break; case FTDM_OOB_ALARM_TRAP: - sng_isdn_event_ind(signal_data->link_id, SNG_L1EVENT_ALARM_ON); + l1_event.type = SNG_L1EVENT_ALARM_ON; + sng_isdn_event_ind(signal_data->link_id, &l1_event); break; default: /* We do not care about the other OOB events for now */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index 940006451a..e3898b9096 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -866,13 +866,15 @@ end_of_trace: return; } -int16_t sngisdn_rcv_data_req(uint16_t spId, uint8_t *buff, uint32_t length) +/* The stacks is wants to transmit a frame */ +int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_l1_frame_t *l1_frame) { ftdm_status_t status; ftdm_wait_flag_t flags = FTDM_WRITE; sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); - + ftdm_size_t length = l1_frame->len; + do { flags = FTDM_WRITE; status = signal_data->dchan->fio->wait(signal_data->dchan, &flags, 1000); @@ -883,7 +885,7 @@ int16_t sngisdn_rcv_data_req(uint16_t spId, uint8_t *buff, uint32_t length) if ((flags & FTDM_WRITE)) { - status = signal_data->dchan->fio->write(signal_data->dchan, buff, (ftdm_size_t*)&length); + status = signal_data->dchan->fio->write(signal_data->dchan, l1_frame->data, (ftdm_size_t*)&length); if (status != FTDM_SUCCESS) { ftdm_log_chan_msg(signal_data->dchan, FTDM_LOG_CRIT, "Failed to transmit frame\n"); return -1; @@ -900,6 +902,45 @@ int16_t sngisdn_rcv_data_req(uint16_t spId, uint8_t *buff, uint32_t length) return 0; } +int16_t sngisdn_rcv_l1_cmd_req(uint16_t spId, sng_l1_cmd_t *l1_cmd) +{ + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; + ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); + + switch(l1_cmd->type) { + case SNG_L1CMD_SET_LINK_STATUS: + { + ftdm_channel_hw_link_status_t status = FTDM_HW_LINK_CONNECTED; + ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_SET_LINK_STATUS, &status); + } + break; + case SNG_L1CMD_GET_LINK_STATUS: + { + ftdm_channel_hw_link_status_t status = 0; + ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_GET_LINK_STATUS, &status); + if (status == FTDM_HW_LINK_CONNECTED) { + l1_cmd->cmd.status = 1; + } else if (status == FTDM_HW_LINK_DISCONNECTED) { + l1_cmd->cmd.status = 0; + } else { + ftdm_log_chan(signal_data->dchan, FTDM_LOG_CRIT, "Invalid link status reported %d\n", status); + l1_cmd->cmd.status = 0; + } + } + break; + case SNG_L1CMD_FLUSH_STATS: + ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_FLUSH_IOSTATS, NULL); + break; + case SNG_L1CMD_FLUSH_BUFFERS: + ftdm_channel_command(signal_data->dchan, FTDM_COMMAND_FLUSH_BUFFERS, NULL); + break; + default: + ftdm_log_chan(signal_data->dchan, FTDM_LOG_CRIT, "Unsupported channel command:%d\n", l1_cmd->type); + return -1; + } + return 0; +} + void sngisdn_rcv_sng_assert(char *message) { ftdm_assert(0, message); diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index d6573ac2de..f9fbb5c044 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -746,6 +746,28 @@ static FIO_COMMAND_FUNCTION(wanpipe_command) } } break; + case FTDM_COMMAND_FLUSH_BUFFERS: + { + err = sangoma_flush_bufs(ftdmchan->sockfd, &tdm_api); + } + break; + case FTDM_COMMAND_FLUSH_IOSTATS: + { + err = sangoma_flush_stats(ftdmchan->sockfd, &tdm_api); + } + break; + case FTDM_COMMAND_SET_RX_QUEUE_SIZE: + { + uint32_t queue_size = FTDM_COMMAND_OBJ_INT; + err = sangoma_set_rx_queue_sz(ftdmchan->sockfd, &tdm_api, queue_size); + } + break; + case FTDM_COMMAND_SET_TX_QUEUE_SIZE: + { + uint32_t queue_size = FTDM_COMMAND_OBJ_INT; + err = sangoma_set_tx_queue_sz(ftdmchan->sockfd, &tdm_api, queue_size); + } + break; default: break; }; @@ -759,45 +781,42 @@ static FIO_COMMAND_FUNCTION(wanpipe_command) return FTDM_SUCCESS; } -static void wanpipe_read_stats(ftdmchan, wp_tdm_api_rx_hdr_t *rx_stats) +static void wanpipe_read_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_rx_hdr_t *rx_stats) { - ftdmchan->iostats.s.rx.error_flags = 0; - if (rx_stats->rx_hdr_errors) { - wanpipe_reset_stats(ftdmchan); - ftdm_log_chan_msg_throttle(ftdmchan, "IO errors\n"); - } + ftdmchan->iostats.stats.rx.flags = 0; - ftdmchan->iostats.s.rx_queue_size = rx_stats->rx_h.rx_h.max_rx_queue_length; - ftdmchan->iostats.s.rx_queue_len = rx_stats->rx_h.current_number_of_frames_in_rx_queue; + ftdmchan->iostats.stats.rx.errors = rx_stats->wp_api_rx_hdr_errors; + ftdmchan->iostats.stats.rx.rx_queue_size = rx_stats->wp_api_rx_hdr_max_queue_length; + ftdmchan->iostats.stats.rx.rx_queue_len = rx_stats->wp_api_rx_hdr_number_of_frames_in_queue; - if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_ABORT); + if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_ABORT); } - if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_DMA); + if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_DMA); } - if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_FIFO); + if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_FIFO); } - if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_CRC); + if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_CRC); } - if (rx_stats->rx_h.wp_api_rx_hdr_error_map & (1<iostats.s.rx), FTDM_IOSTATS_ERROR_FRAME); + if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_FRAME); } - if (ftdmchan->iostats.s.rx_queue_len >= (0.8*ftdmchan->iostats.s.rx_queue_size)) { + if (ftdmchan->iostats.stats.rx.rx_queue_len >= (0.8*ftdmchan->iostats.stats.rx.rx_queue_size)) { ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Rx Queue length exceeded threshold (%d/%d)\n", - ftdmchan->iostats.s.rx_queue_len, ftdmchan->iostats.s.rx_queue_size); + ftdmchan->iostats.stats.rx.rx_queue_len, ftdmchan->iostats.stats.rx.rx_queue_size); - ftdm_set_flag(&(ftdmchan->iostats.s.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); + ftdm_set_flag(&(ftdmchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); } - if (ftdmchan->iostats.s.rx_queue_len >= ftdmchan->iostats.s.rx_queue_size) { + if (ftdmchan->iostats.stats.rx.rx_queue_len >= ftdmchan->iostats.stats.rx.rx_queue_size) { ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Rx Queue Full (%d/%d)\n", - ftdmchan->iostats.s.rx_queue_len, ftdmchan->iostats.s.rx_queue_size); + ftdmchan->iostats.stats.rx.rx_queue_len, ftdmchan->iostats.stats.rx.rx_queue_size); - ftdm_set_flag(&(ftdmchan->iostats.s.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); + ftdm_set_flag(&(ftdmchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); } return; } diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 64ecc2e357..52a5456df1 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -430,12 +430,15 @@ typedef enum { FTDM_COMMAND_FLUSH_TX_BUFFERS, FTDM_COMMAND_FLUSH_RX_BUFFERS, FTDM_COMMAND_FLUSH_BUFFERS, + FTDM_COMMAND_FLUSH_IOSTATS, FTDM_COMMAND_SET_PRE_BUFFER_SIZE, FTDM_COMMAND_SET_LINK_STATUS, FTDM_COMMAND_GET_LINK_STATUS, FTDM_COMMAND_ENABLE_LOOP, FTDM_COMMAND_DISABLE_LOOP, - FTDM_COMMAND_COUNT + FTDM_COMMAND_COUNT, + FTDM_COMMAND_SET_RX_QUEUE_SIZE, + FTDM_COMMAND_SET_TX_QUEUE_SIZE, } ftdm_command_t; /*! \brief Custom memory handler hooks. Not recommended to use unless you need memory allocation customizations */ diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h index 6cbf589044..c7a1533320 100644 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ b/libs/freetdm/src/include/private/ftdm_core.h @@ -391,7 +391,7 @@ typedef struct { uint8_t tx_queue_size; /* max queue size configured */ uint8_t tx_queue_len; /* Current number of elements in queue */ } tx; - } s; + } stats; } ftdm_channel_iostats_t; /* 2^8 table size, one for each byte (sample) value */ diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index 78ac8f63eb..d9cefc3c6f 100644 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ b/libs/freetdm/src/include/private/ftdm_types.h @@ -194,6 +194,7 @@ typedef enum { FTDM_CHANNEL_FEATURE_CALLWAITING = (1 << 6), /*!< Channel will allow call waiting (ie: FXS devices) (read/write) */ FTDM_CHANNEL_FEATURE_HWEC = (1<<7), /*!< Channel has a hardware echo canceller */ FTDM_CHANNEL_FEATURE_HWEC_DISABLED_ON_IDLE = (1<<8), /*!< hardware echo canceller is disabled when there are no calls on this channel */ + FTDM_CHANNEL_FEATURE_IO_STATS = (1<<9), /*!< Channel supports IO statistics (HDLC channels only) */ } ftdm_channel_feature_t; typedef enum { From 65be57d212e601de396d57821bb499a4d802a1c7 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 16 Nov 2010 12:41:56 -0500 Subject: [PATCH 06/55] Fixed for windows compilation issues --- .../ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c | 3 ++- .../ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 8842ef5934..b0848379e9 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -642,10 +642,11 @@ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) void sngisdn_snd_event(ftdm_channel_t *dchan, ftdm_oob_event_t event) { sng_l1_event_t l1_event; + sngisdn_span_data_t *signal_data = NULL; memset(&l1_event, 0, sizeof(l1_event)); - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; + signal_data = (sngisdn_span_data_t*) dchan->span->signal_data; switch(event) { case FTDM_OOB_ALARM_CLEAR: l1_event.type = SNG_L1EVENT_ALARM_OFF; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c index e3898b9096..02e0bdf71b 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_rcv.c @@ -871,9 +871,10 @@ int16_t sngisdn_rcv_l1_data_req(uint16_t spId, sng_l1_frame_t *l1_frame) { ftdm_status_t status; ftdm_wait_flag_t flags = FTDM_WRITE; - sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; - ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); + sngisdn_span_data_t *signal_data = g_sngisdn_data.spans[spId]; ftdm_size_t length = l1_frame->len; + + ftdm_assert(signal_data, "Received Data request on unconfigured span\n"); do { flags = FTDM_WRITE; From c5070aaf52bb37ec63731e82be04f8e78057df21 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 16 Nov 2010 14:56:19 -0500 Subject: [PATCH 07/55] Fixed cyginstall.sh script --- libs/freetdm/cyginstall.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/cyginstall.sh b/libs/freetdm/cyginstall.sh index 311df939af..e2d5885c4e 100644 --- a/libs/freetdm/cyginstall.sh +++ b/libs/freetdm/cyginstall.sh @@ -5,7 +5,8 @@ fsdir=../.. set -x cp Debug/mod/*.dll $fsdir/Debug/mod/ cp mod_freetdm/Debug/*.pdb $fsdir/Debug/mod/ -cp Debug/*.dll $fsdir/Debug/mod/ +cp Debug/freetdm.dll $fsdir/Debug/ +cp Debug/ftmod_*.dll $fsdir/Debug/mod/ cp Debug/*.pdb $fsdir/Debug/mod/ #cp Debug/testsangomaboost.exe $fsdir/Debug/ echo "FRIENDLY REMINDER: RECOMPILE ftmod_wanpipe WHENEVER YOU INSTALL NEW DRIVERS" From 553255c63195ecbc87cdaa72394e425bc6a0f52a Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 19 Nov 2010 14:33:57 -0500 Subject: [PATCH 08/55] Fixed some windows compile warnings from merge --- conf/autoload_configs/callcenter.conf.xml | 1 - conf/autoload_configs/erlang_event.conf.xml | 9 - conf/autoload_configs/modules.conf.xml | 96 -- conf/autoload_configs/switch.conf.xml | 6 - conf/autoload_configs/voicemail.conf.xml | 7 +- conf/dialplan/default.xml | 845 ++---------------- conf/sip_profiles/internal.xml | 20 - conf/skinny_profiles/internal.xml | 2 +- conf/vars.xml | 2 +- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 8 +- .../ftmod_sangoma_isdn_stack_cntrl.c | 1 - .../ftmod_sangoma_isdn_support.c | 26 +- 12 files changed, 108 insertions(+), 915 deletions(-) diff --git a/conf/autoload_configs/callcenter.conf.xml b/conf/autoload_configs/callcenter.conf.xml index a069413ac6..9140193b22 100644 --- a/conf/autoload_configs/callcenter.conf.xml +++ b/conf/autoload_configs/callcenter.conf.xml @@ -13,7 +13,6 @@ - diff --git a/conf/autoload_configs/erlang_event.conf.xml b/conf/autoload_configs/erlang_event.conf.xml index 62deb84f67..ec14e21a25 100644 --- a/conf/autoload_configs/erlang_event.conf.xml +++ b/conf/autoload_configs/erlang_event.conf.xml @@ -2,16 +2,7 @@ - - - - - diff --git a/conf/autoload_configs/modules.conf.xml b/conf/autoload_configs/modules.conf.xml index f5627fe965..90d66f5798 100644 --- a/conf/autoload_configs/modules.conf.xml +++ b/conf/autoload_configs/modules.conf.xml @@ -1,113 +1,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml index 896dd0e712..7a68a7f2bd 100644 --- a/conf/autoload_configs/switch.conf.xml +++ b/conf/autoload_configs/switch.conf.xml @@ -15,11 +15,6 @@ - - - - - @@ -86,7 +81,6 @@ - diff --git a/conf/autoload_configs/voicemail.conf.xml b/conf/autoload_configs/voicemail.conf.xml index 06bd6f6dca..14ad98b41c 100644 --- a/conf/autoload_configs/voicemail.conf.xml +++ b/conf/autoload_configs/voicemail.conf.xml @@ -33,10 +33,9 @@ - --> - - - + + + diff --git a/conf/dialplan/default.xml b/conf/dialplan/default.xml index 42a3bcc31f..9e762b97a2 100644 --- a/conf/dialplan/default.xml +++ b/conf/dialplan/default.xml @@ -1,763 +1,88 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/sip_profiles/internal.xml b/conf/sip_profiles/internal.xml index 93558a3584..50833bfbec 100644 --- a/conf/sip_profiles/internal.xml +++ b/conf/sip_profiles/internal.xml @@ -42,26 +42,6 @@ - - - - - - diff --git a/conf/skinny_profiles/internal.xml b/conf/skinny_profiles/internal.xml index 52da89741d..5feac1ffbf 100644 --- a/conf/skinny_profiles/internal.xml +++ b/conf/skinny_profiles/internal.xml @@ -16,7 +16,7 @@ - + diff --git a/conf/vars.xml b/conf/vars.xml index fced2ef139..c638a80582 100644 --- a/conf/vars.xml +++ b/conf/vars.xml @@ -195,7 +195,7 @@ - + diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 052fbd4021..d8c0e48d2c 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -270,9 +270,11 @@ extern ftdm_sngisdn_data_t g_sngisdn_data; ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span); /* Support functions */ -FT_DECLARE(uint32_t) get_unique_suInstId(int16_t cc_id); -FT_DECLARE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info); -FT_DECLARE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info); +uint32_t get_unique_suInstId(int16_t cc_id); +void clear_call_data(sngisdn_chan_data_t *sngisdn_info); +void clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info); +ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail); +ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); void stack_hdr_init(Header *hdr); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c index d8e6c8e00d..225244f57e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cntrl.c @@ -41,7 +41,6 @@ ftdm_status_t sngisdn_activate_phy(ftdm_span_t *span); ftdm_status_t sngisdn_deactivate_phy(ftdm_span_t *span); ftdm_status_t sngisdn_activate_cc(ftdm_span_t *span); -ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); ftdm_status_t sngisdn_cntrl_q931(ftdm_span_t *span, uint8_t action, uint8_t subaction); ftdm_status_t sngisdn_cntrl_q921(ftdm_span_t *span, uint8_t action, uint8_t subaction); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 7e083073fd..7871debba4 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -39,7 +39,7 @@ ftdm_status_t sngisdn_check_free_ids(void); extern ftdm_sngisdn_data_t g_sngisdn_data; void get_memory_info(void); -FT_DECLARE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info) +void clear_call_data(sngisdn_chan_data_t *sngisdn_info) { uint32_t cc_id = ((sngisdn_span_data_t*)sngisdn_info->ftdmchan->span->signal_data)->cc_id; @@ -56,7 +56,7 @@ FT_DECLARE(void) clear_call_data(sngisdn_chan_data_t *sngisdn_info) return; } -FT_DECLARE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info) +void clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info) { ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_DEBUG, "Clearing glare data (suId:%d suInstId:%u spInstId:%u actv-suInstId:%u actv-spInstId:%u)\n", sngisdn_info->glare.suId, @@ -81,7 +81,7 @@ FT_DECLARE(void) clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info) } -FT_DECLARE(uint32_t) get_unique_suInstId(int16_t cc_id) +uint32_t get_unique_suInstId(int16_t cc_id) { uint32_t suInstId; ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n"); @@ -103,7 +103,7 @@ FT_DECLARE(uint32_t) get_unique_suInstId(int16_t cc_id) return 0; } -FT_DECLARE(ftdm_status_t) get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data) +ftdm_status_t get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data) { ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n"); ftdm_assert_return(g_sngisdn_data.ccs[cc_id].activation_done, FTDM_FAIL, "Trying to find call on unconfigured CC\n"); @@ -115,7 +115,7 @@ FT_DECLARE(ftdm_status_t) get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suIns return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data) +ftdm_status_t get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data) { ftdm_assert_return((cc_id > 0 && cc_id <=MAX_VARIANTS), FTDM_FAIL, "Invalid cc_id\n"); ftdm_assert_return(g_sngisdn_data.ccs[cc_id].activation_done, FTDM_FAIL, "Trying to find call on unconfigured CC\n"); @@ -147,7 +147,7 @@ ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail) return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb) +ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb) { if (cgPtyNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; @@ -174,7 +174,7 @@ FT_DECLARE(ftdm_status_t) cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, C return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb) +ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb) { if (cdPtyNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; @@ -196,7 +196,7 @@ FT_DECLARE(ftdm_status_t) cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, Cd return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb) +ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb) { if (redirNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; @@ -216,7 +216,7 @@ FT_DECLARE(ftdm_status_t) cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, Red return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display) +ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display) { if (display->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; @@ -229,7 +229,7 @@ FT_DECLARE(ftdm_status_t) cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm) +ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm) { uint8_t len = strlen(ftdm->cid_num.digits); if (!len) { @@ -257,7 +257,7 @@ FT_DECLARE(ftdm_status_t) cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_cal return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm) +ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm) { uint8_t len = strlen(ftdm->dnis.digits); if (!len) { @@ -287,7 +287,7 @@ FT_DECLARE(ftdm_status_t) cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_call return FTDM_SUCCESS; } -FT_DECLARE(ftdm_status_t) cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm) +ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm) { uint8_t len = strlen(ftdm->rdnis.digits); if (!len) { @@ -319,7 +319,7 @@ FT_DECLARE(ftdm_status_t) cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_calle } -FT_DECLARE(ftdm_status_t) cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) +ftm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) { uint8_t len; ftdm_caller_data_t *ftdm = &ftdmchan->caller_data; From 5c128405b836188ba02f989c0c682fb77c6de2f9 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 19 Nov 2010 14:41:26 -0500 Subject: [PATCH 09/55] Fix for windows compile errors introduced during previous merge --- .../ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 13 +++++++++++++ .../ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index d8c0e48d2c..81a98cf0d3 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -273,6 +273,10 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ uint32_t get_unique_suInstId(int16_t cc_id); void clear_call_data(sngisdn_chan_data_t *sngisdn_info); void clear_call_glare_data(sngisdn_chan_data_t *sngisdn_info); +ftdm_status_t get_ftdmchan_by_suInstId(int16_t cc_id, uint32_t suInstId, sngisdn_chan_data_t **sngisdn_data); +ftdm_status_t get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn_chan_data_t **sngisdn_data); + + ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail); ftdm_status_t sngisdn_activate_trace(ftdm_span_t *span, sngisdn_tracetype_t trace_opt); @@ -354,6 +358,15 @@ void sngisdn_rcv_cc_ind(CcMngmt *status); void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...); void sngisdn_rcv_sng_assert(char *message); +ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb); +ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb); +ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb); +ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display); +ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm); +ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm); +ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm); +ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan); + uint8_t sngisdn_get_infoTranCap_from_stack(ftdm_bearer_cap_t bearer_capability); uint8_t sngisdn_get_usrInfoLyr1Prot_from_stack(ftdm_user_layer1_prot_t layer1_prot); ftdm_bearer_cap_t sngisdn_get_infoTranCap_from_user(uint8_t bearer_capability); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 7871debba4..056bf66ef2 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -319,7 +319,7 @@ ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ft } -ftm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) +ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) { uint8_t len; ftdm_caller_data_t *ftdm = &ftdmchan->caller_data; From 53c41c0463a332447fd5cf1007265dc45446beec Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Sat, 20 Nov 2010 10:25:02 -0500 Subject: [PATCH 10/55] freetdm: ISDN - Fix for main loop going to sleep without processing events from IO module --- libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 56efcb491c..cb96107ac3 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -431,6 +431,7 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) /* Poll for events, e.g HW DTMF */ ftdm_sangoma_isdn_poll_events(span); + ftdm_span_trigger_signals(span); if (ftdm_sched_get_time_to_next_timer(signal_data->sched, &sleep) == FTDM_SUCCESS) { if (sleep < 0 || sleep > SNGISDN_EVENT_POLL_RATE) { From 04e854136675ba1369a73af712b12971d4ee9c69 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 23 Nov 2010 11:43:52 -0500 Subject: [PATCH 11/55] freetdm: add release event to ftdm core --- libs/freetdm/mod_freetdm/mod_freetdm.c | 7 +++++++ libs/freetdm/src/ftdm_io.c | 9 +++++++++ libs/freetdm/src/include/freetdm.h | 1 + 3 files changed, 17 insertions(+) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index a410e4eac6..165fce0a84 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1690,6 +1690,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxo_signal) } } break; + case FTDM_SIGEVENT_RELEASED: { /* twiddle */ } break; default: { @@ -1744,6 +1745,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal) } } break; + case FTDM_SIGEVENT_RELEASED: { /* twiddle */ } break; case FTDM_SIGEVENT_STOP: { private_t *tech_pvt = NULL; @@ -1966,6 +1968,8 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal) status = ftdm_channel_from_event(sigmsg, &session); } break; + + case FTDM_SIGEVENT_RELEASED: { /* twiddle */ } break; /* on DNIS received from the R2 forward side, return status == FTDM_BREAK to stop requesting DNIS */ case FTDM_SIGEVENT_COLLECTED_DIGIT: @@ -2063,6 +2067,9 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) return ftdm_channel_from_event(sigmsg, &session); } break; + + case FTDM_SIGEVENT_RELEASED: { /* twiddle */ } break; + case FTDM_SIGEVENT_STOP: case FTDM_SIGEVENT_RESTART: { diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 939933af73..24e54574ae 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2349,6 +2349,8 @@ static void close_dtmf_debug(ftdm_channel_t *ftdmchan) static ftdm_status_t ftdm_channel_clear_vars(ftdm_channel_t *ftdmchan); FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan) { + ftdm_sigmsg_t sigmsg; + ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "Null channel can't be done!\n"); ftdm_mutex_lock(ftdmchan->mutex); @@ -2387,6 +2389,13 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan) ftdm_log(FTDM_LOG_DEBUG, "channel done %u:%u\n", ftdmchan->span_id, ftdmchan->chan_id); + memset(&sigmsg, 0, sizeof(sigmsg)); + sigmsg.span_id = ftdmchan->span_id; + sigmsg.chan_id = ftdmchan->chan_id; + sigmsg.channel = ftdmchan; + sigmsg.event_id = FTDM_SIGEVENT_RELEASED; + ftdm_span_send_signal(ftdmchan->span, &sigmsg); + ftdm_mutex_unlock(ftdmchan->mutex); return FTDM_SUCCESS; diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 55e433d9c7..dc181e15c7 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -287,6 +287,7 @@ typedef enum { typedef enum { FTDM_SIGEVENT_START, /*!< Incoming call (ie: incoming SETUP msg or Ring) */ FTDM_SIGEVENT_STOP, /*!< Hangup */ + FTDM_SIGEVENT_RELEASED, /*!< Channel is completely released and available */ FTDM_SIGEVENT_UP, /*!< Outgoing call has been answered */ FTDM_SIGEVENT_FLASH, /*< Flash event (typically on-hook/off-hook for analog devices) */ FTDM_SIGEVENT_PROGRESS, /*!< Outgoing call is making progress */ From af5f0a4acd0426d63791d8f1c7a18608de3955ff Mon Sep 17 00:00:00 2001 From: Arnaldo Pereira Date: Tue, 23 Nov 2010 14:55:59 -0200 Subject: [PATCH 12/55] freetdm: made ftmod_r2 use FTDM_SPAN_USE_SIGNALS_QUEUE and properly send FTDM_SIGEVENT_SIGSTATUS_CHANGED --- libs/freetdm/mod_freetdm/mod_freetdm.c | 8 +++++++ libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c | 28 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index a410e4eac6..73f5660a7a 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -2028,6 +2028,14 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal) } break; + case FTDM_SIGEVENT_SIGSTATUS_CHANGED: + { + ftdm_signaling_status_t sigstatus = sigmsg->raw_data ? *((ftdm_signaling_status_t*)(sigmsg->raw_data)) : sigmsg->sigstatus; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d:%d signalling changed to: %s\n", + spanid, chanid, ftdm_signaling_status2str(sigstatus)); + } + break; + default: { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled event %d from R2 for channel %d:%d\n", diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c index d5344814f0..30de78857a 100644 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c @@ -220,6 +220,23 @@ static char *strsep(char **stringp, const char *delim) } #endif /* WIN32 */ +static void ftdm_r2_set_chan_sig_status(ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status) +{ + ftdm_sigmsg_t sig; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Signalling link status changed to %s\n", ftdm_signaling_status2str(status)); + + memset(&sig, 0, sizeof(sig)); + sig.chan_id = ftdmchan->chan_id; + sig.span_id = ftdmchan->span_id; + sig.channel = ftdmchan; + sig.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; + sig.sigstatus = status; + if (ftdm_span_send_signal(ftdmchan->span, &sig) != FTDM_SUCCESS) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Failed to change channel status to %s\n", ftdm_signaling_status2str(status)); + } + return; +} + static ftdm_call_cause_t ftdm_r2_cause_to_ftdm_cause(ftdm_channel_t *fchan, openr2_call_disconnect_cause_t cause) { switch (cause) { @@ -593,17 +610,14 @@ static void ftdm_r2_on_line_blocked(openr2_chan_t *r2chan) { ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Far end blocked in state %s\n", ftdm_channel_state2str(ftdmchan->state)); - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); + ftdm_r2_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_SUSPENDED); } static void ftdm_r2_on_line_idle(openr2_chan_t *r2chan) { ftdm_channel_t *ftdmchan = openr2_chan_get_client_data(r2chan); ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Far end unblocked in state %s\n", ftdm_channel_state2str(ftdmchan->state)); - ftdm_clear_flag(ftdmchan, FTDM_CHANNEL_SUSPENDED); - - /* XXX when should we set/unset this flag? XXX */ - ftdm_set_flag(ftdmchan, FTDM_CHANNEL_SIG_UP); + ftdm_r2_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP); } static void ftdm_r2_write_log(openr2_log_level_t level, const char *file, const char *function, int line, const char *message) @@ -1130,6 +1144,9 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_r2_configure_span) span->signal_data = r2data; span->outgoing_call = r2_outgoing_call; + /* use signals queue */ + ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); + return FTDM_SUCCESS; fail: @@ -1439,6 +1456,7 @@ static void *ftdm_r2_run(ftdm_thread_t *me, void *obj) } else if (status != FTDM_TIMEOUT) { ftdm_log(FTDM_LOG_ERROR, "ftdm_span_poll_event returned %d.\n", status); } + ftdm_span_trigger_signals(span); ftdm_sleep(20); } From 4a6be5477aaf72d732292b50674ce2d83947e8fd Mon Sep 17 00:00:00 2001 From: Arnaldo Pereira Date: Tue, 23 Nov 2010 17:29:58 -0200 Subject: [PATCH 13/55] freetdm: updated libopenr2 dll name on ftmod_r2 msvc dependency --- libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj index 9ea351ba6a..8942a8f5b6 100644 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.2008.vcproj @@ -60,9 +60,9 @@ /> Date: Tue, 23 Nov 2010 15:49:50 -0500 Subject: [PATCH 14/55] freetdm: do not flush events queue on channel start --- libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index eb42207138..c13455dd21 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -333,8 +333,8 @@ static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start ftdm_log(FTDM_LOG_ERROR, "Failed to enable RBS/CAS events in device %d:%d fd:%d\n", chan->span_id, chan->chan_id, sockfd); continue; } - /* probably done by the driver but lets write defensive code this time */ sangoma_flush_bufs(chan->sockfd, &tdm_api); + sangoma_flush_event_bufs(chan->sockfd, &tdm_api); #else /* * With wanpipe 3.4.4.2 I get failure even though the events are enabled, /var/log/messages said: @@ -514,9 +514,6 @@ static FIO_OPEN_FUNCTION(wanpipe_open) memset(&tdm_api,0,sizeof(tdm_api)); sangoma_tdm_flush_bufs(ftdmchan->sockfd, &tdm_api); -#ifdef LIBSANGOMA_VERSION - sangoma_flush_event_bufs(ftdmchan->sockfd, &tdm_api); -#endif if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921 || ftdmchan->type == FTDM_CHAN_TYPE_DQ931) { ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_NONE; From c059649f8f9d812ec284150f410c0a6d0c77b2d7 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 23 Nov 2010 16:27:40 -0500 Subject: [PATCH 15/55] freetdm: only notify of released channels when is a voice channel --- libs/freetdm/src/ftdm_io.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 24e54574ae..64233a97ac 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2349,8 +2349,6 @@ static void close_dtmf_debug(ftdm_channel_t *ftdmchan) static ftdm_status_t ftdm_channel_clear_vars(ftdm_channel_t *ftdmchan); FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan) { - ftdm_sigmsg_t sigmsg; - ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "Null channel can't be done!\n"); ftdm_mutex_lock(ftdmchan->mutex); @@ -2389,12 +2387,15 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_done(ftdm_channel_t *ftdmchan) ftdm_log(FTDM_LOG_DEBUG, "channel done %u:%u\n", ftdmchan->span_id, ftdmchan->chan_id); - memset(&sigmsg, 0, sizeof(sigmsg)); - sigmsg.span_id = ftdmchan->span_id; - sigmsg.chan_id = ftdmchan->chan_id; - sigmsg.channel = ftdmchan; - sigmsg.event_id = FTDM_SIGEVENT_RELEASED; - ftdm_span_send_signal(ftdmchan->span, &sigmsg); + if (FTDM_IS_VOICE_CHANNEL(ftdmchan)) { + ftdm_sigmsg_t sigmsg; + memset(&sigmsg, 0, sizeof(sigmsg)); + sigmsg.span_id = ftdmchan->span_id; + sigmsg.chan_id = ftdmchan->chan_id; + sigmsg.channel = ftdmchan; + sigmsg.event_id = FTDM_SIGEVENT_RELEASED; + ftdm_span_send_signal(ftdmchan->span, &sigmsg); + } ftdm_mutex_unlock(ftdmchan->mutex); From 9f183fa4b15ec9e5d2249f5da63dc2af3a25d9d2 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 23 Nov 2010 17:41:40 -0500 Subject: [PATCH 16/55] freetdm: ISDN - Added pendingsignals to list of interrupts in span poll thread --- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index cb96107ac3..77ad917bf1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -370,7 +370,7 @@ static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj) static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) { - ftdm_interrupt_t *ftdm_sangoma_isdn_int[2]; + ftdm_interrupt_t *ftdm_sangoma_isdn_int[3]; ftdm_status_t ret_status; ftdm_span_t *span = (ftdm_span_t *) obj; ftdm_channel_t *ftdmchan = NULL; @@ -388,8 +388,13 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) ftdm_log(FTDM_LOG_CRIT, "%s:Failed to get a ftdm_interrupt for span = %s!\n", span->name); goto ftdm_sangoma_isdn_run_exit; } + + if (ftdm_queue_get_interrupt(span->pendingsignals, &ftdm_sangoma_isdn_int[1]) != FTDM_SUCCESS) { + ftdm_log(FTDM_LOG_CRIT, "%s:Failed to get a signal interrupt for span = %s!\n", span->name); + goto ftdm_sangoma_isdn_run_exit; + } - if (ftdm_queue_get_interrupt(signal_data->event_queue, &ftdm_sangoma_isdn_int[1]) != FTDM_SUCCESS) { + if (ftdm_queue_get_interrupt(signal_data->event_queue, &ftdm_sangoma_isdn_int[2]) != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_CRIT, "%s:Failed to get a event interrupt for span = %s!\n", span->name); goto ftdm_sangoma_isdn_run_exit; } @@ -398,8 +403,14 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) /* Check if there are any timers to process */ ftdm_sched_run(signal_data->sched); + ftdm_span_trigger_signals(span); - ret_status = ftdm_interrupt_multiple_wait(ftdm_sangoma_isdn_int, 2, sleep); + if (ftdm_sched_get_time_to_next_timer(signal_data->sched, &sleep) == FTDM_SUCCESS) { + if (sleep < 0 || sleep > SNGISDN_EVENT_POLL_RATE) { + sleep = SNGISDN_EVENT_POLL_RATE; + } + } + ret_status = ftdm_interrupt_multiple_wait(ftdm_sangoma_isdn_int, 3, sleep); /* find out why we returned from the interrupt queue */ switch (ret_status) { case FTDM_SUCCESS: /* there was a state change on the span */ @@ -415,7 +426,6 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) ftdm_sangoma_isdn_process_stack_event(span, sngisdn_event); ftdm_safe_free(sngisdn_event); } - ftdm_span_trigger_signals(span); break; case FTDM_TIMEOUT: /* twiddle */ @@ -431,13 +441,6 @@ static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj) /* Poll for events, e.g HW DTMF */ ftdm_sangoma_isdn_poll_events(span); - ftdm_span_trigger_signals(span); - - if (ftdm_sched_get_time_to_next_timer(signal_data->sched, &sleep) == FTDM_SUCCESS) { - if (sleep < 0 || sleep > SNGISDN_EVENT_POLL_RATE) { - sleep = SNGISDN_EVENT_POLL_RATE; - } - } } /* clear the IN_THREAD flag so that we know the thread is done */ From 473a04651c3971883cc413b1ee53f4c1ee3135ce Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Wed, 24 Nov 2010 09:28:34 -0500 Subject: [PATCH 17/55] freetdm: add missing string for SIGEVENT_RELEASED --- libs/freetdm/src/include/freetdm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index dc181e15c7..508c6996d5 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -301,7 +301,7 @@ typedef enum { FTDM_SIGEVENT_COLLISION, /*!< Outgoing call was dropped because an incoming call arrived at the same time */ FTDM_SIGEVENT_INVALID } ftdm_signal_event_t; -#define SIGNAL_STRINGS "START", "STOP", "UP", "FLASH", "PROGRESS", \ +#define SIGNAL_STRINGS "START", "STOP", "RELEASED", "UP", "FLASH", "PROGRESS", \ "PROGRESS_MEDIA", "ALARM_TRAP", "ALARM_CLEAR", \ "COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "INVALID" From b814dc17ce5aefded953fc7e30db257088f70475 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 24 Nov 2010 20:04:43 -0500 Subject: [PATCH 18/55] freetdm: ISDN Changes to better match SIP-to-TDM states --- libs/freetdm/mod_freetdm/mod_freetdm.c | 15 ++- libs/freetdm/src/ftdm_io.c | 16 +-- .../src/ftmod/ftmod_analog/ftmod_analog.c | 16 +-- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 66 +++++++++-- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 26 ++++- .../ftmod_sangoma_isdn_cfg.c | 9 ++ .../ftmod_sangoma_isdn_stack_hndl.c | 108 +++++++++++++----- .../ftmod_sangoma_isdn_stack_out.c | 85 ++++++++++++-- .../ftmod_sangoma_isdn_support.c | 18 +++ libs/freetdm/src/include/freetdm.h | 8 +- libs/freetdm/src/include/private/ftdm_types.h | 8 +- libs/freetdm/src/testanalog.c | 2 +- 12 files changed, 303 insertions(+), 74 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 8d961123cb..27dc8d8c92 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -425,8 +425,11 @@ static switch_status_t channel_on_routing(switch_core_session_t *session) tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel)); + assert(tech_pvt->ftdmchan != NULL); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel)); + + ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_PROCEED); return SWITCH_STATUS_SUCCESS; } @@ -852,7 +855,7 @@ static switch_status_t channel_receive_message_b(switch_core_session_t *session, switch (msg->message_id) { case SWITCH_MESSAGE_INDICATE_RINGING: { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_PROGRESS); + ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_RINGING); } break; case SWITCH_MESSAGE_INDICATE_PROGRESS: @@ -935,7 +938,7 @@ static switch_status_t channel_receive_message_fxs(switch_core_session_t *sessio !switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_RING_READY) ) { - ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_RING); + ftdm_channel_call_indicate(tech_pvt->ftdmchan, FTDM_CHANNEL_INDICATE_RINGING); switch_channel_mark_ring_ready(channel); } break; @@ -2133,7 +2136,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) spanid, chanid, (uuid) ? uuid : "N/A"); } } - break; + break; case FTDM_SIGEVENT_SIGSTATUS_CHANGED: { ftdm_signaling_status_t sigstatus = sigmsg->raw_data ? *((ftdm_signaling_status_t*)(sigmsg->raw_data)) : sigmsg->sigstatus; @@ -2141,6 +2144,10 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) spanid, chanid, ftdm_signaling_status2str(sigstatus)); } break; + case FTDM_SIGEVENT_PROCEED: + case FTDM_SIGEVENT_MSG: + /* FS does not have handlers for these messages, so ignore them for now */ + break; default: { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled msg type %d for channel %d:%d\n", diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 64233a97ac..ede3ff8fc8 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2033,7 +2033,6 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char goto done; } - if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) { ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1); } @@ -2202,14 +2201,19 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch switch (indication) { /* FIXME: ring and busy cannot be used with all signaling stacks * (particularly isdn stacks I think, we should emulate or just move to hangup with busy cause) */ - case FTDM_CHANNEL_INDICATE_RING: - ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RING, 1); + case FTDM_CHANNEL_INDICATE_RINGING: + ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_RINGING, 1); break; - case FTDM_CHANNEL_INDICATE_BUSY: ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_BUSY, 1); break; - + case FTDM_CHANNEL_INDICATE_PROCEED: + if (ftdm_test_flag(ftdmchan->span, FTDM_SPAN_USE_PROCEED_STATE)) { + if (ftdmchan->state == FTDM_CHANNEL_STATE_RING) { + ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROCEED, 1); + } + } + break; case FTDM_CHANNEL_INDICATE_PROGRESS: if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { ftdm_set_flag(ftdmchan, FTDM_CHANNEL_PROGRESS); @@ -2217,7 +2221,6 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1); } break; - case FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA: if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { ftdm_set_flag(ftdmchan, FTDM_CHANNEL_PROGRESS); @@ -2236,7 +2239,6 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1); } break; - default: ftdm_log(file, func, line, FTDM_LOG_LEVEL_WARNING, "Do not know how to indicate %d\n", indication); status = FTDM_FAIL; diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c index fc9bea6ef0..99d256655a 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c @@ -438,7 +438,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) { if (state_counter > 5000 || !ftdm_test_flag(ftdmchan, FTDM_CHANNEL_CALLERID_DETECT)) { ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_CALLERID_DETECT, NULL); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IDLE); + ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING); } } break; @@ -492,8 +492,8 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) } if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OFFHOOK) && - (ftdmchan->last_state == FTDM_CHANNEL_STATE_RING || ftdmchan->last_state == FTDM_CHANNEL_STATE_DIALTONE - || ftdmchan->last_state >= FTDM_CHANNEL_STATE_IDLE)) { + (ftdmchan->last_state == FTDM_CHANNEL_STATE_RINGING || ftdmchan->last_state == FTDM_CHANNEL_STATE_DIALTONE + || ftdmchan->last_state >= FTDM_CHANNEL_STATE_RING)) { ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_BUSY); } else { ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING; @@ -535,7 +535,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) } } case FTDM_CHANNEL_STATE_UP: - case FTDM_CHANNEL_STATE_IDLE: + case FTDM_CHANNEL_STATE_RING: { ftdm_sleep(interval); continue; @@ -599,7 +599,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) ftdm_channel_use(ftdmchan); } break; - case FTDM_CHANNEL_STATE_IDLE: + case FTDM_CHANNEL_STATE_RING: { ftdm_channel_use(ftdmchan); sig.event_id = FTDM_SIGEVENT_START; @@ -669,7 +669,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) continue; } break; - case FTDM_CHANNEL_STATE_RING: + case FTDM_CHANNEL_STATE_RINGING: { ftdm_buffer_zero(dt_buffer); teletone_run(&ts, ftdmchan->span->tone_map[FTDM_TONEMAP_RING]); @@ -732,7 +732,7 @@ static void *ftdm_analog_channel_run(ftdm_thread_t *me, void *obj) if (last_digit && (!collecting || ((elapsed - last_digit > analog_data->digit_timeout) || strlen(dtmf) >= analog_data->max_dialstr))) { ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Number obtained [%s]\n", dtmf); - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IDLE); + ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RING); last_digit = 0; collecting = 0; } @@ -890,7 +890,7 @@ static __inline__ ftdm_status_t process_event(ftdm_span_t *span, ftdm_event_t *e if (ftdm_test_flag(analog_data, FTDM_ANALOG_CALLERID)) { ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_GET_CALLERID); } else { - ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_IDLE); + ftdm_set_state_locked(event->channel, FTDM_CHANNEL_STATE_RING); } event->channel->ring_count = 1; ftdm_mutex_unlock(event->channel->mutex); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 77ad917bf1..6f5f838590 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -115,7 +115,19 @@ ftdm_state_map_t sangoma_isdn_state_map = { ZSD_INBOUND, ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_RING, FTDM_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_END} + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_END} + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_PROCEED, FTDM_END}, + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA,FTDM_END} + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_RINGING, FTDM_END}, + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_END}, }, { ZSD_INBOUND, @@ -189,9 +201,17 @@ ftdm_state_map_t sangoma_isdn_state_map = { ZSD_OUTBOUND, ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_DIALING, FTDM_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, - FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_CHANNEL_STATE_DOWN, FTDM_END} + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, + FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, + FTDM_CHANNEL_STATE_DOWN, FTDM_END} }, + { + ZSD_OUTBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_PROCEED, FTDM_END}, + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, + FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_END}, + }, { ZSD_OUTBOUND, ZSM_UNACCEPTABLE, @@ -604,13 +624,15 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) break; case FTDM_CHANNEL_STATE_GET_CALLERID: { - sngisdn_set_flag(sngisdn_info, FLAG_SENT_PROCEED); - sngisdn_snd_proceed(ftdmchan); + if (!sngisdn_test_flag(sngisdn_info, FLAG_SENT_PROCEED)) { + sngisdn_set_flag(sngisdn_info, FLAG_SENT_PROCEED); + sngisdn_snd_proceed(ftdmchan); + } /* Wait in this state until we get FACILITY msg */ } break; case FTDM_CHANNEL_STATE_RING: /* incoming call request */ - { + { ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending incoming call from %s to %s to FTDM core\n", ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.dnis.digits); /* we have enough information to inform FTDM of the call*/ @@ -635,6 +657,25 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) } } break; + case FTDM_CHANNEL_STATE_PROCEED: + { + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { + /*OUTBOUND...so we were told by the line of this so noifiy the user*/ + sigev.event_id = FTDM_SIGEVENT_PROCEED; + ftdm_span_send_signal(ftdmchan->span, &sigev); + } else { + if (!sngisdn_test_flag(sngisdn_info, FLAG_SENT_PROCEED)) { + sngisdn_set_flag(sngisdn_info, FLAG_SENT_PROCEED); + sngisdn_snd_proceed(ftdmchan); + } + } + } + break; + case FTDM_CHANNEL_STATE_RINGING: + { + sngisdn_snd_alert(ftdmchan, SNGISDN_PROGIND_NETE_ISDN); + } + break; case FTDM_CHANNEL_STATE_PROGRESS: { /*check if the channel is inbound or outbound*/ @@ -642,9 +683,12 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) /*OUTBOUND...so we were told by the line of this so noifiy the user*/ sigev.event_id = FTDM_SIGEVENT_PROGRESS; ftdm_span_send_signal(ftdmchan->span, &sigev); - } else if (!sngisdn_test_flag(sngisdn_info, FLAG_SENT_PROCEED)) { - sngisdn_set_flag(sngisdn_info, FLAG_SENT_PROCEED); - sngisdn_snd_proceed(ftdmchan); + } else { + /* If we already sent a PROCEED before, do not send a PROGRESS as there is nothing to indicate to the remote switch */ + if (ftdmchan->last_state != FTDM_CHANNEL_STATE_PROCEED) { + /* Send a progress message, indicating: Call is not end-to-end ISDN, further call progress may be available */ + sngisdn_snd_progress(ftdmchan, SNGISDN_PROGIND_NETE_ISDN); + } } } break; @@ -654,7 +698,8 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) sigev.event_id = FTDM_SIGEVENT_PROGRESS_MEDIA; ftdm_span_send_signal(ftdmchan->span, &sigev); } else { - sngisdn_snd_progress(ftdmchan); + /* Send a progress message, indicating: In-band information/pattern available */ + sngisdn_snd_progress(ftdmchan, SNGISDN_PROGIND_IB_AVAIL); } } break; @@ -992,6 +1037,7 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) span->state_map = &sangoma_isdn_state_map; ftdm_set_flag(span, FTDM_SPAN_USE_CHAN_QUEUE); ftdm_set_flag(span, FTDM_SPAN_USE_SIGNALS_QUEUE); + ftdm_set_flag(span, FTDM_SPAN_USE_PROCEED_STATE); if (span->trunk_type == FTDM_TRUNK_BRI_PTMP || span->trunk_type == FTDM_TRUNK_BRI) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 81a98cf0d3..25ffef85e5 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -75,7 +75,8 @@ typedef enum { FLAG_DELAYED_REL = (1 << 7), FLAG_SENT_PROCEED = (1 << 8), FLAG_SEND_DISC = (1 << 9), - FLAG_ACTIVATING = (1 << 10), /* Used for BRI only, flag is set after we request line CONNECTED */ + /* Used for BRI only, flag is set after we request line CONNECTED */ + FLAG_ACTIVATING = (1 << 10), } sngisdn_flag_t; @@ -135,6 +136,21 @@ typedef enum { SNGISDN_EVENT_RST_IND, } ftdm_sngisdn_event_id_t; +typedef enum { + /* Call is not end-to-end ISDN */ + SNGISDN_PROGIND_NETE_ISDN = 1, + /* Destination address is non-ISDN */ + SNGISDN_PROGIND_DEST_NISDN, + /* Origination address is non-ISDN */ + SNGISDN_PROGIND_ORIG_NISDN, + /* Call has returned to the ISDN */ + SNGISDN_PROGIND_RET_ISDN, + /* Interworking as occured and has resulted in a telecommunication service change */ + SNGISDN_PROGIND_SERV_CHANGE, + /* In-band information or an appropriate pattern is now available */ + SNGISDN_PROGIND_IB_AVAIL, +} ftdm_sngisdn_progind_t; + /* Only timers that can be cancelled are listed here */ #define SNGISDN_NUM_TIMERS 1 /* Increase NUM_TIMERS as number of ftdm_sngisdn_timer_t increases */ @@ -181,6 +197,7 @@ typedef struct sngisdn_span_data { uint8_t trace_flags; /* TODO: change to flags, so we can use ftdm_test_flag etc.. */ uint8_t overlap_dial; uint8_t setup_arb; + uint8_t facility_ie_decode; uint8_t facility; int8_t facility_timeout; uint8_t num_local_numbers; @@ -288,13 +305,14 @@ void stack_pst_init(Pst *pst); void sngisdn_snd_setup(ftdm_channel_t *ftdmchan); void sngisdn_snd_setup_ack(ftdm_channel_t *ftdmchan); void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan); -void sngisdn_snd_progress(ftdm_channel_t *ftdmchan); -void sngisdn_snd_alert(ftdm_channel_t *ftdmchan); +void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); +void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); void sngisdn_snd_connect(ftdm_channel_t *ftdmchan); void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan); void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare); void sngisdn_snd_reset(ftdm_channel_t *ftdmchan); void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan); +void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan); void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan); void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan); void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len); @@ -362,6 +380,8 @@ ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgP ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb); ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb); ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display); +ftdm_status_t cpy_facility_ie_from_stack(ftdm_caller_data_t *ftdm, uint8_t *data, uint32_t data_len); + ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm); ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm); ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index 3b264ae02f..657aa5e206 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -190,6 +190,7 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ signal_data->min_digits = 8; signal_data->overlap_dial = SNGISDN_OPT_DEFAULT; signal_data->setup_arb = SNGISDN_OPT_DEFAULT; + signal_data->facility_ie_decode = SNGISDN_OPT_TRUE; signal_data->timer_t3 = 8; signal_data->link_id = span->span_id; @@ -289,6 +290,14 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ if (signal_data->facility_timeout < 0) { signal_data->facility_timeout = 0; } + } else if (!strcasecmp(var, "facility-ie-decode")) { + if (!strcasecmp(val, "yes")) { + signal_data->facility_ie_decode = SNGISDN_OPT_TRUE; + } else if (!strcasecmp(val, "no")) { + signal_data->facility_ie_decode = SNGISDN_OPT_FALSE; + } else { + ftdm_log(FTDM_LOG_ERROR, "Invalid value for parameter:%s:%s\n", var, val); + } } else { ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 3fe0422a4e..209284a8b6 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -144,31 +144,35 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", conEvnt->ni2OctStr.str.val[3]); } } - - if (signal_data->facility == SNGISDN_OPT_TRUE && conEvnt->facilityStr.eh.pres) { - /* Verify whether the Caller Name will come in a subsequent FACILITY message */ - uint16_t ret_val; - char retrieved_str[255]; - - ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str); - /* - return values for "sng_isdn_retrieve_facility_information_following": - If there will be no information following, or fails to decode IE, returns -1 - If there will be no information following, but current FACILITY IE contains a caller name, returns 0 - If there will be information following, returns 1 - */ - if (ret_val == 1) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Expecting Caller name in FACILITY\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID); - /* Launch timer in case we never get a FACILITY msg */ - if (signal_data->facility_timeout) { - ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, - sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_TIMER_FACILITY]); + if (conEvnt->facilityStr.eh.pres) { + if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { + cpy_facility_ie_from_stack(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); + } else if (signal_data->facility == SNGISDN_OPT_TRUE) { + /* Verify whether the Caller Name will come in a subsequent FACILITY message */ + uint16_t ret_val; + char retrieved_str[255]; + + ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str); + /* + return values for "sng_isdn_retrieve_facility_information_following": + If there will be no information following, or fails to decode IE, returns -1 + If there will be no information following, but current FACILITY IE contains a caller name, returns 0 + If there will be information following, returns 1 + */ + + if (ret_val == 1) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Expecting Caller name in FACILITY\n"); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID); + /* Launch timer in case we never get a FACILITY msg */ + if (signal_data->facility_timeout) { + ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, + sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_TIMER_FACILITY]); + } + break; + } else if (ret_val == 0) { + strcpy(ftdmchan->caller_data.cid_name, retrieved_str); } - break; - } else if (ret_val == 0) { - strcpy(ftdmchan->caller_data.cid_name, retrieved_str); } } } @@ -269,6 +273,7 @@ void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event) if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { switch(ftdmchan->state) { + case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: case FTDM_CHANNEL_STATE_DIALING: @@ -367,8 +372,10 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) case MI_CALLPROC: switch(ftdmchan->state) { - case FTDM_CHANNEL_STATE_DIALING: - if (evntType == MI_PROGRESS || + case FTDM_CHANNEL_STATE_DIALING: + if (evntType == MI_CALLPROC) { + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROCEED); + } else if (evntType == MI_PROGRESS || (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL)) { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); } else { @@ -417,6 +424,7 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) } break; case FTDM_CHANNEL_STATE_RING: + case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: case FTDM_CHANNEL_STATE_UP: @@ -446,6 +454,7 @@ void sngisdn_process_disc_ind (sngisdn_event_data_t *sngisdn_event) uint32_t spInstId = sngisdn_event->spInstId; sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; DiscEvnt *discEvnt = &sngisdn_event->event.discEvnt; @@ -454,12 +463,20 @@ void sngisdn_process_disc_ind (sngisdn_event_data_t *sngisdn_event) ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Processing DISCONNECT (suId:%u suInstId:%u spInstId:%u)\n", suId, suInstId, spInstId); ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); - switch (ftdmchan->state) { + switch (ftdmchan->state) { case FTDM_CHANNEL_STATE_RING: case FTDM_CHANNEL_STATE_DIALING: + case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: - case FTDM_CHANNEL_STATE_UP: + case FTDM_CHANNEL_STATE_UP: + if (discEvnt->facilityStr.eh.pres) { + if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { + cpy_facility_ie_from_stack(&ftdmchan->caller_data, discEvnt->facilityStr.facilityStr.val, discEvnt->facilityStr.facilityStr.len); + } else { + /* Call libsng_isdn facility decode function and copy variables here */ + } + } if (discEvnt->causeDgn[0].eh.pres && discEvnt->causeDgn[0].causeVal.pres) { ftdmchan->caller_data.hangup_cause = discEvnt->causeDgn[0].causeVal.val; } else { @@ -503,6 +520,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) uint32_t spInstId = sngisdn_event->spInstId; sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; RelEvnt *relEvnt = &sngisdn_event->event.relEvnt; @@ -538,6 +556,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) sngisdn_set_avail_rate(ftdmchan->span, SNGISDN_AVAIL_DOWN); } /* fall-through */ + case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: case FTDM_CHANNEL_STATE_UP: @@ -547,6 +566,15 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) not changed while we were waiting for ftdmchan->mutex by comparing suInstId's */ if (((sngisdn_chan_data_t*)ftdmchan->call_data)->suInstId == suInstId || ((sngisdn_chan_data_t*)ftdmchan->call_data)->spInstId == spInstId) { + + if (relEvnt->facilityStr.eh.pres) { + if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { + cpy_facility_ie_from_stack(&ftdmchan->caller_data, relEvnt->facilityStr.facilityStr.val, relEvnt->facilityStr.facilityStr.len); + } else { + /* Call libsng_isdn facility decode function and copy variables here */ + } + } + if (relEvnt->causeDgn[0].eh.pres && relEvnt->causeDgn[0].causeVal.pres) { ftdmchan->caller_data.hangup_cause = relEvnt->causeDgn[0].causeVal.val; ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "cause:%d\n", ftdmchan->caller_data.hangup_cause); @@ -725,15 +753,16 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event) switch (ftdmchan->state) { case FTDM_CHANNEL_STATE_GET_CALLERID: /* Update the caller ID Name */ + if (facEvnt->facElmt.facStr.pres) { char retrieved_str[255]; - + /* return values for "sng_isdn_retrieve_facility_information_following": If there will be no information following, or fails to decode IE, returns -1 If there will be no information following, but current FACILITY IE contains a caller name, returns 0 If there will be information following, returns 1 */ - + if (sng_isdn_retrieve_facility_caller_name(&facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len, retrieved_str) == 0) { strcpy(ftdmchan->caller_data.cid_name, retrieved_str); } else { @@ -751,6 +780,25 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event) /* We received the caller ID Name in FACILITY, but its too late, facility-timeout already occurred */ ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "FACILITY received, but we already proceeded with call\n"); break; + case FTDM_CHANNEL_STATE_UP: + { + ftdm_sigmsg_t sigev; + if (facEvnt->facElmt.facStr.pres) { + if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { + cpy_facility_ie_from_stack(&ftdmchan->caller_data, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len); + } else { + /* Call libsng_isdn facility decode function and copy variables here */ + } + } + memset(&sigev, 0, sizeof(sigev)); + sigev.chan_id = ftdmchan->chan_id; + sigev.span_id = ftdmchan->span_id; + sigev.channel = ftdmchan; + + sigev.event_id = FTDM_SIGEVENT_MSG; + ftdm_span_send_signal(ftdmchan->span, &sigev); + } + break; default: /* We do not support other FACILITY types for now, so do nothing */ break; @@ -865,6 +913,7 @@ void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event) ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "T302 Timer expired, proceeding with call\n"); ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RING); break; + case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: ftdm_log_chan_msg(ftdmchan, FTDM_LOG_WARNING, "Remote switch expecting OVERLAP receive, but we are already PROCEEDING\n"); @@ -882,6 +931,7 @@ void sngisdn_process_sta_cfm (sngisdn_event_data_t *sngisdn_event) break; case 3: switch (ftdmchan->state) { + case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: /* T310 timer has expired */ ftdmchan->caller_data.hangup_cause = staEvnt->causeDgn[0].causeVal.val; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 2853335efc..385d1eba9d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -34,6 +34,9 @@ #include "ftmod_sangoma_isdn.h" +static void sngisdn_set_prog_desc(ProgInd *progInd, ftdm_sngisdn_progind_t prod_ind); +static void sngisdn_set_facilityStr(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); + void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) { ConEvnt conEvnt; @@ -138,6 +141,8 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) cpy_redir_num_from_user(&conEvnt.redirNmb, &ftdmchan->caller_data); cpy_calling_name_from_user(&conEvnt, ftdmchan); + sngisdn_set_facilityStr(ftdmchan, &conEvnt.facilityStr); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); if (sng_isdn_con_request(signal_data->cc_id, sngisdn_info->suInstId, &conEvnt, signal_data->dchan_id, sngisdn_info->ces)) { @@ -323,14 +328,14 @@ void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan) return; } -void sngisdn_snd_progress(ftdm_channel_t *ftdmchan) +void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind) { CnStEvnt cnStEvnt; sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { + if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending PROGRESS, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); @@ -351,7 +356,8 @@ void sngisdn_snd_progress(ftdm_channel_t *ftdmchan) cnStEvnt.progInd.codeStand0.pres = PRSNT_NODEF; cnStEvnt.progInd.codeStand0.val = IN_CSTD_CCITT; cnStEvnt.progInd.progDesc.pres = PRSNT_NODEF; - cnStEvnt.progInd.progDesc.val = IN_PD_IBAVAIL; + + sngisdn_set_prog_desc(&cnStEvnt.progInd, prog_ind); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROGRESS (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_PROGRESS, signal_data->dchan_id, sngisdn_info->ces)) { @@ -360,14 +366,14 @@ void sngisdn_snd_progress(ftdm_channel_t *ftdmchan) return; } -void sngisdn_snd_alert(ftdm_channel_t *ftdmchan) +void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind) { CnStEvnt cnStEvnt; sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { + if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending ALERT, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); @@ -382,7 +388,7 @@ void sngisdn_snd_alert(ftdm_channel_t *ftdmchan) cnStEvnt.progInd.codeStand0.pres = PRSNT_NODEF; cnStEvnt.progInd.codeStand0.val = IN_CSTD_CCITT; cnStEvnt.progInd.progDesc.pres = PRSNT_NODEF; - cnStEvnt.progInd.progDesc.val = IN_PD_NOTETEISDN; + sngisdn_set_prog_desc(&cnStEvnt.progInd, prog_ind); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending ALERT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); @@ -456,6 +462,27 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan) return; } +void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan) +{ + FacEvnt facEvnt; + + sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + + if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending FACILITY, but no call data, ignoring (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); + return; + } + + memset(&facEvnt, 0, sizeof(facEvnt)); + + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending FACILITY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + + if (sng_isdn_facility_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &facEvnt, MI_FACIL, signal_data->dchan_id, sngisdn_info->ces)) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused FACILITY request\n"); + } + return; +} void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan) { @@ -510,7 +537,7 @@ void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan) sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { + if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending DISCONNECT, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); @@ -531,6 +558,8 @@ void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan) discEvnt.causeDgn[0].recommend.pres = NOTPRSNT; discEvnt.causeDgn[0].dgnVal.pres = NOTPRSNT; + sngisdn_set_facilityStr(ftdmchan, &discEvnt.facilityStr); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending DISCONNECT (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); if (sng_isdn_disc_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &discEvnt)) { ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused DISCONNECT request\n"); @@ -575,6 +604,8 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) spInstId = sngisdn_info->spInstId; } + sngisdn_set_facilityStr(ftdmchan, &relEvnt.facilityStr); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending RELEASE/RELEASE COMPLETE (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, suInstId, spInstId); if (glare) { @@ -589,6 +620,46 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) return; } +static void sngisdn_set_prog_desc(ProgInd *progInd, ftdm_sngisdn_progind_t prog_ind) +{ + switch(prog_ind) { + case SNGISDN_PROGIND_NETE_ISDN: + progInd->progDesc.val = IN_PD_NOTETEISDN; + break; + case SNGISDN_PROGIND_DEST_NISDN: + progInd->progDesc.val = IN_PD_DSTNOTISDN; + break; + case SNGISDN_PROGIND_ORIG_NISDN: + progInd->progDesc.val = IN_PD_ORGNOTISDN; + break; + case SNGISDN_PROGIND_RET_ISDN: + progInd->progDesc.val = IN_PD_CALLRET; + break; + case SNGISDN_PROGIND_SERV_CHANGE: + /* Trillium defines do not match ITU-T Q931 Progress descriptions, + indicate a delayed response for now */ + progInd->progDesc.val = IN_PD_DELRESP; + break; + case SNGISDN_PROGIND_IB_AVAIL: + progInd->progDesc.val = IN_PD_IBAVAIL; + break; + } + return; +} + +static void sngisdn_set_facilityStr(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) +{ + const char *facility_str = NULL; + + facility_str = ftdm_channel_get_var(ftdmchan, "isdn.facility.val"); + if (facility_str) { + facilityStr->eh.pres = PRSNT_NODEF; + facilityStr->facilityStr.len = strlen(facility_str); + memcpy(facilityStr->facilityStr.val, facility_str, facilityStr->facilityStr.len); + } + return; +} + /* We received an incoming frame on the d-channel, send data to the stack */ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 056bf66ef2..379c481c0e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -229,6 +229,24 @@ ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *dis return FTDM_SUCCESS; } +ftdm_status_t cpy_facility_ie_from_stack(ftdm_caller_data_t *caller_data, uint8_t *data, uint32_t data_len) +{ + if (data_len > sizeof(caller_data->raw_data)-2) { + ftdm_log(FTDM_LOG_CRIT, "Length of Facility IE exceeds maximum length\n"); + return FTDM_FAIL; + } + + memset(caller_data->raw_data, 0, sizeof(caller_data->raw_data)); + /* Always include Facility IE identifier + len so this can be used as a sanity check by the user */ + caller_data->raw_data[0] = 0x1C; + caller_data->raw_data[1] = data_len; + + memcpy(&caller_data->raw_data[2], data, data_len); + caller_data->raw_data_len = data_len+2; + + return FTDM_SUCCESS; +} + ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm) { uint8_t len = strlen(ftdm->cid_num.digits); diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 508c6996d5..87da5d1dd0 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -289,7 +289,8 @@ typedef enum { FTDM_SIGEVENT_STOP, /*!< Hangup */ FTDM_SIGEVENT_RELEASED, /*!< Channel is completely released and available */ FTDM_SIGEVENT_UP, /*!< Outgoing call has been answered */ - FTDM_SIGEVENT_FLASH, /*< Flash event (typically on-hook/off-hook for analog devices) */ + FTDM_SIGEVENT_FLASH, /*!< Flash event (typically on-hook/off-hook for analog devices) */ + FTDM_SIGEVENT_PROCEED, /*!< Outgoing call got a response */ FTDM_SIGEVENT_PROGRESS, /*!< Outgoing call is making progress */ FTDM_SIGEVENT_PROGRESS_MEDIA, /*!< Outgoing call is making progress and there is media available */ FTDM_SIGEVENT_ALARM_TRAP, /*!< Hardware alarm ON */ @@ -299,9 +300,10 @@ typedef enum { FTDM_SIGEVENT_RESTART, /*!< Restart has been requested. Typically you hangup your call resources here */ FTDM_SIGEVENT_SIGSTATUS_CHANGED, /*!< Signaling protocol status changed (ie: D-chan up), see new status in raw_data ftdm_sigmsg_t member */ FTDM_SIGEVENT_COLLISION, /*!< Outgoing call was dropped because an incoming call arrived at the same time */ + FTDM_SIGEVENT_MSG, /* !< We received an in-call msg */ FTDM_SIGEVENT_INVALID } ftdm_signal_event_t; -#define SIGNAL_STRINGS "START", "STOP", "RELEASED", "UP", "FLASH", "PROGRESS", \ +#define SIGNAL_STRINGS "START", "STOP", "RELEASED", "UP", "FLASH", "PROCEED", "PROGRESS", \ "PROGRESS_MEDIA", "ALARM_TRAP", "ALARM_CLEAR", \ "COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "INVALID" @@ -581,7 +583,7 @@ typedef enum { * This is used during incoming calls when you want to request the signaling stack * to notify about indications occurring locally */ typedef enum { - FTDM_CHANNEL_INDICATE_RING, + FTDM_CHANNEL_INDICATE_RINGING, FTDM_CHANNEL_INDICATE_PROCEED, FTDM_CHANNEL_INDICATE_PROGRESS, FTDM_CHANNEL_INDICATE_PROGRESS_MEDIA, diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index d9cefc3c6f..f265cb1a3d 100644 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ b/libs/freetdm/src/include/private/ftdm_types.h @@ -181,6 +181,8 @@ typedef enum { * after having called ftdm_send_span_signal(), which with this flag it will just enqueue the signal * for later delivery */ FTDM_SPAN_USE_SIGNALS_QUEUE = (1 << 10), + /* If this flag is set, channel will be moved to proceed state when calls goes to routing */ + FTDM_SPAN_USE_PROCEED_STATE = (1 << 11), } ftdm_span_flag_t; /*! \brief Channel supported features */ @@ -204,6 +206,7 @@ typedef enum { FTDM_CHANNEL_STATE_DIALTONE, FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_RING, + FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_BUSY, FTDM_CHANNEL_STATE_ATTN, FTDM_CHANNEL_STATE_GENRING, @@ -211,6 +214,7 @@ typedef enum { FTDM_CHANNEL_STATE_GET_CALLERID, FTDM_CHANNEL_STATE_CALLWAITING, FTDM_CHANNEL_STATE_RESTART, + FTDM_CHANNEL_STATE_PROCEED, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, @@ -223,8 +227,8 @@ typedef enum { FTDM_CHANNEL_STATE_INVALID } ftdm_channel_state_t; #define CHANNEL_STATE_STRINGS "DOWN", "HOLD", "SUSPENDED", "DIALTONE", "COLLECT", \ - "RING", "BUSY", "ATTN", "GENRING", "DIALING", "GET_CALLERID", "CALLWAITING", \ - "RESTART", "PROGRESS", "PROGRESS_MEDIA", "UP", "IDLE", "TERMINATING", "CANCEL", \ + "RING", "RINGING", "BUSY", "ATTN", "GENRING", "DIALING", "GET_CALLERID", "CALLWAITING", \ + "RESTART", "PROCEED", "PROGRESS", "PROGRESS_MEDIA", "UP", "IDLE", "TERMINATING", "CANCEL", \ "HANGUP", "HANGUP_COMPLETE", "IN_LOOP", "INVALID" FTDM_STR2ENUM_P(ftdm_str2ftdm_channel_state, ftdm_channel_state2str, ftdm_channel_state_t) diff --git a/libs/freetdm/src/testanalog.c b/libs/freetdm/src/testanalog.c index 84d09f73c9..326bb5aec5 100644 --- a/libs/freetdm/src/testanalog.c +++ b/libs/freetdm/src/testanalog.c @@ -50,7 +50,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_signal) switch(sigmsg->event_id) { case FTDM_SIGEVENT_START: - ftdm_channel_call_indicate(sigmsg->channel, FTDM_CHANNEL_INDICATE_RING); + ftdm_channel_call_indicate(sigmsg->channel, FTDM_CHANNEL_INDICATE_RINGING); ftdm_log(FTDM_LOG_DEBUG, "launching thread and indicating ring\n"); ftdm_thread_create_detached(test_call, sigmsg->channel); break; From 7433a1e5786f91f07f3b13f392596943062b4a13 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 25 Nov 2010 13:16:44 -0500 Subject: [PATCH 19/55] Fix for caller ID not received properly on BRI --- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 20 +-- .../ftmod_sangoma_isdn_stack_hndl.c | 22 +-- .../ftmod_sangoma_isdn_stack_out.c | 30 ++--- .../ftmod_sangoma_isdn_support.c | 125 +++++++++++------- libs/freetdm/src/include/freetdm.h | 6 +- 5 files changed, 115 insertions(+), 88 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 25ffef85e5..a82ed283e1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -376,16 +376,18 @@ void sngisdn_rcv_cc_ind(CcMngmt *status); void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...); void sngisdn_rcv_sng_assert(char *message); -ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb); -ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb); -ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb); -ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display); -ftdm_status_t cpy_facility_ie_from_stack(ftdm_caller_data_t *ftdm, uint8_t *data, uint32_t data_len); +ftdm_status_t get_calling_num(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb); +ftdm_status_t get_called_num(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb); +ftdm_status_t get_redir_num(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb); +ftdm_status_t get_calling_name_from_display(ftdm_caller_data_t *ftdm, Display *display); +ftdm_status_t get_calling_name_from_usr_usr(ftdm_caller_data_t *ftdm, UsrUsr *usrUsr); +ftdm_status_t get_facility_ie(ftdm_caller_data_t *ftdm, uint8_t *data, uint32_t data_len); -ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm); -ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm); -ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm); -ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan); +ftdm_status_t set_calling_num(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm); +ftdm_status_t set_called_num(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm); +ftdm_status_t set_redir_num(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm); +ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan); +ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); uint8_t sngisdn_get_infoTranCap_from_stack(ftdm_bearer_cap_t bearer_capability); uint8_t sngisdn_get_usrInfoLyr1Prot_from_stack(ftdm_user_layer1_prot_t layer1_prot); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index 209284a8b6..a541a655d8 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -127,10 +127,14 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) ftdm_channel_add_var(ftdmchan, "isdn_specific_var", "1"); #endif /* Fill in call information */ - cpy_calling_num_from_stack(&ftdmchan->caller_data, &conEvnt->cgPtyNmb); - cpy_called_num_from_stack(&ftdmchan->caller_data, &conEvnt->cdPtyNmb); - cpy_calling_name_from_stack(&ftdmchan->caller_data, &conEvnt->display); - cpy_redir_num_from_stack(&ftdmchan->caller_data, &conEvnt->redirNmb); + get_calling_num(&ftdmchan->caller_data, &conEvnt->cgPtyNmb); + get_called_num(&ftdmchan->caller_data, &conEvnt->cdPtyNmb); + get_redir_num(&ftdmchan->caller_data, &conEvnt->redirNmb); + + if (get_calling_name_from_display(&ftdmchan->caller_data, &conEvnt->display) != FTDM_SUCCESS) { + get_calling_name_from_usr_usr(&ftdmchan->caller_data, &conEvnt->usrUsr); + } + ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Incoming call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits); if (conEvnt->bearCap[0].eh.pres) { @@ -147,7 +151,7 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) if (conEvnt->facilityStr.eh.pres) { if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - cpy_facility_ie_from_stack(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); + get_facility_ie(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); } else if (signal_data->facility == SNGISDN_OPT_TRUE) { /* Verify whether the Caller Name will come in a subsequent FACILITY message */ uint16_t ret_val; @@ -413,7 +417,7 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) ftdm_size_t min_digits = ((sngisdn_span_data_t*)ftdmchan->span->signal_data)->min_digits; ftdm_size_t num_digits; - cpy_called_num_from_stack(&ftdmchan->caller_data, &cnStEvnt->cdPtyNmb); + get_called_num(&ftdmchan->caller_data, &cnStEvnt->cdPtyNmb); num_digits = strlen(ftdmchan->caller_data.dnis.digits); if (cnStEvnt->sndCmplt.eh.pres || num_digits >= min_digits) { @@ -472,7 +476,7 @@ void sngisdn_process_disc_ind (sngisdn_event_data_t *sngisdn_event) case FTDM_CHANNEL_STATE_UP: if (discEvnt->facilityStr.eh.pres) { if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - cpy_facility_ie_from_stack(&ftdmchan->caller_data, discEvnt->facilityStr.facilityStr.val, discEvnt->facilityStr.facilityStr.len); + get_facility_ie(&ftdmchan->caller_data, discEvnt->facilityStr.facilityStr.val, discEvnt->facilityStr.facilityStr.len); } else { /* Call libsng_isdn facility decode function and copy variables here */ } @@ -569,7 +573,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) if (relEvnt->facilityStr.eh.pres) { if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - cpy_facility_ie_from_stack(&ftdmchan->caller_data, relEvnt->facilityStr.facilityStr.val, relEvnt->facilityStr.facilityStr.len); + get_facility_ie(&ftdmchan->caller_data, relEvnt->facilityStr.facilityStr.val, relEvnt->facilityStr.facilityStr.len); } else { /* Call libsng_isdn facility decode function and copy variables here */ } @@ -785,7 +789,7 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event) ftdm_sigmsg_t sigev; if (facEvnt->facElmt.facStr.pres) { if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - cpy_facility_ie_from_stack(&ftdmchan->caller_data, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len); + get_facility_ie(&ftdmchan->caller_data, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len); } else { /* Call libsng_isdn facility decode function and copy variables here */ } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 385d1eba9d..36c6782a97 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -35,7 +35,6 @@ #include "ftmod_sangoma_isdn.h" static void sngisdn_set_prog_desc(ProgInd *progInd, ftdm_sngisdn_progind_t prod_ind); -static void sngisdn_set_facilityStr(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) { @@ -136,12 +135,11 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) } ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Outgoing call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits); - cpy_called_num_from_user(&conEvnt.cdPtyNmb, &ftdmchan->caller_data); - cpy_calling_num_from_user(&conEvnt.cgPtyNmb, &ftdmchan->caller_data); - cpy_redir_num_from_user(&conEvnt.redirNmb, &ftdmchan->caller_data); - cpy_calling_name_from_user(&conEvnt, ftdmchan); - - sngisdn_set_facilityStr(ftdmchan, &conEvnt.facilityStr); + set_called_num(&conEvnt.cdPtyNmb, &ftdmchan->caller_data); + set_calling_num(&conEvnt.cgPtyNmb, &ftdmchan->caller_data); + set_redir_num(&conEvnt.redirNmb, &ftdmchan->caller_data); + set_calling_name(&conEvnt, ftdmchan); + set_facility_ie(ftdmchan, &conEvnt.facilityStr); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); @@ -558,7 +556,8 @@ void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan) discEvnt.causeDgn[0].recommend.pres = NOTPRSNT; discEvnt.causeDgn[0].dgnVal.pres = NOTPRSNT; - sngisdn_set_facilityStr(ftdmchan, &discEvnt.facilityStr); + set_facility_ie(ftdmchan, &discEvnt.facilityStr); + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending DISCONNECT (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); if (sng_isdn_disc_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &discEvnt)) { @@ -604,7 +603,7 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) spInstId = sngisdn_info->spInstId; } - sngisdn_set_facilityStr(ftdmchan, &relEvnt.facilityStr); + set_facility_ie(ftdmchan, &relEvnt.facilityStr); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending RELEASE/RELEASE COMPLETE (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, suInstId, spInstId); @@ -647,19 +646,6 @@ static void sngisdn_set_prog_desc(ProgInd *progInd, ftdm_sngisdn_progind_t prog_ return; } -static void sngisdn_set_facilityStr(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) -{ - const char *facility_str = NULL; - - facility_str = ftdm_channel_get_var(ftdmchan, "isdn.facility.val"); - if (facility_str) { - facilityStr->eh.pres = PRSNT_NODEF; - facilityStr->facilityStr.len = strlen(facility_str); - memcpy(facilityStr->facilityStr.val, facility_str, facilityStr->facilityStr.len); - } - return; -} - /* We received an incoming frame on the d-channel, send data to the stack */ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 379c481c0e..4ddb90bbd3 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -147,76 +147,79 @@ ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail) return FTDM_SUCCESS; } -ftdm_status_t cpy_calling_num_from_stack(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb) +ftdm_status_t get_calling_num(ftdm_caller_data_t *caller_data, CgPtyNmb *cgPtyNmb) { if (cgPtyNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } if (cgPtyNmb->screenInd.pres == PRSNT_NODEF) { - ftdm->screen = cgPtyNmb->screenInd.val; + caller_data->screen = cgPtyNmb->screenInd.val; } if (cgPtyNmb->presInd0.pres == PRSNT_NODEF) { - ftdm->pres = cgPtyNmb->presInd0.val; + caller_data->pres = cgPtyNmb->presInd0.val; } if (cgPtyNmb->nmbPlanId.pres == PRSNT_NODEF) { - ftdm->cid_num.plan = cgPtyNmb->nmbPlanId.val; + caller_data->cid_num.plan = cgPtyNmb->nmbPlanId.val; } + if (cgPtyNmb->typeNmb1.pres == PRSNT_NODEF) { - ftdm->cid_num.type = cgPtyNmb->typeNmb1.val; + caller_data->cid_num.type = cgPtyNmb->typeNmb1.val; } if (cgPtyNmb->nmbDigits.pres == PRSNT_NODEF) { - ftdm_copy_string(ftdm->cid_num.digits, (const char*)cgPtyNmb->nmbDigits.val, cgPtyNmb->nmbDigits.len+1); + ftdm_copy_string(caller_data->cid_num.digits, (const char*)cgPtyNmb->nmbDigits.val, cgPtyNmb->nmbDigits.len+1); } + memcpy(&caller_data->ani, &caller_data->cid_num, sizeof(caller_data->ani)); return FTDM_SUCCESS; } -ftdm_status_t cpy_called_num_from_stack(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb) +ftdm_status_t get_called_num(ftdm_caller_data_t *caller_data, CdPtyNmb *cdPtyNmb) { if (cdPtyNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } if (cdPtyNmb->nmbPlanId.pres == PRSNT_NODEF) { - ftdm->dnis.plan = cdPtyNmb->nmbPlanId.val; + caller_data->dnis.plan = cdPtyNmb->nmbPlanId.val; } if (cdPtyNmb->typeNmb0.pres == PRSNT_NODEF) { - ftdm->dnis.type = cdPtyNmb->typeNmb0.val; + caller_data->dnis.type = cdPtyNmb->typeNmb0.val; } if (cdPtyNmb->nmbDigits.pres == PRSNT_NODEF) { - unsigned i = strlen(ftdm->dnis.digits); + /* In overlap receive mode, append the new digits to the existing dnis */ + unsigned i = strlen(caller_data->dnis.digits); - ftdm_copy_string(&ftdm->dnis.digits[i], (const char*)cdPtyNmb->nmbDigits.val, cdPtyNmb->nmbDigits.len+1); + ftdm_copy_string(&caller_data->dnis.digits[i], (const char*)cdPtyNmb->nmbDigits.val, cdPtyNmb->nmbDigits.len+1); } return FTDM_SUCCESS; } -ftdm_status_t cpy_redir_num_from_stack(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb) +ftdm_status_t get_redir_num(ftdm_caller_data_t *caller_data, RedirNmb *redirNmb) { if (redirNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } if (redirNmb->nmbPlanId.pres == PRSNT_NODEF) { - ftdm->rdnis.plan = redirNmb->nmbPlanId.val; + caller_data->rdnis.plan = redirNmb->nmbPlanId.val; } if (redirNmb->typeNmb.pres == PRSNT_NODEF) { - ftdm->rdnis.type = redirNmb->typeNmb.val; + caller_data->rdnis.type = redirNmb->typeNmb.val; } if (redirNmb->nmbDigits.pres == PRSNT_NODEF) { - ftdm_copy_string(ftdm->rdnis.digits, (const char*)redirNmb->nmbDigits.val, redirNmb->nmbDigits.len+1); + ftdm_copy_string(caller_data->rdnis.digits, (const char*)redirNmb->nmbDigits.val, redirNmb->nmbDigits.len+1); } return FTDM_SUCCESS; } -ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *display) +ftdm_status_t get_calling_name_from_display(ftdm_caller_data_t *caller_data, Display *display) { if (display->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; @@ -225,11 +228,29 @@ ftdm_status_t cpy_calling_name_from_stack(ftdm_caller_data_t *ftdm, Display *dis return FTDM_FAIL; } - ftdm_copy_string(ftdm->cid_name, (const char*)display->dispInfo.val, display->dispInfo.len+1); + ftdm_copy_string(caller_data->cid_name, (const char*)display->dispInfo.val, display->dispInfo.len+1); return FTDM_SUCCESS; } -ftdm_status_t cpy_facility_ie_from_stack(ftdm_caller_data_t *caller_data, uint8_t *data, uint32_t data_len) +ftdm_status_t get_calling_name_from_usr_usr(ftdm_caller_data_t *caller_data, UsrUsr *usrUsr) +{ + if (usrUsr->eh.pres != PRSNT_NODEF) { + return FTDM_FAIL; + } + + if (usrUsr->protocolDisc.val != PD_IA5) { + return FTDM_FAIL; + } + + if (usrUsr->usrInfo.pres != PRSNT_NODEF) { + return FTDM_FAIL; + } + + ftdm_copy_string(caller_data->cid_name, (const char*)usrUsr->usrInfo.val, usrUsr->usrInfo.len+1); + return FTDM_SUCCESS; +} + +ftdm_status_t get_facility_ie(ftdm_caller_data_t *caller_data, uint8_t *data, uint32_t data_len) { if (data_len > sizeof(caller_data->raw_data)-2) { ftdm_log(FTDM_LOG_CRIT, "Length of Facility IE exceeds maximum length\n"); @@ -247,67 +268,67 @@ ftdm_status_t cpy_facility_ie_from_stack(ftdm_caller_data_t *caller_data, uint8_ return FTDM_SUCCESS; } -ftdm_status_t cpy_calling_num_from_user(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm) +ftdm_status_t set_calling_num(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *caller_data) { - uint8_t len = strlen(ftdm->cid_num.digits); + uint8_t len = strlen(caller_data->cid_num.digits); if (!len) { return FTDM_SUCCESS; } cgPtyNmb->eh.pres = PRSNT_NODEF; cgPtyNmb->screenInd.pres = PRSNT_NODEF; - cgPtyNmb->screenInd.val = ftdm->screen; + cgPtyNmb->screenInd.val = caller_data->screen; cgPtyNmb->presInd0.pres = PRSNT_NODEF; - cgPtyNmb->presInd0.val = ftdm->pres; - + cgPtyNmb->presInd0.val = caller_data->pres; + cgPtyNmb->nmbPlanId.pres = PRSNT_NODEF; - cgPtyNmb->nmbPlanId.val = ftdm->cid_num.plan; + cgPtyNmb->nmbPlanId.val = caller_data->cid_num.plan; cgPtyNmb->typeNmb1.pres = PRSNT_NODEF; - cgPtyNmb->typeNmb1.val = ftdm->cid_num.type; + cgPtyNmb->typeNmb1.val = caller_data->cid_num.type; cgPtyNmb->nmbDigits.pres = PRSNT_NODEF; cgPtyNmb->nmbDigits.len = len; - memcpy(cgPtyNmb->nmbDigits.val, ftdm->cid_num.digits, len); + memcpy(cgPtyNmb->nmbDigits.val, caller_data->cid_num.digits, len); return FTDM_SUCCESS; } -ftdm_status_t cpy_called_num_from_user(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm) +ftdm_status_t set_called_num(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *caller_data) { - uint8_t len = strlen(ftdm->dnis.digits); + uint8_t len = strlen(caller_data->dnis.digits); if (!len) { return FTDM_SUCCESS; } cdPtyNmb->eh.pres = PRSNT_NODEF; cdPtyNmb->nmbPlanId.pres = PRSNT_NODEF; - if (ftdm->dnis.plan == FTDM_NPI_INVALID) { + if (caller_data->dnis.plan == FTDM_NPI_INVALID) { cdPtyNmb->nmbPlanId.val = FTDM_NPI_UNKNOWN; } else { - cdPtyNmb->nmbPlanId.val = ftdm->dnis.plan; + cdPtyNmb->nmbPlanId.val = caller_data->dnis.plan; } cdPtyNmb->typeNmb0.pres = PRSNT_NODEF; - if (ftdm->dnis.type == FTDM_TON_INVALID) { + if (caller_data->dnis.type == FTDM_TON_INVALID) { cdPtyNmb->typeNmb0.val = FTDM_TON_UNKNOWN; } else { - cdPtyNmb->typeNmb0.val = ftdm->dnis.type; + cdPtyNmb->typeNmb0.val = caller_data->dnis.type; } cdPtyNmb->nmbDigits.pres = PRSNT_NODEF; cdPtyNmb->nmbDigits.len = len; - memcpy(cdPtyNmb->nmbDigits.val, ftdm->dnis.digits, len); + memcpy(cdPtyNmb->nmbDigits.val, caller_data->dnis.digits, len); return FTDM_SUCCESS; } -ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm) +ftdm_status_t set_redir_num(RedirNmb *redirNmb, ftdm_caller_data_t *caller_data) { - uint8_t len = strlen(ftdm->rdnis.digits); + uint8_t len = strlen(caller_data->rdnis.digits); if (!len) { return FTDM_SUCCESS; } @@ -315,36 +336,36 @@ ftdm_status_t cpy_redir_num_from_user(RedirNmb *redirNmb, ftdm_caller_data_t *ft redirNmb->eh.pres = PRSNT_NODEF; redirNmb->nmbPlanId.pres = PRSNT_NODEF; - if (ftdm->rdnis.plan == FTDM_NPI_INVALID) { + if (caller_data->rdnis.plan == FTDM_NPI_INVALID) { redirNmb->nmbPlanId.val = FTDM_NPI_UNKNOWN; } else { - redirNmb->nmbPlanId.val = ftdm->rdnis.plan; + redirNmb->nmbPlanId.val = caller_data->rdnis.plan; } redirNmb->typeNmb.pres = PRSNT_NODEF; - if (ftdm->rdnis.type == FTDM_TON_INVALID) { + if (caller_data->rdnis.type == FTDM_TON_INVALID) { redirNmb->typeNmb.val = FTDM_TON_UNKNOWN; } else { - redirNmb->typeNmb.val = ftdm->rdnis.type; + redirNmb->typeNmb.val = caller_data->rdnis.type; } redirNmb->nmbDigits.pres = PRSNT_NODEF; redirNmb->nmbDigits.len = len; - memcpy(redirNmb->nmbDigits.val, ftdm->rdnis.digits, len); + memcpy(redirNmb->nmbDigits.val, caller_data->rdnis.digits, len); return FTDM_SUCCESS; } -ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) +ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) { uint8_t len; - ftdm_caller_data_t *ftdm = &ftdmchan->caller_data; + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; /* sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; */ sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; - len = strlen(ftdm->cid_name); + len = strlen(caller_data->cid_name); if (!len) { return FTDM_SUCCESS; } @@ -359,7 +380,7 @@ ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmc conEvnt->usrUsr.usrInfo.len = len; /* in sangoma_brid we used to send usr-usr info as !, change to previous style if current one does not work */ - memcpy(conEvnt->usrUsr.usrInfo.val, ftdm->cid_name, len); + memcpy(conEvnt->usrUsr.usrInfo.val, caller_data->cid_name, len); } else { switch (signal_data->switchtype) { case SNGISDN_SWITCH_NI2: @@ -377,7 +398,7 @@ ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmc conEvnt->display.eh.pres = PRSNT_NODEF; conEvnt->display.dispInfo.pres = PRSNT_NODEF; conEvnt->display.dispInfo.len = len; - memcpy(conEvnt->display.dispInfo.val, ftdm->cid_name, len); + memcpy(conEvnt->display.dispInfo.val, caller_data->cid_name, len); break; case SNGISDN_SWITCH_QSIG: /* It seems like QSIG does not support Caller ID Name */ @@ -390,6 +411,20 @@ ftdm_status_t cpy_calling_name_from_user(ConEvnt *conEvnt, ftdm_channel_t *ftdmc return FTDM_SUCCESS; } +ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) +{ + const char *facility_str = NULL; + + facility_str = ftdm_channel_get_var(ftdmchan, "isdn.facility.val"); + if (facility_str) { + facilityStr->eh.pres = PRSNT_NODEF; + facilityStr->facilityStr.len = strlen(facility_str); + memcpy(facilityStr->facilityStr.val, facility_str, facilityStr->facilityStr.len); + return FTDM_SUCCESS; + } + return FTDM_FAIL; +} + void sngisdn_t3_timeout(void* p_sngisdn_info) { sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 87da5d1dd0..014eeef852 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -285,7 +285,7 @@ typedef enum { /*! \brief Signaling messages sent by the stacks */ typedef enum { - FTDM_SIGEVENT_START, /*!< Incoming call (ie: incoming SETUP msg or Ring) */ + FTDM_SIGEVENT_START,/*!< Incoming call (ie: incoming SETUP msg or Ring) */ FTDM_SIGEVENT_STOP, /*!< Hangup */ FTDM_SIGEVENT_RELEASED, /*!< Channel is completely released and available */ FTDM_SIGEVENT_UP, /*!< Outgoing call has been answered */ @@ -300,12 +300,12 @@ typedef enum { FTDM_SIGEVENT_RESTART, /*!< Restart has been requested. Typically you hangup your call resources here */ FTDM_SIGEVENT_SIGSTATUS_CHANGED, /*!< Signaling protocol status changed (ie: D-chan up), see new status in raw_data ftdm_sigmsg_t member */ FTDM_SIGEVENT_COLLISION, /*!< Outgoing call was dropped because an incoming call arrived at the same time */ - FTDM_SIGEVENT_MSG, /* !< We received an in-call msg */ + FTDM_SIGEVENT_MSG, /*!< We received an in-call msg */ FTDM_SIGEVENT_INVALID } ftdm_signal_event_t; #define SIGNAL_STRINGS "START", "STOP", "RELEASED", "UP", "FLASH", "PROCEED", "PROGRESS", \ "PROGRESS_MEDIA", "ALARM_TRAP", "ALARM_CLEAR", \ - "COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "INVALID" + "COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "MSG", "INVALID" /*! \brief Move from string to ftdm_signal_event_t and viceversa */ FTDM_STR2ENUM_P(ftdm_str2ftdm_signal_event, ftdm_signal_event2str, ftdm_signal_event_t) From b8fb8acca152a5850b4a0fa4c0625f0094909059 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 25 Nov 2010 16:16:36 -0500 Subject: [PATCH 20/55] freetdm: ISDN allow change state from PROCEED to UP --- libs/freetdm/src/ftdm_io.c | 7 ++++++- .../src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 3 ++- .../ftmod_sangoma_isdn_stack_hndl.c | 11 +++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index ede3ff8fc8..6f543304a2 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2033,6 +2033,11 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char goto done; } +#if 0 + /* DAVIDY - We will fail RFC's if we do that, but some modules apart from ftmod_sangoma_isdn + * expect the call to always to go PROGRESS and PROGRESS MEDIA state before going to UP, so + * remove this only in netborder branch for now */ + if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) { ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1); } @@ -2052,7 +2057,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call has moved to TERMINATING while we're moving to UP\n"); goto done; } - +#endif ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 1); done: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 6f5f838590..9aa52f816c 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -121,7 +121,8 @@ ftdm_state_map_t sangoma_isdn_state_map = { ZSD_INBOUND, ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_PROCEED, FTDM_END}, - {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA,FTDM_END} + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, + FTDM_CHANNEL_STATE_UP, FTDM_END} }, { ZSD_INBOUND, diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index a541a655d8..f10fa766e3 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -377,18 +377,17 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) switch(ftdmchan->state) { case FTDM_CHANNEL_STATE_DIALING: - if (evntType == MI_CALLPROC) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROCEED); - } else if (evntType == MI_PROGRESS || - (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL)) { + if (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL) { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); + } else if (evntType == MI_CALLPROC) { + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROCEED); } else { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS); } break; + case FTDM_CHANNEL_STATE_PROCEED: case FTDM_CHANNEL_STATE_PROGRESS: - if (evntType == MI_PROGRESS || - (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL)) { + if (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL) { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); } break; From 2973776b6480309a5fe95aa8b2a3ba5151288c6b Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 25 Nov 2010 16:36:49 -0500 Subject: [PATCH 21/55] changed set_facility_ie --- Freeswitch.2008.sln | 20 +++++-------------- .../ftmod_sangoma_isdn_support.c | 12 +++++------ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Freeswitch.2008.sln b/Freeswitch.2008.sln index 01a4cf43c1..4ffd66abac 100644 --- a/Freeswitch.2008.sln +++ b/Freeswitch.2008.sln @@ -36,7 +36,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Default", "Default", "{3B08FEFD-4D3D-4C16-BA94-EE83509E32A0}" ProjectSection(SolutionItems) = preProject conf\freeswitch.xml = conf\freeswitch.xml - conf\vars.xml = conf\vars.xml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Release", "Release", "{7BFD517E-7F8F-4A40-A78E-8D3632738227}" @@ -57,7 +56,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Build System", "_Build Sys bootstrap.sh = bootstrap.sh build\buildlib.sh = build\buildlib.sh configure.in = configure.in - Makefile.am = Makefile.am build\modmake.rules.in = build\modmake.rules.in build\modules.conf.in = build\modules.conf.in libs\win32\util.vbs = libs\win32\util.vbs @@ -92,15 +90,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa conf\autoload_configs\limit.conf.xml = conf\autoload_configs\limit.conf.xml conf\autoload_configs\local_stream.conf.xml = conf\autoload_configs\local_stream.conf.xml conf\autoload_configs\logfile.conf.xml = conf\autoload_configs\logfile.conf.xml - conf\autoload_configs\modules.conf.xml = conf\autoload_configs\modules.conf.xml conf\autoload_configs\openmrcp.conf.xml = conf\autoload_configs\openmrcp.conf.xml conf\autoload_configs\portaudio.conf.xml = conf\autoload_configs\portaudio.conf.xml conf\autoload_configs\rss.conf.xml = conf\autoload_configs\rss.conf.xml conf\autoload_configs\sofia.conf.xml = conf\autoload_configs\sofia.conf.xml conf\autoload_configs\spidermonkey.conf.xml = conf\autoload_configs\spidermonkey.conf.xml - conf\autoload_configs\switch.conf.xml = conf\autoload_configs\switch.conf.xml conf\autoload_configs\syslog.conf.xml = conf\autoload_configs\syslog.conf.xml - conf\autoload_configs\voicemail.conf.xml = conf\autoload_configs\voicemail.conf.xml conf\autoload_configs\wanpipe.conf.xml = conf\autoload_configs\wanpipe.conf.xml conf\autoload_configs\woomera.conf.xml = conf\autoload_configs\woomera.conf.xml conf\autoload_configs\xml_cdr.conf.xml = conf\autoload_configs\xml_cdr.conf.xml @@ -111,7 +106,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{C7E2382E-2C22-4D18-BF93-80C6A1FFA7AC}" ProjectSection(SolutionItems) = preProject - conf\dialplan\default.xml = conf\dialplan\default.xml conf\dialplan\public.xml = conf\dialplan\public.xml EndProjectSection EndProject @@ -123,7 +117,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profiles", "{8E2E8798-8B6F-4A55-8E4F-4E6FDE40ED26}" ProjectSection(SolutionItems) = preProject conf\sip_profiles\external.xml = conf\sip_profiles\external.xml - conf\sip_profiles\internal.xml = conf\sip_profiles\internal.xml conf\sip_profiles\nat.xml = conf\sip_profiles\nat.xml EndProjectSection EndProject @@ -308,9 +301,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{23874F4B-C0AF-4587-9F7E-DB0F06DE8CB4}" - ProjectSection(SolutionItems) = preProject - conf\dialplan\default.xml = conf\dialplan\default.xml - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory", "directory", "{19ED97F6-30D8-4FCE-AE1D-8B7FCB170D40}" ProjectSection(SolutionItems) = preProject @@ -1271,15 +1261,15 @@ Global {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|Win32.Build.0 = Release|Win32 {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|x64.ActiveCfg = Release|x64 {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|x64.Build.0 = Release|x64 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|Win32.ActiveCfg = Release|x64 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|x64.ActiveCfg = Release|x64 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|x64.Build.0 = Release|x64 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|Win32.ActiveCfg = Release|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|Win32.Build.0 = Release|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|x64.ActiveCfg = Release|Win32 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.ActiveCfg = Debug|Win32 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.Build.0 = Debug|Win32 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|x64.ActiveCfg = Debug|x64 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|x64.ActiveCfg = Debug|Win32 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.ActiveCfg = Release|Win32 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.Build.0 = Release|Win32 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.ActiveCfg = Release|x64 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.ActiveCfg = Release|Win32 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|Win32.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.Build.0 = Release|x64 diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 4ddb90bbd3..c9aa3f035c 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -412,14 +412,12 @@ ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) } ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) -{ - const char *facility_str = NULL; - - facility_str = ftdm_channel_get_var(ftdmchan, "isdn.facility.val"); - if (facility_str) { +{ + if (ftdmchan->caller_data.raw_data_len && + ftdmchan->caller_data.raw_data[0] == 0x1C) { facilityStr->eh.pres = PRSNT_NODEF; - facilityStr->facilityStr.len = strlen(facility_str); - memcpy(facilityStr->facilityStr.val, facility_str, facilityStr->facilityStr.len); + facilityStr->facilityStr.len = ftdmchan->caller_data.raw_data_len-2; + memcpy(facilityStr->facilityStr.val, &ftdmchan->caller_data.raw_data[2], facilityStr->facilityStr.len); return FTDM_SUCCESS; } return FTDM_FAIL; From 5c747b699cfe3b2e19a3dc66a815cf7bfc9574a0 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 25 Nov 2010 18:54:15 -0500 Subject: [PATCH 22/55] Fix for receiving/transmitting facility IE --- .../ftmod_sangoma_isdn_stack_hndl.c | 23 ++++++++++--------- .../ftmod_sangoma_isdn_stack_out.c | 2 -- .../ftmod_sangoma_isdn_support.c | 4 +++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index f10fa766e3..f3fc23e317 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -142,21 +142,22 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) ftdmchan->caller_data.bearer_capability = sngisdn_get_infoTranCap_from_stack(conEvnt->bearCap[0].infoTranCap.val); } - if (signal_data->switchtype == SNGISDN_SWITCH_NI2) { - if (conEvnt->shift11.eh.pres && conEvnt->ni2OctStr.eh.pres) { - if (conEvnt->ni2OctStr.str.len == 4 && conEvnt->ni2OctStr.str.val[0] == 0x37) { - snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", conEvnt->ni2OctStr.str.val[3]); - } + + if (conEvnt->shift11.eh.pres && conEvnt->ni2OctStr.eh.pres) { + if (conEvnt->ni2OctStr.str.len == 4 && conEvnt->ni2OctStr.str.val[0] == 0x37) { + snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", conEvnt->ni2OctStr.str.val[3]); } + } - if (conEvnt->facilityStr.eh.pres) { - if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - get_facility_ie(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); - } else if (signal_data->facility == SNGISDN_OPT_TRUE) { + if (conEvnt->facilityStr.eh.pres) { + if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { + get_facility_ie(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); + } else if (signal_data->facility == SNGISDN_OPT_TRUE) { + if (signal_data->switchtype == SNGISDN_SWITCH_NI2) { /* Verify whether the Caller Name will come in a subsequent FACILITY message */ uint16_t ret_val; char retrieved_str[255]; - + ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str); /* return values for "sng_isdn_retrieve_facility_information_following": @@ -170,7 +171,7 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID); /* Launch timer in case we never get a FACILITY msg */ if (signal_data->facility_timeout) { - ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, + ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_TIMER_FACILITY]); } break; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 36c6782a97..1b906a2004 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -412,7 +412,6 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan) memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - cnStEvnt.chanId.eh.pres = PRSNT_NODEF; cnStEvnt.chanId.prefExc.pres = PRSNT_NODEF; cnStEvnt.chanId.prefExc.val = IN_PE_EXCLSVE; @@ -557,7 +556,6 @@ void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan) discEvnt.causeDgn[0].dgnVal.pres = NOTPRSNT; set_facility_ie(ftdmchan, &discEvnt.facilityStr); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending DISCONNECT (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); if (sng_isdn_disc_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &discEvnt)) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index c9aa3f035c..241bb43a90 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -412,14 +412,16 @@ ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) } ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) -{ +{ if (ftdmchan->caller_data.raw_data_len && ftdmchan->caller_data.raw_data[0] == 0x1C) { facilityStr->eh.pres = PRSNT_NODEF; + facilityStr->facilityStr.pres = PRSNT_NODEF; facilityStr->facilityStr.len = ftdmchan->caller_data.raw_data_len-2; memcpy(facilityStr->facilityStr.val, &ftdmchan->caller_data.raw_data[2], facilityStr->facilityStr.len); return FTDM_SUCCESS; } + return FTDM_FAIL; } From 0b7a2d4c92501980983bd71365f339a674a86a3c Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 26 Nov 2010 15:10:18 -0500 Subject: [PATCH 23/55] freetdm: remove openzap projects --- libs/freetdm/openzap.2005.sln | 82 ---- .../ftmod_analog/ozmod_analog.2005.vcproj | 202 ---------- .../ozmod_analog_em.2005.vcproj | 202 ---------- .../ftmod_wanpipe/ozmod_wanpipe.2005.vcproj | 196 ---------- .../ftmod_wanpipe/wanpipe_tdm_api_iface.h | 351 ------------------ 5 files changed, 1033 deletions(-) delete mode 100644 libs/freetdm/openzap.2005.sln delete mode 100644 libs/freetdm/src/ftmod/ftmod_analog/ozmod_analog.2005.vcproj delete mode 100644 libs/freetdm/src/ftmod/ftmod_analog_em/ozmod_analog_em.2005.vcproj delete mode 100644 libs/freetdm/src/ftmod/ftmod_wanpipe/ozmod_wanpipe.2005.vcproj delete mode 100644 libs/freetdm/src/ftmod/ftmod_wanpipe/wanpipe_tdm_api_iface.h diff --git a/libs/freetdm/openzap.2005.sln b/libs/freetdm/openzap.2005.sln deleted file mode 100644 index c9f666b381..0000000000 --- a/libs/freetdm/openzap.2005.sln +++ /dev/null @@ -1,82 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openzap", "msvc\openzap.2005.vcproj", "{93B8812C-3EC4-4F78-8970-FFBFC99E167D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testanalog", "msvc\testanalog\testanalog.2005.vcproj", "{BB833648-BAFF-4BE2-94DB-F8BB043C588C}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testisdn", "msvc\testisdn\testisdn.2005.vcproj", "{6DA6FD42-641D-4147-92F5-3BC4AAA6589B}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_openzap", "mod_openzap\mod_openzap.2005.vcproj", "{FE3540C5-3303-46E0-A69E-D92F775687F1}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozmod_analog", "src\ozmod\ozmod_analog\ozmod_analog.2005.vcproj", "{37C94798-6E33-4B4F-8EE0-C72A7DC91157}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozmod_analog_em", "src\ozmod\ozmod_analog_em\ozmod_analog_em.2005.vcproj", "{C539D7C8-26A8-4A94-B938-77672165C130}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozmod_isdn", "src\ozmod\ozmod_isdn\ozmod_isdn.2005.vcproj", "{729344A5-D5E9-434D-8EE8-AF8C6C795D15}" - ProjectSection(ProjectDependencies) = postProject - {93B8812C-3EC4-4F78-8970-FFBFC99E167D} = {93B8812C-3EC4-4F78-8970-FFBFC99E167D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozmod_wanpipe", "src\ozmod\ozmod_wanpipe\ozmod_wanpipe.2005.vcproj", "{1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozmod_pika", "src\ozmod\ozmod_pika\ozmod_pika.2005.vcproj", "{E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.ActiveCfg = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Debug|Win32.Build.0 = Debug|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.ActiveCfg = Release|Win32 - {93B8812C-3EC4-4F78-8970-FFBFC99E167D}.Release|Win32.Build.0 = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.ActiveCfg = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Debug|Win32.Build.0 = Debug|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.ActiveCfg = Release|Win32 - {BB833648-BAFF-4BE2-94DB-F8BB043C588C}.Release|Win32.Build.0 = Release|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Debug|Win32.Build.0 = Debug|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.ActiveCfg = Release|Win32 - {6DA6FD42-641D-4147-92F5-3BC4AAA6589B}.Release|Win32.Build.0 = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.ActiveCfg = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Debug|Win32.Build.0 = Debug|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.ActiveCfg = Release|Win32 - {FE3540C5-3303-46E0-A69E-D92F775687F1}.Release|Win32.Build.0 = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.ActiveCfg = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Debug|Win32.Build.0 = Debug|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.ActiveCfg = Release|Win32 - {37C94798-6E33-4B4F-8EE0-C72A7DC91157}.Release|Win32.Build.0 = Release|Win32 - {C539D7C8-26A8-4A94-B938-77672165C130}.Debug|Win32.ActiveCfg = Debug|Win32 - {C539D7C8-26A8-4A94-B938-77672165C130}.Debug|Win32.Build.0 = Debug|Win32 - {C539D7C8-26A8-4A94-B938-77672165C130}.Release|Win32.ActiveCfg = Release|Win32 - {C539D7C8-26A8-4A94-B938-77672165C130}.Release|Win32.Build.0 = Release|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|Win32.ActiveCfg = Debug|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Debug|Win32.Build.0 = Debug|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|Win32.ActiveCfg = Release|Win32 - {729344A5-D5E9-434D-8EE8-AF8C6C795D15}.Release|Win32.Build.0 = Release|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Debug|Win32.ActiveCfg = Debug|Win32 - {1A145EE9-BBD8-45E5-98CD-EB4BE99E1DCD}.Release|Win32.ActiveCfg = Release|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Debug|Win32.ActiveCfg = Debug|Win32 - {E886B4D5-AB4F-4092-B8F4-3B06E1E462EF}.Release|Win32.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ozmod_analog.2005.vcproj b/libs/freetdm/src/ftmod/ftmod_analog/ozmod_analog.2005.vcproj deleted file mode 100644 index 7a1cf53b20..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog/ozmod_analog.2005.vcproj +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ozmod_analog_em.2005.vcproj b/libs/freetdm/src/ftmod/ftmod_analog_em/ozmod_analog_em.2005.vcproj deleted file mode 100644 index 9ecbadc232..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ozmod_analog_em.2005.vcproj +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ozmod_wanpipe.2005.vcproj b/libs/freetdm/src/ftmod/ftmod_wanpipe/ozmod_wanpipe.2005.vcproj deleted file mode 100644 index abebf30427..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ozmod_wanpipe.2005.vcproj +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/wanpipe_tdm_api_iface.h b/libs/freetdm/src/ftmod/ftmod_wanpipe/wanpipe_tdm_api_iface.h deleted file mode 100644 index 3801ff9c8c..0000000000 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/wanpipe_tdm_api_iface.h +++ /dev/null @@ -1,351 +0,0 @@ -/***************************************************************************** -* wanpipe_tdm_api_iface.h -* -* WANPIPE(tm) AFT TE1 Hardware Support -* -* Authors: Nenad Corbic -* -* Copyright (c) 2007 - 08, Sangoma Technologies -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -* ============================================================================ -* Oct 04, 2005 Nenad Corbic Initial version. -* -* Jul 25, 2006 David Rokhvarg Ported to Windows. -*****************************************************************************/ - -#ifndef __WANPIPE_TDM_API_IFACE_H_ -#define __WANPIPE_TDM_API_IFACE_H_ - - -#if defined(__WINDOWS__) -typedef HANDLE sng_fd_t; -#else -typedef int sng_fd_t; -#endif - -/* Indicate to library that new features exist */ -#define WP_TDM_FEATURE_DTMF_EVENTS 1 -#define WP_TDM_FEATURE_FE_ALARM 1 -#define WP_TDM_FEATURE_EVENTS 1 -#define WP_TDM_FEATURE_LINK_STATUS 1 - -enum wanpipe_tdm_api_cmds { - - SIOC_WP_TDM_GET_USR_MTU_MRU, /* 0x00 */ - - SIOC_WP_TDM_SET_USR_PERIOD, /* 0x01 */ - SIOC_WP_TDM_GET_USR_PERIOD, /* 0x02 */ - - SIOC_WP_TDM_SET_HW_MTU_MRU, /* 0x03 */ - SIOC_WP_TDM_GET_HW_MTU_MRU, /* 0x04 */ - - SIOC_WP_TDM_SET_CODEC, /* 0x05 */ - SIOC_WP_TDM_GET_CODEC, /* 0x06 */ - - SIOC_WP_TDM_SET_POWER_LEVEL, /* 0x07 */ - SIOC_WP_TDM_GET_POWER_LEVEL, /* 0x08 */ - - SIOC_WP_TDM_TOGGLE_RX, /* 0x09 */ - SIOC_WP_TDM_TOGGLE_TX, /* 0x0A */ - - SIOC_WP_TDM_GET_HW_CODING, /* 0x0B */ - SIOC_WP_TDM_SET_HW_CODING, /* 0x0C */ - - SIOC_WP_TDM_GET_FULL_CFG, /* 0x0D */ - - SIOC_WP_TDM_SET_EC_TAP, /* 0x0E */ - SIOC_WP_TDM_GET_EC_TAP, /* 0x0F */ - - SIOC_WP_TDM_ENABLE_RBS_EVENTS, /* 0x10 */ - SIOC_WP_TDM_DISABLE_RBS_EVENTS, /* 0x11 */ - SIOC_WP_TDM_WRITE_RBS_BITS, /* 0x12 */ - - SIOC_WP_TDM_GET_STATS, /* 0x13 */ - SIOC_WP_TDM_FLUSH_BUFFERS, /* 0x14 */ - - SIOC_WP_TDM_READ_EVENT, /* 0x15 */ - - SIOC_WP_TDM_SET_EVENT, /* 0x16 */ - - SIOC_WP_TDM_SET_RX_GAINS, /* 0x17 */ - SIOC_WP_TDM_SET_TX_GAINS, /* 0x18 */ - SIOC_WP_TDM_CLEAR_RX_GAINS, /* 0x19 */ - SIOC_WP_TDM_CLEAR_TX_GAINS, /* 0x1A */ - - SIOC_WP_TDM_GET_FE_ALARMS, /* 0x1B */ - - SIOC_WP_TDM_ENABLE_HWEC, /* 0x1C */ - SIOC_WP_TDM_DISABLE_HWEC, /* 0x1D */ - - SIOC_WP_TDM_SET_FE_STATUS, /* 0x1E */ - SIOC_WP_TDM_GET_FE_STATUS, /* 0x1F */ - - SIOC_WP_TDM_GET_HW_DTMF, /* 0x20 */ - - SIOC_WP_TDM_NOTSUPP /* */ - -}; - -#define SIOC_WP_TDM_GET_LINK_STATUS SIOC_WP_TDM_GET_FE_STATUS - -enum wanpipe_tdm_api_events { - WP_TDMAPI_EVENT_NONE, - WP_TDMAPI_EVENT_RBS, - WP_TDMAPI_EVENT_ALARM, - WP_TDMAPI_EVENT_DTMF, - WP_TDMAPI_EVENT_RM_DTMF, - WP_TDMAPI_EVENT_RXHOOK, - WP_TDMAPI_EVENT_RING, - WP_TDMAPI_EVENT_RING_DETECT, - WP_TDMAPI_EVENT_RING_TRIP_DETECT, - WP_TDMAPI_EVENT_TONE, - WP_TDMAPI_EVENT_TXSIG_KEWL, - WP_TDMAPI_EVENT_TXSIG_START, - WP_TDMAPI_EVENT_TXSIG_OFFHOOK, - WP_TDMAPI_EVENT_TXSIG_ONHOOK, - WP_TDMAPI_EVENT_ONHOOKTRANSFER, - WP_TDMAPI_EVENT_SETPOLARITY, - WP_TDMAPI_EVENT_BRI_CHAN_LOOPBACK, - WP_TDMAPI_EVENT_LINK_STATUS -}; - -#define WP_TDMAPI_EVENT_FE_ALARM WP_TDMAPI_EVENT_ALARM - - -#define WP_TDMAPI_EVENT_ENABLE 0x01 -#define WP_TDMAPI_EVENT_DISABLE 0x02 -#define WP_TDMAPI_EVENT_MODE_DECODE(mode) \ - ((mode) == WP_TDMAPI_EVENT_ENABLE) ? "Enable" : \ - ((mode) == WP_TDMAPI_EVENT_DISABLE) ? "Disable" : \ - "(Unknown mode)" - -#define WPTDM_A_BIT WAN_RBS_SIG_A -#define WPTDM_B_BIT WAN_RBS_SIG_B -#define WPTDM_C_BIT WAN_RBS_SIG_C -#define WPTDM_D_BIT WAN_RBS_SIG_D - -#define WP_TDMAPI_EVENT_RXHOOK_OFF 0x01 -#define WP_TDMAPI_EVENT_RXHOOK_ON 0x02 -#define WP_TDMAPI_EVENT_RXHOOK_DECODE(state) \ - ((state) == WP_TDMAPI_EVENT_RXHOOK_OFF) ? "Off-hook" : \ - ((state) == WP_TDMAPI_EVENT_RXHOOK_ON) ? "On-hook" : \ - "(Unknown state)" - -#define WP_TDMAPI_EVENT_RING_PRESENT 0x01 -#define WP_TDMAPI_EVENT_RING_STOP 0x02 -#define WP_TDMAPI_EVENT_RING_DECODE(state) \ - ((state) == WP_TDMAPI_EVENT_RING_PRESENT) ? "Ring Present" : \ - ((state) == WP_TDMAPI_EVENT_RING_STOP) ? "Ring Stop" : \ - "(Unknown state)" - -#define WP_TDMAPI_EVENT_RING_TRIP_PRESENT 0x01 -#define WP_TDMAPI_EVENT_RING_TRIP_STOP 0x02 -#define WP_TDMAPI_EVENT_RING_TRIP_DECODE(state) \ - ((state) == WP_TDMAPI_EVENT_RING_TRIP_PRESENT) ? "Ring Present" : \ - ((state) == WP_TDMAPI_EVENT_RING_TRIP_STOP) ? "Ring Stop" : \ - "(Unknown state)" -/*Link Status */ -#define WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED 0x01 -#define WP_TDMAPI_EVENT_LINK_STATUS_DISCONNECTED 0x02 -#define WP_TDMAPI_EVENT_LINK_STATUS_DECODE(status) \ - ((status) == WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED) ? "Connected" : \ - ((status) == WP_TDMAPI_EVENT_LINK_STATUS_DISCONNECTED) ? "Disconnected" : \ - "Unknown" -#define WP_TDMAPI_EVENT_TONE_DIAL 0x01 -#define WP_TDMAPI_EVENT_TONE_BUSY 0x02 -#define WP_TDMAPI_EVENT_TONE_RING 0x03 -#define WP_TDMAPI_EVENT_TONE_CONGESTION 0x04 - -/* BRI channels list */ -#define WAN_BRI_BCHAN1 0x01 -#define WAN_BRI_BCHAN2 0x02 -#define WAN_BRI_DCHAN 0x03 - - -typedef struct { - - u_int8_t type; - u_int8_t mode; - u_int32_t time_stamp; - u_int8_t channel; - u_int32_t chan_map; - u_int8_t span; - union { - struct { - u_int8_t alarm; - } te1_alarm; - struct { - u_int8_t rbs_bits; - } te1_rbs; - struct { - u_int8_t state; - u_int8_t sig; - } rm_hook; - struct { - u_int8_t state; - } rm_ring; - struct { - u_int8_t type; - } rm_tone; - struct { - u_int8_t digit; /* DTMF: digit */ - u_int8_t port; /* DTMF: SOUT/ROUT */ - u_int8_t type; /* DTMF: PRESET/STOP */ - } dtmf; - struct { - u_int16_t polarity; - u_int16_t ohttimer; - } rm_common; - struct{ - u_int16_t status; - } linkstatus; - } wp_tdm_api_event_u; -#define wp_tdm_api_event_type type -#define wp_tdm_api_event_mode mode -#define wp_tdm_api_event_alarm wp_tdm_api_event_u.te1_alarm.alarm -#define wp_tdm_api_event_alarm wp_tdm_api_event_u.te1_alarm.alarm -#define wp_tdm_api_event_rbs_bits wp_tdm_api_event_u.te1_rbs.rbs_bits -#define wp_tdm_api_event_hook_state wp_tdm_api_event_u.rm_hook.state -#define wp_tdm_api_event_hook_sig wp_tdm_api_event_u.rm_hook.sig -#define wp_tdm_api_event_ring_state wp_tdm_api_event_u.rm_ring.state -#define wp_tdm_api_event_tone_type wp_tdm_api_event_u.rm_tone.type -#define wp_tdm_api_event_dtmf_digit wp_tdm_api_event_u.dtmf.digit -#define wp_tdm_api_event_dtmf_type wp_tdm_api_event_u.dtmf.type -#define wp_tdm_api_event_dtmf_port wp_tdm_api_event_u.dtmf.port -#define wp_tdm_api_event_ohttimer wp_tdm_api_event_u.rm_common.ohttimer -#define wp_tdm_api_event_polarity wp_tdm_api_event_u.rm_common.polarity -#define wp_tdm_api_event_link_status wp_tdm_api_event_u.linkstatus.status -} wp_tdm_api_event_t; - -typedef struct { - union { - unsigned char reserved[16]; - }wp_rx_hdr_u; -} wp_tdm_api_rx_hdr_t; - -typedef struct { - wp_tdm_api_rx_hdr_t hdr; - unsigned char data[1]; -} wp_tdm_api_rx_element_t; - -typedef struct { - union { - struct { - unsigned char _rbs_rx_bits; - unsigned int _time_stamp; - }wp_tx; - unsigned char reserved[16]; - }wp_tx_hdr_u; -#define wp_api_time_stamp wp_tx_hdr_u.wp_tx._time_stamp -} wp_tdm_api_tx_hdr_t; - -typedef struct { - wp_tdm_api_tx_hdr_t hdr; - unsigned char data[1]; -} wp_tdm_api_tx_element_t; - - - -typedef struct wp_tdm_chan_stats -{ - unsigned int rx_packets; /* total packets received */ - unsigned int tx_packets; /* total packets transmitted */ - unsigned int rx_bytes; /* total bytes received */ - unsigned int tx_bytes; /* total bytes transmitted */ - unsigned int rx_errors; /* bad packets received */ - unsigned int tx_errors; /* packet transmit problems */ - unsigned int rx_dropped; /* no space in linux buffers */ - unsigned int tx_dropped; /* no space available in linux */ - unsigned int multicast; /* multicast packets received */ -#if !defined(__WINDOWS__) - unsigned int collisions; -#endif - /* detailed rx_errors: */ - unsigned int rx_length_errors; - unsigned int rx_over_errors; /* receiver ring buff overflow */ - unsigned int rx_crc_errors; /* recved pkt with crc error */ - unsigned int rx_frame_errors; /* recv'd frame alignment error */ -#if !defined(__WINDOWS__) - unsigned int rx_fifo_errors; /* recv'r fifo overrun */ -#endif - unsigned int rx_missed_errors; /* receiver missed packet */ - - /* detailed tx_errors */ -#if !defined(__WINDOWS__) - unsigned int tx_aborted_errors; - unsigned int tx_carrier_errors; -#endif - unsigned int tx_fifo_errors; - unsigned int tx_heartbeat_errors; - unsigned int tx_window_errors; - -}wp_tdm_chan_stats_t; - - - -typedef struct wanpipe_tdm_api_cmd{ - unsigned int cmd; - unsigned int hw_tdm_coding; /* Set/Get HW TDM coding: uLaw muLaw */ - unsigned int hw_mtu_mru; /* Set/Get HW TDM MTU/MRU */ - unsigned int usr_period; /* Set/Get User Period in ms */ - unsigned int tdm_codec; /* Set/Get TDM Codec: SLinear */ - unsigned int power_level; /* Set/Get Power level treshold */ - unsigned int rx_disable; /* Enable/Disable Rx */ - unsigned int tx_disable; /* Enable/Disable Tx */ - unsigned int usr_mtu_mru; /* Set/Get User TDM MTU/MRU */ - unsigned int ec_tap; /* Echo Cancellation Tap */ - unsigned int rbs_poll; /* Enable/Disable RBS Polling */ - unsigned int rbs_rx_bits; /* Rx RBS Bits */ - unsigned int rbs_tx_bits; /* Tx RBS Bits */ - unsigned int hdlc; /* HDLC based device */ - unsigned int idle_flag; /* IDLE flag to Tx */ - unsigned int fe_alarms; /* FE Alarms detected */ - wp_tdm_chan_stats_t stats; /* TDM Statistics */ - /* Do NOT add anything above this! Important for binary backward compatibility. */ - wp_tdm_api_event_t event; /* TDM Event */ - unsigned int data_len; - void *data; - unsigned char fe_status; /* FE status - Connected or Disconnected */ - unsigned int hw_dtmf; /* HW DTMF enabled */ -}wanpipe_tdm_api_cmd_t; - -typedef struct wanpipe_tdm_api_event{ - int (*wp_rbs_event)(sng_fd_t fd, unsigned char rbs_bits); - int (*wp_dtmf_event)(sng_fd_t fd, unsigned char dtmf, unsigned char type, unsigned char port); - int (*wp_rxhook_event)(sng_fd_t fd, unsigned char hook_state); - int (*wp_ring_detect_event)(sng_fd_t fd, unsigned char ring_state); - int (*wp_ring_trip_detect_event)(sng_fd_t fd, unsigned char ring_state); - int (*wp_fe_alarm_event)(sng_fd_t fd, unsigned char fe_alarm_event); - int (*wp_link_status_event)(sng_fd_t fd, unsigned char link_status_event); -}wanpipe_tdm_api_event_t; - -typedef struct wanpipe_tdm_api{ - wanpipe_tdm_api_cmd_t wp_tdm_cmd; - wanpipe_tdm_api_event_t wp_tdm_event; -}wanpipe_tdm_api_t; - - -#endif From 7a7a387f551a8b2a52a64dd3590f73e29ee5112e Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Fri, 26 Nov 2010 15:49:18 -0500 Subject: [PATCH 24/55] freetdm: improve IO stats (cherry picked from R2 branch) --- .../ftmod_sangoma_isdn_stack_out.c | 14 +- .../src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 131 ++++++++++++++---- libs/freetdm/src/include/private/ftdm_core.h | 44 +++--- 3 files changed, 132 insertions(+), 57 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 1b906a2004..62d6d023b8 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -655,32 +655,32 @@ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) memcpy(&l1_frame.data, data, len); - if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_CRC)) { + if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_CRC)) { l1_frame.flags |= SNG_L1FRAME_ERROR_CRC; } - if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_FRAME)) { + if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_FRAME)) { l1_frame.flags |= SNG_L1FRAME_ERROR_FRAME; } - if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_ABORT)) { + if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_ABORT)) { l1_frame.flags |= SNG_L1FRAME_ERROR_ABORT; } - if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_FIFO)) { + if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_FIFO)) { l1_frame.flags |= SNG_L1FRAME_ERROR_FIFO; } - if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_DMA)) { + if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_DMA)) { l1_frame.flags |= SNG_L1FRAME_ERROR_DMA; } - if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES)) { + if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES)) { /* Should we trigger congestion here? */ l1_frame.flags |= SNG_L1FRAME_QUEUE_THRES; } - if (ftdm_test_flag(&(dchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL)) { + if (ftdm_test_flag(&(dchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL)) { /* Should we trigger congestion here? */ l1_frame.flags |= SNG_L1FRAME_QUEUE_FULL; } diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index c13455dd21..c20ad82a3b 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -513,7 +513,10 @@ static FIO_OPEN_FUNCTION(wanpipe_open) wanpipe_tdm_api_t tdm_api; memset(&tdm_api,0,sizeof(tdm_api)); + sangoma_tdm_flush_bufs(ftdmchan->sockfd, &tdm_api); + sangoma_flush_stats(ftdmchan->sockfd, &tdm_api); + memset(&ftdmchan->iostats, 0, sizeof(ftdmchan->iostats)); if (ftdmchan->type == FTDM_CHAN_TYPE_DQ921 || ftdmchan->type == FTDM_CHAN_TYPE_DQ931) { ftdmchan->native_codec = ftdmchan->effective_codec = FTDM_CODEC_NONE; @@ -750,6 +753,7 @@ static FIO_COMMAND_FUNCTION(wanpipe_command) case FTDM_COMMAND_FLUSH_IOSTATS: { err = sangoma_flush_stats(ftdmchan->sockfd, &tdm_api); + memset(&ftdmchan->iostats, 0, sizeof(ftdmchan->iostats)); } break; case FTDM_COMMAND_SET_RX_QUEUE_SIZE: @@ -777,44 +781,110 @@ static FIO_COMMAND_FUNCTION(wanpipe_command) return FTDM_SUCCESS; } +static void wanpipe_write_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_tx_hdr_t *tx_stats) +{ + ftdmchan->iostats.tx.errors = tx_stats->wp_api_tx_hdr_errors; + ftdmchan->iostats.tx.queue_size = tx_stats->wp_api_tx_hdr_max_queue_length; + ftdmchan->iostats.tx.queue_len = tx_stats->wp_api_tx_hdr_number_of_frames_in_queue; + + if (ftdmchan->iostats.tx.queue_len >= (0.8 * ftdmchan->iostats.tx.queue_size)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Tx Queue length exceeded 80% threshold (%d/%d)\n", + ftdmchan->iostats.tx.queue_len, ftdmchan->iostats.tx.queue_size); + ftdm_set_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_THRES); + } else if (ftdm_test_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_THRES)){ + ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Tx Queue length reduced 80% threshold (%d/%d)\n", + ftdmchan->iostats.tx.queue_len, ftdmchan->iostats.tx.queue_size); + ftdm_clear_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_THRES); + } + + if (ftdmchan->iostats.tx.queue_len >= ftdmchan->iostats.rx.queue_size) { + ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Tx Queue Full (%d/%d)\n", + ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); + } else if (ftdm_test_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_FULL)){ + ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Tx Queue no longer full (%d/%d)\n", + ftdmchan->iostats.tx.queue_len, ftdmchan->iostats.tx.queue_size); + ftdm_clear_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_FULL); + } + + if (ftdmchan->iostats.tx.idle_packets < tx_stats->wp_api_tx_hdr_number_of_frames_in_queue) { + ftdmchan->iostats.tx.idle_packets = tx_stats->wp_api_tx_hdr_tx_idle_packets; + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Tx idle: %d\n", ftdmchan->iostats.tx.idle_packets); + } + + if (!ftdmchan->iostats.tx.packets) { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "First packet write stats: Tx queue len: %d, Tx queue size: %d, Tx idle: %d\n", + ftdmchan->iostats.tx.queue_len, + ftdmchan->iostats.tx.queue_size, + ftdmchan->iostats.tx.idle_packets); + } + + ftdmchan->iostats.tx.packets++; +} + static void wanpipe_read_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_rx_hdr_t *rx_stats) { - ftdmchan->iostats.stats.rx.flags = 0; - - ftdmchan->iostats.stats.rx.errors = rx_stats->wp_api_rx_hdr_errors; - ftdmchan->iostats.stats.rx.rx_queue_size = rx_stats->wp_api_rx_hdr_max_queue_length; - ftdmchan->iostats.stats.rx.rx_queue_len = rx_stats->wp_api_rx_hdr_number_of_frames_in_queue; + ftdmchan->iostats.rx.errors = rx_stats->wp_api_rx_hdr_errors; + ftdmchan->iostats.rx.queue_size = rx_stats->wp_api_rx_hdr_max_queue_length; + ftdmchan->iostats.rx.queue_len = rx_stats->wp_api_rx_hdr_number_of_frames_in_queue; - if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_ABORT); - } - if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_DMA); - } - if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_FIFO); - } - if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_CRC); - } - if (rx_stats->wp_api_rx_hdr_error_map & (1<iostats.stats.rx), FTDM_IOSTATS_ERROR_FRAME); + if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_ABORT_ERROR_BIT))) { + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_ABORT); + } else { + ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_ABORT); } - if (ftdmchan->iostats.stats.rx.rx_queue_len >= (0.8*ftdmchan->iostats.stats.rx.rx_queue_size)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Rx Queue length exceeded threshold (%d/%d)\n", - ftdmchan->iostats.stats.rx.rx_queue_len, ftdmchan->iostats.stats.rx.rx_queue_size); - - ftdm_set_flag(&(ftdmchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); + if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_DMA_ERROR_BIT))) { + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_DMA); + } else { + ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_DMA); + } + + if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_FIFO_ERROR_BIT))) { + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FIFO); + } else { + ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FIFO); + } + + if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_CRC_ERROR_BIT))) { + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_CRC); + } else { + ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_CRC); + } + + if ((rx_stats->wp_api_rx_hdr_error_map & (1 << WP_FRAME_ERROR_BIT))) { + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FRAME); + } else { + ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_FRAME); + } + + if (ftdmchan->iostats.rx.queue_len >= (0.8 * ftdmchan->iostats.rx.queue_size)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Rx Queue length exceeded 80% threshold (%d/%d)\n", + ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); + } else if (ftdm_test_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES)){ + /* any reason we have wanpipe_tdm_api_iface.h in ftmod_wanpipe/ dir? */ + ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Rx Queue length reduced 80% threshold (%d/%d)\n", + ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); + ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_THRES); } - if (ftdmchan->iostats.stats.rx.rx_queue_len >= ftdmchan->iostats.stats.rx.rx_queue_size) { + if (ftdmchan->iostats.rx.queue_len >= ftdmchan->iostats.rx.queue_size) { ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Rx Queue Full (%d/%d)\n", - ftdmchan->iostats.stats.rx.rx_queue_len, ftdmchan->iostats.stats.rx.rx_queue_size); - - ftdm_set_flag(&(ftdmchan->iostats.stats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); + ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); + ftdm_set_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); + } else if (ftdm_test_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL)){ + ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Rx Queue no longer full (%d/%d)\n", + ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); + ftdm_clear_flag(&(ftdmchan->iostats.rx), FTDM_IOSTATS_ERROR_QUEUE_FULL); } - return; + + if (!ftdmchan->iostats.rx.packets) { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "First packet read stats: Rx queue len: %d, Rx queue size: %d\n", + ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.rx.queue_size); + } + + ftdmchan->iostats.rx.packets++; } /** @@ -875,6 +945,9 @@ static FIO_WRITE_FUNCTION(wanpipe_write) /* should we be checking if bsent == *datalen here? */ if (bsent > 0) { *datalen = bsent; + if (ftdm_channel_test_feature(ftdmchan, FTDM_CHANNEL_FEATURE_IO_STATS)) { + wanpipe_write_stats(ftdmchan, &hdrframe); + } return FTDM_SUCCESS; } diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h index 06f899c8c9..7683ec7145 100644 --- a/libs/freetdm/src/include/private/ftdm_core.h +++ b/libs/freetdm/src/include/private/ftdm_core.h @@ -368,30 +368,32 @@ typedef struct { } ftdm_channel_history_entry_t; typedef enum { - FTDM_IOSTATS_ERROR_CRC = (1<<0), - FTDM_IOSTATS_ERROR_FRAME = (1<<1), - FTDM_IOSTATS_ERROR_ABORT = (1<<2), - FTDM_IOSTATS_ERROR_FIFO = (1<<3), - FTDM_IOSTATS_ERROR_DMA = (1<<4), - FTDM_IOSTATS_ERROR_QUEUE_THRES = (1<<5), /* Queue reached high threshold */ - FTDM_IOSTATS_ERROR_QUEUE_FULL = (1<<6), /* Queue is full */ + FTDM_IOSTATS_ERROR_CRC = (1 << 0), + FTDM_IOSTATS_ERROR_FRAME = (1 << 1), + FTDM_IOSTATS_ERROR_ABORT = (1 << 2), + FTDM_IOSTATS_ERROR_FIFO = (1 << 3), + FTDM_IOSTATS_ERROR_DMA = (1 << 4), + FTDM_IOSTATS_ERROR_QUEUE_THRES = (1 << 5), /* Queue reached high threshold */ + FTDM_IOSTATS_ERROR_QUEUE_FULL = (1 << 6), /* Queue is full */ } ftdm_iostats_error_type_t; typedef struct { - union { - struct { - uint32_t errors; - uint16_t flags; - uint8_t rx_queue_size; /* max queue size configured */ - uint8_t rx_queue_len; /* Current number of elements in queue */ - } rx; - struct { - uint32_t errors; - uint16_t flags; - uint8_t tx_queue_size; /* max queue size configured */ - uint8_t tx_queue_len; /* Current number of elements in queue */ - } tx; - } stats; + struct { + uint32_t errors; + uint16_t flags; + uint8_t queue_size; /* max queue size configured */ + uint8_t queue_len; /* Current number of elements in queue */ + uint64_t packets; + } rx; + + struct { + uint32_t errors; + uint16_t flags; + uint8_t idle_packets; + uint8_t queue_size; /* max queue size configured */ + uint8_t queue_len; /* Current number of elements in queue */ + uint64_t packets; + } tx; } ftdm_channel_iostats_t; /* 2^8 table size, one for each byte (sample) value */ From bce61e7f926ca424c04340d217ac5ee3246fe454 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 10:49:23 -0500 Subject: [PATCH 25/55] freetdm: ftmod_wanpipe - use SANGOMA_WAIT_INFINITE instead of -1 --- libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index c20ad82a3b..65c587c350 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -121,6 +121,10 @@ static __inline__ int tdmv_api_wait_socket(ftdm_channel_t *ftdmchan, int timeout uint32_t outflags = 0; sangoma_wait_obj_t *sangoma_wait_obj = ftdmchan->io_data; + if (timeout == -1) { + timeout = SANGOMA_WAIT_INFINITE; + } + err = sangoma_waitfor(sangoma_wait_obj, inflags, &outflags, timeout); *flags = 0; if (err == SANG_STATUS_SUCCESS) { From a523e7755c111023ec767e298206fd7657693b94 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 11:07:40 -0500 Subject: [PATCH 26/55] freetdm: get rid of Linux warnings in testsangomaboost.c --- libs/freetdm/src/testsangomaboost.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/src/testsangomaboost.c b/libs/freetdm/src/testsangomaboost.c index 38eac3c190..85b5332635 100644 --- a/libs/freetdm/src/testsangomaboost.c +++ b/libs/freetdm/src/testsangomaboost.c @@ -45,10 +45,14 @@ #include -#include "freetdm.h" #include #include #include +#ifdef __linux__ +#define __USE_BSD +#include +#endif +#include "freetdm.h" /* arbitrary limit for max calls in this sample program */ @@ -338,9 +342,9 @@ int main(int argc, char *argv[]) exit(-1); } - if (!strcasecmp(argv[2], "cpe")) { + if (!strcmp(argv[2], "cpe")) { sigtype = "pri_cpe"; - } else if (!strcasecmp(argv[2], "net")) { + } else if (!strcmp(argv[2], "net")) { sigtype = "pri_net"; } else { fprintf(stderr, "Valid signaling types are cpe and net only\n"); From 469728a8656431e334e77d92d398cca05fa6c4a0 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 11:38:38 -0500 Subject: [PATCH 27/55] freetdm: clear out wait flags in the core on timeout --- libs/freetdm/src/ftdm_io.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 6f543304a2..4df4d81fe1 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2828,21 +2828,17 @@ done: FT_DECLARE(ftdm_status_t) ftdm_channel_wait(ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t to) { - assert(ftdmchan != NULL); - assert(ftdmchan->fio != NULL); + ftdm_status_t status = FTDM_FAIL; + ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "Null channel\n"); + ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "Null io interface\n"); + ftdm_assert_return(ftdmchan->fio->wait != NULL, FTDM_NOTIMPL, "wait method not implemented\n"); - if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "channel not open"); - return FTDM_FAIL; - } - - if (!ftdmchan->fio->wait) { - snprintf(ftdmchan->last_error, sizeof(ftdmchan->last_error), "method not implemented"); - return FTDM_FAIL; + status = ftdmchan->fio->wait(ftdmchan, flags, to); + if (status == FTDM_TIMEOUT) { + /* make sure the flags are cleared on timeout */ + *flags = 0; } - - return ftdmchan->fio->wait(ftdmchan, flags, to); - + return status; } /*******************************/ From ef4a4ed03498769c34bfbb22fce1e100a3e3b5e8 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 30 Nov 2010 11:01:54 -0600 Subject: [PATCH 28/55] run execute_on_answer on_media _on_ring apps async --- src/include/switch_core.h | 2 ++ src/switch_channel.c | 21 ++++++++++++++++++--- src/switch_core_session.c | 26 ++++++++++++++++++++++++++ src/switch_ivr_bridge.c | 12 +----------- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 231b26f269..33df7e31dd 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -882,6 +882,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(_In_ switch_core_sessio SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flags(_In_ switch_core_session_t *session, _In_ const char *app, _In_opt_z_ const char *arg, _Out_opt_ int32_t *flags); +SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg); + SWITCH_DECLARE(switch_status_t) switch_core_session_get_app_flags(const char *app, int32_t *flags); /*! diff --git a/src/switch_channel.c b/src/switch_channel.c index c63a1aadb9..a9c87c5954 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -2518,7 +2518,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready_value(swi if ((arg = strchr(app, ' '))) { *arg++ = '\0'; } - switch_core_session_execute_application(channel->session, app, arg); + + if (switch_core_session_in_thread(channel->session)) { + switch_core_session_execute_application(channel->session, app, arg); + } else { + switch_core_session_execute_application_async(channel->session, app, arg); + } } return SWITCH_STATUS_SUCCESS; @@ -2571,7 +2576,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_ if ((arg = strchr(app, ' '))) { *arg++ = '\0'; } - switch_core_session_execute_application(channel->session, app, arg); + + if (switch_core_session_in_thread(channel->session)) { + switch_core_session_execute_application(channel->session, app, arg); + } else { + switch_core_session_execute_application_async(channel->session, app, arg); + } } if ((var = switch_channel_get_variable(channel, SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE))) { @@ -2750,7 +2760,12 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan } switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s execute on answer: %s(%s)\n", channel->name, app, switch_str_nil(arg)); - switch_core_session_execute_application(channel->session, app, arg); + + if (switch_core_session_in_thread(channel->session)) { + switch_core_session_execute_application(channel->session, app, arg); + } else { + switch_core_session_execute_application_async(channel->session, app, arg); + } } } diff --git a/src/switch_core_session.c b/src/switch_core_session.c index aaa47cc696..a84bfabaf0 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -855,6 +855,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_sess if (switch_queue_trypush(session->event_queue, *event) == SWITCH_STATUS_SUCCESS) { *event = NULL; status = SWITCH_STATUS_SUCCESS; + + if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_test_flag(session->channel, CF_THREAD_SLEEPING)) { + switch_core_session_wake_session_thread(session); + } } } @@ -1814,6 +1818,28 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_app_flags(const char *ap } +SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg) +{ + switch_event_t *execute_event; + + if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute"); + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", app); + + if (arg) { + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg); + } + + switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true"); + switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE); + + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; +} + + SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flags(switch_core_session_t *session, const char *app, const char *arg, int32_t *flags) { diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 4cae1a67e2..4d320d0e5c 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -348,20 +348,10 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj) if (read_frame_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) { if (exec_app) { - switch_event_t *execute_event; switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "%s Bridge execute app %s(%s)\n", switch_channel_get_name(chan_a), exec_app, exec_data); - if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute"); - switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", exec_app); - if (exec_data) { - switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", exec_data); - } - //switch_event_add_header(execute_event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5); - switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true"); - switch_core_session_queue_private_event(session_a, &execute_event, SWITCH_FALSE); - } + switch_core_session_execute_application_async(session_a, exec_app, exec_data); exec_app = exec_data = NULL; } From 5b15e03f30eabcba91b0c1bec09a489221bbaaaa Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 30 Nov 2010 11:24:59 -0600 Subject: [PATCH 29/55] swigall --- .../languages/mod_managed/freeswitch_wrap.cxx | 28 +++++++++++++++++++ src/mod/languages/mod_managed/managed/swig.cs | 16 +++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index ca001f64b1..d2f63b1006 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -7626,6 +7626,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_execute_application_get_fl } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_execute_application_async(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_core_session_execute_application_async(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_app_flags(char * jarg1, void * jarg2) { int jresult ; char *arg1 = (char *) 0 ; @@ -7856,6 +7872,18 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_session_event_count(void } +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_session_messages_waiting(void * jarg1) { + unsigned long jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + uint32_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (uint32_t)switch_core_session_messages_waiting(arg1); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_dequeue_event(void * jarg1, void * jarg2, int jarg3) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index bd901911ed..fd4915f013 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -1439,6 +1439,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_execute_application_async(SWIGTYPE_p_switch_core_session session, string app, string arg) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_execute_application_async(SWIGTYPE_p_switch_core_session.getCPtr(session), app, arg); + return ret; + } + public static switch_status_t switch_core_session_get_app_flags(string app, SWIGTYPE_p_int flags) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_app_flags(app, SWIGTYPE_p_int.getCPtr(flags)); return ret; @@ -1518,6 +1523,11 @@ public class freeswitch { return ret; } + public static uint switch_core_session_messages_waiting(SWIGTYPE_p_switch_core_session session) { + uint ret = freeswitchPINVOKE.switch_core_session_messages_waiting(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + public static switch_status_t switch_core_session_dequeue_event(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_event arg1, switch_bool_t force) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_dequeue_event(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_event.getCPtr(arg1), (int)force); return ret; @@ -7449,6 +7459,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_execute_application_get_flags")] public static extern int switch_core_session_execute_application_get_flags(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_execute_application_async")] + public static extern int switch_core_session_execute_application_async(HandleRef jarg1, string jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_app_flags")] public static extern int switch_core_session_get_app_flags(string jarg1, HandleRef jarg2); @@ -7497,6 +7510,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_event_count")] public static extern uint switch_core_session_event_count(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_messages_waiting")] + public static extern uint switch_core_session_messages_waiting(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_dequeue_event")] public static extern int switch_core_session_dequeue_event(HandleRef jarg1, HandleRef jarg2, int jarg3); From 302d5bb18f5604c180d1eb3c48b80929e1b306ae Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 25 Nov 2010 19:19:32 -0500 Subject: [PATCH 30/55] Changes for ftdm variables --- libs/freetdm/mod_freetdm/mod_freetdm.c | 73 +++-- libs/freetdm/src/ftdm_call_utils.c | 135 +++++---- libs/freetdm/src/ftdm_io.c | 20 +- .../ftmod_sangoma_boost/ftdm_sangoma_boost.h | 2 +- .../ftmod_sangoma_boost/ftmod_sangoma_boost.c | 14 +- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 11 +- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 72 +++-- .../ftmod_sangoma_isdn_cfg.c | 97 +++--- .../ftmod_sangoma_isdn_stack_hndl.c | 99 +++--- .../ftmod_sangoma_isdn_stack_out.c | 90 ++---- .../ftmod_sangoma_isdn_support.c | 285 ++++++++++++++++-- .../ftmod_sangoma_isdn_trace.c | 15 + .../ftmod_sangoma_isdn_trace.h | 6 + libs/freetdm/src/include/freetdm.h | 82 +++-- libs/freetdm/src/include/ftdm_call_utils.h | 118 ++++++++ libs/freetdm/src/include/ftdm_declare.h | 17 ++ .../src/include/private/ftdm_call_utils.h | 47 --- 17 files changed, 792 insertions(+), 391 deletions(-) create mode 100644 libs/freetdm/src/include/ftdm_call_utils.h delete mode 100644 libs/freetdm/src/include/private/ftdm_call_utils.h diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 27dc8d8c92..07d4e88f33 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -149,6 +149,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig); +static const char* channel_get_variable(switch_core_session_t *session, switch_event_t *var_event, const char *variable_name); ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session_t **sp); void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream); void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stream); @@ -1049,6 +1050,27 @@ switch_io_routines_t freetdm_io_routines = { /*.receive_message*/ channel_receive_message }; +static const char* channel_get_variable(switch_core_session_t *session, switch_event_t *var_event, const char *variable_name) +{ + const char *variable = NULL; + + if (var_event) { + if ((variable = switch_event_get_header(var_event, variable_name))) { + return variable; + } + } + if (session) { + switch_channel_t *channel = switch_core_session_get_channel(session); + if ((variable = switch_channel_get_variable(channel, variable_name))) { + return variable; + } + } + if ((variable = switch_core_get_variable(variable_name))) { + return variable; + } + return NULL; +} + /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines that allocate memory or you will have 1 channel with memory allocated from another channel's pool! */ @@ -1226,20 +1248,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi } } - if (session) { - /* take out some other values from the session if they're present */ - switch_channel_t *channel = switch_core_session_get_channel(session); - const char *freetdmvar; - freetdmvar = switch_channel_get_variable(channel, "freetdm_bearer_capability"); - if (freetdmvar) { - caller_data.bearer_capability = (uint8_t)atoi(freetdmvar); - } - freetdmvar = switch_channel_get_variable(channel, "freetdm_bearer_layer1"); - if (freetdmvar) { - caller_data.bearer_layer1 = (uint8_t)atoi(freetdmvar); - } - } - if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) { caller_data.screen = 1; } @@ -1248,29 +1256,37 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi caller_data.pres = 1; } - if (!zstr(dest)) { - ftdm_set_string(caller_data.dnis.digits, dest); + if ((var = channel_get_variable(session, var_event, "freetdm_bearer_capability"))) { + caller_data.bearer_capability = (uint8_t)atoi(var); } - if ((var = switch_event_get_header(var_event, "freetdm_outbound_ton")) || (var = switch_core_get_variable("freetdm_outbound_ton"))) { - if (!strcasecmp(var, "national")) { - caller_data.dnis.type = FTDM_TON_NATIONAL; - } else if (!strcasecmp(var, "international")) { - caller_data.dnis.type = FTDM_TON_INTERNATIONAL; - } else if (!strcasecmp(var, "local")) { - caller_data.dnis.type = FTDM_TON_SUBSCRIBER_NUMBER; - } else if (!strcasecmp(var, "unknown")) { - caller_data.dnis.type = FTDM_TON_UNKNOWN; - } + if ((var = channel_get_variable(session, var_event, "freetdm_bearer_layer1"))) { + caller_data.bearer_layer1 = (uint8_t)atoi(var); + } + + if ((var = channel_get_variable(session, var_event, "freetdm_screening_ind"))) { + ftdm_set_screening_ind(var, &caller_data.screen); + } + + if ((var = channel_get_variable(session, var_event, "freetdm_presentation_ind"))) { + ftdm_set_presentation_ind(var, &caller_data.pres); + } + + if ((var = channel_get_variable(session, var_event, "freetdm_outbound_ton"))) { + ftdm_set_ton(var, &caller_data.dnis.type); } else { caller_data.dnis.type = outbound_profile->destination_number_ton; } - if ((var = switch_event_get_header(var_event, "freetdm_custom_call_data")) || (var = switch_core_get_variable("freetdm_custom_call_data"))) { + if ((var = channel_get_variable(session, var_event, "freetdm_custom_call_data"))) { ftdm_set_string(caller_data.raw_data, var); caller_data.raw_data_len = (uint32_t)strlen(var); } + if (!zstr(dest)) { + ftdm_set_string(caller_data.dnis.digits, dest); + } + caller_data.dnis.plan = outbound_profile->destination_number_numplan; /* blindly copy data from outbound_profile. They will be overwritten @@ -2074,6 +2090,9 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal) switch(sigmsg->event_id) { case FTDM_SIGEVENT_START: { + ftdm_channel_add_var(sigmsg->channel, "screening_ind", ftdm_screening2str(caller_data->screen)); + ftdm_channel_add_var(sigmsg->channel, "presentation_ind", ftdm_presentation2str(caller_data->pres)); + ftdm_enable_channel_dtmf(sigmsg->channel, NULL); return ftdm_channel_from_event(sigmsg, &session); } diff --git a/libs/freetdm/src/ftdm_call_utils.c b/libs/freetdm/src/ftdm_call_utils.c index d91b3bc9e2..52d2557a01 100644 --- a/libs/freetdm/src/ftdm_call_utils.c +++ b/libs/freetdm/src/ftdm_call_utils.c @@ -36,80 +36,101 @@ #include -FT_DECLARE(ftdm_status_t) ftdm_span_set_npi(const char *npi_string, uint8_t *target) +FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *string, uint8_t *target) { - if (!strcasecmp(npi_string, "isdn") || !strcasecmp(npi_string, "e164")) { - *target = FTDM_NPI_ISDN; - } else if (!strcasecmp(npi_string, "data")) { - *target = FTDM_NPI_DATA; - } else if (!strcasecmp(npi_string, "telex")) { - *target = FTDM_NPI_TELEX; - } else if (!strcasecmp(npi_string, "national")) { - *target = FTDM_NPI_NATIONAL; - } else if (!strcasecmp(npi_string, "private")) { - *target = FTDM_NPI_PRIVATE; - } else if (!strcasecmp(npi_string, "reserved")) { - *target = FTDM_NPI_RESERVED; - } else if (!strcasecmp(npi_string, "unknown")) { - *target = FTDM_NPI_UNKNOWN; - } else { - ftdm_log(FTDM_LOG_WARNING, "Invalid NPI value (%s)\n", npi_string); - *target = FTDM_NPI_UNKNOWN; - return FTDM_FAIL; + int val; + ftdm_status_t status = FTDM_SUCCESS; + + val = ftdm_str2ftdm_npi(string); + if (val == FTDM_NPI_INVALID) { + ftdm_log(FTDM_LOG_WARNING, "Invalid NPI string (%s)\n", string); + status = FTDM_FAIL; + val = FTDM_NPI_UNKNOWN; } - return FTDM_SUCCESS; + *target = val; + return status; } -FT_DECLARE(ftdm_status_t) ftdm_span_set_ton(const char *ton_string, uint8_t *target) +FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *string, uint8_t *target) { - if (!strcasecmp(ton_string, "national")) { - *target = FTDM_TON_NATIONAL; - } else if (!strcasecmp(ton_string, "international")) { - *target = FTDM_TON_INTERNATIONAL; - } else if (!strcasecmp(ton_string, "local")) { - *target = FTDM_TON_SUBSCRIBER_NUMBER; - } else if (!strcasecmp(ton_string, "unknown")) { - *target = FTDM_TON_UNKNOWN; - } else { - ftdm_log(FTDM_LOG_WARNING, "Invalid TON value (%s)\n", ton_string); - *target = FTDM_TON_UNKNOWN; - return FTDM_FAIL; + int val; + ftdm_status_t status = FTDM_SUCCESS; + + val = ftdm_str2ftdm_ton(string); + if (val == FTDM_TON_INVALID) { + ftdm_log(FTDM_LOG_WARNING, "Invalid TON string (%s)\n", string); + status = FTDM_FAIL; + val = FTDM_TON_UNKNOWN; } - return FTDM_SUCCESS; + *target = val; + return status; } -FT_DECLARE(ftdm_status_t) ftdm_span_set_bearer_capability(const char *bc_string, ftdm_bearer_cap_t *target) +FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *string, uint8_t *target) { - if (!strcasecmp(bc_string, "speech")) { - *target = FTDM_BEARER_CAP_SPEECH; - } else if (!strcasecmp(bc_string, "unrestricted-digital")) { - *target = FTDM_BEARER_CAP_64K_UNRESTRICTED; - } else if (!strcasecmp(bc_string, "3.1Khz")) { - *target = FTDM_BEARER_CAP_3_1KHZ_AUDIO; - } else { - ftdm_log(FTDM_LOG_WARNING, "Unsupported Bearer Capability value (%s)\n", bc_string); - return FTDM_FAIL; + int val; + ftdm_status_t status = FTDM_SUCCESS; + + val = ftdm_str2ftdm_bearer_cap(string); + if (val == FTDM_NPI_INVALID) { + ftdm_log(FTDM_LOG_WARNING, "Invalid Bearer-Capability string (%s)\n", string); + status = FTDM_FAIL; + val = FTDM_BEARER_CAP_SPEECH; } - return FTDM_SUCCESS; + + *target = val; + return status; } -FT_DECLARE(ftdm_status_t) ftdm_span_set_bearer_layer1(const char *bc_string, ftdm_user_layer1_prot_t *target) +FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *string, uint8_t *target) { - if (!strcasecmp(bc_string, "v110")) { - *target = FTDM_USER_LAYER1_PROT_V110; - } else if (!strcasecmp(bc_string, "ulaw")) { - *target = FTDM_USER_LAYER1_PROT_ULAW; - } else if (!strcasecmp(bc_string, "alaw")) { - *target =FTDM_USER_LAYER1_PROT_ALAW ; - } else { - ftdm_log(FTDM_LOG_WARNING, "Unsupported Bearer Layer1 Prot value (%s)\n", bc_string); - return FTDM_FAIL; + int val; + ftdm_status_t status = FTDM_SUCCESS; + + val = ftdm_str2ftdm_usr_layer1_prot(string); + if (val == FTDM_USER_LAYER1_PROT_INVALID) { + ftdm_log(FTDM_LOG_WARNING, "Invalid Bearer Layer 1 Protocol string (%s)\n", string); + status = FTDM_FAIL; + val = FTDM_USER_LAYER1_PROT_ULAW; } - return FTDM_SUCCESS; + + *target = val; + return status; } +FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *target) +{ + int val; + ftdm_status_t status = FTDM_SUCCESS; -FT_DECLARE(ftdm_status_t) ftdm_is_number(char *number) + val = ftdm_str2ftdm_screening(string); + if (val == FTDM_SCREENING_INVALID) { + ftdm_log(FTDM_LOG_WARNING, "Invalid screening indicator string (%s)\n", string); + status = FTDM_FAIL; + val = FTDM_SCREENING_NOT_SCREENED; + } + + *target = val; + return status; +} + +FT_DECLARE(ftdm_status_t) ftdm_set_presentation_ind(const char *string, uint8_t *target) +{ + int val; + ftdm_status_t status = FTDM_SUCCESS; + + val = ftdm_str2ftdm_presentation(string); + if (val == FTDM_PRES_INVALID) { + ftdm_log(FTDM_LOG_WARNING, "Invalid presentation string (%s)\n", string); + status = FTDM_FAIL; + val = FTDM_PRES_ALLOWED; + } + + *target = val; + return status; +} + +FT_DECLARE(ftdm_status_t) ftdm_is_number(const char *number) { if (!number) { return FTDM_FAIL; diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index ede3ff8fc8..3e48586a4e 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -150,6 +150,24 @@ FTDM_STR2ENUM(ftdm_str2ftdm_chan_type, ftdm_chan_type2str, ftdm_chan_type_t, CHA FTDM_ENUM_NAMES(SIGNALING_STATUS_NAMES, SIGSTATUS_STRINGS) FTDM_STR2ENUM(ftdm_str2ftdm_signaling_status, ftdm_signaling_status2str, ftdm_signaling_status_t, SIGNALING_STATUS_NAMES, FTDM_SIG_STATE_INVALID) +FTDM_ENUM_NAMES(TON_NAMES, TON_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_ton, ftdm_ton2str, ftdm_ton_t, TON_NAMES, FTDM_TON_INVALID) + +FTDM_ENUM_NAMES(NPI_NAMES, NPI_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_npi, ftdm_npi2str, ftdm_npi_t, NPI_NAMES, FTDM_NPI_INVALID) + +FTDM_ENUM_NAMES(PRESENTATION_NAMES, PRESENTATION_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_presentation, ftdm_presentation2str, ftdm_presentation_t, PRESENTATION_NAMES, FTDM_PRES_INVALID) + +FTDM_ENUM_NAMES(SCREENING_NAMES, SCREENING_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_screening, ftdm_screening2str, ftdm_screening_t, SCREENING_NAMES, FTDM_SCREENING_INVALID) + +FTDM_ENUM_NAMES(BEARER_CAP_NAMES, BEARER_CAP_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_bearer_cap, ftdm_bearer_cap2str, ftdm_bearer_cap_t, BEARER_CAP_NAMES, FTDM_BEARER_CAP_INVALID) + +FTDM_ENUM_NAMES(USER_LAYER1_PROT_NAMES, USER_LAYER1_PROT_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_usr_layer1_prot, ftdm_user_layer1_prot2str, ftdm_user_layer1_prot_t, USER_LAYER1_PROT_NAMES, FTDM_USER_LAYER1_PROT_INVALID) + static ftdm_status_t ftdm_group_add_channels(ftdm_span_t* span, int currindex, const char* name); static const char *cut_path(const char *in) @@ -4822,7 +4840,7 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t if (sigmsg->channel) { ftdm_mutex_lock(sigmsg->channel->mutex); } - + /* some core things to do on special events */ switch (sigmsg->event_id) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftdm_sangoma_boost.h b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftdm_sangoma_boost.h index 5a3ca76c56..6fbf272d07 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftdm_sangoma_boost.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftdm_sangoma_boost.h @@ -58,7 +58,7 @@ typedef struct ftdm_sangoma_boost_trunkgroup { ftdm_size_t size; /* Number of b-channels in group */ unsigned int last_used_index; /* index of last b-channel used */ ftdm_channel_t* ftdmchans[MAX_CHANS_PER_TRUNKGROUP]; - //DAVIDY need to merge congestion timeouts to this struct + //TODO need to merge congestion timeouts to this struct } ftdm_sangoma_boost_trunkgroup_t; #endif diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c index c9691e232b..50a01cc0ec 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.c @@ -55,7 +55,7 @@ ftdm_mutex_t *g_boost_modules_mutex = NULL; ftdm_hash_t *g_boost_modules_hash = NULL; #define MAX_TRUNK_GROUPS 64 -//DAVIDY need to merge congestion_timeouts with ftdm_sangoma_boost_trunkgroups +//TODO need to merge congestion_timeouts with ftdm_sangoma_boost_trunkgroups static time_t congestion_timeouts[MAX_TRUNK_GROUPS]; static ftdm_sangoma_boost_trunkgroup_t *g_trunkgroups[MAX_TRUNK_GROUPS]; @@ -2582,17 +2582,17 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_boost_configure_span) } else if (!strcasecmp(var, "remote_port")) { remote_port = atoi(val); } else if (!strcasecmp(var, "outbound-called-ton")) { - ftdm_span_set_ton(val, &span->default_caller_data.dnis.type); + ftdm_set_ton(val, &span->default_caller_data.dnis.type); } else if (!strcasecmp(var, "outbound-called-npi")) { - ftdm_span_set_npi(val, &span->default_caller_data.dnis.plan); + ftdm_set_npi(val, &span->default_caller_data.dnis.plan); } else if (!strcasecmp(var, "outbound-calling-ton")) { - ftdm_span_set_ton(val, &span->default_caller_data.cid_num.type); + ftdm_set_ton(val, &span->default_caller_data.cid_num.type); } else if (!strcasecmp(var, "outbound-calling-npi")) { - ftdm_span_set_npi(val, &span->default_caller_data.cid_num.plan); + ftdm_set_npi(val, &span->default_caller_data.cid_num.plan); } else if (!strcasecmp(var, "outbound-rdnis-ton")) { - ftdm_span_set_ton(val, &span->default_caller_data.rdnis.type); + ftdm_set_ton(val, &span->default_caller_data.rdnis.type); } else if (!strcasecmp(var, "outbound-rdnis-npi")) { - ftdm_span_set_npi(val, &span->default_caller_data.rdnis.plan); + ftdm_set_npi(val, &span->default_caller_data.rdnis.plan); } else if (!sigmod) { snprintf(span->last_error, sizeof(span->last_error), "Unknown parameter [%s]", var); FAIL_CONFIG_RETURN(FTDM_FAIL); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 6f5f838590..8831ac4185 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -40,8 +40,8 @@ #include #endif -static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj); +static void *ftdm_sangoma_isdn_run(ftdm_thread_t *me, void *obj); static ftdm_status_t ftdm_sangoma_isdn_stop(ftdm_span_t *span); static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span); @@ -673,7 +673,8 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) break; case FTDM_CHANNEL_STATE_RINGING: { - sngisdn_snd_alert(ftdmchan, SNGISDN_PROGIND_NETE_ISDN); + ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN}; + sngisdn_snd_alert(ftdmchan, prog_ind); } break; case FTDM_CHANNEL_STATE_PROGRESS: @@ -687,7 +688,8 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) /* If we already sent a PROCEED before, do not send a PROGRESS as there is nothing to indicate to the remote switch */ if (ftdmchan->last_state != FTDM_CHANNEL_STATE_PROCEED) { /* Send a progress message, indicating: Call is not end-to-end ISDN, further call progress may be available */ - sngisdn_snd_progress(ftdmchan, SNGISDN_PROGIND_NETE_ISDN); + ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN}; + sngisdn_snd_progress(ftdmchan, prog_ind); } } } @@ -699,7 +701,8 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) ftdm_span_send_signal(ftdmchan->span, &sigev); } else { /* Send a progress message, indicating: In-band information/pattern available */ - sngisdn_snd_progress(ftdmchan, SNGISDN_PROGIND_IB_AVAIL); + ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_IB_AVAIL}; + sngisdn_snd_progress(ftdmchan, prog_ind); } } break; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index a82ed283e1..6957f9925e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -138,17 +138,47 @@ typedef enum { typedef enum { /* Call is not end-to-end ISDN */ - SNGISDN_PROGIND_NETE_ISDN = 1, + SNGISDN_PROGIND_DESCR_NETE_ISDN, /* Destination address is non-ISDN */ - SNGISDN_PROGIND_DEST_NISDN, + SNGISDN_PROGIND_DESCR_DEST_NISDN, /* Origination address is non-ISDN */ - SNGISDN_PROGIND_ORIG_NISDN, + SNGISDN_PROGIND_DESCR_ORIG_NISDN, /* Call has returned to the ISDN */ - SNGISDN_PROGIND_RET_ISDN, + SNGISDN_PROGIND_DESCR_RET_ISDN, /* Interworking as occured and has resulted in a telecommunication service change */ - SNGISDN_PROGIND_SERV_CHANGE, - /* In-band information or an appropriate pattern is now available */ - SNGISDN_PROGIND_IB_AVAIL, + SNGISDN_PROGIND_DESCR_SERV_CHANGE, + /* In-band information or an appropriate pattern is now available */ + SNGISDN_PROGIND_DESCR_IB_AVAIL, + /* Invalid */ + SNGISDN_PROGIND_DESCR_INVALID, +} ftdm_sngisdn_progind_descr_t; +#define SNGISDN_PROGIND_DESCR_STRINGS "not-end-to-end-isdn", "destination-is-non-isdn", "origination-is-non-isdn", "call-returned-to-isdn", "service-change", "inband-info-available", "invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t); + +typedef enum { + /* User */ + SNGISDN_PROGIND_LOC_USER, + /* Private network serving the local user */ + SNGISDN_PROGIND_LOC_PRIV_NET_LOCAL_USR, + /* Public network serving the local user */ + SNGISDN_PROGIND_LOC_PUB_NET_LOCAL_USR, + /* Transit network */ + SNGISDN_PROGIND_LOC_TRANSIT_NET, + /* Public network serving remote user */ + SNGISDN_PROGIND_LOC_PUB_NET_REMOTE_USR, + /* Private network serving remote user */ + SNGISDN_PROGIND_LOC_PRIV_NET_REMOTE_USR, + /* Network beyond the interworking point */ + SNGISDN_PROGIND_LOC_NET_BEYOND_INTRW, + /* Invalid */ + SNGISDN_PROGIND_LOC_INVALID, +} ftdm_sngisdn_progind_loc_t; +#define SNGISDN_PROGIND_LOC_STRINGS "user", "private-net-local-user", "public-net-local-user", "transit-network", "public-net-remote-user", "private-net-remote-user", "beyond-interworking", "invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t); + +typedef struct ftdm_sngisdn_prog_ind { + ftdm_sngisdn_progind_loc_t loc; /* location */ + ftdm_sngisdn_progind_descr_t descr; /* description */ } ftdm_sngisdn_progind_t; /* Only timers that can be cancelled are listed here */ @@ -201,6 +231,7 @@ typedef struct sngisdn_span_data { uint8_t facility; int8_t facility_timeout; uint8_t num_local_numbers; + uint8_t ignore_cause_value; uint8_t timer_t3; char* local_numbers[SNGISDN_NUM_LOCAL_NUMBERS]; ftdm_sched_t *sched; @@ -376,18 +407,25 @@ void sngisdn_rcv_cc_ind(CcMngmt *status); void sngisdn_rcv_sng_log(uint8_t level, char *fmt,...); void sngisdn_rcv_sng_assert(char *message); -ftdm_status_t get_calling_num(ftdm_caller_data_t *ftdm, CgPtyNmb *cgPtyNmb); -ftdm_status_t get_called_num(ftdm_caller_data_t *ftdm, CdPtyNmb *cdPtyNmb); -ftdm_status_t get_redir_num(ftdm_caller_data_t *ftdm, RedirNmb *redirNmb); -ftdm_status_t get_calling_name_from_display(ftdm_caller_data_t *ftdm, Display *display); -ftdm_status_t get_calling_name_from_usr_usr(ftdm_caller_data_t *ftdm, UsrUsr *usrUsr); -ftdm_status_t get_facility_ie(ftdm_caller_data_t *ftdm, uint8_t *data, uint32_t data_len); +ftdm_status_t get_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); +ftdm_status_t get_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb); +ftdm_status_t get_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb); +ftdm_status_t get_calling_name_from_display(ftdm_channel_t *ftdmchan, Display *display); +ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr); +ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad); +ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd); +ftdm_status_t get_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); +ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, ftdm_size_t data_len); -ftdm_status_t set_calling_num(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *ftdm); -ftdm_status_t set_called_num(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *ftdm); -ftdm_status_t set_redir_num(RedirNmb *redirNmb, ftdm_caller_data_t *ftdm); -ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan); +ftdm_status_t set_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb); +ftdm_status_t set_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb); +ftdm_status_t set_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb); +ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt); +ftdm_status_t set_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad); +ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_sngisdn_progind_t prog_ind); ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr); +ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, ftdm_size_t *data_len); + uint8_t sngisdn_get_infoTranCap_from_stack(ftdm_bearer_cap_t bearer_capability); uint8_t sngisdn_get_usrInfoLyr1Prot_from_stack(ftdm_user_layer1_prot_t layer1_prot); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index 657aa5e206..6b4e73ab25 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -34,13 +34,24 @@ #include "ftmod_sangoma_isdn.h" -ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span); -ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span); -ftdm_status_t add_local_number(const char* val, ftdm_span_t *span); +static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span); +static ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span); +static ftdm_status_t add_local_number(const char* val, ftdm_span_t *span); +static ftdm_status_t parse_yesno(const char* var, const char* val, uint8_t *target); extern ftdm_sngisdn_data_t g_sngisdn_data; -ftdm_status_t add_local_number(const char* val, ftdm_span_t *span) +static ftdm_status_t parse_yesno(const char* var, const char* val, uint8_t *target) +{ + if (ftdm_true(val)) { + *target = SNGISDN_OPT_TRUE; + } else { + *target = SNGISDN_OPT_FALSE; + } + return FTDM_SUCCESS; +} + +static ftdm_status_t add_local_number(const char* val, ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; @@ -53,7 +64,7 @@ ftdm_status_t add_local_number(const char* val, ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span) +static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span) { unsigned i; ftdm_iterator_t *chaniter = NULL; @@ -160,7 +171,7 @@ ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span) return FTDM_SUCCESS; } -ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span) +static ftdm_status_t parse_signalling(const char* signalling, ftdm_span_t *span) { sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) span->signal_data; if (!strcasecmp(signalling, "net") || @@ -190,7 +201,8 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ signal_data->min_digits = 8; signal_data->overlap_dial = SNGISDN_OPT_DEFAULT; signal_data->setup_arb = SNGISDN_OPT_DEFAULT; - signal_data->facility_ie_decode = SNGISDN_OPT_TRUE; + signal_data->facility_ie_decode = SNGISDN_OPT_DEFAULT; + signal_data->ignore_cause_value = SNGISDN_OPT_DEFAULT; signal_data->timer_t3 = 8; signal_data->link_id = span->span_id; @@ -202,20 +214,19 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ if (span->trunk_type == FTDM_TRUNK_BRI || span->trunk_type == FTDM_TRUNK_BRI_PTMP) { - - ftdm_span_set_npi("unknown", &span->default_caller_data.dnis.plan); - ftdm_span_set_ton("unknown", &span->default_caller_data.dnis.type); - ftdm_span_set_npi("unknown", &span->default_caller_data.cid_num.plan); - ftdm_span_set_ton("unknown", &span->default_caller_data.cid_num.type); - ftdm_span_set_npi("unknown", &span->default_caller_data.rdnis.plan); - ftdm_span_set_ton("unknown", &span->default_caller_data.rdnis.type); + ftdm_set_npi("unknown", &span->default_caller_data.dnis.plan); + ftdm_set_ton("unknown", &span->default_caller_data.dnis.type); + ftdm_set_npi("unknown", &span->default_caller_data.cid_num.plan); + ftdm_set_ton("unknown", &span->default_caller_data.cid_num.type); + ftdm_set_npi("unknown", &span->default_caller_data.rdnis.plan); + ftdm_set_ton("unknown", &span->default_caller_data.rdnis.type); } else { - ftdm_span_set_npi("e164", &span->default_caller_data.dnis.plan); - ftdm_span_set_ton("national", &span->default_caller_data.dnis.type); - ftdm_span_set_npi("e164", &span->default_caller_data.cid_num.plan); - ftdm_span_set_ton("national", &span->default_caller_data.cid_num.type); - ftdm_span_set_npi("e164", &span->default_caller_data.rdnis.plan); - ftdm_span_set_ton("national", &span->default_caller_data.rdnis.type); + ftdm_set_npi("isdn", &span->default_caller_data.dnis.plan); + ftdm_set_ton("national", &span->default_caller_data.dnis.type); + ftdm_set_npi("isdn", &span->default_caller_data.cid_num.plan); + ftdm_set_ton("national", &span->default_caller_data.cid_num.type); + ftdm_set_npi("isdn", &span->default_caller_data.rdnis.plan); + ftdm_set_ton("national", &span->default_caller_data.rdnis.type); } for (paramindex = 0; ftdm_parameters[paramindex].var; paramindex++) { @@ -247,41 +258,29 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ } else { ftdm_log(FTDM_LOG_ERROR, "Invalid value for parameter:%s:%s\n", var, val); } - } else if (!strcasecmp(var, "setup arbitration")) { - if (!strcasecmp(val, "yes")) { - signal_data->setup_arb = SNGISDN_OPT_TRUE; - } else if (!strcasecmp(val, "no")) { - signal_data->setup_arb = SNGISDN_OPT_FALSE; - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid value for parameter:%s:%s\n", var, val); - } + } else if (!strcasecmp(var, "setup-arbitration")) { + parse_yesno(var, val, &signal_data->setup_arb); } else if (!strcasecmp(var, "facility")) { - if (!strcasecmp(val, "yes")) { - signal_data->facility = SNGISDN_OPT_TRUE; - } else if (!strcasecmp(val, "no")) { - signal_data->facility = SNGISDN_OPT_FALSE; - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid value for parameter:%s:%s\n", var, val); - } + parse_yesno(var, val, &signal_data->facility); } else if (!strcasecmp(var, "min_digits")) { signal_data->min_digits = atoi(val); } else if (!strcasecmp(var, "outbound-called-ton")) { - ftdm_span_set_ton(val, &span->default_caller_data.dnis.type); + ftdm_set_ton(val, &span->default_caller_data.dnis.type); } else if (!strcasecmp(var, "outbound-called-npi")) { - ftdm_span_set_npi(val, &span->default_caller_data.dnis.plan); + ftdm_set_npi(val, &span->default_caller_data.dnis.plan); } else if (!strcasecmp(var, "outbound-calling-ton")) { - ftdm_span_set_ton(val, &span->default_caller_data.cid_num.type); + ftdm_set_ton(val, &span->default_caller_data.cid_num.type); } else if (!strcasecmp(var, "outbound-calling-npi")) { - ftdm_span_set_npi(val, &span->default_caller_data.cid_num.plan); + ftdm_set_npi(val, &span->default_caller_data.cid_num.plan); } else if (!strcasecmp(var, "outbound-rdnis-ton")) { - ftdm_span_set_ton(val, &span->default_caller_data.rdnis.type); + ftdm_set_ton(val, &span->default_caller_data.rdnis.type); } else if (!strcasecmp(var, "outbound-rdnis-npi")) { - ftdm_span_set_npi(val, &span->default_caller_data.rdnis.plan); + ftdm_set_npi(val, &span->default_caller_data.rdnis.plan); } else if (!strcasecmp(var, "outbound-bearer_cap")) { - ftdm_span_set_bearer_capability(val, &span->default_caller_data.bearer_capability); + ftdm_set_bearer_capability(val, (uint8_t*)&span->default_caller_data.bearer_capability); } else if (!strcasecmp(var, "outbound-bearer_layer1")) { - ftdm_span_set_bearer_layer1(val, &span->default_caller_data.bearer_layer1); - } else if (!strcasecmp(var, "local-number")) { + ftdm_set_bearer_layer1(val, (uint8_t*)&span->default_caller_data.bearer_layer1); + } else if (!strcasecmp(var, "local-number")) { if (add_local_number(val, span) != FTDM_SUCCESS) { return FTDM_FAIL; } @@ -291,13 +290,9 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ signal_data->facility_timeout = 0; } } else if (!strcasecmp(var, "facility-ie-decode")) { - if (!strcasecmp(val, "yes")) { - signal_data->facility_ie_decode = SNGISDN_OPT_TRUE; - } else if (!strcasecmp(val, "no")) { - signal_data->facility_ie_decode = SNGISDN_OPT_FALSE; - } else { - ftdm_log(FTDM_LOG_ERROR, "Invalid value for parameter:%s:%s\n", var, val); - } + parse_yesno(var, val, &signal_data->facility_ie_decode); + } else if (!strcasecmp(var, "ignore-cause-value")) { + parse_yesno(var, val, &signal_data->ignore_cause_value); } else { ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index a541a655d8..6bf0c25212 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -127,13 +127,15 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) ftdm_channel_add_var(ftdmchan, "isdn_specific_var", "1"); #endif /* Fill in call information */ - get_calling_num(&ftdmchan->caller_data, &conEvnt->cgPtyNmb); - get_called_num(&ftdmchan->caller_data, &conEvnt->cdPtyNmb); - get_redir_num(&ftdmchan->caller_data, &conEvnt->redirNmb); + get_calling_num(ftdmchan, &conEvnt->cgPtyNmb); + get_called_num(ftdmchan, &conEvnt->cdPtyNmb); + get_redir_num(ftdmchan, &conEvnt->redirNmb); + get_calling_subaddr(ftdmchan, &conEvnt->cgPtySad); - if (get_calling_name_from_display(&ftdmchan->caller_data, &conEvnt->display) != FTDM_SUCCESS) { - get_calling_name_from_usr_usr(&ftdmchan->caller_data, &conEvnt->usrUsr); + if (get_calling_name_from_display(ftdmchan, &conEvnt->display) != FTDM_SUCCESS) { + get_calling_name_from_usr_usr(ftdmchan, &conEvnt->usrUsr); } + get_prog_ind_ie(ftdmchan, &conEvnt->progInd); ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Incoming call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits); @@ -148,35 +150,35 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", conEvnt->ni2OctStr.str.val[3]); } } + } - if (conEvnt->facilityStr.eh.pres) { - if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - get_facility_ie(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); - } else if (signal_data->facility == SNGISDN_OPT_TRUE) { - /* Verify whether the Caller Name will come in a subsequent FACILITY message */ - uint16_t ret_val; - char retrieved_str[255]; - - ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str); - /* - return values for "sng_isdn_retrieve_facility_information_following": - If there will be no information following, or fails to decode IE, returns -1 - If there will be no information following, but current FACILITY IE contains a caller name, returns 0 - If there will be information following, returns 1 - */ + if (conEvnt->facilityStr.eh.pres) { + if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { + get_facility_ie(ftdmchan, &conEvnt->facilityStr); + } else if (signal_data->facility == SNGISDN_OPT_TRUE) { + /* Verify whether the Caller Name will come in a subsequent FACILITY message */ + uint16_t ret_val; + char retrieved_str[255]; - if (ret_val == 1) { - ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Expecting Caller name in FACILITY\n"); - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID); - /* Launch timer in case we never get a FACILITY msg */ - if (signal_data->facility_timeout) { - ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, - sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_TIMER_FACILITY]); - } - break; - } else if (ret_val == 0) { - strcpy(ftdmchan->caller_data.cid_name, retrieved_str); + ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str); + /* + return values for "sng_isdn_retrieve_facility_information_following": + If there will be no information following, or fails to decode IE, returns -1 + If there will be no information following, but current FACILITY IE contains a caller name, returns 0 + If there will be information following, returns 1 + */ + + if (ret_val == 1) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Expecting Caller name in FACILITY\n"); + ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID); + /* Launch timer in case we never get a FACILITY msg */ + if (signal_data->facility_timeout) { + ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, + sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_TIMER_FACILITY]); } + break; + } else if (ret_val == 0) { + strcpy(ftdmchan->caller_data.cid_name, retrieved_str); } } } @@ -254,8 +256,7 @@ void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event) ISDN_FUNC_TRACE_ENTER(__FUNCTION__); - /* Function does not require any info from conStEvnt struct for now */ - /* CnStEvnt *cnStEvnt = &sngisdn_event->event.cnStEvnt; */ + CnStEvnt *cnStEvnt = &sngisdn_event->event.cnStEvnt; ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); @@ -281,6 +282,7 @@ void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event) case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: case FTDM_CHANNEL_STATE_DIALING: + get_prog_ind_ie(ftdmchan, &cnStEvnt->progInd); ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_UP); break; case FTDM_CHANNEL_STATE_HANGUP_COMPLETE: @@ -344,9 +346,13 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) suId, suInstId, spInstId, ces); switch(evntType) { + case MI_CALLPROC: case MI_PROGRESS: - if (signal_data->switchtype == SNGISDN_SWITCH_NI2 && - cnStEvnt->causeDgn[0].eh.pres && cnStEvnt->causeDgn[0].causeVal.pres) { + case MI_ALERTING: + get_prog_ind_ie(ftdmchan, &cnStEvnt->progInd); + + if (signal_data->ignore_cause_value != SNGISDN_OPT_TRUE && + cnStEvnt->causeDgn[0].eh.pres && cnStEvnt->causeDgn[0].causeVal.pres) { switch(cnStEvnt->causeDgn[0].causeVal.val) { case 17: /* User Busy */ @@ -371,24 +377,17 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) goto sngisdn_process_cnst_ind_end; } } - /* fall-through */ - case MI_ALERTING: - case MI_CALLPROC: - + switch(ftdmchan->state) { case FTDM_CHANNEL_STATE_DIALING: - if (evntType == MI_CALLPROC) { - ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROCEED); - } else if (evntType == MI_PROGRESS || - (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL)) { + case FTDM_CHANNEL_STATE_PROCEED: + if (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL) { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); } else { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS); } - break; case FTDM_CHANNEL_STATE_PROGRESS: - if (evntType == MI_PROGRESS || - (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL)) { + if (cnStEvnt->progInd.eh.pres && cnStEvnt->progInd.progDesc.val == IN_PD_IBAVAIL) { ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); } break; @@ -417,7 +416,7 @@ void sngisdn_process_cnst_ind (sngisdn_event_data_t *sngisdn_event) ftdm_size_t min_digits = ((sngisdn_span_data_t*)ftdmchan->span->signal_data)->min_digits; ftdm_size_t num_digits; - get_called_num(&ftdmchan->caller_data, &cnStEvnt->cdPtyNmb); + get_called_num(ftdmchan, &cnStEvnt->cdPtyNmb); num_digits = strlen(ftdmchan->caller_data.dnis.digits); if (cnStEvnt->sndCmplt.eh.pres || num_digits >= min_digits) { @@ -476,7 +475,7 @@ void sngisdn_process_disc_ind (sngisdn_event_data_t *sngisdn_event) case FTDM_CHANNEL_STATE_UP: if (discEvnt->facilityStr.eh.pres) { if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - get_facility_ie(&ftdmchan->caller_data, discEvnt->facilityStr.facilityStr.val, discEvnt->facilityStr.facilityStr.len); + get_facility_ie(ftdmchan, &discEvnt->facilityStr); } else { /* Call libsng_isdn facility decode function and copy variables here */ } @@ -573,7 +572,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event) if (relEvnt->facilityStr.eh.pres) { if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - get_facility_ie(&ftdmchan->caller_data, relEvnt->facilityStr.facilityStr.val, relEvnt->facilityStr.facilityStr.len); + get_facility_ie(ftdmchan, &relEvnt->facilityStr); } else { /* Call libsng_isdn facility decode function and copy variables here */ } @@ -789,7 +788,7 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event) ftdm_sigmsg_t sigev; if (facEvnt->facElmt.facStr.pres) { if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - get_facility_ie(&ftdmchan->caller_data, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len); + get_facility_ie_str(ftdmchan, &facEvnt->facElmt.facStr.val[2], facEvnt->facElmt.facStr.len); } else { /* Call libsng_isdn facility decode function and copy variables here */ } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 36c6782a97..e91f21f55e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -34,13 +34,12 @@ #include "ftmod_sangoma_isdn.h" -static void sngisdn_set_prog_desc(ProgInd *progInd, ftdm_sngisdn_progind_t prod_ind); - void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) { - ConEvnt conEvnt; + ConEvnt conEvnt; sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; - sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN}; ftdm_assert((!sngisdn_info->suInstId && !sngisdn_info->spInstId), "Trying to call out, but call data was not cleared\n"); @@ -118,14 +117,6 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) conEvnt.chanId.chanNmbSlotMap.val[0] = ftdmchan->physical_chan_id; } - conEvnt.progInd.eh.pres = PRSNT_NODEF; - conEvnt.progInd.location.pres = PRSNT_NODEF; - conEvnt.progInd.location.val = IN_LOC_USER; - conEvnt.progInd.codeStand0.pres = PRSNT_NODEF; - conEvnt.progInd.codeStand0.val = IN_CSTD_CCITT; - conEvnt.progInd.progDesc.pres = PRSNT_NODEF; - conEvnt.progInd.progDesc.val = IN_PD_NOTETEISDN; /* Not end-to-end ISDN */ - if (signal_data->switchtype == SNGISDN_SWITCH_EUROISDN) { conEvnt.sndCmplt.eh.pres = PRSNT_NODEF; } @@ -135,11 +126,13 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan) } ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Outgoing call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits); - set_called_num(&conEvnt.cdPtyNmb, &ftdmchan->caller_data); - set_calling_num(&conEvnt.cgPtyNmb, &ftdmchan->caller_data); - set_redir_num(&conEvnt.redirNmb, &ftdmchan->caller_data); - set_calling_name(&conEvnt, ftdmchan); + set_called_num(ftdmchan, &conEvnt.cdPtyNmb); + set_calling_num(ftdmchan, &conEvnt.cgPtyNmb); + set_calling_subaddr(ftdmchan, &conEvnt.cgPtySad); + set_redir_num(ftdmchan, &conEvnt.redirNmb); + set_calling_name(ftdmchan, &conEvnt); set_facility_ie(ftdmchan, &conEvnt.facilityStr); + set_prog_ind_ie(ftdmchan, &conEvnt.progInd, prog_ind); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending SETUP (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); @@ -347,15 +340,7 @@ void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ } memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - - cnStEvnt.progInd.eh.pres = PRSNT_NODEF; - cnStEvnt.progInd.location.pres = PRSNT_NODEF; - cnStEvnt.progInd.location.val = IN_LOC_USER; - cnStEvnt.progInd.codeStand0.pres = PRSNT_NODEF; - cnStEvnt.progInd.codeStand0.val = IN_CSTD_CCITT; - cnStEvnt.progInd.progDesc.pres = PRSNT_NODEF; - - sngisdn_set_prog_desc(&cnStEvnt.progInd, prog_ind); + set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending PROGRESS (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_PROGRESS, signal_data->dchan_id, sngisdn_info->ces)) { @@ -380,13 +365,7 @@ void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - cnStEvnt.progInd.eh.pres = PRSNT_NODEF; - cnStEvnt.progInd.location.pres = PRSNT_NODEF; - cnStEvnt.progInd.location.val = IN_LOC_USER; - cnStEvnt.progInd.codeStand0.pres = PRSNT_NODEF; - cnStEvnt.progInd.codeStand0.val = IN_CSTD_CCITT; - cnStEvnt.progInd.progDesc.pres = PRSNT_NODEF; - sngisdn_set_prog_desc(&cnStEvnt.progInd, prog_ind); + set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending ALERT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); @@ -398,10 +377,10 @@ void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind void sngisdn_snd_connect(ftdm_channel_t *ftdmchan) { - CnStEvnt cnStEvnt; - + CnStEvnt cnStEvnt; sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_NETE_ISDN}; if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending CONNECT, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); @@ -444,14 +423,8 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan) cnStEvnt.chanId.chanNmbSlotMap.len = 1; cnStEvnt.chanId.chanNmbSlotMap.val[0] = ftdmchan->physical_chan_id; } - - cnStEvnt.progInd.eh.pres = PRSNT_NODEF; - cnStEvnt.progInd.location.pres = PRSNT_NODEF; - cnStEvnt.progInd.location.val = IN_LOC_USER; - cnStEvnt.progInd.codeStand0.pres = PRSNT_NODEF; - cnStEvnt.progInd.codeStand0.val = IN_CSTD_CCITT; - cnStEvnt.progInd.progDesc.pres = PRSNT_NODEF; - cnStEvnt.progInd.progDesc.val = IN_PD_NOTETEISDN; /* Not end-to-end ISDN */ + + set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind); ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); if (sng_isdn_con_response(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &cnStEvnt, signal_data->dchan_id, sngisdn_info->ces)) { @@ -473,7 +446,12 @@ void sngisdn_snd_fac_req(ftdm_channel_t *ftdmchan) } memset(&facEvnt, 0, sizeof(facEvnt)); - + + set_facility_ie_str(ftdmchan, &facEvnt.facElmt.facStr.val[2], (ftdm_size_t*)&facEvnt.facElmt.facStr.len); + + facEvnt.facElmt.facStr.val[0] = 0x1C; + facEvnt.facElmt.facStr.val[1] = facEvnt.facElmt.facStr.len; + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending FACILITY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); if (sng_isdn_facility_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &facEvnt, MI_FACIL, signal_data->dchan_id, sngisdn_info->ces)) { @@ -619,32 +597,6 @@ void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare) return; } -static void sngisdn_set_prog_desc(ProgInd *progInd, ftdm_sngisdn_progind_t prog_ind) -{ - switch(prog_ind) { - case SNGISDN_PROGIND_NETE_ISDN: - progInd->progDesc.val = IN_PD_NOTETEISDN; - break; - case SNGISDN_PROGIND_DEST_NISDN: - progInd->progDesc.val = IN_PD_DSTNOTISDN; - break; - case SNGISDN_PROGIND_ORIG_NISDN: - progInd->progDesc.val = IN_PD_ORGNOTISDN; - break; - case SNGISDN_PROGIND_RET_ISDN: - progInd->progDesc.val = IN_PD_CALLRET; - break; - case SNGISDN_PROGIND_SERV_CHANGE: - /* Trillium defines do not match ITU-T Q931 Progress descriptions, - indicate a delayed response for now */ - progInd->progDesc.val = IN_PD_DELRESP; - break; - case SNGISDN_PROGIND_IB_AVAIL: - progInd->progDesc.val = IN_PD_IBAVAIL; - break; - } - return; -} /* We received an incoming frame on the d-channel, send data to the stack */ void sngisdn_snd_data(ftdm_channel_t *dchan, uint8_t *data, ftdm_size_t len) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 4ddb90bbd3..964d06caaf 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -33,6 +33,15 @@ */ #include "ftmod_sangoma_isdn.h" +#define SNGISDN_Q931_FACILITY_IE_ID 0x1C + +/* ftmod_sangoma_isdn specific enum look-up functions */ + +FTDM_ENUM_NAMES(SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t, SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_INVALID) + +FTDM_ENUM_NAMES(SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_STRINGS) +FTDM_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t, SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_INVALID) ftdm_status_t sngisdn_check_free_ids(void); @@ -129,7 +138,6 @@ ftdm_status_t get_ftdmchan_by_spInstId(int16_t cc_id, uint32_t spInstId, sngisdn ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail) { - if (span->trunk_type == FTDM_TRUNK_BRI || span->trunk_type == FTDM_TRUNK_BRI_PTMP) { @@ -147,8 +155,9 @@ ftdm_status_t sngisdn_set_avail_rate(ftdm_span_t *span, sngisdn_avail_t avail) return FTDM_SUCCESS; } -ftdm_status_t get_calling_num(ftdm_caller_data_t *caller_data, CgPtyNmb *cgPtyNmb) +ftdm_status_t get_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb) { + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; if (cgPtyNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } @@ -176,8 +185,9 @@ ftdm_status_t get_calling_num(ftdm_caller_data_t *caller_data, CgPtyNmb *cgPtyNm return FTDM_SUCCESS; } -ftdm_status_t get_called_num(ftdm_caller_data_t *caller_data, CdPtyNmb *cdPtyNmb) +ftdm_status_t get_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb) { + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; if (cdPtyNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } @@ -199,8 +209,9 @@ ftdm_status_t get_called_num(ftdm_caller_data_t *caller_data, CdPtyNmb *cdPtyNmb return FTDM_SUCCESS; } -ftdm_status_t get_redir_num(ftdm_caller_data_t *caller_data, RedirNmb *redirNmb) +ftdm_status_t get_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb) { + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; if (redirNmb->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } @@ -219,8 +230,9 @@ ftdm_status_t get_redir_num(ftdm_caller_data_t *caller_data, RedirNmb *redirNmb) return FTDM_SUCCESS; } -ftdm_status_t get_calling_name_from_display(ftdm_caller_data_t *caller_data, Display *display) +ftdm_status_t get_calling_name_from_display(ftdm_channel_t *ftdmchan, Display *display) { + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; if (display->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } @@ -232,8 +244,9 @@ ftdm_status_t get_calling_name_from_display(ftdm_caller_data_t *caller_data, Dis return FTDM_SUCCESS; } -ftdm_status_t get_calling_name_from_usr_usr(ftdm_caller_data_t *caller_data, UsrUsr *usrUsr) +ftdm_status_t get_calling_name_from_usr_usr(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr) { + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; if (usrUsr->eh.pres != PRSNT_NODEF) { return FTDM_FAIL; } @@ -250,26 +263,124 @@ ftdm_status_t get_calling_name_from_usr_usr(ftdm_caller_data_t *caller_data, Usr return FTDM_SUCCESS; } -ftdm_status_t get_facility_ie(ftdm_caller_data_t *caller_data, uint8_t *data, uint32_t data_len) +ftdm_status_t get_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad) { + char subaddress[100]; + + if (cgPtySad->eh.pres != PRSNT_NODEF) { + return FTDM_FAIL; + } + memset(subaddress, 0, sizeof(subaddress)); + if(cgPtySad->sadInfo.len >= sizeof(subaddress)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Calling Party Subaddress exceeds local size limit (len:%d max:%d)\n", cgPtySad->sadInfo.len, sizeof(subaddress)); + cgPtySad->sadInfo.len = sizeof(subaddress)-1; + } + + memcpy(subaddress, (char*)cgPtySad->sadInfo.val, cgPtySad->sadInfo.len); + subaddress[cgPtySad->sadInfo.len] = '\0'; + ftdm_channel_add_var(ftdmchan, "isdn.calling_subaddr", subaddress); + return FTDM_SUCCESS; +} + +ftdm_status_t get_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) +{ + if (!facilityStr->eh.pres) { + return FTDM_FAIL; + } + + return get_facility_ie_str(ftdmchan, facilityStr->facilityStr.val, facilityStr->facilityStr.len); +} + +ftdm_status_t get_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, ftdm_size_t data_len) +{ + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; if (data_len > sizeof(caller_data->raw_data)-2) { ftdm_log(FTDM_LOG_CRIT, "Length of Facility IE exceeds maximum length\n"); return FTDM_FAIL; } - + memset(caller_data->raw_data, 0, sizeof(caller_data->raw_data)); /* Always include Facility IE identifier + len so this can be used as a sanity check by the user */ - caller_data->raw_data[0] = 0x1C; + caller_data->raw_data[0] = SNGISDN_Q931_FACILITY_IE_ID; caller_data->raw_data[1] = data_len; memcpy(&caller_data->raw_data[2], data, data_len); caller_data->raw_data_len = data_len+2; - return FTDM_SUCCESS; } -ftdm_status_t set_calling_num(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *caller_data) +ftdm_status_t get_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd) { + uint8_t val; + if (!progInd->eh.pres) { + return FTDM_FAIL; + } + + if (progInd->progDesc.pres) { + switch (progInd->progDesc.val) { + case IN_PD_NOTETEISDN: + val = SNGISDN_PROGIND_DESCR_NETE_ISDN; + break; + case IN_PD_DSTNOTISDN: + val = SNGISDN_PROGIND_DESCR_DEST_NISDN; + break; + case IN_PD_ORGNOTISDN: + val = SNGISDN_PROGIND_DESCR_ORIG_NISDN; + break; + case IN_PD_CALLRET: + val = SNGISDN_PROGIND_DESCR_RET_ISDN; + break; + case IN_PD_DELRESP: + val = SNGISDN_PROGIND_DESCR_SERV_CHANGE; + break; + case IN_PD_IBAVAIL: + val = SNGISDN_PROGIND_DESCR_IB_AVAIL; + break; + default: + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Unknown Progress Indicator Description (%d)\n", progInd->progDesc.val); + val = SNGISDN_PROGIND_DESCR_INVALID; + break; + } + ftdm_channel_add_var(ftdmchan, "isdn.prog_ind.descr", ftdm_sngisdn_progind_descr2str(val)); + } + + if (progInd->location.pres) { + switch (progInd->location.val) { + case IN_LOC_USER: + val = SNGISDN_PROGIND_LOC_USER; + break; + case IN_LOC_PRIVNETLU: + val = SNGISDN_PROGIND_LOC_PRIV_NET_LOCAL_USR; + break; + case IN_LOC_PUBNETLU: + val = SNGISDN_PROGIND_LOC_PUB_NET_LOCAL_USR; + break; + case IN_LOC_TRANNET: + val = SNGISDN_PROGIND_LOC_TRANSIT_NET; + break; + case IN_LOC_PUBNETRU: + val = SNGISDN_PROGIND_LOC_PUB_NET_REMOTE_USR; + break; + case IN_LOC_PRIVNETRU: + val = SNGISDN_PROGIND_LOC_PRIV_NET_REMOTE_USR; + break; + case IN_LOC_NETINTER: + val = SNGISDN_PROGIND_LOC_NET_BEYOND_INTRW; + break; + default: + ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Unknown Progress Indicator Location (%d)", progInd->location.val); + val = SNGISDN_PROGIND_LOC_INVALID; + break; + } + ftdm_channel_add_var(ftdmchan, "isdn.prog_ind.loc", ftdm_sngisdn_progind_loc2str(val)); + } + return FTDM_SUCCESS; +} + + +ftdm_status_t set_calling_num(ftdm_channel_t *ftdmchan, CgPtyNmb *cgPtyNmb) +{ + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; uint8_t len = strlen(caller_data->cid_num.digits); if (!len) { return FTDM_SUCCESS; @@ -296,9 +407,11 @@ ftdm_status_t set_calling_num(CgPtyNmb *cgPtyNmb, ftdm_caller_data_t *caller_dat return FTDM_SUCCESS; } -ftdm_status_t set_called_num(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *caller_data) +ftdm_status_t set_called_num(ftdm_channel_t *ftdmchan, CdPtyNmb *cdPtyNmb) { + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; uint8_t len = strlen(caller_data->dnis.digits); + if (!len) { return FTDM_SUCCESS; } @@ -326,8 +439,9 @@ ftdm_status_t set_called_num(CdPtyNmb *cdPtyNmb, ftdm_caller_data_t *caller_data return FTDM_SUCCESS; } -ftdm_status_t set_redir_num(RedirNmb *redirNmb, ftdm_caller_data_t *caller_data) +ftdm_status_t set_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb) { + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; uint8_t len = strlen(caller_data->rdnis.digits); if (!len) { return FTDM_SUCCESS; @@ -358,7 +472,7 @@ ftdm_status_t set_redir_num(RedirNmb *redirNmb, ftdm_caller_data_t *caller_data) } -ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) +ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt) { uint8_t len; ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; @@ -411,20 +525,139 @@ ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) return FTDM_SUCCESS; } +ftdm_status_t set_calling_subaddr(ftdm_channel_t *ftdmchan, CgPtySad *cgPtySad) +{ + const char* clg_subaddr = NULL; + clg_subaddr = ftdm_channel_get_var(ftdmchan, "isdn.calling_subaddr"); + if ((clg_subaddr != NULL) && (*clg_subaddr)) { + unsigned len = strlen (clg_subaddr); + cgPtySad->eh.pres = PRSNT_NODEF; + cgPtySad->typeSad.pres = 1; + cgPtySad->typeSad.val = 0; /* NSAP */ + cgPtySad->oddEvenInd.pres = 1; + cgPtySad->oddEvenInd.val = 0; + + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Sending Calling Party Subaddress:%s\n", clg_subaddr); + cgPtySad->sadInfo.pres = 1; + cgPtySad->sadInfo.len = len; + memcpy(cgPtySad->sadInfo.val, clg_subaddr, len); + } + return FTDM_SUCCESS; +} + + ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) { - const char *facility_str = NULL; - - facility_str = ftdm_channel_get_var(ftdmchan, "isdn.facility.val"); - if (facility_str) { + ftdm_status_t status; + status = set_facility_ie_str(ftdmchan, facilityStr->facilityStr.val, (ftdm_size_t*)&facilityStr->facilityStr.len); + if (status == FTDM_SUCCESS) { facilityStr->eh.pres = PRSNT_NODEF; - facilityStr->facilityStr.len = strlen(facility_str); - memcpy(facilityStr->facilityStr.val, facility_str, facilityStr->facilityStr.len); - return FTDM_SUCCESS; + facilityStr->facilityStr.pres = PRSNT_NODEF; } + return status; +} + +ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, ftdm_size_t *data_len) +{ + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; + + if (caller_data->raw_data_len > 0 && caller_data->raw_data[0] == SNGISDN_Q931_FACILITY_IE_ID) { + + *data_len = caller_data->raw_data[1]; + memcpy(data, &caller_data->raw_data[2], *data_len); + return FTDM_SUCCESS; + } return FTDM_FAIL; } +ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_sngisdn_progind_t prog_ind) +{ + const char *str = NULL; + int descr = prog_ind.descr; + int loc = prog_ind.loc; + + str = ftdm_channel_get_var(ftdmchan, "isdn.prog_ind.descr"); + if (str && *str) { + /* User wants to override progress indicator */ + descr = ftdm_str2ftdm_sngisdn_progind_descr(str); + } + + if (descr == SNGISDN_PROGIND_DESCR_INVALID) { + /* User does not want to send progress indicator */ + return FTDM_SUCCESS; + } + + str = ftdm_channel_get_var(ftdmchan, "isdn.prog_ind.loc"); + if (str && *str) { + loc = ftdm_str2ftdm_sngisdn_progind_loc(str); + } + if (loc == SNGISDN_PROGIND_LOC_INVALID) { + loc = SNGISDN_PROGIND_LOC_USER; + } + + progInd->eh.pres = PRSNT_NODEF; + progInd->codeStand0.pres = PRSNT_NODEF; + progInd->codeStand0.val = IN_CSTD_CCITT; + + progInd->progDesc.pres = PRSNT_NODEF; + switch(descr) { + case SNGISDN_PROGIND_DESCR_NETE_ISDN: + progInd->progDesc.val = IN_PD_NOTETEISDN; + break; + case SNGISDN_PROGIND_DESCR_DEST_NISDN: + progInd->progDesc.val = IN_PD_DSTNOTISDN; + break; + case SNGISDN_PROGIND_DESCR_ORIG_NISDN: + progInd->progDesc.val = IN_PD_ORGNOTISDN; + break; + case SNGISDN_PROGIND_DESCR_RET_ISDN: + progInd->progDesc.val = IN_PD_CALLRET; + break; + case SNGISDN_PROGIND_DESCR_SERV_CHANGE: + /* Trillium defines do not match ITU-T Q931 Progress descriptions, + indicate a delayed response for now */ + progInd->progDesc.val = IN_PD_DELRESP; + break; + case SNGISDN_PROGIND_DESCR_IB_AVAIL: + progInd->progDesc.val = IN_PD_IBAVAIL; + break; + default: + ftdm_log(FTDM_LOG_WARNING, "Invalid prog_ind description:%d\n", descr); + progInd->progDesc.val = IN_PD_NOTETEISDN; + break; + } + + progInd->location.pres = PRSNT_NODEF; + switch (loc) { + case SNGISDN_PROGIND_LOC_USER: + progInd->location.val = IN_LOC_USER; + break; + case SNGISDN_PROGIND_LOC_PRIV_NET_LOCAL_USR: + progInd->location.val = IN_LOC_PRIVNETLU; + break; + case SNGISDN_PROGIND_LOC_PUB_NET_LOCAL_USR: + progInd->location.val = IN_LOC_PUBNETLU; + break; + case SNGISDN_PROGIND_LOC_TRANSIT_NET: + progInd->location.val = IN_LOC_TRANNET; + break; + case SNGISDN_PROGIND_LOC_PUB_NET_REMOTE_USR: + progInd->location.val = IN_LOC_PUBNETRU; + break; + case SNGISDN_PROGIND_LOC_PRIV_NET_REMOTE_USR: + progInd->location.val = IN_LOC_PRIVNETRU; + break; + case SNGISDN_PROGIND_LOC_NET_BEYOND_INTRW: + progInd->location.val = IN_LOC_NETINTER; + break; + default: + ftdm_log(FTDM_LOG_WARNING, "Invalid prog_ind location:%d\n", loc); + progInd->location.val = IN_PD_NOTETEISDN; + } + return FTDM_SUCCESS; +} + + void sngisdn_t3_timeout(void* p_sngisdn_info) { sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info; @@ -581,13 +814,12 @@ uint8_t sngisdn_get_infoTranCap_from_stack(ftdm_bearer_cap_t bearer_capability) switch(bearer_capability) { case FTDM_BEARER_CAP_SPEECH: return IN_ITC_SPEECH; - case FTDM_BEARER_CAP_64K_UNRESTRICTED: return IN_ITC_UNRDIG; - case FTDM_BEARER_CAP_3_1KHZ_AUDIO: return IN_ITC_A31KHZ; - + case FTDM_BEARER_CAP_INVALID: + return IN_ITC_SPEECH; /* Do not put a default case here, so we can see compile warnings if we have unhandled cases */ } return FTDM_BEARER_CAP_SPEECH; @@ -598,13 +830,12 @@ uint8_t sngisdn_get_usrInfoLyr1Prot_from_stack(ftdm_user_layer1_prot_t layer1_pr switch(layer1_prot) { case FTDM_USER_LAYER1_PROT_V110: return IN_UIL1_CCITTV110; - case FTDM_USER_LAYER1_PROT_ULAW: return IN_UIL1_G711ULAW; - case FTDM_USER_LAYER1_PROT_ALAW: return IN_UIL1_G711ALAW; - + case FTDM_USER_LAYER1_PROT_INVALID: + return IN_UIL1_G711ULAW; /* Do not put a default case here, so we can see compile warnings if we have unhandled cases */ } return IN_UIL1_G711ULAW; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c index 624d35c147..e5167164b3 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.c @@ -613,6 +613,21 @@ uint32_t sngisdn_decode_ie(char *str, uint32_t *str_len, uint8_t current_codeset return 0; break; case PROT_Q931_IE_CALLED_PARTY_SUBADDRESS: + { + uint8_t type; + uint8_t currentOct, j=0; + char calling_subaddr_string[82]; + memset(calling_subaddr_string, 0, sizeof(calling_subaddr_string)); + type = get_bits(OCTET(3),5,7); + currentOct = 3; + while(currentOct++ <= len+1) { + calling_subaddr_string[j++]=ia5[get_bits(OCTET(currentOct),1,4)][get_bits(OCTET(currentOct),5,8)]; + } + calling_subaddr_string[j++]='\0'; + *str_len += sprintf(&str[*str_len], "%s (l:%d) type:%s(%d) \n", + calling_subaddr_string, (j-1), get_code_2_str(type, dcodQ931TypeOfSubaddressTable), type); + } + break; case PROT_Q931_IE_REDIRECTION_NUMBER: case PROT_Q931_IE_NOTIFICATION_IND: case PROT_Q931_IE_DATE_TIME: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h index d210c50db9..f054de9377 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_trace.h @@ -544,5 +544,11 @@ struct code2str dcodQ931GenDigitsTypeTable[] = { {-1, "Invalid"}, }; +struct code2str dcodQ931TypeOfSubaddressTable[] = { + { 0x00, "NSAP"}, + { 0x02, "User-specified"}, + { -1, "Invalid"}, +}; + #endif /* __FTMOD_SANGOMA_ISDN_TRACE_H__ */ diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h index 014eeef852..45254e817f 100644 --- a/libs/freetdm/src/include/freetdm.h +++ b/libs/freetdm/src/include/freetdm.h @@ -41,6 +41,7 @@ #include "ftdm_declare.h" +#include "ftdm_call_utils.h" /*! \brief Max number of channels per physical span */ #define FTDM_MAX_CHANNELS_PHYSICAL_SPAN 32 @@ -62,23 +63,6 @@ #define FTDM_INVALID_INT_PARM 0xFF -/*! \brief FreeTDM APIs possible return codes */ -typedef enum { - FTDM_SUCCESS, /*!< Success */ - FTDM_FAIL, /*!< Failure, generic error return code, use ftdm_channel_get_last_error or ftdm_span_get_last_error for details */ - FTDM_MEMERR, /*!< Memory error, most likely allocation failure */ - FTDM_TIMEOUT, /*!< Operation timed out (ie: polling on a device)*/ - FTDM_NOTIMPL, /*!< Operation not implemented */ - FTDM_BREAK, /*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */ - FTDM_EINVAL /*!< Invalid argument */ -} ftdm_status_t; - -/*! \brief FreeTDM bool type. */ -typedef enum { - FTDM_FALSE, - FTDM_TRUE -} ftdm_bool_t; - /*! \brief Thread/Mutex OS abstraction API. */ #include "ftdm_os.h" @@ -220,8 +204,10 @@ typedef enum { FTDM_TON_SUBSCRIBER_NUMBER, FTDM_TON_ABBREVIATED_NUMBER, FTDM_TON_RESERVED, - FTDM_TON_INVALID = 255 + FTDM_TON_INVALID } ftdm_ton_t; +#define TON_STRINGS "unknown", "international", "national", "network-specific", "subscriber-number", "abbreviated-number", "reserved", "invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_ton, ftdm_ton2str, ftdm_ton_t) /*! Numbering Plan Identification (NPI) */ typedef enum { @@ -232,8 +218,52 @@ typedef enum { FTDM_NPI_NATIONAL = 8, FTDM_NPI_PRIVATE = 9, FTDM_NPI_RESERVED = 10, - FTDM_NPI_INVALID = 255 + FTDM_NPI_INVALID } ftdm_npi_t; +#define NPI_STRINGS "unknown", "ISDN", "data", "telex", "national", "private", "reserved", "invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_npi, ftdm_npi2str, ftdm_npi_t) + +/*! Presentation Ind */ +typedef enum { + FTDM_PRES_ALLOWED, + FTDM_PRES_RESTRICTED, + FTDM_PRES_NOT_AVAILABLE, + FTDM_PRES_RESERVED, + FTDM_PRES_INVALID +} ftdm_presentation_t; +#define PRESENTATION_STRINGS "presentation-allowed", "presentation-restricted", "number-not-available", "reserved", "Invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_presentation, ftdm_presentation2str, ftdm_presentation_t) + +/*! Screening Ind */ +typedef enum { + FTDM_SCREENING_NOT_SCREENED, + FTDM_SCREENING_VERIFIED_PASSED, + FTDM_SCREENING_VERIFIED_FAILED, + FTDM_SCREENING_NETWORK_PROVIDED, + FTDM_SCREENING_INVALID +} ftdm_screening_t; +#define SCREENING_STRINGS "user-provided-not-screened", "user-provided-verified-and-passed", "user-provided-verified-and-failed", "network-provided", "invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_screening, ftdm_screening2str, ftdm_screening_t) + +/*! \brief bearer capability */ +typedef enum { + FTDM_BEARER_CAP_SPEECH = 0x00, + FTDM_BEARER_CAP_64K_UNRESTRICTED = 0x02, + FTDM_BEARER_CAP_3_1KHZ_AUDIO = 0x03, + FTDM_BEARER_CAP_INVALID +} ftdm_bearer_cap_t; +#define BEARER_CAP_STRINGS "speech", "unrestricted-digital-information", "3.1-Khz-audio", "invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_bearer_cap, ftdm_bearer_cap2str, ftdm_bearer_cap_t) + +/*! \brief user information layer 1 protocol */ +typedef enum { + FTDM_USER_LAYER1_PROT_V110 = 0x01, + FTDM_USER_LAYER1_PROT_ULAW = 0x02, + FTDM_USER_LAYER1_PROT_ALAW = 0x03, + FTDM_USER_LAYER1_PROT_INVALID +} ftdm_user_layer1_prot_t; +#define USER_LAYER1_PROT_STRINGS "V.110", "u-law", "a-law", "Invalid" +FTDM_STR2ENUM_P(ftdm_str2ftdm_usr_layer1_prot, ftdm_user_layer1_prot2str, ftdm_user_layer1_prot_t) /*! \brief Number abstraction */ typedef struct { @@ -242,20 +272,6 @@ typedef struct { uint8_t plan; } ftdm_number_t; -/*! \brief bearer capability */ -typedef enum { - FTDM_BEARER_CAP_SPEECH = 0x00, - FTDM_BEARER_CAP_64K_UNRESTRICTED = 0x02, - FTDM_BEARER_CAP_3_1KHZ_AUDIO = 0x03 -} ftdm_bearer_cap_t; - -/*! \brief user information layer 1 protocol */ -typedef enum { - FTDM_USER_LAYER1_PROT_V110 = 0x01, - FTDM_USER_LAYER1_PROT_ULAW = 0x02, - FTDM_USER_LAYER1_PROT_ALAW = 0x03, -} ftdm_user_layer1_prot_t; - /*! \brief Caller information */ typedef struct ftdm_caller_data { char cid_date[8]; /*!< Caller ID date */ diff --git a/libs/freetdm/src/include/ftdm_call_utils.h b/libs/freetdm/src/include/ftdm_call_utils.h new file mode 100644 index 0000000000..835a5c6cdc --- /dev/null +++ b/libs/freetdm/src/include/ftdm_call_utils.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2010, Sangoma Technologies + * David Yat Sin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the original author; nor the names of any contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __FTDM_CALL_UTILS_H__ +#define __FTDM_CALL_UTILS_H__ + +/*! + * \brief Set the Numbering Plan Identification from a string + * + * \param npi_string string value + * \param target the target to set value to + * + * \retval FTDM_SUCCESS success + * \retval FTDM_FAIL failure + */ +FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *npi_string, uint8_t *target); + + +/*! + * \brief Set the Type of number from a string + * + * \param ton_string string value + * \param target the target to set value to + * + * \retval FTDM_SUCCESS success + * \retval FTDM_FAIL failure + */ +FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *ton_string, uint8_t *target); + +/*! + * \brief Set the Bearer Capability from a string + * + * \param bc_string string value + * \param target the target to set value to + * + * \retval FTDM_SUCCESS success + * \retval FTDM_FAIL failure + */ +FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *bc_string, uint8_t *target); + +/*! + * \brief Set the Bearer Capability - Layer 1 from a string + * + * \param bc_string string value + * \param target the target to set value to + * + * \retval FTDM_SUCCESS success + * \retval FTDM_FAIL failure + */ +FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *bc_string, uint8_t *target); + +/*! + * \brief Set the Screening Ind from a string + * + * \param screen_string string value + * \param target the target to set value to + * + * \retval FTDM_SUCCESS success + * \retval FTDM_FAIL failure + */ +FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *target); + + +/*! + * \brief Set the Presentation Ind from an enum + * + * \param screen_string string value + * \param target the target to set value to + * + * \retval FTDM_SUCCESS success + * \retval FTDM_FAIL failure + */ +FT_DECLARE(ftdm_status_t) ftdm_set_presentation_ind(const char *string, uint8_t *target); + + +/*! + * \brief Checks whether a string contains only numbers + * + * \param number string value + * + * \retval FTDM_SUCCESS success + * \retval FTDM_FAIL failure + */ +FT_DECLARE(ftdm_status_t) ftdm_is_number(const char *number); + +#endif /* __FTDM_CALL_UTILS_H__ */ + diff --git a/libs/freetdm/src/include/ftdm_declare.h b/libs/freetdm/src/include/ftdm_declare.h index ab3b5c8966..4aba703f28 100644 --- a/libs/freetdm/src/include/ftdm_declare.h +++ b/libs/freetdm/src/include/ftdm_declare.h @@ -171,6 +171,23 @@ typedef int ftdm_socket_t; #include #endif +/*! \brief FreeTDM APIs possible return codes */ +typedef enum { + FTDM_SUCCESS, /*!< Success */ + FTDM_FAIL, /*!< Failure, generic error return code, use ftdm_channel_get_last_error or ftdm_span_get_last_error for details */ + FTDM_MEMERR, /*!< Memory error, most likely allocation failure */ + FTDM_TIMEOUT, /*!< Operation timed out (ie: polling on a device)*/ + FTDM_NOTIMPL, /*!< Operation not implemented */ + FTDM_BREAK, /*!< Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */ + FTDM_EINVAL /*!< Invalid argument */ +} ftdm_status_t; + +/*! \brief FreeTDM bool type. */ +typedef enum { + FTDM_FALSE, + FTDM_TRUE +} ftdm_bool_t; + /*! * \brief FreeTDM channel. * This is the basic data structure used to place calls and I/O operations diff --git a/libs/freetdm/src/include/private/ftdm_call_utils.h b/libs/freetdm/src/include/private/ftdm_call_utils.h deleted file mode 100644 index 782abde927..0000000000 --- a/libs/freetdm/src/include/private/ftdm_call_utils.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2010, Sangoma Technologies - * David Yat Sin - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of the original author; nor the names of any contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __FTDM_CALL_UTILS_H__ -#define __FTDM_CALL_UTILS_H__ - -#include "freetdm.h" - -FT_DECLARE(ftdm_status_t) ftdm_span_set_npi(const char *npi_string, uint8_t *target); -FT_DECLARE(ftdm_status_t) ftdm_span_set_ton(const char *ton_string, uint8_t *target); -FT_DECLARE(ftdm_status_t) ftdm_span_set_bearer_capability(const char *bc_string, ftdm_bearer_cap_t *target); -FT_DECLARE(ftdm_status_t) ftdm_span_set_bearer_layer1(const char *bc_string, ftdm_user_layer1_prot_t *target); -FT_DECLARE(ftdm_status_t) ftdm_is_number(char *number); - -#endif /* __FTDM_CALL_UTILS_H__ */ - From e3b070c88fa02406890b35e554f5c0ac1ad6aa36 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 13:21:47 -0500 Subject: [PATCH 31/55] freetdm: ftmod_wanpipe - do not test 80% tx queue full --- libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c index fbb827e27f..0ac628a260 100644 --- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c +++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c @@ -791,16 +791,7 @@ static void wanpipe_write_stats(ftdm_channel_t *ftdmchan, wp_tdm_api_tx_hdr_t *t ftdmchan->iostats.tx.queue_size = tx_stats->wp_api_tx_hdr_max_queue_length; ftdmchan->iostats.tx.queue_len = tx_stats->wp_api_tx_hdr_number_of_frames_in_queue; - if (ftdmchan->iostats.tx.queue_len >= (0.8 * ftdmchan->iostats.tx.queue_size)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_WARNING, "Tx Queue length exceeded 80% threshold (%d/%d)\n", - ftdmchan->iostats.tx.queue_len, ftdmchan->iostats.tx.queue_size); - ftdm_set_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_THRES); - } else if (ftdm_test_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_THRES)){ - ftdm_log_chan(ftdmchan, FTDM_LOG_NOTICE, "Tx Queue length reduced 80% threshold (%d/%d)\n", - ftdmchan->iostats.tx.queue_len, ftdmchan->iostats.tx.queue_size); - ftdm_clear_flag(&(ftdmchan->iostats.tx), FTDM_IOSTATS_ERROR_QUEUE_THRES); - } - + /* we don't test for 80% full in tx since is typically full for voice channels, should we test tx 80% full for D-channels? */ if (ftdmchan->iostats.tx.queue_len >= ftdmchan->iostats.tx.queue_size) { ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Tx Queue Full (%d/%d)\n", ftdmchan->iostats.rx.queue_len, ftdmchan->iostats.tx.queue_size); From 1f329ad521926c5af22a710a7e473daec0177f3e Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 13:28:14 -0500 Subject: [PATCH 32/55] set the right configs in sync with mainstream --- conf/autoload_configs/callcenter.conf.xml | 1 + conf/autoload_configs/erlang_event.conf.xml | 9 ++ conf/autoload_configs/modules.conf.xml | 96 +++++++++++++++++++++ conf/autoload_configs/switch.conf.xml | 6 ++ conf/autoload_configs/voicemail.conf.xml | 7 +- conf/sip_profiles/internal.xml | 20 +++++ conf/skinny_profiles/internal.xml | 2 +- conf/vars.xml | 2 +- 8 files changed, 138 insertions(+), 5 deletions(-) diff --git a/conf/autoload_configs/callcenter.conf.xml b/conf/autoload_configs/callcenter.conf.xml index 9140193b22..a069413ac6 100644 --- a/conf/autoload_configs/callcenter.conf.xml +++ b/conf/autoload_configs/callcenter.conf.xml @@ -13,6 +13,7 @@ + diff --git a/conf/autoload_configs/erlang_event.conf.xml b/conf/autoload_configs/erlang_event.conf.xml index ec14e21a25..62deb84f67 100644 --- a/conf/autoload_configs/erlang_event.conf.xml +++ b/conf/autoload_configs/erlang_event.conf.xml @@ -2,7 +2,16 @@ + + + + + diff --git a/conf/autoload_configs/modules.conf.xml b/conf/autoload_configs/modules.conf.xml index 90d66f5798..f5627fe965 100644 --- a/conf/autoload_configs/modules.conf.xml +++ b/conf/autoload_configs/modules.conf.xml @@ -1,17 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml index 7a68a7f2bd..896dd0e712 100644 --- a/conf/autoload_configs/switch.conf.xml +++ b/conf/autoload_configs/switch.conf.xml @@ -15,6 +15,11 @@ + + + + + @@ -81,6 +86,7 @@ + diff --git a/conf/autoload_configs/voicemail.conf.xml b/conf/autoload_configs/voicemail.conf.xml index 14ad98b41c..06bd6f6dca 100644 --- a/conf/autoload_configs/voicemail.conf.xml +++ b/conf/autoload_configs/voicemail.conf.xml @@ -33,9 +33,10 @@ - - - + --> + + + diff --git a/conf/sip_profiles/internal.xml b/conf/sip_profiles/internal.xml index 69b0d15be4..3e756a85c0 100644 --- a/conf/sip_profiles/internal.xml +++ b/conf/sip_profiles/internal.xml @@ -42,6 +42,26 @@ + + + + + + diff --git a/conf/skinny_profiles/internal.xml b/conf/skinny_profiles/internal.xml index 5feac1ffbf..52da89741d 100644 --- a/conf/skinny_profiles/internal.xml +++ b/conf/skinny_profiles/internal.xml @@ -16,7 +16,7 @@ - + diff --git a/conf/vars.xml b/conf/vars.xml index c638a80582..fced2ef139 100644 --- a/conf/vars.xml +++ b/conf/vars.xml @@ -195,7 +195,7 @@ - + From cefedc0da9a8248cbebde655ecc73701d7cfcd1d Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 13:30:37 -0500 Subject: [PATCH 33/55] sync .sln file with mainstream, ppl stop blindly using git commit -a! --- Freeswitch.2008.sln | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Freeswitch.2008.sln b/Freeswitch.2008.sln index 4ffd66abac..01a4cf43c1 100644 --- a/Freeswitch.2008.sln +++ b/Freeswitch.2008.sln @@ -36,6 +36,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Default", "Default", "{3B08FEFD-4D3D-4C16-BA94-EE83509E32A0}" ProjectSection(SolutionItems) = preProject conf\freeswitch.xml = conf\freeswitch.xml + conf\vars.xml = conf\vars.xml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Release", "Release", "{7BFD517E-7F8F-4A40-A78E-8D3632738227}" @@ -56,6 +57,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Build System", "_Build Sys bootstrap.sh = bootstrap.sh build\buildlib.sh = build\buildlib.sh configure.in = configure.in + Makefile.am = Makefile.am build\modmake.rules.in = build\modmake.rules.in build\modules.conf.in = build\modules.conf.in libs\win32\util.vbs = libs\win32\util.vbs @@ -90,12 +92,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa conf\autoload_configs\limit.conf.xml = conf\autoload_configs\limit.conf.xml conf\autoload_configs\local_stream.conf.xml = conf\autoload_configs\local_stream.conf.xml conf\autoload_configs\logfile.conf.xml = conf\autoload_configs\logfile.conf.xml + conf\autoload_configs\modules.conf.xml = conf\autoload_configs\modules.conf.xml conf\autoload_configs\openmrcp.conf.xml = conf\autoload_configs\openmrcp.conf.xml conf\autoload_configs\portaudio.conf.xml = conf\autoload_configs\portaudio.conf.xml conf\autoload_configs\rss.conf.xml = conf\autoload_configs\rss.conf.xml conf\autoload_configs\sofia.conf.xml = conf\autoload_configs\sofia.conf.xml conf\autoload_configs\spidermonkey.conf.xml = conf\autoload_configs\spidermonkey.conf.xml + conf\autoload_configs\switch.conf.xml = conf\autoload_configs\switch.conf.xml conf\autoload_configs\syslog.conf.xml = conf\autoload_configs\syslog.conf.xml + conf\autoload_configs\voicemail.conf.xml = conf\autoload_configs\voicemail.conf.xml conf\autoload_configs\wanpipe.conf.xml = conf\autoload_configs\wanpipe.conf.xml conf\autoload_configs\woomera.conf.xml = conf\autoload_configs\woomera.conf.xml conf\autoload_configs\xml_cdr.conf.xml = conf\autoload_configs\xml_cdr.conf.xml @@ -106,6 +111,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{C7E2382E-2C22-4D18-BF93-80C6A1FFA7AC}" ProjectSection(SolutionItems) = preProject + conf\dialplan\default.xml = conf\dialplan\default.xml conf\dialplan\public.xml = conf\dialplan\public.xml EndProjectSection EndProject @@ -117,6 +123,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profiles", "{8E2E8798-8B6F-4A55-8E4F-4E6FDE40ED26}" ProjectSection(SolutionItems) = preProject conf\sip_profiles\external.xml = conf\sip_profiles\external.xml + conf\sip_profiles\internal.xml = conf\sip_profiles\internal.xml conf\sip_profiles\nat.xml = conf\sip_profiles\nat.xml EndProjectSection EndProject @@ -301,6 +308,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoloa EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{23874F4B-C0AF-4587-9F7E-DB0F06DE8CB4}" + ProjectSection(SolutionItems) = preProject + conf\dialplan\default.xml = conf\dialplan\default.xml + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory", "directory", "{19ED97F6-30D8-4FCE-AE1D-8B7FCB170D40}" ProjectSection(SolutionItems) = preProject @@ -1261,15 +1271,15 @@ Global {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|Win32.Build.0 = Release|Win32 {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|x64.ActiveCfg = Release|x64 {89385C74-5860-4174-9CAF-A39E7C48909C}.Release|x64.Build.0 = Release|x64 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|Win32.ActiveCfg = Release|Win32 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|Win32.Build.0 = Release|Win32 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|x64.ActiveCfg = Release|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|Win32.ActiveCfg = Release|x64 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|x64.ActiveCfg = Release|x64 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.All|x64.Build.0 = Release|x64 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.ActiveCfg = Debug|Win32 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|Win32.Build.0 = Debug|Win32 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|x64.ActiveCfg = Debug|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Debug|x64.ActiveCfg = Debug|x64 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.ActiveCfg = Release|Win32 {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|Win32.Build.0 = Release|Win32 - {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.ActiveCfg = Release|Win32 + {1AD3F51E-BBB6-4090-BA39-9DFAB1EF1F5F}.Release|x64.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|Win32.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.ActiveCfg = Release|x64 {692F6330-4D87-4C82-81DF-40DB5892636E}.All|x64.Build.0 = Release|x64 From c4369fc84dc00348169f0e7adc9a0169d864ac96 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 30 Nov 2010 15:34:22 -0600 Subject: [PATCH 34/55] add uuid_fileman : <-- same vals as the callbacks in js and lua to control the currently playing file of a channel from the cli or ESL (for the people who were ignoring me on the conference call so I decided to implement it instead of try to explain it ) --- src/include/private/switch_core_pvt.h | 1 + src/include/switch_core.h | 5 + src/include/switch_ivr.h | 5 + .../applications/mod_commands/mod_commands.c | 43 +++++++ src/switch_core_rwlock.c | 40 ++++++ src/switch_core_session.c | 1 + src/switch_cpp.cpp | 115 +---------------- src/switch_ivr.c | 118 ++++++++++++++++++ src/switch_ivr_play_say.c | 44 +++++++ 9 files changed, 258 insertions(+), 114 deletions(-) diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 3df9001b0c..13410a00ae 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -135,6 +135,7 @@ struct switch_core_session { switch_mutex_t *frame_read_mutex; switch_thread_rwlock_t *rwlock; + switch_thread_rwlock_t *io_rwlock; void *streams[SWITCH_MAX_STREAMS]; int stream_count; diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 33df7e31dd..840a06c204 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -354,6 +354,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void); ///\ingroup core1 ///\{ + +SWITCH_DECLARE(switch_status_t) switch_core_session_io_read_lock(switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_core_session_io_write_lock(switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_core_session_io_rwunlock(switch_core_session_t *session); + #ifdef SWITCH_DEBUG_RWLOCKS SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line); #endif diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 249ac63a58..d277bd030f 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -874,6 +874,11 @@ SWITCH_DECLARE(void) switch_ivr_dmachine_set_input_timeout_ms(switch_ivr_dmachin SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_clear_realm(switch_ivr_dmachine_t *dmachine, const char *realm); SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_set_realm(switch_ivr_dmachine_t *dmachine, const char *realm); + +SWITCH_DECLARE(switch_status_t) switch_ivr_get_file_handle(switch_core_session_t *session, switch_file_handle_t **fh); +SWITCH_DECLARE(switch_status_t) switch_ivr_release_file_handle(switch_core_session_t *session, switch_file_handle_t **fh); +SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp); + /** @} */ SWITCH_END_EXTERN_C diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index ba4b6d310d..c7edfd5420 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -3968,6 +3968,47 @@ SWITCH_STANDARD_API(uuid_getvar_function) return SWITCH_STATUS_SUCCESS; } + +#define FILEMAN_SYNTAX " :" +SWITCH_STANDARD_API(uuid_fileman_function) +{ + switch_core_session_t *psession = NULL; + char *mycmd = NULL, *argv[4] = { 0 }; + int argc = 0; + + if (!zstr(cmd) && (mycmd = strdup(cmd))) { + argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + if (argc >= 2 && !zstr(argv[0])) { + char *uuid = argv[0]; + char *cmd = argv[1]; + + if ((psession = switch_core_session_locate(uuid))) { + switch_channel_t *channel; + switch_file_handle_t *fh = NULL; + + channel = switch_core_session_get_channel(psession); + + if (switch_ivr_get_file_handle(psession, &fh) == SWITCH_STATUS_SUCCESS) { + switch_ivr_process_fh(psession, cmd, fh); + switch_ivr_release_file_handle(psession, &fh); + } + + switch_core_session_rwunlock(psession); + + } else { + stream->write_function(stream, "-ERR No Such Channel!\n"); + } + goto done; + } + } + + stream->write_function(stream, "-USAGE: %s\n", GETVAR_SYNTAX); + + done: + switch_safe_free(mycmd); + return SWITCH_STATUS_SUCCESS; +} + #define UUID_SEND_DTMF_SYNTAX " " SWITCH_STANDARD_API(uuid_send_dtmf_function) { @@ -4674,6 +4715,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "uuid_display", "change display", uuid_display_function, DISPLAY_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_dump", "uuid_dump", uuid_dump_function, DUMP_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_exists", "see if a uuid exists", uuid_exists_function, EXISTS_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "uuid_fileman", "uuid_fileman", uuid_fileman_function, FILEMAN_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_flush_dtmf", "Flush dtmf on a given uuid", uuid_flush_dtmf_function, ""); SWITCH_ADD_API(commands_api_interface, "uuid_getvar", "uuid_getvar", uuid_getvar_function, GETVAR_SYNTAX); SWITCH_ADD_API(commands_api_interface, "uuid_hold", "hold", uuid_hold_function, HOLD_SYNTAX); @@ -4785,6 +4827,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add uuid_display ::console::list_uuid"); switch_console_set_complete("add uuid_dump ::console::list_uuid"); switch_console_set_complete("add uuid_exists ::console::list_uuid"); + switch_console_set_complete("add uuid_fileman ::console::list_uuid"); switch_console_set_complete("add uuid_flush_dtmf ::console::list_uuid"); switch_console_set_complete("add uuid_getvar ::console::list_uuid"); switch_console_set_complete("add uuid_hold ::console::list_uuid"); diff --git a/src/switch_core_rwlock.c b/src/switch_core_rwlock.c index 4285491dc1..57168d9a29 100644 --- a/src/switch_core_rwlock.c +++ b/src/switch_core_rwlock.c @@ -36,6 +36,46 @@ #include "private/switch_core_pvt.h" +SWITCH_DECLARE(switch_status_t) switch_core_session_io_read_lock(switch_core_session_t *session) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + + if (session->io_rwlock) { + if (switch_thread_rwlock_tryrdlock(session->io_rwlock) == SWITCH_STATUS_SUCCESS) { + status = SWITCH_STATUS_SUCCESS; + } + } + + return status; +} + +SWITCH_DECLARE(switch_status_t) switch_core_session_io_write_lock(switch_core_session_t *session) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + + if (session->io_rwlock) { + switch_thread_rwlock_wrlock(session->io_rwlock); + status = SWITCH_STATUS_SUCCESS; + } + + return status; +} + + +SWITCH_DECLARE(switch_status_t) switch_core_session_io_rwunlock(switch_core_session_t *session) +{ + switch_status_t status = SWITCH_STATUS_FALSE; + + if (session->io_rwlock) { + switch_thread_rwlock_unlock(session->io_rwlock); + status = SWITCH_STATUS_SUCCESS; + } + + return status; +} + + + #ifdef SWITCH_DEBUG_RWLOCKS SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session, const char *file, const char *func, int line) #else diff --git a/src/switch_core_session.c b/src/switch_core_session.c index a84bfabaf0..fc7648155a 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1667,6 +1667,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_ switch_thread_rwlock_create(&session->bug_rwlock, session->pool); switch_thread_cond_create(&session->cond, session->pool); switch_thread_rwlock_create(&session->rwlock, session->pool); + switch_thread_rwlock_create(&session->io_rwlock, session->pool); switch_queue_create(&session->message_queue, SWITCH_MESSAGE_QUEUE_LEN, session->pool); switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool); switch_queue_create(&session->private_event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool); diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 469ae18c4b..40462db567 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -1269,120 +1269,7 @@ SWITCH_DECLARE(switch_status_t) CoreSession::process_callback_result(char *resul this_check(SWITCH_STATUS_FALSE); sanity_check(SWITCH_STATUS_FALSE); - if (zstr(result)) { - return SWITCH_STATUS_SUCCESS; - } - - if (fhp) { - if (!switch_test_flag(fhp, SWITCH_FILE_OPEN)) { - return SWITCH_STATUS_FALSE; - } - - if (!strncasecmp(result, "speed", 5)) { - char *p; - - if ((p = strchr(result, ':'))) { - p++; - if (*p == '+' || *p == '-') { - int step; - if (!(step = atoi(p))) { - step = 1; - } - fhp->speed += step; - } else { - int speed = atoi(p); - fhp->speed = speed; - } - return SWITCH_STATUS_SUCCESS; - } - - return SWITCH_STATUS_FALSE; - - } else if (!strncasecmp(result, "volume", 6)) { - char *p; - - if ((p = strchr(result, ':'))) { - p++; - if (*p == '+' || *p == '-') { - int step; - if (!(step = atoi(p))) { - step = 1; - } - fhp->vol += step; - } else { - int vol = atoi(p); - fhp->vol = vol; - } - return SWITCH_STATUS_SUCCESS; - } - - if (fhp->vol) { - switch_normalize_volume(fhp->vol); - } - - return SWITCH_STATUS_FALSE; - } else if (!strcasecmp(result, "pause")) { - if (switch_test_flag(fhp, SWITCH_FILE_PAUSE)) { - switch_clear_flag(fhp, SWITCH_FILE_PAUSE); - } else { - switch_set_flag(fhp, SWITCH_FILE_PAUSE); - } - return SWITCH_STATUS_SUCCESS; - } else if (!strcasecmp(result, "stop")) { - return SWITCH_STATUS_FALSE; - } else if (!strcasecmp(result, "truncate")) { - switch_core_file_truncate(fhp, 0); - } else if (!strcasecmp(result, "restart")) { - unsigned int pos = 0; - fhp->speed = 0; - switch_core_file_seek(fhp, &pos, 0, SEEK_SET); - return SWITCH_STATUS_SUCCESS; - } else if (!strncasecmp(result, "seek", 4)) { - switch_codec_t *codec; - unsigned int samps = 0; - unsigned int pos = 0; - char *p; - codec = switch_core_session_get_read_codec(session); - - if ((p = strchr(result, ':'))) { - p++; - if (*p == '+' || *p == '-') { - int step; - int32_t target; - if (!(step = atoi(p))) { - step = 1000; - } - - samps = step * (codec->implementation->samples_per_second / 1000); - target = (int32_t)fhp->pos + samps; - - if (target < 0) { - target = 0; - } - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", target); - switch_core_file_seek(fhp, &pos, target, SEEK_SET); - - } else { - samps = atoi(p) * (codec->implementation->samples_per_second / 1000); - if (samps < 0) { - samps = 0; - } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", samps); - switch_core_file_seek(fhp, &pos, samps, SEEK_SET); - } - } - - return SWITCH_STATUS_SUCCESS; - } - } - - if (!strcmp(result, "true") || !strcmp(result, "undefined")) { - return SWITCH_STATUS_SUCCESS; - } - - - return SWITCH_STATUS_FALSE; + return switch_ivr_process_fh(session, result, fhp); } /* For Emacs: diff --git a/src/switch_ivr.c b/src/switch_ivr.c index df88451a3d..00917adc34 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2563,6 +2563,124 @@ SWITCH_DECLARE(switch_bool_t) switch_ivr_uuid_exists(const char *uuid) return exists; } +SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp) +{ + if (zstr(cmd)) { + return SWITCH_STATUS_SUCCESS; + } + + if (fhp) { + if (!switch_test_flag(fhp, SWITCH_FILE_OPEN)) { + return SWITCH_STATUS_FALSE; + } + + if (!strncasecmp(cmd, "speed", 5)) { + char *p; + + if ((p = strchr(cmd, ':'))) { + p++; + if (*p == '+' || *p == '-') { + int step; + if (!(step = atoi(p))) { + step = 1; + } + fhp->speed += step; + } else { + int speed = atoi(p); + fhp->speed = speed; + } + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; + + } else if (!strncasecmp(cmd, "volume", 6)) { + char *p; + + if ((p = strchr(cmd, ':'))) { + p++; + if (*p == '+' || *p == '-') { + int step; + if (!(step = atoi(p))) { + step = 1; + } + fhp->vol += step; + } else { + int vol = atoi(p); + fhp->vol = vol; + } + return SWITCH_STATUS_SUCCESS; + } + + if (fhp->vol) { + switch_normalize_volume(fhp->vol); + } + + return SWITCH_STATUS_FALSE; + } else if (!strcasecmp(cmd, "pause")) { + if (switch_test_flag(fhp, SWITCH_FILE_PAUSE)) { + switch_clear_flag(fhp, SWITCH_FILE_PAUSE); + } else { + switch_set_flag(fhp, SWITCH_FILE_PAUSE); + } + return SWITCH_STATUS_SUCCESS; + } else if (!strcasecmp(cmd, "stop")) { + return SWITCH_STATUS_FALSE; + } else if (!strcasecmp(cmd, "truncate")) { + switch_core_file_truncate(fhp, 0); + } else if (!strcasecmp(cmd, "restart")) { + unsigned int pos = 0; + fhp->speed = 0; + switch_core_file_seek(fhp, &pos, 0, SEEK_SET); + return SWITCH_STATUS_SUCCESS; + } else if (!strncasecmp(cmd, "seek", 4)) { + switch_codec_t *codec; + unsigned int samps = 0; + unsigned int pos = 0; + char *p; + codec = switch_core_session_get_read_codec(session); + + if ((p = strchr(cmd, ':'))) { + p++; + if (*p == '+' || *p == '-') { + int step; + int32_t target; + if (!(step = atoi(p))) { + step = 1000; + } + + samps = step * (codec->implementation->samples_per_second / 1000); + target = (int32_t)fhp->pos + samps; + + if (target < 0) { + target = 0; + } + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", target); + switch_core_file_seek(fhp, &pos, target, SEEK_SET); + + } else { + samps = atoi(p) * (codec->implementation->samples_per_second / 1000); + if (samps < 0) { + samps = 0; + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", samps); + switch_core_file_seek(fhp, &pos, samps, SEEK_SET); + } + } + + return SWITCH_STATUS_SUCCESS; + } + } + + if (!strcmp(cmd, "true") || !strcmp(cmd, "undefined")) { + return SWITCH_STATUS_SUCCESS; + } + + return SWITCH_STATUS_FALSE; + +} + /* For Emacs: * Local Variables: diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 7285b894ea..3c8fa5e10f 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -913,6 +913,31 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi return SWITCH_STATUS_SUCCESS; } +SWITCH_DECLARE(switch_status_t) switch_ivr_get_file_handle(switch_core_session_t *session, switch_file_handle_t **fh) +{ + switch_file_handle_t *fhp; + switch_channel_t *channel = switch_core_session_get_channel(session); + + *fh = NULL; + switch_core_session_io_read_lock(session); + + if ((fhp = switch_channel_get_private(channel, "__fh"))) { + *fh = fhp; + return SWITCH_STATUS_SUCCESS; + } + + switch_core_session_io_rwunlock(session); + + return SWITCH_STATUS_FALSE; +} + +SWITCH_DECLARE(switch_status_t) switch_ivr_release_file_handle(switch_core_session_t *session, switch_file_handle_t **fh) +{ + *fh = NULL; + switch_core_session_io_rwunlock(session); + + return SWITCH_STATUS_SUCCESS; +} #define FILE_STARTSAMPLES 1024 * 32 #define FILE_BLOCKSIZE 1024 * 8 @@ -994,6 +1019,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } + + if (play_delimiter) { file_dup = switch_core_session_strdup(session, file); argc = switch_separate_string(file_dup, play_delimiter, argv, (sizeof(argv) / sizeof(argv[0]))); @@ -1134,6 +1161,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess status = SWITCH_STATUS_NOTFOUND; continue; } + + switch_core_session_io_write_lock(session); + switch_channel_set_private(channel, "__fh", fh); + switch_core_session_io_rwunlock(session); + if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) { asis = 1; } @@ -1208,7 +1240,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval); + switch_core_session_io_write_lock(session); + switch_channel_set_private(channel, "__fh", NULL); + switch_core_session_io_rwunlock(session); + switch_core_file_close(fh); + switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE); status = SWITCH_STATUS_GENERR; continue; @@ -1228,6 +1265,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess if (switch_core_timer_init(&timer, timer_name, interval, samples, pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Setup timer failed!\n"); switch_core_codec_destroy(&codec); + switch_core_session_io_write_lock(session); + switch_channel_set_private(channel, "__fh", NULL); + switch_core_session_io_rwunlock(session); switch_core_file_close(fh); switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE); status = SWITCH_STATUS_GENERR; @@ -1538,6 +1578,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_out); + switch_core_session_io_write_lock(session); + switch_channel_set_private(channel, "__fh", NULL); + switch_core_session_io_rwunlock(session); + switch_core_file_close(fh); if (fh->audio_buffer) { From 15b5170b14396e1e17b6f75a3da01695cb49eff3 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 16:42:58 -0500 Subject: [PATCH 35/55] freetdm: ftmod_libpri - add support for RINGING state --- libs/freetdm/mod_freetdm/mod_freetdm.c | 12 ++++++------ libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 07d4e88f33..b5c8b84c0c 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -841,9 +841,9 @@ static switch_status_t channel_receive_message_b(switch_core_session_t *session, assert(tech_pvt != NULL); if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } + switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); + return SWITCH_STATUS_FALSE; + } if (ftdm_channel_call_check_hangup(tech_pvt->ftdmchan)) { return SWITCH_STATUS_SUCCESS; @@ -888,9 +888,9 @@ static switch_status_t channel_receive_message_fxo(switch_core_session_t *sessio assert(tech_pvt != NULL); if (switch_test_flag(tech_pvt, TFLAG_DEAD)) { - switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); - return SWITCH_STATUS_FALSE; - } + switch_channel_hangup(channel, SWITCH_CAUSE_LOSE_RACE); + return SWITCH_STATUS_FALSE; + } if (switch_channel_test_flag(channel, CF_OUTBOUND)) { return SWITCH_STATUS_SUCCESS; diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c index c8e865214c..68f0e9e5a4 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c @@ -462,7 +462,7 @@ static ftdm_state_map_t isdn_state_map = { ZSD_INBOUND, ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_RING, FTDM_END}, - {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_END} + {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_UP, FTDM_END} }, { ZSD_INBOUND, @@ -479,7 +479,7 @@ static ftdm_state_map_t isdn_state_map = { { ZSD_INBOUND, ZSM_UNACCEPTABLE, - {FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_END}, + {FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_END}, {FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, FTDM_CHANNEL_STATE_CANCEL, FTDM_CHANNEL_STATE_UP, FTDM_END}, }, @@ -537,6 +537,8 @@ static __inline__ void state_advance(ftdm_channel_t *chan) break; case FTDM_CHANNEL_STATE_PROGRESS: + /* RINGING is an alias for PROGRESS state in inbound calls ATM */ + case FTDM_CHANNEL_STATE_RINGING: { if (ftdm_test_flag(chan, FTDM_CHANNEL_OUTBOUND)) { sig.event_id = FTDM_SIGEVENT_PROGRESS; From a1d6596ea627285828e5425282c60052c4a88b27 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 30 Nov 2010 15:50:15 -0600 Subject: [PATCH 36/55] swigall --- .../languages/mod_managed/freeswitch_wrap.cxx | 80 +++++++++++++++++++ src/mod/languages/mod_managed/managed/swig.cs | 78 ++++++++++++++++++ src/mod/languages/mod_perl/mod_perl_wrap.cpp | 6 +- 3 files changed, 161 insertions(+), 3 deletions(-) diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index d2f63b1006..f4bf780086 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -6744,6 +6744,42 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_destroy() { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_io_read_lock(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_io_read_lock(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_io_write_lock(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_io_write_lock(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_io_rwunlock(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_io_rwunlock(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_read_lock(void * jarg1) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -28317,6 +28353,50 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_dmachine_set_realm(void * jarg1, ch } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_get_file_handle(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_file_handle_t **arg2 = (switch_file_handle_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_file_handle_t **)jarg2; + result = (switch_status_t)switch_ivr_get_file_handle(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_release_file_handle(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_file_handle_t **arg2 = (switch_file_handle_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_file_handle_t **)jarg2; + result = (switch_status_t)switch_ivr_release_file_handle(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_process_fh(void * jarg1, char * jarg2, void * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_file_handle_t *arg3 = (switch_file_handle_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_file_handle_t *)jarg3; + result = (switch_status_t)switch_ivr_process_fh(arg1,(char const *)arg2,arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index fd4915f013..10fd3c6bc6 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -1103,6 +1103,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_io_read_lock(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_io_read_lock(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + + public static switch_status_t switch_core_session_io_write_lock(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_io_write_lock(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + + public static switch_status_t switch_core_session_io_rwunlock(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_io_rwunlock(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + public static switch_status_t switch_core_session_read_lock(SWIGTYPE_p_switch_core_session session) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_read_lock(SWIGTYPE_p_switch_core_session.getCPtr(session)); return ret; @@ -4471,6 +4486,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_get_file_handle(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_file_handle fh) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_get_file_handle(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_file_handle.getCPtr(fh)); + return ret; + } + + public static switch_status_t switch_ivr_release_file_handle(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_file_handle fh) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_release_file_handle(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_file_handle.getCPtr(fh)); + return ret; + } + + public static switch_status_t switch_ivr_process_fh(SWIGTYPE_p_switch_core_session session, string cmd, switch_file_handle fhp) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_process_fh(SWIGTYPE_p_switch_core_session.getCPtr(session), cmd, switch_file_handle.getCPtr(fhp)); + return ret; + } + public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -7255,6 +7285,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_destroy")] public static extern int switch_core_destroy(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_io_read_lock")] + public static extern int switch_core_session_io_read_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_io_write_lock")] + public static extern int switch_core_session_io_write_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_io_rwunlock")] + public static extern int switch_core_session_io_rwunlock(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_read_lock")] public static extern int switch_core_session_read_lock(HandleRef jarg1); @@ -12244,6 +12283,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_set_realm")] public static extern int switch_ivr_dmachine_set_realm(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_get_file_handle")] + public static extern int switch_ivr_get_file_handle(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_release_file_handle")] + public static extern int switch_ivr_release_file_handle(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_process_fh")] + public static extern int switch_ivr_process_fh(HandleRef jarg1, string jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")] public static extern int SWITCH_RTP_MAX_BUF_LEN_get(); @@ -17119,6 +17167,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_switch_file_handle { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_switch_file_handle(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_switch_file_handle() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_file_handle obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.35 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_p_switch_frame { private HandleRef swigCPtr; diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index 370c88bc99..2efbdf1abc 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -9732,17 +9732,17 @@ XS(SWIG_init) { SWIG_TypeClientData(SWIGTYPE_p_IVRMenu, (void*) "freeswitch::IVRMenu"); SWIG_TypeClientData(SWIGTYPE_p_API, (void*) "freeswitch::API"); SWIG_TypeClientData(SWIGTYPE_p_input_callback_state, (void*) "freeswitch::input_callback_state_t"); - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_HUP", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_HUP))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_FREE", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_FREE))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_RDLOCK", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_RDLOCK))); SvREADONLY_on(sv); From 086245a70103f87fc16eb294e23738cca95b1817 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Tue, 30 Nov 2010 17:21:48 -0500 Subject: [PATCH 37/55] freetdm: do not skip states if FREETDM_SKIP_SIG_STATES is not defined --- libs/freetdm/src/ftdm_io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index cffd98203b..bcaa15a77c 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2051,10 +2051,10 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char goto done; } -#if 0 - /* DAVIDY - We will fail RFC's if we do that, but some modules apart from ftmod_sangoma_isdn +#ifndef FREETDM_SKIP_SIG_STATES + /* We will fail RFC's if we not skip states, but some modules apart from ftmod_sangoma_isdn * expect the call to always to go PROGRESS and PROGRESS MEDIA state before going to UP, so - * remove this only in netborder branch for now */ + * remove this only in netborder branch for now while we update the sig modules */ if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) { ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1); From 35ba58e64994efa0a2c97a08b5164a5ea9f20679 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 30 Nov 2010 16:45:05 -0500 Subject: [PATCH 38/55] freetdm - ISDN:Fix for windows compilation issues --- libs/freetdm/src/ftdm_call_utils.c | 12 +++---- libs/freetdm/src/ftdm_io.c | 2 -- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 4 +-- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 31 +++++++++++++++++-- .../ftmod_sangoma_isdn_stack_hndl.c | 5 ++- .../ftmod_sangoma_isdn_support.c | 8 ++--- 6 files changed, 42 insertions(+), 20 deletions(-) diff --git a/libs/freetdm/src/ftdm_call_utils.c b/libs/freetdm/src/ftdm_call_utils.c index 52d2557a01..69f2fb4fff 100644 --- a/libs/freetdm/src/ftdm_call_utils.c +++ b/libs/freetdm/src/ftdm_call_utils.c @@ -38,7 +38,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_npi(string); @@ -53,7 +53,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *string, uint8_t *target) FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_ton(string); @@ -68,7 +68,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *string, uint8_t *target) FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_bearer_cap(string); @@ -84,7 +84,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *string, uint8_t FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_usr_layer1_prot(string); @@ -100,7 +100,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *string, uint8_t *ta FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_screening(string); @@ -116,7 +116,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *ta FT_DECLARE(ftdm_status_t) ftdm_set_presentation_ind(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_presentation(string); diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index bcaa15a77c..5ba7e389f8 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -38,8 +38,6 @@ */ #define _GNU_SOURCE -#ifndef WIN32 -#endif #include "private/ftdm_core.h" #include #ifdef WIN32 diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index 02927d7c88..03b5a5fb1d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -799,9 +799,7 @@ static void ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdmchan) break; case FTDM_CHANNEL_STATE_DOWN: /* the call is finished and removed */ { - uint8_t glare = 0; - - glare = sngisdn_test_flag(sngisdn_info, FLAG_GLARE); + uint8_t glare = sngisdn_test_flag(sngisdn_info, FLAG_GLARE); /* clear all of the call specific data store in the channel structure */ clear_call_data(sngisdn_info); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 9cddecb04e..b9ab3395ae 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -64,6 +64,33 @@ /* TODO: rename all *_cc_* to *_an_* */ +#define SNGISDN_ENUM_NAMES(_NAME, _STRINGS) static const char * _NAME [] = { _STRINGS , NULL }; +#define SNGISDN_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) _TYPE _FUNC1 (const char *name); const char * _FUNC2 (_TYPE type); +#define SNGISDN_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX) \ + _TYPE _FUNC1 (const char *name) \ +{ \ + int i; \ + _TYPE t = _MAX ; \ + \ + for (i = 0; i < _MAX ; i++) { \ + if (!strcasecmp(name, _STRINGS[i])) { \ + t = (_TYPE) i; \ + break; \ +} \ +} \ + \ + return t; \ +} \ + const char * _FUNC2 (_TYPE type) \ +{ \ + if (type > _MAX) { \ + type = _MAX; \ +} \ + return _STRINGS[(int)type]; \ +} \ + + + typedef enum { FLAG_RESET_RX = (1 << 0), FLAG_RESET_TX = (1 << 1), @@ -153,7 +180,7 @@ typedef enum { SNGISDN_PROGIND_DESCR_INVALID, } ftdm_sngisdn_progind_descr_t; #define SNGISDN_PROGIND_DESCR_STRINGS "not-end-to-end-isdn", "destination-is-non-isdn", "origination-is-non-isdn", "call-returned-to-isdn", "service-change", "inband-info-available", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t); +SNGISDN_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t); typedef enum { /* User */ @@ -174,7 +201,7 @@ typedef enum { SNGISDN_PROGIND_LOC_INVALID, } ftdm_sngisdn_progind_loc_t; #define SNGISDN_PROGIND_LOC_STRINGS "user", "private-net-local-user", "public-net-local-user", "transit-network", "public-net-remote-user", "private-net-remote-user", "beyond-interworking", "invalid" -FTDM_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t); +SNGISDN_STR2ENUM_P(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t); typedef struct ftdm_sngisdn_prog_ind { ftdm_sngisdn_progind_loc_t loc; /* location */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index c4e9f4a33f..d557ca3ba0 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -255,10 +255,9 @@ void sngisdn_process_con_cfm (sngisdn_event_data_t *sngisdn_event) uint8_t ces = sngisdn_event->ces; sngisdn_chan_data_t *sngisdn_info = sngisdn_event->sngisdn_info; ftdm_channel_t *ftdmchan = sngisdn_info->ftdmchan; - - ISDN_FUNC_TRACE_ENTER(__FUNCTION__); - CnStEvnt *cnStEvnt = &sngisdn_event->event.cnStEvnt; + + ISDN_FUNC_TRACE_ENTER(__FUNCTION__); ftdm_assert(!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE), "State change flag pending\n"); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index 964d06caaf..42bcd1e20a 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -37,11 +37,11 @@ /* ftmod_sangoma_isdn specific enum look-up functions */ -FTDM_ENUM_NAMES(SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t, SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_INVALID) +SNGISDN_ENUM_NAMES(SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_STRINGS) +SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_descr, ftdm_sngisdn_progind_descr2str, ftdm_sngisdn_progind_descr_t, SNGISDN_PROGIND_DESCR_NAMES, SNGISDN_PROGIND_DESCR_INVALID) -FTDM_ENUM_NAMES(SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_STRINGS) -FTDM_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t, SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_INVALID) +SNGISDN_ENUM_NAMES(SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_STRINGS) +SNGISDN_STR2ENUM(ftdm_str2ftdm_sngisdn_progind_loc, ftdm_sngisdn_progind_loc2str, ftdm_sngisdn_progind_loc_t, SNGISDN_PROGIND_LOC_NAMES, SNGISDN_PROGIND_LOC_INVALID) ftdm_status_t sngisdn_check_free_ids(void); From a669f76f786e2a74d3621cf5d4f9b0ad30d7e89a Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 30 Nov 2010 17:38:44 -0600 Subject: [PATCH 39/55] Fix issue when fs_path is used so we pick the correct media IP in our outbound invite this was soemthing that wouldn't work correctly over ATT on the iphone. --- src/mod/endpoints/mod_sofia/mod_sofia.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 3bb926adf3..74c4c0897e 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -3900,7 +3900,26 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session switch_channel_set_variable_printf(nchannel, "sip_local_network_addr", "%s", profile->extsipip ? profile->extsipip : profile->sipip); switch_channel_set_variable(nchannel, "sip_profile_name", profile_name); - switch_split_user_domain(switch_core_session_strdup(nsession, tech_pvt->dest), NULL, &tech_pvt->remote_ip); + if (switch_stristr("fs_path", tech_pvt->dest)) { + char *remote_host = NULL; + const char *s; + + if ((s = switch_stristr("fs_path=", tech_pvt->dest))) { + s += 8; + } + + if (s) { + remote_host = switch_core_session_strdup(nsession, s); + switch_url_decode(remote_host); + } + if (!zstr(remote_host)) { + switch_split_user_domain(remote_host, NULL, &tech_pvt->remote_ip); + } + } + + if (zstr(tech_pvt->remote_ip)) { + switch_split_user_domain(switch_core_session_strdup(nsession, tech_pvt->dest), NULL, &tech_pvt->remote_ip); + } if (dest_to) { if (strchr(dest_to, '@')) { From 82394b37687cb43ae3805d14a7ed9ca20da95a63 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 30 Nov 2010 18:22:12 -0600 Subject: [PATCH 40/55] add switch_ivr_insert_file to insert one file into another at an arbitrary sample point --- src/include/switch_ivr.h | 1 + src/switch_ivr.c | 156 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index d277bd030f..da366c5b8d 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -878,6 +878,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_set_realm(switch_ivr_dmachin SWITCH_DECLARE(switch_status_t) switch_ivr_get_file_handle(switch_core_session_t *session, switch_file_handle_t **fh); SWITCH_DECLARE(switch_status_t) switch_ivr_release_file_handle(switch_core_session_t *session, switch_file_handle_t **fh); SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp); +SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *session, const char *file, const char *insert_file, switch_size_t sample_point); /** @} */ diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 00917adc34..46ba4e6659 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -2681,6 +2681,162 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *ses } +#define START_SAMPLES 32768 + +SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *session, const char *file, const char *insert_file, switch_size_t sample_point) +{ + switch_file_handle_t orig_fh = { 0 }; + switch_file_handle_t new_fh = { 0 }; + switch_codec_implementation_t read_impl = { 0 }; + char *tmp_file; + switch_uuid_t uuid; + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; + int16_t *abuf = NULL; + switch_size_t olen = 0; + int asis = 0; + switch_channel_t *channel = switch_core_session_get_channel(session); + switch_size_t sample_count = 0; + uint32_t pos = 0; + char *ext; + + switch_uuid_get(&uuid); + switch_uuid_format(uuid_str, &uuid); + + if ((ext = strrchr(file, '.'))) { + ext++; + } else { + ext = "wav"; + } + + tmp_file = switch_core_session_sprintf(session, "%s%smsg_%s.%s", + SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str, ext); + + switch_core_session_get_read_impl(session, &read_impl); + + new_fh.channels = read_impl.number_of_channels; + new_fh.native_rate = read_impl.actual_samples_per_second; + + + if (switch_core_file_open(&new_fh, + tmp_file, + new_fh.channels, + read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to open file %s\n", tmp_file); + goto end; + } + + + if (switch_core_file_open(&orig_fh, + file, + new_fh.channels, + read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to open file %s\n", file); + goto end; + } + + + switch_zmalloc(abuf, START_SAMPLES * sizeof(*abuf)); + + if (switch_test_flag((&orig_fh), SWITCH_FILE_NATIVE)) { + asis = 1; + } + + while (switch_channel_ready(channel)) { + olen = START_SAMPLES; + + if (!asis) { + olen /= 2; + } + + if ((sample_count + olen) > sample_point) { + olen = sample_point - sample_count; + } + + if (!olen || switch_core_file_read(&orig_fh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) { + break; + } + + sample_count += olen; + + switch_core_file_write(&new_fh, abuf, &olen); + } + + switch_core_file_close(&orig_fh); + + + if (switch_core_file_open(&orig_fh, + insert_file, + new_fh.channels, + read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to open file %s\n", file); + goto end; + } + + + while (switch_channel_ready(channel)) { + olen = START_SAMPLES; + + if (!asis) { + olen /= 2; + } + + if (switch_core_file_read(&orig_fh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) { + break; + } + + sample_count += olen; + + switch_core_file_write(&new_fh, abuf, &olen); + } + + switch_core_file_close(&orig_fh); + + if (switch_core_file_open(&orig_fh, + file, + new_fh.channels, + read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to open file %s\n", file); + goto end; + } + + pos = 0; + switch_core_file_seek(&orig_fh, &pos, sample_point, SEEK_SET); + + while (switch_channel_ready(channel)) { + olen = START_SAMPLES; + + if (!asis) { + olen /= 2; + } + + if (switch_core_file_read(&orig_fh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) { + break; + } + + sample_count += olen; + + switch_core_file_write(&new_fh, abuf, &olen); + } + + end: + + if (switch_test_flag((&orig_fh), SWITCH_FILE_OPEN)) { + switch_core_file_close(&orig_fh); + } + + if (switch_test_flag((&new_fh), SWITCH_FILE_OPEN)) { + switch_core_file_close(&new_fh); + } + + switch_file_rename(tmp_file, file, switch_core_session_get_pool(session)); + unlink(tmp_file); + + switch_safe_free(abuf); + + return SWITCH_STATUS_SUCCESS; +} + + /* For Emacs: * Local Variables: From 77a7f93d6799ebf7cfb433af7a78b2c7b6ace60d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 30 Nov 2010 18:23:01 -0600 Subject: [PATCH 41/55] reswig --- .../languages/mod_managed/freeswitch_wrap.cxx | 24 +++++++++++++++++++ src/mod/languages/mod_managed/managed/swig.cs | 9 +++++++ 2 files changed, 33 insertions(+) diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index f4bf780086..a65d82d9cb 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -28397,6 +28397,30 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_process_fh(void * jarg1, char * jar } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_insert_file(void * jarg1, char * jarg2, char * jarg3, void * jarg4) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_size_t arg4 ; + switch_status_t result; + switch_size_t *argp4 ; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + argp4 = (switch_size_t *)jarg4; + if (!argp4) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return 0; + } + arg4 = *argp4; + result = (switch_status_t)switch_ivr_insert_file(arg1,(char const *)arg2,(char const *)arg3,arg4); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 10fd3c6bc6..e024c586f8 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -4501,6 +4501,12 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_insert_file(SWIGTYPE_p_switch_core_session session, string file, string insert_file, SWIGTYPE_p_switch_size_t sample_point) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_insert_file(SWIGTYPE_p_switch_core_session.getCPtr(session), file, insert_file, SWIGTYPE_p_switch_size_t.getCPtr(sample_point)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -12292,6 +12298,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_process_fh")] public static extern int switch_ivr_process_fh(HandleRef jarg1, string jarg2, HandleRef jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_insert_file")] + public static extern int switch_ivr_insert_file(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")] public static extern int SWITCH_RTP_MAX_BUF_LEN_get(); From bc34a24d4c7a70f5b526252495a19ba5f3d2de86 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 30 Nov 2010 18:35:43 -0600 Subject: [PATCH 42/55] get ready for ClueCon 11 --- build/Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/Makefile.am b/build/Makefile.am index 4b426ef6e3..1d57dad528 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -6,8 +6,13 @@ all: @echo " + Install by running: +" @echo " + +" @echo " + $(MK) install +" + @echo " + +" + @echo " + While you're waiting, register for ClueCon! +" + @echo " + http://www.cluecon.com +" + @echo " + +" @echo " +-----------------------------------------------+" + install: @echo " +---------- FreeSWITCH install Complete ----------+" @echo " + FreeSWITCH has been successfully installed. +" From 2343f68597f7f5d2986aeef1f85f579add45b0c4 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Tue, 30 Nov 2010 21:43:28 -0600 Subject: [PATCH 43/55] VS2010 reswig --- .../mod_managed/freeswitch_wrap.2010.cxx | 132 ++++++++++++++++++ .../mod_managed/managed/swig.2010.cs | 103 ++++++++++++++ 2 files changed, 235 insertions(+) diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx index 4a0b52efec..8033a8faa5 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.2010.cxx @@ -6454,6 +6454,42 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_destroy() { } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_io_read_lock(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_io_read_lock(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_io_write_lock(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_io_write_lock(arg1); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_io_rwunlock(void * jarg1) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (switch_status_t)switch_core_session_io_rwunlock(arg1); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_read_lock(void * jarg1) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -7336,6 +7372,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_execute_application_get_fl } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_execute_application_async(void * jarg1, char * jarg2, char * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + result = (switch_status_t)switch_core_session_execute_application_async(arg1,(char const *)arg2,(char const *)arg3); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_get_app_flags(char * jarg1, void * jarg2) { int jresult ; char *arg1 = (char *) 0 ; @@ -7566,6 +7618,18 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_session_event_count(void } +SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_core_session_messages_waiting(void * jarg1) { + unsigned long jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + uint32_t result; + + arg1 = (switch_core_session_t *)jarg1; + result = (uint32_t)switch_core_session_messages_waiting(arg1); + jresult = (unsigned long)result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_session_dequeue_event(void * jarg1, void * jarg2, int jarg3) { int jresult ; switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; @@ -27597,6 +27661,74 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_dmachine_set_realm(void * jarg1, ch } +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_get_file_handle(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_file_handle_t **arg2 = (switch_file_handle_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_file_handle_t **)jarg2; + result = (switch_status_t)switch_ivr_get_file_handle(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_release_file_handle(void * jarg1, void * jarg2) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_file_handle_t **arg2 = (switch_file_handle_t **) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_file_handle_t **)jarg2; + result = (switch_status_t)switch_ivr_release_file_handle(arg1,arg2); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_process_fh(void * jarg1, char * jarg2, void * jarg3) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + switch_file_handle_t *arg3 = (switch_file_handle_t *) 0 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (switch_file_handle_t *)jarg3; + result = (switch_status_t)switch_ivr_process_fh(arg1,(char const *)arg2,arg3); + jresult = result; + return jresult; +} + + +SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_insert_file(void * jarg1, char * jarg2, char * jarg3, void * jarg4) { + int jresult ; + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + switch_size_t arg4 ; + switch_size_t *argp4 ; + switch_status_t result; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (char *)jarg2; + arg3 = (char *)jarg3; + argp4 = (switch_size_t *)jarg4; + if (!argp4) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return 0; + } + arg4 = *argp4; + result = (switch_status_t)switch_ivr_insert_file(arg1,(char const *)arg2,(char const *)arg3,arg4); + jresult = result; + return jresult; +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; diff --git a/src/mod/languages/mod_managed/managed/swig.2010.cs b/src/mod/languages/mod_managed/managed/swig.2010.cs index 2897fef1e5..4d14f10879 100644 --- a/src/mod/languages/mod_managed/managed/swig.2010.cs +++ b/src/mod/languages/mod_managed/managed/swig.2010.cs @@ -1113,6 +1113,21 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_io_read_lock(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_io_read_lock(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + + public static switch_status_t switch_core_session_io_write_lock(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_io_write_lock(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + + public static switch_status_t switch_core_session_io_rwunlock(SWIGTYPE_p_switch_core_session session) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_io_rwunlock(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + public static switch_status_t switch_core_session_read_lock(SWIGTYPE_p_switch_core_session session) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_read_lock(SWIGTYPE_p_switch_core_session.getCPtr(session)); return ret; @@ -1449,6 +1464,11 @@ public class freeswitch { return ret; } + public static switch_status_t switch_core_session_execute_application_async(SWIGTYPE_p_switch_core_session session, string app, string arg) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_execute_application_async(SWIGTYPE_p_switch_core_session.getCPtr(session), app, arg); + return ret; + } + public static switch_status_t switch_core_session_get_app_flags(string app, SWIGTYPE_p_int flags) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_get_app_flags(app, SWIGTYPE_p_int.getCPtr(flags)); return ret; @@ -1528,6 +1548,11 @@ public class freeswitch { return ret; } + public static uint switch_core_session_messages_waiting(SWIGTYPE_p_switch_core_session session) { + uint ret = freeswitchPINVOKE.switch_core_session_messages_waiting(SWIGTYPE_p_switch_core_session.getCPtr(session)); + return ret; + } + public static switch_status_t switch_core_session_dequeue_event(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_event arg1, switch_bool_t force) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_session_dequeue_event(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_event.getCPtr(arg1), (int)force); return ret; @@ -4471,6 +4496,27 @@ public class freeswitch { return ret; } + public static switch_status_t switch_ivr_get_file_handle(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_file_handle fh) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_get_file_handle(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_file_handle.getCPtr(fh)); + return ret; + } + + public static switch_status_t switch_ivr_release_file_handle(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_p_switch_file_handle fh) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_release_file_handle(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_p_switch_file_handle.getCPtr(fh)); + return ret; + } + + public static switch_status_t switch_ivr_process_fh(SWIGTYPE_p_switch_core_session session, string cmd, switch_file_handle fhp) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_process_fh(SWIGTYPE_p_switch_core_session.getCPtr(session), cmd, switch_file_handle.getCPtr(fhp)); + return ret; + } + + public static switch_status_t switch_ivr_insert_file(SWIGTYPE_p_switch_core_session session, string file, string insert_file, SWIGTYPE_p_switch_size_t sample_point) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_insert_file(SWIGTYPE_p_switch_core_session.getCPtr(session), file, insert_file, SWIGTYPE_p_switch_size_t.getCPtr(sample_point)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -7259,6 +7305,15 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_destroy")] public static extern int switch_core_destroy(); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_io_read_lock")] + public static extern int switch_core_session_io_read_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_io_write_lock")] + public static extern int switch_core_session_io_write_lock(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_io_rwunlock")] + public static extern int switch_core_session_io_rwunlock(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_read_lock")] public static extern int switch_core_session_read_lock(HandleRef jarg1); @@ -7463,6 +7518,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_execute_application_get_flags")] public static extern int switch_core_session_execute_application_get_flags(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_execute_application_async")] + public static extern int switch_core_session_execute_application_async(HandleRef jarg1, string jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_get_app_flags")] public static extern int switch_core_session_get_app_flags(string jarg1, HandleRef jarg2); @@ -7511,6 +7569,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_event_count")] public static extern uint switch_core_session_event_count(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_messages_waiting")] + public static extern uint switch_core_session_messages_waiting(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_dequeue_event")] public static extern int switch_core_session_dequeue_event(HandleRef jarg1, HandleRef jarg2, int jarg3); @@ -12242,6 +12303,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_dmachine_set_realm")] public static extern int switch_ivr_dmachine_set_realm(HandleRef jarg1, string jarg2); + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_get_file_handle")] + public static extern int switch_ivr_get_file_handle(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_release_file_handle")] + public static extern int switch_ivr_release_file_handle(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_process_fh")] + public static extern int switch_ivr_process_fh(HandleRef jarg1, string jarg2, HandleRef jarg3); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_insert_file")] + public static extern int switch_ivr_insert_file(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")] public static extern int SWITCH_RTP_MAX_BUF_LEN_get(); @@ -17157,6 +17230,36 @@ namespace FreeSWITCH.Native { using System; using System.Runtime.InteropServices; +public class SWIGTYPE_p_p_switch_file_handle { + private HandleRef swigCPtr; + + internal SWIGTYPE_p_p_switch_file_handle(IntPtr cPtr, bool futureUse) { + swigCPtr = new HandleRef(this, cPtr); + } + + protected SWIGTYPE_p_p_switch_file_handle() { + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + + internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_file_handle obj) { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } +} + +} +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.1 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +namespace FreeSWITCH.Native { + +using System; +using System.Runtime.InteropServices; + public class SWIGTYPE_p_p_switch_frame { private HandleRef swigCPtr; From 92f43440729f16831fa9a3e840843486a942906e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 1 Dec 2010 09:46:06 -0600 Subject: [PATCH 44/55] FS-2892 --- src/mod/endpoints/mod_sofia/sofia_glue.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 57a2bfaa6a..451d7881b7 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -3732,6 +3732,14 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_ if (!t38_options) { t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t)); + + // set some default value + t38_options->T38FaxVersion = 0; + t38_options->T38MaxBitRate = 9600; + t38_options->T38FaxRateManagement = switch_core_session_strdup(tech_pvt->session, "transferredTCF"); + t38_options->T38FaxUdpEC = switch_core_session_strdup(tech_pvt->session, "t38UDPRedundancy"); + t38_options->T38FaxMaxBuffer = 500; + t38_options->T38FaxMaxDatagram = 500; } t38_options->remote_port = (switch_port_t)m->m_port; From 1ba98b02b9b2a44d1504f5c4546a7088907ed4eb Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 1 Dec 2010 09:54:28 -0600 Subject: [PATCH 45/55] FS-2852 --- src/switch_xml.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/switch_xml.c b/src/switch_xml.c index a7bfe413d0..05cfe9fd4c 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -1980,19 +1980,16 @@ static char not_so_threadsafe_error_buffer[256] = ""; SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **err) { char path_buf[1024]; - uint8_t hasmain = 0, errcnt = 0; + uint8_t errcnt = 0; switch_xml_t new_main, r = NULL; switch_mutex_lock(XML_LOCK); if (MAIN_XML_ROOT) { - hasmain++; - if (!reload) { r = switch_xml_root(); goto done; } - switch_thread_rwlock_wrlock(RWLOCK); } switch_snprintf(path_buf, sizeof(path_buf), "%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, "freeswitch.xml"); @@ -2007,9 +2004,15 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e } else { switch_xml_t old_root; *err = "Success"; + + switch_thread_rwlock_wrlock(RWLOCK); + old_root = MAIN_XML_ROOT; MAIN_XML_ROOT = new_main; switch_set_flag(MAIN_XML_ROOT, SWITCH_XML_ROOT); + + switch_thread_rwlock_unlock(RWLOCK); + switch_xml_free(old_root); /* switch_xml_free_in_thread(old_root); */ } @@ -2018,10 +2021,6 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_open_root(uint8_t reload, const char **e errcnt++; } - if (hasmain) { - switch_thread_rwlock_unlock(RWLOCK); - } - if (errcnt == 0) { switch_event_t *event; if (switch_event_create(&event, SWITCH_EVENT_RELOADXML) == SWITCH_STATUS_SUCCESS) { From 43c91d5fce868bc7a6b9055494cd3e0d46ade964 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Wed, 1 Dec 2010 10:25:02 -0600 Subject: [PATCH 46/55] misc windows x64 fixes --- libs/freetdm/freetdm.2008.sln | 2 - .../msvc/testboost/testboost.2008.vcproj | 160 ++-- .../testboost/testsangomaboost.2008.vcproj | 156 ++-- .../ftmod_analog/ftmod_analog.2008.vcproj | 706 +++++++++--------- .../ftmod_analog_em.2008.vcproj | 706 +++++++++--------- .../ftmod_sangoma_boost.2008.vcproj | 156 ++-- 6 files changed, 942 insertions(+), 944 deletions(-) diff --git a/libs/freetdm/freetdm.2008.sln b/libs/freetdm/freetdm.2008.sln index f059d941d3..2e8c7c4adb 100644 --- a/libs/freetdm/freetdm.2008.sln +++ b/libs/freetdm/freetdm.2008.sln @@ -161,10 +161,8 @@ Global {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|Win32.Build.0 = Release|Win32 {B2AF4EA6-0CD7-4529-9EB5-5AF43DB90395}.Release|x64.ActiveCfg = Release|Win32 {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|Win32.ActiveCfg = Debug|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|Win32.Build.0 = Debug|Win32 {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Debug|x64.ActiveCfg = Debug|Win32 {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|Win32.ActiveCfg = Release|Win32 - {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|Win32.Build.0 = Release|Win32 {08C3EA27-A51D-47F8-B47D-B189C649CF30}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution diff --git a/libs/freetdm/msvc/testboost/testboost.2008.vcproj b/libs/freetdm/msvc/testboost/testboost.2008.vcproj index afb44b6469..5707033f33 100644 --- a/libs/freetdm/msvc/testboost/testboost.2008.vcproj +++ b/libs/freetdm/msvc/testboost/testboost.2008.vcproj @@ -22,7 +22,7 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2008.vcproj index 448f03a545..09349fc05f 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2008.vcproj +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.2008.vcproj @@ -1,353 +1,353 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2008.vcproj index 8ad183797a..837ba7de0f 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2008.vcproj +++ b/libs/freetdm/src/ftmod/ftmod_analog_em/ftmod_analog_em.2008.vcproj @@ -1,353 +1,353 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2008.vcproj b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2008.vcproj index e7fc1d6549..73e421818f 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2008.vcproj +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_boost/ftmod_sangoma_boost.2008.vcproj @@ -95,83 +95,6 @@ Name="VCPostBuildEventTool" /> - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + From ca28a80658d50a9fab14f3022c40536b385b6b9b Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 1 Dec 2010 10:31:28 -0600 Subject: [PATCH 47/55] update caller_profile to have correct uuid when using custom uuid from originate string --- src/switch_core_session.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/switch_core_session.c b/src/switch_core_session.c index fc7648155a..2567d17712 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1327,6 +1327,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(switch_core_session { switch_event_t *event; switch_core_session_message_t msg = { 0 }; + switch_caller_profile_t *profile; switch_assert(use_uuid); @@ -1343,6 +1344,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(switch_core_session msg.string_array_arg[1] = use_uuid; switch_core_session_receive_message(session, &msg); + if ((profile = switch_channel_get_caller_profile(session->channel))) { + profile->uuid = switch_core_strdup(profile->pool, use_uuid); + } + switch_event_create(&event, SWITCH_EVENT_CHANNEL_UUID); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Old-Unique-ID", session->uuid_str); switch_core_hash_delete(session_manager.session_table, session->uuid_str); From 6b52a43314824943a3ef19b86bd577d5729416eb Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Wed, 1 Dec 2010 11:55:05 -0600 Subject: [PATCH 48/55] fix build warnings --- libs/freetdm/src/ftdm_call_utils.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/freetdm/src/ftdm_call_utils.c b/libs/freetdm/src/ftdm_call_utils.c index 52d2557a01..69f2fb4fff 100644 --- a/libs/freetdm/src/ftdm_call_utils.c +++ b/libs/freetdm/src/ftdm_call_utils.c @@ -38,7 +38,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_npi(string); @@ -53,7 +53,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_npi(const char *string, uint8_t *target) FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_ton(string); @@ -68,7 +68,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_ton(const char *string, uint8_t *target) FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_bearer_cap(string); @@ -84,7 +84,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_bearer_capability(const char *string, uint8_t FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_usr_layer1_prot(string); @@ -100,7 +100,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_bearer_layer1(const char *string, uint8_t *ta FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_screening(string); @@ -116,7 +116,7 @@ FT_DECLARE(ftdm_status_t) ftdm_set_screening_ind(const char *string, uint8_t *ta FT_DECLARE(ftdm_status_t) ftdm_set_presentation_ind(const char *string, uint8_t *target) { - int val; + uint8_t val; ftdm_status_t status = FTDM_SUCCESS; val = ftdm_str2ftdm_presentation(string); From 5df1683c38851b71ac0f74fbf058e32437140c55 Mon Sep 17 00:00:00 2001 From: Geovani Ricardo Wiedenhoft Date: Wed, 1 Dec 2010 16:40:35 -0200 Subject: [PATCH 49/55] - Notifies the pre_answer - Dialplan examples - New version of commons - Priority of contexts - New K3L install script - getk3l.sh - CLI return in XML - More options in GET and SET commands - Events (ESL) to send/receive SMS. - fax-adjustment-timeout implemented - accountcode and language - Owner destroy - Destroy wait for resources release - static const expression - Hangup cause --- build/modules.conf.in | 2 +- conf/autoload_configs/modules.conf.xml | 1 + .../mod_khomp/Install/files/khomp.conf.xml | 61 +- src/mod/endpoints/mod_khomp/Makefile | 20 +- .../mod_khomp/commons/{ => base}/atomic.hpp | 24 +- .../commons/{ => base}/config_commons.hpp | 9 +- .../mod_khomp/commons/base/config_options.cpp | 302 ++++ .../mod_khomp/commons/base/config_options.hpp | 772 +++++++++++ .../commons/base/configurator/configfile.cpp | 241 ++++ .../{ => base}/configurator/configfile.hpp | 70 +- .../commons/base/configurator/option.cpp | 186 +++ .../{ => base}/configurator/option.hpp | 112 +- .../commons/base/configurator/restriction.cpp | 358 +++++ .../commons/base/configurator/restriction.hpp | 269 ++++ .../{ => base}/configurator/section.cpp | 100 +- .../commons/base/configurator/section.hpp | 260 ++++ .../mod_khomp/commons/base/const_this.hpp | 15 + .../mod_khomp/commons/{ => base}/flagger.hpp | 0 .../mod_khomp/commons/{ => base}/format.cpp | 138 +- .../mod_khomp/commons/{ => base}/format.hpp | 505 +++---- .../mod_khomp/commons/{ => base}/function.hpp | 140 +- .../commons/{ => base}/initializer.hpp | 16 +- .../mod_khomp/commons/{ => base}/k3lapi.cpp | 70 +- .../mod_khomp/commons/{ => base}/k3lapi.hpp | 470 ++++--- .../mod_khomp/commons/{ => base}/k3lutil.cpp | 50 +- .../mod_khomp/commons/{ => base}/k3lutil.hpp | 6 +- .../mod_khomp/commons/{ => base}/logger.hpp | 56 +- .../commons/{ => base}/noncopyable.hpp | 0 .../commons/{ => base}/refcounter.hpp | 11 +- .../mod_khomp/commons/{ => base}/regex.cpp | 5 +- .../mod_khomp/commons/{ => base}/regex.hpp | 77 +- .../mod_khomp/commons/base/ringbuffer.cpp | 485 +++++++ .../commons/{ => base}/ringbuffer.hpp | 62 +- .../commons/{ => base}/saved_condition.cpp | 0 .../commons/{ => base}/saved_condition.hpp | 0 .../commons/{ => base}/scoped_lock.hpp | 0 .../commons/{ => base}/simple_lock.hpp | 4 +- .../mod_khomp/commons/{ => base}/strings.cpp | 56 +- .../mod_khomp/commons/{ => base}/strings.hpp | 19 +- .../system}/freeswitch/saved_condition.cpp | 46 +- .../system}/freeswitch/saved_condition.hpp | 32 +- .../system}/freeswitch/simple_lock.hpp | 32 +- .../{ => base/system}/freeswitch/thread.hpp | 66 +- .../commons/{ => base}/tagged_union.hpp | 62 +- .../mod_khomp/commons/{ => base}/thread.hpp | 0 .../mod_khomp/commons/{ => base}/timer.cpp | 14 + .../mod_khomp/commons/{ => base}/timer.hpp | 11 +- .../mod_khomp/commons/{ => base}/types.hpp | 24 +- .../{variant.hpp => base/variable.hpp} | 127 +- .../mod_khomp/commons/{ => base}/verbose.cpp | 980 ++++++------- .../mod_khomp/commons/base/verbose.hpp | 303 ++++ .../mod_khomp/commons/config_options.cpp | 710 ---------- .../mod_khomp/commons/config_options.hpp | 286 ---- .../commons/configurator/configfile.cpp | 241 ---- .../mod_khomp/commons/configurator/option.cpp | 185 --- .../commons/configurator/restriction.cpp | 353 ----- .../commons/configurator/restriction.hpp | 321 ----- .../commons/configurator/section.hpp | 226 --- .../mod_khomp/commons/ringbuffer.cpp | 575 -------- .../commons/tools/generate-verbose-headers.sh | 183 +++ .../endpoints/mod_khomp/commons/verbose.hpp | 505 ------- src/mod/endpoints/mod_khomp/docs/Manual.html | 16 +- src/mod/endpoints/mod_khomp/docs/Manual.pdf | Bin 469674 -> 470343 bytes src/mod/endpoints/mod_khomp/docs/README.pdf | Bin 399120 -> 399119 bytes .../endpoints/mod_khomp/docs/README_en.pdf | Bin 314414 -> 314413 bytes .../endpoints/mod_khomp/docs/User_Guide.html | 18 +- .../endpoints/mod_khomp/docs/User_Guide.pdf | Bin 509356 -> 509260 bytes .../mod_khomp/examples/intercept.xml | 26 + .../endpoints/mod_khomp/examples/transfer.xml | 43 + .../mod_khomp/include/applications.h | 83 +- src/mod/endpoints/mod_khomp/include/cli.h | 254 ++-- src/mod/endpoints/mod_khomp/include/defs.h | 4 +- src/mod/endpoints/mod_khomp/include/frame.h | 2 +- src/mod/endpoints/mod_khomp/include/globals.h | 4 +- .../endpoints/mod_khomp/include/khomp_pvt.h | 66 +- .../mod_khomp/include/khomp_pvt_fxo.h | 6 +- .../mod_khomp/include/khomp_pvt_gsm.h | 4 +- .../mod_khomp/include/khomp_pvt_kxe1.h | 29 +- .../mod_khomp/include/khomp_pvt_passive.h | 8 +- src/mod/endpoints/mod_khomp/include/opt.h | 316 ++--- .../endpoints/mod_khomp/include/revision.h | 2 +- src/mod/endpoints/mod_khomp/include/spec.h | 7 - src/mod/endpoints/mod_khomp/include/utils.h | 90 ++ src/mod/endpoints/mod_khomp/mod_khomp.cpp | 77 +- .../endpoints/mod_khomp/src/applications.cpp | 15 +- src/mod/endpoints/mod_khomp/src/cli.cpp | 1214 +++++++++++++---- src/mod/endpoints/mod_khomp/src/globals.cpp | 4 +- src/mod/endpoints/mod_khomp/src/khomp_pvt.cpp | 270 +++- .../endpoints/mod_khomp/src/khomp_pvt_fxo.cpp | 51 +- .../endpoints/mod_khomp/src/khomp_pvt_gsm.cpp | 31 +- .../mod_khomp/src/khomp_pvt_kxe1.cpp | 187 +-- .../mod_khomp/src/khomp_pvt_passive.cpp | 7 +- src/mod/endpoints/mod_khomp/src/opt.cpp | 416 +++--- src/mod/endpoints/mod_khomp/src/spec.cpp | 40 +- src/mod/endpoints/mod_khomp/src/utils.cpp | 78 +- .../mod_khomp/support/klog-config.cpp | 4 + .../mod_khomp/support/klog-config.hpp | 6 + .../mod_khomp/{install.sh => tools/getk3l.sh} | 12 +- 98 files changed, 7491 insertions(+), 6153 deletions(-) rename src/mod/endpoints/mod_khomp/commons/{ => base}/atomic.hpp (90%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/config_commons.hpp (92%) create mode 100644 src/mod/endpoints/mod_khomp/commons/base/config_options.cpp create mode 100644 src/mod/endpoints/mod_khomp/commons/base/config_options.hpp create mode 100644 src/mod/endpoints/mod_khomp/commons/base/configurator/configfile.cpp rename src/mod/endpoints/mod_khomp/commons/{ => base}/configurator/configfile.hpp (65%) create mode 100644 src/mod/endpoints/mod_khomp/commons/base/configurator/option.cpp rename src/mod/endpoints/mod_khomp/commons/{ => base}/configurator/option.hpp (52%) create mode 100644 src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.cpp create mode 100644 src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.hpp rename src/mod/endpoints/mod_khomp/commons/{ => base}/configurator/section.cpp (59%) create mode 100644 src/mod/endpoints/mod_khomp/commons/base/configurator/section.hpp create mode 100644 src/mod/endpoints/mod_khomp/commons/base/const_this.hpp rename src/mod/endpoints/mod_khomp/commons/{ => base}/flagger.hpp (100%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/format.cpp (89%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/format.hpp (81%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/function.hpp (65%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/initializer.hpp (86%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/k3lapi.cpp (77%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/k3lapi.hpp (50%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/k3lutil.cpp (83%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/k3lutil.hpp (95%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/logger.hpp (89%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/noncopyable.hpp (100%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/refcounter.hpp (94%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/regex.cpp (94%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/regex.hpp (78%) create mode 100644 src/mod/endpoints/mod_khomp/commons/base/ringbuffer.cpp rename src/mod/endpoints/mod_khomp/commons/{ => base}/ringbuffer.hpp (88%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/saved_condition.cpp (100%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/saved_condition.hpp (100%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/scoped_lock.hpp (100%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/simple_lock.hpp (96%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/strings.cpp (87%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/strings.hpp (81%) rename src/mod/endpoints/mod_khomp/commons/{ => base/system}/freeswitch/saved_condition.cpp (83%) rename src/mod/endpoints/mod_khomp/commons/{ => base/system}/freeswitch/saved_condition.hpp (94%) rename src/mod/endpoints/mod_khomp/commons/{ => base/system}/freeswitch/simple_lock.hpp (96%) rename src/mod/endpoints/mod_khomp/commons/{ => base/system}/freeswitch/thread.hpp (94%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/tagged_union.hpp (84%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/thread.hpp (100%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/timer.cpp (96%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/timer.hpp (93%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/types.hpp (88%) rename src/mod/endpoints/mod_khomp/commons/{variant.hpp => base/variable.hpp} (53%) rename src/mod/endpoints/mod_khomp/commons/{ => base}/verbose.cpp (82%) create mode 100644 src/mod/endpoints/mod_khomp/commons/base/verbose.hpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/config_options.cpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/config_options.hpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/configurator/configfile.cpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/configurator/option.cpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/configurator/restriction.cpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/configurator/restriction.hpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/configurator/section.hpp delete mode 100644 src/mod/endpoints/mod_khomp/commons/ringbuffer.cpp create mode 100755 src/mod/endpoints/mod_khomp/commons/tools/generate-verbose-headers.sh delete mode 100644 src/mod/endpoints/mod_khomp/commons/verbose.hpp create mode 100644 src/mod/endpoints/mod_khomp/examples/intercept.xml create mode 100644 src/mod/endpoints/mod_khomp/examples/transfer.xml rename src/mod/endpoints/mod_khomp/{install.sh => tools/getk3l.sh} (93%) diff --git a/build/modules.conf.in b/build/modules.conf.in index 37244a188a..13e655672c 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -62,6 +62,7 @@ endpoints/mod_loopback #endpoints/mod_skinny #endpoints/mod_skypopen #endpoints/mod_h323 +#endpoints/mod_khomp #../../libs/openzap/mod_openzap #../../libs/freetdm/mod_freetdm #asr_tts/mod_unimrcp @@ -105,5 +106,4 @@ say/mod_say_ru #say/mod_say_th ## Experimental Modules (don't cry if they're broken) -#endpoints/mod_khomp #../../contrib/mod/xml_int/mod_xml_odbc diff --git a/conf/autoload_configs/modules.conf.xml b/conf/autoload_configs/modules.conf.xml index f5627fe965..118d7c4d81 100644 --- a/conf/autoload_configs/modules.conf.xml +++ b/conf/autoload_configs/modules.conf.xml @@ -38,6 +38,7 @@ + diff --git a/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml b/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml index 45268f304b..79c00516b9 100644 --- a/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml +++ b/src/mod/endpoints/mod_khomp/Install/files/khomp.conf.xml @@ -95,16 +95,6 @@ should be opened for the channel. Limited to 25ms min, 500ms max. --> - - - - - - - - - - diff --git a/src/mod/endpoints/mod_khomp/Makefile b/src/mod/endpoints/mod_khomp/Makefile index 94923c7cda..db1a6fe4e4 100644 --- a/src/mod/endpoints/mod_khomp/Makefile +++ b/src/mod/endpoints/mod_khomp/Makefile @@ -1,6 +1,9 @@ MODNAME := mod_khomp VERBOSE := 1 +#FreeSWITCH source PATH is needed: +# Set FREESWITCH_PATH + ifeq ($(strip $(FREESWITCH_PATH)),) BASE := ../../../../ else @@ -11,12 +14,12 @@ curr_dir := $(shell pwd) versions := -DFS_VERSION_MAJOR=$(shell bash $(curr_dir)/tools/getversion.sh "SWITCH_VERSION_MAJOR" $(BASE)) -DFS_VERSION_MINOR=$(shell bash $(curr_dir)/tools/getversion.sh "SWITCH_VERSION_MINOR" $(BASE)) -DFS_VERSION_MICRO=$(shell bash $(curr_dir)/tools/getversion.sh "SWITCH_VERSION_MICRO" $(BASE)) -LOCAL_CFLAGS = -I./ -I./include -I./commons -I./support -D_REENTRANT -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DK3L_HOSTSYSTEM -DCOMMONS_LIBRARY_USING_FREESWITCH -g -ggdb #-DDEBUG_FLAGS +LOCAL_CFLAGS = -I./ -I./include -I./commons -I./commons/base -I./support -D_REENTRANT -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DK3L_HOSTSYSTEM -DCOMMONS_LIBRARY_USING_FREESWITCH -g -ggdb #-DDEBUG_FLAGS LOCAL_CFLAGS += $(versions) LOCAL_LDFLAGS = -lk3l -LOCAL_OBJS = ./commons/k3lapi.o ./commons/k3lutil.o ./commons/config_options.o ./commons/format.o ./commons/strings.o ./commons/ringbuffer.o ./commons/verbose.o ./commons/saved_condition.o ./commons/regex.o ./commons/timer.o ./commons/configurator/configfile.o ./commons/configurator/option.o ./commons/configurator/section.o ./commons/configurator/restriction.o +LOCAL_OBJS = ./commons/base/k3lapi.o ./commons/base/k3lutil.o ./commons/base/config_options.o ./commons/base/format.o ./commons/base/strings.o ./commons/base/ringbuffer.o ./commons/base/verbose.o ./commons/base/saved_condition.o ./commons/base/regex.o ./commons/base/timer.o ./commons/base/configurator/configfile.o ./commons/base/configurator/option.o ./commons/base/configurator/section.o ./commons/base/configurator/restriction.o ./commons/base/verbose_traits.o LOCAL_OBJS += ./support/klog-config.o ./support/klog-options.o ./support/config_defaults.o LOCAL_OBJS += ./src/globals.o ./src/opt.o ./src/frame.o ./src/utils.o ./src/lock.o ./src/spec.o ./src/applications.o ./src/khomp_pvt_fxo.o ./src/khomp_pvt_gsm.o ./src/khomp_pvt_kxe1.o ./src/khomp_pvt_passive.o ./src/khomp_pvt.o ./src/logger.o ./src/cli.o @@ -27,7 +30,20 @@ conf_file_install = $(sysconfdir)/autoload_configs include $(BASE)/build/modmake.rules +local_depend: + @if test ! -f $(curr_dir)/commons/base/verbose_traits.hpp || test ! -f $(curr_dir)/commons/base/verbose_traits.cpp ; then \ + echo "Generating verbose_traits" ;\ + bash $(curr_dir)/commons/tools/generate-verbose-headers.sh commons/base/ include/k3l.h ;\ + fi; + depend_install: + @if test "w`kserver --version 2>/dev/null | grep 2.1`" == "w" ; then \ + echo "###############################################################################" ;\ + echo "Install k3l from KHOMP." ;\ + echo "Run: $(curr_dir)/tools/getk3l.sh" ;\ + echo "###############################################################################" ;\ + exit 1;\ + fi; @echo "Copy $(conf_file_name)" @if test -d $(conf_file_install) ; then \ if test -f $(conf_file_dir)/$(conf_file_name) ; then \ diff --git a/src/mod/endpoints/mod_khomp/commons/atomic.hpp b/src/mod/endpoints/mod_khomp/commons/base/atomic.hpp similarity index 90% rename from src/mod/endpoints/mod_khomp/commons/atomic.hpp rename to src/mod/endpoints/mod_khomp/commons/base/atomic.hpp index daa598c9b4..02278b390c 100644 --- a/src/mod/endpoints/mod_khomp/commons/atomic.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/atomic.hpp @@ -64,17 +64,31 @@ namespace Atomic PunnedType pval; pval.valtype = VAL; \ unsigned long long vexp = *(pexp.podtype); \ unsigned long long vval = *(pval.podtype); \ - unsigned long long res = (unsigned long long)exp; \ + unsigned long vval32 = (unsigned long)vval; \ unsigned char chg = 0; \ - asm volatile("lock; cmpxchg8b %2; sete %1;" \ + asm volatile( \ + "xchgl %%ebx, %4;" \ + "lock; cmpxchg8b %2; sete %1;" \ + "movl %4, %%ebx; " \ : "+A" (vexp), /* 0 (result) */ \ - "=q" (chg) /* 1 */ \ + "=c" (chg) /* 1 */ \ : "m" (*(unsigned char**)(PTR)), /* 2 */ \ - "b" ((unsigned long)(vval)), \ - "c" ((unsigned long)(vval >> 32))); \ + "c" ((unsigned long)(vval >> 32)), \ + "m" (vval32)); \ *(pexp.podtype) = vexp; \ return (chg != 0 ? true : false); +// "movl %%ecx, %4;" +// +// "m" (*((unsigned long*)(*(pval.podtype)))), +// "m" ((unsigned long)(vval >> 32)) +// +// "m" (*((unsigned long*)(&vval))), +// "m" ((unsigned long)(vval >> 32)) +// +// unsigned long long vval = *(pval.podtype); +// unsigned long long res = (unsigned long long)exp; +// // Types used for making CMPXCHG instructions independent from base type. template < typename ValType, typename PodType > diff --git a/src/mod/endpoints/mod_khomp/commons/config_commons.hpp b/src/mod/endpoints/mod_khomp/commons/base/config_commons.hpp similarity index 92% rename from src/mod/endpoints/mod_khomp/commons/config_commons.hpp rename to src/mod/endpoints/mod_khomp/commons/base/config_commons.hpp index de8f327df4..dad16f4e92 100644 --- a/src/mod/endpoints/mod_khomp/commons/config_commons.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/config_commons.hpp @@ -63,7 +63,12 @@ #error Unknown implementation selected. Please define COMMONS_LIBRARY_USING_* correctly. #endif -#define COMMONS_INCLUDE(file) +#define COMMONS_INCLUDE(file) + +#define COMMONS_VERSION_MAJOR 1 +#define COMMONS_VERSION_MINOR 1 + +#define COMMONS_AT_LEAST(x,y) \ + (COMMONS_VERSION_MAJOR > x || (COMMONS_VERSION_MAJOR == x && COMMONS_VERSION_MINOR >= y)) #endif /* _CONFIG_COMMONS_HPP_ */ - diff --git a/src/mod/endpoints/mod_khomp/commons/base/config_options.cpp b/src/mod/endpoints/mod_khomp/commons/base/config_options.cpp new file mode 100644 index 0000000000..7412b4b1a0 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/config_options.cpp @@ -0,0 +1,302 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include + +void Config::Restriction::checkRange(const std::string & name, const SIntType value, const Range < SIntType > & range) +{ + if (value < range.minimum) + throw Failure(STG(FMT("value '%d' out-of-range for option '%s' (too low)") % value % name)); + + if (value > range.maximum) + throw Failure(STG(FMT("value '%d' out-of-range for option '%s' (too high)") % value % name)); + + if (((value - range.minimum) % range.step) != 0) + throw Failure(STG(FMT("value '%d' out-of-range for option '%s' (outside allowed step)") % value % name)); +} + +void Config::Restriction::checkRange(const std::string & name, const UIntType value, const Range < UIntType > & range) +{ + if (value < range.minimum) + throw Failure(STG(FMT("value '%d' out-of-range for option '%s' (too low)") % value % name)); + + if (value > range.maximum) + throw Failure(STG(FMT("value '%d' out-of-range for option '%s' (too high)") % value % name)); + + if (((value - range.minimum) % range.step) != 0) + throw Failure(STG(FMT("value '%d' out-of-range for option '%s' (outside allowed step)") % value % name)); +} + +void Config::Restriction::checkStringSet(const std::string & name, const StringType & value, const StringSet & allowed) +{ + if (allowed.empty()) + return; + + if (allowed.find(value) != allowed.end()) + return; + + std::string strlist; + + for (StringSet::const_iterator i = allowed.begin(); i != allowed.end(); i++) + { + strlist += " '"; + strlist += (*i); + strlist += "'"; + } + + throw Failure(STG(FMT("value '%s' not allowed for option '%s' (allowed values:%s)") + % value % name % strlist)); +} + +Config::Option::Option(std::string name, Config::Option::StringMemberType value, const StringType defvalue, StringSet & allowed, bool listme) +: _myname(name), _option(InnerStringType(name, value, defvalue, allowed)), _listme(listme), _values(NULL) +{}; + +Config::Option::Option(std::string name, Config::Option::StringMemberType value, const StringType defvalue, bool listme) +: _myname(name), _option(InnerStringType(name, value, defvalue)), _listme(listme), _values(NULL) +{}; + +Config::Option::Option(std::string name, Config::Option::BooleanMemberType value, const BooleanType defvalue, bool listme) +: _myname(name), _option(InnerBooleanType(name, value, defvalue)), _listme(listme), _values(NULL) +{}; + +Config::Option::Option(std::string name, Config::Option::SIntMemberType value, const SIntType defvalue, + SIntType min, SIntType max, SIntType step, bool listme) +: _myname(name), _option(InnerSIntType(name, value, defvalue, min, max, step)), _listme(listme), _values(NULL) +{}; + +Config::Option::Option(std::string name, Config::Option::UIntMemberType value, const UIntType defvalue, + UIntType min, UIntType max, UIntType step, bool listme) +: _myname(name), _option(InnerUIntType(name, value, defvalue, min, max, step)), _listme(listme), _values(NULL) +{}; + +Config::Option::Option(const Config::Option & o) +: _myname(o._myname), _option(o._option), _listme(o._listme), _values(o._values) +{}; + +Config::Option::Option(std::string name, Config::Option::FunctionMemberType value, const StringType defvalue, StringSet & allowed, bool listme) +: _myname(name), _option(InnerFunctionType(name, value, defvalue, allowed)), _listme(listme), _values(NULL) +{}; + +Config::Option::Option(std::string name, Config::Option::FunctionMemberType value, const StringType defvalue, bool listme) +: _myname(name), _option(InnerFunctionType(name, value, defvalue)), _listme(listme), _values(NULL) +{}; + +Config::Option::~Option(void) +{ + if (_values) + { + for (unsigned int i = 0; _values[i] != NULL; i++) + delete _values[i]; + + delete[] _values; + _values = NULL; + } +}; + +const char ** Config::Option::values(void) +{ + if (_values != NULL) + return _values; + + /**/ if (_option.check()) + { + _values = new const char*[3]; + + _values[0] = strdup("yes"); + _values[1] = strdup("no"); + _values[2] = NULL; + + } + else if (_option.check()) + { + const InnerSIntType & tmp = _option.get(); + + unsigned int count = ((tmp._range.maximum - tmp._range.minimum) / tmp._range.step) + 1; + unsigned int index = 0; + + _values = new const char*[count + 1]; + + for (SIntType i = tmp._range.minimum; i <= tmp._range.maximum; i += tmp._range.step, ++index) + _values[index] = strdup(STG(FMT("%d") % i).c_str()); + + _values[index] = NULL; + } + else if (_option.check()) + { + const InnerUIntType & tmp = _option.get(); + + unsigned int count = ((tmp._range.maximum - tmp._range.minimum) / tmp._range.step) + 1; + unsigned int index = 0; + + _values = new const char*[count + 1]; + + for (UIntType i = tmp._range.minimum; i <= tmp._range.maximum; i += tmp._range.step, ++index) + _values[index] = strdup(STG(FMT("%d") % i).c_str()); + + _values[index] = NULL; + } + else if (_option.check()) + { + const InnerStringType & tmp = _option.get(); + + _values = new const char*[ tmp._allowed.size() + 1 ]; + + unsigned int index = 0; + + for (StringSet::iterator i = tmp._allowed.begin(); i != tmp._allowed.end(); ++i, ++index) + _values[index] = strdup((*i).c_str()); + + _values[index] = NULL; + } + else if (_option.check()) + { + const InnerFunctionType & tmp = _option.get(); + + _values = new const char*[ tmp._allowed.size() + 1 ]; + + unsigned int index = 0; + + for (StringSet::iterator i = tmp._allowed.begin(); i != tmp._allowed.end(); ++i, ++index) + _values[index] = strdup((*i).c_str()); + + _values[index] = NULL; + } + else + { + throw Failure(STG(FMT("values() not implemented for type used in option '%s'") % _myname)); + } + + return _values; +}; + +/*********************************/ + +Config::Options::Options(void) +: _values(NULL) +{}; + +Config::Options::~Options() +{ + if (_values) + { + for (unsigned int i = 0; _values[i] != NULL; i++) + free((void*)(_values[i])); + + delete[] _values; + _values = NULL; + } +}; + +bool Config::Options::add(Config::Option option) +{ + std::pair ret = _map.insert(OptionPair(option.name(), option)); + + return ret.second; +} + +bool Config::Options::synonym(std::string equiv_opt, std::string main_opt) +{ + std::pair ret = _syn_map.insert(SynOptionPair(equiv_opt, main_opt)); + + return ret.second; +} + +Config::StringSet Config::Options::options(void) +{ + StringSet res; + + for (OptionMap::iterator i = _map.begin(); i != _map.end(); i++) + res.insert(i->first); + + return res; +} + +const char ** Config::Options::values(const char * name) +{ + OptionMap::iterator iter = find_option(name); + + if (iter == _map.end()) + throw Failure(STG(FMT("unknown option '%s'") % name)); + + return iter->second.values(); +} + +const char ** Config::Options::values(void) +{ + if (_values != NULL) + return _values; + + unsigned int count = 0; + + for (OptionMap::iterator i = _map.begin(); i != _map.end(); ++i) + if (i->second.listme()) + ++count; + + _values = new const char*[ count + 1 ]; + + unsigned int index = 0; + + for (OptionMap::iterator i = _map.begin(); i != _map.end(); ++i) + { + if (i->second.listme()) + { + _values[index] = strdup(i->first.c_str()); + ++index; + } + } + + _values[index] = NULL; + + return _values; +} + +Config::Options::OptionMap::iterator Config::Options::find_option(std::string name) +{ + SynOptionMap::iterator syn_iter = _syn_map.find(name); + + if (syn_iter != _syn_map.end()) + name = syn_iter->second; + + OptionMap::iterator iter = _map.find(name); + + return iter; +} diff --git a/src/mod/endpoints/mod_khomp/commons/base/config_options.hpp b/src/mod/endpoints/mod_khomp/commons/base/config_options.hpp new file mode 100644 index 0000000000..59e381f893 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/config_options.hpp @@ -0,0 +1,772 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef _CONFIG_OPTIONS_HPP_ +#define _CONFIG_OPTIONS_HPP_ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace Config +{ + /* exceptions */ + + struct Failure: public std::runtime_error + { + Failure(const std::string & msg) : std::runtime_error(msg) {}; + }; + + struct EmptyValue: public std::runtime_error + { + EmptyValue(): std::runtime_error("accessed option still not loaded from configuration") {}; + }; + + /* types */ + + typedef int SIntType; + typedef unsigned int UIntType; + typedef bool BooleanType; + typedef std::string StringType; + + template < typename Type > + struct Value; + + template < typename Type > + struct InnerOptionBase; + + template < typename Type > + struct InnerOption; + + struct Option; + + /* here we go! */ + + template < typename Type > + struct Range + { + Range(const Type _minimum, const Type _maximum, const Type _step) + : minimum(_minimum), maximum(_maximum), step(_step) {}; + + const Type minimum, maximum, step; + }; + + typedef std::set < std::string > StringSet; + + template < typename Type > + struct Value: COUNTER_SUPER(Value < Type >) + { + friend class COUNTER_CLASS(Value < Type >); + friend class InnerOptionBase< Type >; + friend class InnerOption < Type >; + friend class Option; + + Value() + : _tmpval(0), _stored(0), _loaded(false), _inited(false) + {}; + + Value(const Value & o) + : COUNTER_REFER(o, Value < Type >), + _tmpval(o._tmpval), _stored(o._stored), + _loaded(o._loaded), _inited(o._inited) + {}; + + const Type & operator()(void) const + { + if (!_inited) + throw EmptyValue(); + + if (!_stored) + return *_tmpval; + + return *_stored; + }; + + const Type & get(void) const { return operator()(); }; + bool loaded(void) const { return _loaded; }; + + void store(const Type val) + { + if (_tmpval) + { + delete _tmpval; + _tmpval = 0; + } + + _tmpval = new Type(val); + + _loaded = true; + _inited = true; + } + + protected: + void unreference(void) + { + _inited = false; + _loaded = false; + + if (_tmpval) + { + delete _tmpval; + _tmpval = 0; + } + + if (_stored) + { + delete _stored; + _stored = 0; + } + }; + + protected: + void commit(Type def) + { + if (_tmpval) + { + { + delete _stored; + _stored = 0; + } + + _stored = _tmpval; + _tmpval = 0; + } + else + { + if (!_stored) + _stored = new Type(def); + } + + _loaded = true; + _inited = true; + }; + + void reset(void) + { + _loaded = false; + } + + protected: + const Type * _tmpval; + const Type * _stored; + bool _loaded; + bool _inited; + }; + + struct FunctionValue + { + friend class InnerFunctionType; + friend class Option; + + FunctionValue() + : _loaded(false), _inited(false) {}; + + virtual ~FunctionValue() {}; + + public: + virtual void operator()(const StringType & val) + { + throw Failure("undefined operator() for value"); + } + + const StringType & get(void) const + { + if (!_inited) + throw EmptyValue(); + + return _stored; + }; + + bool loaded(void) const { return _loaded; }; + + protected: + void commit(const StringType def) + { + if (_tmpval.empty()) + { + _stored = def; + } + else + { + _stored = _tmpval; + _tmpval.clear(); + } + + operator()(_stored); + + _loaded = true; + _inited = true; + }; + + void store(const StringType val) + { + _tmpval = val; + _loaded = true; + _inited = true; + } + + void reset(void) + { + _loaded = false; + } + + private: + StringType _tmpval; + StringType _stored; + bool _loaded; + bool _inited; + }; + + /* NOTE: we use a non-templated classe to place this functions inside the .cpp */ + struct Restriction + { + static void checkRange(const std::string & name, const SIntType value, const Range < SIntType > & range); + static void checkRange(const std::string & name, const UIntType value, const Range < UIntType > & range); + static void checkStringSet(const std::string & name, const StringType & value, const StringSet & allowed); + }; + + template < typename Type > + struct InnerOptionBase + { + typedef Variable < Value < Type > > MemberValue; + + InnerOptionBase(const std::string name, MemberValue option, const Type defvalue) + : _name(name), _option(option), _default(defvalue) {}; + + template < typename Object > + void reset(Object * const obj) const + { + _option(obj).reset(); + } + + template < typename Object > + const Type & get(const Object * const obj) const + { + return _option(obj).get(); + } + + template < typename Object > + bool loaded(const Object * const obj) const + { + return _option(obj).loaded(); + } + + protected: + const std::string _name; + MemberValue _option; + const Type _default; + }; + + template < > + struct InnerOption < SIntType >: public InnerOptionBase < SIntType > + { + typedef InnerOptionBase < SIntType > Super; + typedef Super::MemberValue MemberValue; + + InnerOption(const std::string name, MemberValue option, const SIntType defval, + const SIntType min, const SIntType max, const SIntType step) + : Super(name, option, defval), _range(min, max, step) {}; + + template < typename Object > + void commit(Object * const obj) const + { + Restriction::checkRange(_name, _default, _range); + _option(obj).commit(_default); + }; + + template < typename Object > + void store(Object * const obj, const SIntType stored) const + { + Restriction::checkRange(_name, _default, _range); + _option(obj).store(stored); + } + + using Super::reset; + using Super::get; + + const Range< SIntType > _range; + }; + + template < > + struct InnerOption < UIntType >: public InnerOptionBase < UIntType > + { + typedef InnerOptionBase < UIntType > Super; + typedef Super::MemberValue MemberValue; + + InnerOption(const std::string name, MemberValue option, const UIntType defval, + const UIntType min, const UIntType max, const UIntType step) + : Super(name, option, defval), _range(min, max, step) {}; + + template < typename Object > + void commit(Object * const obj) const + { + Restriction::checkRange(_name, _default, _range); + _option(obj).commit(_default); + }; + + template < typename Object > + void store(Object * const obj, const UIntType stored) const + { + Restriction::checkRange(_name, _default, _range); + _option(obj).store(stored); + } + + using Super::reset; + using Super::get; + + const Range< UIntType > _range; + }; + + template < > + struct InnerOption < BooleanType >: public InnerOptionBase < BooleanType > + { + typedef InnerOptionBase < BooleanType > Super; + typedef Super::MemberValue MemberValue; + + InnerOption(std::string name, MemberValue option, BooleanType defval) + : Super(name, option, defval) {}; + + template < typename Object > + void commit(Object * obj) const + { + _option(obj).commit(_default); + }; + + template < typename Object > + void store(Object * obj, BooleanType stored) const + { + _option(obj).store(stored); + } + + using Super::reset; + using Super::get; + }; + + template < > + struct InnerOption < StringType >: public InnerOptionBase < StringType > + { + typedef InnerOptionBase < StringType > Super; + typedef Super::MemberValue MemberValue; + + InnerOption(const std::string name, MemberValue option, const StringType defval, const StringSet & allowed) + : Super(name, option, defval), _allowed(allowed) {}; + + InnerOption(const std::string name, MemberValue option, const StringType defval) + : Super(name, option, defval) {}; + + template < typename Object > + void commit(Object * const obj) const + { + Restriction::checkStringSet(_name, _default, _allowed); + _option(obj).commit(_default); + }; + + template < typename Object > + void store(Object * const obj, const StringType stored) const + { + Restriction::checkStringSet(_name, _default, _allowed); + _option(obj).store(stored); + } + + using Super::reset; + using Super::get; + + const StringSet _allowed; + }; + + struct InnerFunctionType + { + typedef Variable < FunctionValue > MemberValue; + + InnerFunctionType(const std::string name, MemberValue option, const StringType defval, const StringSet & allowed) + : _name(name), _option(option), _default(defval), _allowed(allowed) {}; + + InnerFunctionType(const std::string name, MemberValue option, const StringType defval) + : _name(name), _option(option), _default(defval) {}; + + template < typename Object > + const StringType & get(const Object * const obj) const + { + return _option(obj).get(); + } + + template < typename Object > + bool loaded(const Object * const obj) const + { + return _option(obj).loaded(); + } + + template < typename Object > + void reset(Object * const obj) const + { + _option(obj).reset(); + } + + template < typename Object > + void commit(Object * const obj) const + { + Restriction::checkStringSet(_name, _default, _allowed); + _option(obj).commit(_default); + }; + + template < typename Object > + void store(Object * const obj, const StringType stored) const + { + Restriction::checkStringSet(_name, _default, _allowed); + _option(obj).store(stored); + } + + protected: + const std::string _name; + MemberValue _option; + const StringType _default; + + public: + const StringSet _allowed; + }; + + struct Option + { + typedef InnerOption < SIntType > InnerSIntType; + typedef InnerOption < UIntType > InnerUIntType; + typedef InnerOption < BooleanType > InnerBooleanType; + typedef InnerOption < StringType > InnerStringType; + + typedef Variable < Value < SIntType > > SIntMemberType; + typedef Variable < Value < UIntType > > UIntMemberType; + typedef Variable < Value < BooleanType > > BooleanMemberType; + typedef Variable < Value < StringType > > StringMemberType; + + typedef Variable < FunctionValue > FunctionMemberType; + + typedef Tagged::Union < InnerStringType, + Tagged::Union < InnerBooleanType, + Tagged::Union < InnerSIntType , + Tagged::Union < InnerUIntType, + Tagged::Union < InnerFunctionType > > > > > + InnerType; + + explicit Option(std::string, StringMemberType, const StringType, StringSet & allowed, bool listme = true); + explicit Option(std::string, StringMemberType, const StringType = "", bool listme = true); + explicit Option(std::string, SIntMemberType, const SIntType = 0, SIntType min = INT_MIN, SIntType max = INT_MAX, SIntType step = 1, bool listme = true); + explicit Option(std::string, UIntMemberType, const UIntType = 0, UIntType min = 0, UIntType max = UINT_MAX, UIntType step = 1, bool listme = true); + explicit Option(std::string, BooleanMemberType, const BooleanType = false, bool listme = true); + + explicit Option(std::string, FunctionMemberType, const StringType, StringSet & allowed, bool listme = true); + explicit Option(std::string, FunctionMemberType, const StringType = "", bool listme = true); + + Option(const Option & o); + + ~Option(void); + + template < typename Object > + void set(Object * object, std::string value) + { + try + { + /**/ if (_option.check()) _option.get().store(object, value); + else if (_option.check()) _option.get().store(object, value); + else if (_option.check()) _option.get().store(object, Strings::toboolean(value)); + else if (_option.check()) _option.get().store(object, Strings::tolong(value)); + else if (_option.check()) _option.get().store(object, Strings::toulong(value)); + else + { + throw Failure(STG(FMT("set() not implemented for type used in option '%s'") % _myname)); + } + } + catch (Strings::invalid_value & e) + { + throw Failure(STG(FMT("got invalid value '%s' for option '%s'") % value % _myname)); + } + catch (EmptyVariable & e) + { + throw Failure(STG(FMT("uninitialized variable while setting value '%s' for option '%s'") % value % _myname)); + } + } + + template < typename Object > + std::string get(const Object * const object) const + { + try + { + /**/ if (_option.check()) return _option.get().get(object); + else if (_option.check()) return _option.get().get(object); + else if (_option.check()) return (_option.get().get(object) ? "yes" : "no"); + else if (_option.check()) return STG(FMT("%d") % _option.get().get(object)); + else if (_option.check()) return STG(FMT("%u") % _option.get().get(object)); + else + { + throw Failure(STG(FMT("get() not implemented for type used in option '%s'") % _myname)); + } + } + catch (EmptyVariable & e) + { + throw Failure(STG(FMT("uninitialized variable while getting value for option '%s'") % _myname)); + } + } + + template < typename Object > + bool loaded(const Object * const object) const + { + try + { + /**/ if (_option.check()) return _option.get().loaded(object); + else if (_option.check()) return _option.get().loaded(object); + else if (_option.check()) return _option.get().loaded(object); + else if (_option.check()) return _option.get().loaded(object); + else if (_option.check()) return _option.get().loaded(object); + else + { + throw Failure(STG(FMT("loaded() not implemented for type used in option '%s'") % _myname)); + } + } + catch (EmptyVariable & e) + { + throw Failure(STG(FMT("uninitialized variable while checking load status for option '%s'") % _myname)); + } + } + + template < typename Object > + void reset(Object * const object) + { + try + { + /**/ if (_option.check()) _option.get().reset(object); + else if (_option.check()) _option.get().reset(object); + else if (_option.check()) _option.get().reset(object); + else if (_option.check()) _option.get().reset(object); + else if (_option.check()) _option.get().reset(object); + else + { + throw Failure(STG(FMT("reset() not implemented for type used in option '%s'") % _myname)); + } + } + catch (EmptyVariable & e) + { + throw Failure(STG(FMT("uninitialized variable while reseting status for option '%s'") % _myname)); + } + } + + template < typename Object > + void commit(Object * const object) + { + try + { + /**/ if (_option.check()) _option.get().commit(object); + else if (_option.check()) _option.get().commit(object); + else if (_option.check()) _option.get().commit(object); + else if (_option.check()) _option.get().commit(object); + else if (_option.check()) _option.get().commit(object); + else + { + throw Failure(STG(FMT("commit() not implemented for type used in option '%s'") % _myname)); + } + } + catch (EmptyVariable & e) + { + throw Failure(STG(FMT("uninitialized variable while commiting option '%s'") % _myname)); + } + } + + const std::string & name(void) const { return _myname; } + bool listme(void) const { return _listme; }; + + const char ** values(void); + + template < typename Object > + void copyFrom(const Object * const srcobj, Object * const dstobj, bool force = false) + { + if (loaded(dstobj) && !force) + return; + + if (loaded(srcobj)) + set(dstobj, get(srcobj)); + else + reset(dstobj); + } + + protected: + const std::string _myname; + InnerType _option; + const bool _listme; + const char ** _values; + }; + + struct Options + { + typedef std::vector < std::string > Messages; + + Options(); + ~Options(); + + typedef std::set < std::string > StringSet; + + typedef std::map < std::string, Option > OptionMap; + typedef std::pair < std::string, Option > OptionPair; + + typedef std::map < std::string, std::string > SynOptionMap; + typedef std::pair < std::string, std::string > SynOptionPair; + + bool add(Option option); + + /* only valid in "process" (for backwards compatibility config files) */ + bool synonym(std::string, std::string); + + template < typename Type > + void set(const std::string & name, Type value) + { + OptionMap::iterator iter = find_option(name); + + if (iter == _map.end()) + throw Failure(STG(FMT("unknown option: %s") % name)); + + iter->second.set(value); + } + + template < typename Object > + std::string get(const Object * const object, const std::string & name) + { + OptionMap::iterator iter = find_option(name); + + if (iter == _map.end()) + throw Failure(STG(FMT("unknown option: %s") % name)); + + return iter->second.get(object); + } + + template < typename Object > + void process(Object * const object, const char * name, const char * value) + { + OptionMap::iterator iter = find_option(name); + + if (iter == _map.end()) + throw Failure(STG(FMT("unknown option '%s'") % name)); + + iter->second.set(object, value); + } + + template < typename Object > + Messages commit(Object * const object) + { + Messages msgs; + + for (OptionMap::iterator i = _map.begin(); i != _map.end(); ++i) + { + try + { + i->second.commit(object); + } + catch (Failure & e) + { + msgs.push_back(e.what()); + } + } + + return msgs; + } + + template < typename Object > + void reset(Object * object) + { + for (OptionMap::iterator i = _map.begin(); i != _map.end(); ++i) + i->second.reset(object); + } + + template < typename Object > + bool loaded(Object * object, std::string name) + { + OptionMap::iterator iter = find_option(name); + + if (iter == _map.end()) + return false; + + return iter->second.loaded(object); + } + + bool exists(const std::string & name) + { + OptionMap::iterator iter = find_option(name); + + return (iter != _map.end()); + } + + StringSet options(void); + + const char ** values(const char *); /* option value */ + const char ** values(void); /* values from options */ + + template < typename Object > + void copyFrom(const std::string & name, const Object * const src_obj, Object * const dst_obj, bool force = false) + { + OptionMap::iterator iter = find_option(name); + + if (iter == _map.end()) + throw Failure(STG(FMT("unknown option '%s'") % name)); + + iter->second.copyFrom(src_obj, dst_obj, force); + } + + template < typename Object > + void copyFrom(Object * src_obj, Object * dst_obj, bool force = false) + { + for (OptionMap::iterator iter = _map.begin(); iter != _map.end(); ++iter) + iter->second.copyFrom(src_obj, dst_obj, force); + } + + protected: + OptionMap::iterator find_option(std::string); + + protected: + OptionMap _map; + SynOptionMap _syn_map; + + const char ** _values; + }; +}; + +#endif /* _CONFIG_OPTIONS_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/base/configurator/configfile.cpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/configfile.cpp new file mode 100644 index 0000000000..8a46587a59 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/configfile.cpp @@ -0,0 +1,241 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ +#include + +#include + +#if _MSC_VER >= 1400 +#undef close +#endif + +void Configfile::ignore(const std::string & str) +{ + _ignores.insert(str); +}; + +bool Configfile::select(Section **ptr, const std::string & str) +{ + /* default section == this! */ + *ptr = this; + + /* always success by default */ + return true; +}; + +bool Configfile::adjust(Section * section, const std::string & opt, const std::string & val) +{ + return section->load(opt, val); +}; + +bool Configfile::deserialize(std::ifstream & fd) +{ + Section * section = NULL; + + /* default selection! */ + if (!select(§ion)) + { + _errors.push_back("default selection has failed!"); + return false; + } + + size_t count = 0; + + while (fd.good()) + { + std::string str; + + /* read one line! */ + std::getline(fd, str); + + size_t lst = str.size() - 1; + + if (str.size() >= 1 && str[lst] == '\r') //cuida das quebras de linha do tipo \r\n + { + str.erase(lst,1); + --lst; + } + + /* empty line! */ + if (str.size() == 0) + continue; + + /* comment! */ + if (str[0] == '#') + continue; + + ++count; + + if (str[0] == '[' && str[lst] == ']') + { + str.erase(0,1); --lst; + str.erase(lst,1); --lst; + + if (!select(§ion, str)) + { + _errors.push_back(STG(FMT("erroneous section '%s'") % str)); + + /* ignore this section */ + section = NULL; + continue; + } + } + else + { + std::string::size_type pos = str.find('='); + + if (pos == std::string::npos) + { + _errors.push_back(STG(FMT("erroneous separator '%s'") % str)); + continue; + }; + + if (section == NULL) + { + _errors.push_back(STG(FMT("no section for option '%s'") % str)); + continue; + } + + std::string opt(str.substr(0,pos)); + std::string val(str.substr(pos+1)); + + if (_ignores.find(opt) != _ignores.end()) + continue; + + if (val == "@") val = ""; + + if (adjust(section, opt, val)) + continue; + + _errors.push_back(STG(FMT("option '%s' does " + "not exist or '%s' is not a valid value (at section '%s')") + % opt % val % section->name())); + } + } + + // retorna 'true' se arquivo tinha alguma coisa valida. + return (count != 0); +} + +bool Configfile::obtain() +{ + std::ifstream fd(_filename.c_str()); + + if (!fd.is_open()) + { + _errors.push_back(STG(FMT("unable to open file '%s': %s") + % _filename % strerror(errno))); + return false; + }; + + if (!deserialize(fd)) + { + fd.close(); + return false; + } + + fd.close(); + return true; +}; + +void Configfile::recurse(std::ofstream & fd, Section * section) +{ + typedef Section::SectionMap::const_iterator SectionIter; + typedef Section::OptionMap::const_iterator OptionIter; + + for (OptionIter i = section->option_begin(); i != section->option_end(); i++) + { + std::string res; + + if ((*i).second.store(res)) + { + if (res == "") res = "@"; + fd << (*i).first << "=" << res << std::endl; + } + } + + if (!section->recursive()) + return; + + for (SectionIter j = section->section_begin(); j != section->section_end(); j++) + recurse(fd, (*j).second); +} + +bool Configfile::serialize(std::ofstream & fd) +{ + recurse(fd, this); + return true; +} + +bool Configfile::provide() +{ + std::string tmp(_filename); + tmp += ".new"; + + std::ofstream fd(tmp.c_str()); + + if (!fd.good()) + { + _errors.push_back(STG(FMT("unable to open file '%s': %s") + % tmp % strerror(errno))); + return false; + } + + if (!serialize(fd)) + { + fd.close(); + return false; + } + + fd.close(); + + if (rename(tmp.c_str(), _filename.c_str()) != 0) + { + _errors.push_back(STG(FMT("unable to replace config file '%s': %s") + % _filename % strerror(errno))); + return false; + } + + return true; +} + +#if _MSC_VER >= 1400 +#define close _close +#endif diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/configfile.hpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/configfile.hpp similarity index 65% rename from src/mod/endpoints/mod_khomp/commons/configurator/configfile.hpp rename to src/mod/endpoints/mod_khomp/commons/base/configurator/configfile.hpp index 61f42469af..e725c09964 100644 --- a/src/mod/endpoints/mod_khomp/commons/configurator/configfile.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/configfile.hpp @@ -1,7 +1,7 @@ -/* +/* KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & Com. - + Copyright (C) 2007-2009 Khomp Ind. & 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/ @@ -23,20 +23,20 @@ The LGPL header follows below: - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include @@ -53,38 +53,38 @@ struct Configfile: public Section { - typedef std::list < std::string > ErrorVector; - typedef std::set < std::string > NameSet; + typedef std::list < std::string > ErrorVector; + typedef std::set < std::string > NameSet; - Configfile(std::string name, std::string desc) - : Section(name, desc), _good(false) {}; + Configfile(const std::string & name, const std::string & desc) + : Section(name, desc), _good(false) {}; - virtual ~Configfile() {}; + virtual ~Configfile() {}; - bool good() { return _good; }; - std::string & filename() { return _filename; }; + bool good() const { return _good; }; + const std::string & filename() const { return _filename; }; - ErrorVector & errors() { return _errors; }; + const ErrorVector & errors() const { return _errors; }; - void ignore(std::string); + void ignore(const std::string &); - virtual bool obtain(); - virtual bool provide(); + virtual bool obtain(); + virtual bool provide(); protected: - virtual bool select(Section **, std::string str = ""); - virtual bool adjust(Section *, std::string & opt, std::string & val); + virtual bool select(Section **, const std::string & str = ""); + virtual bool adjust(Section *, const std::string & opt, const std::string & val); - virtual bool deserialize(std::ifstream &); - virtual bool serialize(std::ofstream &); + virtual bool deserialize(std::ifstream &); + virtual bool serialize(std::ofstream &); - void recurse(std::ofstream &, Section *); + void recurse(std::ofstream &, Section *); protected: - bool _good; - ErrorVector _errors; - NameSet _ignores; - std::string _filename; + bool _good; + ErrorVector _errors; + NameSet _ignores; + std::string _filename; }; #endif /* _CONFIG_CONFIGFILE_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/base/configurator/option.cpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/option.cpp new file mode 100644 index 0000000000..6de9212bf3 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/option.cpp @@ -0,0 +1,186 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include + +bool Option::equals(const std::string & value) const +{ + switch (_restriction.numeral()) + { + case Restriction::N_UNIQUE: + { + Restriction::Value my_value; + + if (!_restriction.get(Restriction::F_USER, my_value)) + return false; + + return (my_value == value); + } + case Restriction::N_MULTIPLE: + { + Restriction::Vector my_values; + + if (!_restriction.get(Restriction::F_USER, my_values)) + return false; + + for (Restriction::Vector::iterator i = my_values.begin(); i != my_values.end(); i++) + { + if ((*i) == value) + return true; + } + + return false; + } + } + + return false; +} + +bool Option::load(const std::string & value) +{ + bool ret = _restriction.set( (const Restriction::Format)Restriction::F_FILE, value); + + if (ret) _modified = false; + + return ret; +} + +bool Option::change(const std::string & value) +{ + bool ret = _restriction.set(Restriction::F_FILE, value); + + if (ret) _modified = true; + + return ret; +} + +bool Option::store(std::string & value) const +{ + switch (_restriction.numeral()) + { + case Restriction::N_UNIQUE: + return _restriction.get(Restriction::F_FILE, value); + + case Restriction::N_MULTIPLE: + { + Restriction::Vector values; + + if (!_restriction.get(Restriction::F_FILE, values)) + return false; + + Strings::Merger strs; + + for (Restriction::Vector::iterator i = values.begin(); i != values.end(); i++) + strs.add(*i); + + value = strs.merge(","); + + return true; + } + + default: + return false; + } +} + +/* +Option::Flags Option::set(const char * value) +{ + std::string str_value(value); + return set(str_value); +} +*/ + +Option::Flags Option::set(const Restriction::Value & value) +{ + Restriction::Value last_value, curr_value; + Flags flags; + + bool ret1 = _restriction.get(Restriction::F_USER, last_value); + + if (!_restriction.set(Restriction::F_USER, value)) + return flags; + + flags[F_ADJUSTED] = true; + + bool ret2 = _restriction.get(Restriction::F_USER, curr_value); + + if (!ret1 || (ret2 && (last_value != curr_value))) + { + flags[F_MODIFIED] = true; + _modified = true; + } + + return flags; +} + +Option::Flags Option::set(const Restriction::Vector & values) +{ + Restriction::Vector last_values, curr_values; + Flags flags; + + bool ret1 = _restriction.get(Restriction::F_USER, last_values); + + if (!_restriction.set(Restriction::F_USER, values)) + return flags; + + flags[F_ADJUSTED] = true; + + bool ret2 = _restriction.get(Restriction::F_USER, curr_values); + + if (!ret1 || (ret2 && (last_values != curr_values))) + { + flags[F_MODIFIED] = true; + _modified = true; + } + + return flags; +} + +bool Option::get(Restriction::Value & value) const +{ + return _restriction.get(Restriction::F_USER, value); +} + +bool Option::get(Restriction::Vector & values) const +{ + return _restriction.get(Restriction::F_USER, values); +} diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/option.hpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/option.hpp similarity index 52% rename from src/mod/endpoints/mod_khomp/commons/configurator/option.hpp rename to src/mod/endpoints/mod_khomp/commons/base/configurator/option.hpp index 8aa103a0cc..e46ab75902 100644 --- a/src/mod/endpoints/mod_khomp/commons/configurator/option.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/option.hpp @@ -1,7 +1,7 @@ -/* +/* KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & Com. - + Copyright (C) 2007-2009 Khomp Ind. & 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/ @@ -23,20 +23,20 @@ The LGPL header follows below: - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -56,67 +57,72 @@ struct Option { enum FlagTypes { - F_MODIFIED = 0x0, /* if option was modified */ - F_ADJUSTED = 0x1, /* if option was correctly formated */ + F_MODIFIED = 0x0, /* if option was modified */ + F_ADJUSTED = 0x1, /* if option was correctly formated */ }; - struct Flags: public std::vector - { - Flags(): std::vector(2) {}; - }; + struct Flags: public std::vector + { + Flags(): std::vector(2) {}; + }; - typedef Restriction::Value Value; - typedef Restriction::Vector Vector; + typedef Restriction::Value Value; + typedef Restriction::Vector Vector; /* exception */ - struct InvalidDefaultValue + struct InvalidDefaultValue: public std::runtime_error { - InvalidDefaultValue(std::string name, std::string value) - : _name(name), _value(value) {}; + InvalidDefaultValue(const std::string & name, const std::string & value) + : std::runtime_error(STG(FMT("invalid default value '%s' for option '%s'") % value % name)), + _name(name), _value(value) + {}; - std::string & name() { return _name; }; - std::string & value() { return _value; }; + ~InvalidDefaultValue() throw () + {}; + + const std::string & name() const { return _name; }; + const std::string & value() const { return _value; }; protected: - std::string _name; - std::string _value; + const std::string _name; + const std::string _value; }; - Option(std::string name, std::string desc, std::string defvalue, Restriction restriction) - : _name(name), _desc(desc), _restriction(restriction), _modified(true) - { - std::string value(defvalue); + Option(const std::string & name, const std::string & desc, const std::string & defvalue, const Restriction & restriction) + : _name(name), _description(desc), _restriction(restriction), _modified(true) + { +// std::string value(defvalue); - if (!(set(value)[F_ADJUSTED])) + if (!(set(defvalue)[F_ADJUSTED])) throw InvalidDefaultValue(name, defvalue); - } + } - const std::string & name() { return _name; }; - const std::string & description() { return _desc; }; + const std::string & name() const { return _name; }; + const std::string & description() const { return _description; }; - Restriction & restriction() { return _restriction; }; - bool modified() { return _modified; }; + const Restriction & restriction() const { return _restriction; }; + bool modified() const { return _modified; }; public: - bool load(std::string &); - bool change(std::string &); - bool store(std::string &); + bool load(const std::string &); + bool change(const std::string &); + bool store(std::string &) const; - Flags set(const char *); - Flags set(Value &); - Flags set(Vector &); +// Flags set(const char *); + Flags set(const Value &); + Flags set(const Vector &); - bool get(Value &); - bool get(Vector &); + bool get(Value &) const; + bool get(Vector &) const; - bool equals(std::string &); + bool equals(const std::string &) const; protected: - std::string _name; - std::string _desc; + const std::string _name; + const std::string _description; - Restriction _restriction; - bool _modified; + Restriction _restriction; + bool _modified; }; #endif /* _CONFIG_OPTION_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.cpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.cpp new file mode 100644 index 0000000000..52be1ea881 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.cpp @@ -0,0 +1,358 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include +#include + +#include +#include + +#include + +/* internal helper! */ +bool Restriction::equalNumber(const double a, const double b) +{ + char tmp1[64]; + char tmp2[64]; + + snprintf(tmp1, sizeof(tmp1), "%.3f", a); + snprintf(tmp2, sizeof(tmp2), "%.3f", b); + + if (strncmp(tmp1, tmp2, sizeof(tmp1))) + return false; + + return true; +} + +/* process value to our internal representation */ + +bool Restriction::process(Restriction::Format fmt, + const Restriction::Value & value, Restriction::Value & final) const +{ + switch (_bounds) + { + case B_RANGE: + { + if (_kind != K_NUMBER) + return false; + + std::string tmpvalue; + + Restriction::Value::const_iterator itr = value.begin(); + Restriction::Value::const_iterator end = value.end(); + + tmpvalue.reserve(value.size()); + + // f*cking dot/comma notation! + for (; itr != end; ++itr) + tmpvalue += ((*itr) != ',' ? (*itr) : '.'); + + try + { + double newvalue = Strings::todouble(tmpvalue); + + if (newvalue < _init && newvalue > _fini) + return false; + + double res = (newvalue - _init) / _step; + + if (!Restriction::equalNumber(res, rint(res))) + return false; + + final = value; + return true; + } + catch (...) + { + return false; + } + } + + case B_LIST: + for (List::const_iterator i = _list.begin(); i != _list.end(); i++) + { + const Value & tmp = (*i); + + if (tmp == value) + { + final = value; + return true; + } + } + return false; + + case B_MAPS: + switch (fmt) + { + case F_USER: + { + Map::const_iterator i = _map_from_usr.find(value); + + if (i == _map_from_usr.end()) + return false; + + const Value & tmp = (*i).second; + + final = tmp; + return true; + } + + case F_FILE: + { + Map::const_iterator i = _map_from_cfg.find(value); + + if (i == _map_from_cfg.end()) + return false; + + final = value; + return true; + } + + default: + break; + } + return false; + + case B_FREE: + final = value; + return true; + + default: + break; + } + + return false; +} + +/* unprocess the value (outputs the external representation) */ + +bool Restriction::unprocess(Restriction::Format fmt, + const Restriction::Value & value, Restriction::Value & final) const +{ + switch (_bounds) + { + case B_MAPS: + + switch (fmt) + { + case F_USER: + { + Map::const_iterator i = _map_from_cfg.find(value); + + if (i == _map_from_cfg.end()) + return false; + + final = (*i).second; + return true; + } + default: + break; + } + + default: + final = value; + return true; + } +} + +/***************************** *****************************/ + +bool Restriction::get(Restriction::Format fmt, Restriction::Value & value) const +{ + if (_numeral != N_UNIQUE) + return false; + + if (!unprocess(fmt, _value._unique, value)) + return false; + + return true; +} + +bool Restriction::get(Restriction::Format fmt, Restriction::Vector & values) const +{ + if (_numeral != N_MULTIPLE) + return false; + + const List & my_values = _value._multiple; + + for (List::const_iterator i = my_values.begin(); i != my_values.end(); i++) + { + const Value & value = (*i); + + Value final; + + if (!unprocess(fmt, value, final)) + return false; + + values.push_back(final); + }; + + return true; +} + +/***************************** *****************************/ + +bool Restriction::set(Restriction::Format fmt, const Restriction::Value & value) +{ + switch (_numeral) + { + case N_UNIQUE: + { + Value final; + + if (!constThis().process(fmt, value, final)) + return false; + + _value._unique = final; + return true; + } + + case N_MULTIPLE: + { + if (value == "@" || value == "#" || value == "") + { + _value._multiple.clear(); + return true; + } + + Strings::vector_type values; + Strings::tokenize(value, values, ","); + + return set(fmt, values); + } + + default: + return false; + } +} + +bool Restriction::set(Restriction::Format fmt, const Restriction::Vector & values) +{ + if (_numeral != N_MULTIPLE) + return false; + + if (values.empty()) + { + _value._multiple.clear(); + } + else + { + /* list needed to store temporary values */ + List finals; + + for (Vector::const_iterator i = values.begin(); i != values.end(); i++) + { + const Value & value = (*i); + + Value final; + + if (!constThis().process(fmt, value, final)) + return false; + + finals.push_back(final); + } + + List & lst = _value._multiple; + + /* need to clear values set before */ + lst.clear(); + + for (List::iterator i = finals.begin(); i != finals.end(); i++) + { + Value value = (*i); + lst.push_back(value); + } + }; + + return true; +} + +/***************************** *****************************/ + +void Restriction::allowed(Restriction::Vector & vals) const +{ + switch (_bounds) + { + case B_FREE: + return; + + case B_LIST: + for (List::const_iterator i = _list.begin(); i != _list.end(); i++) + vals.push_back(*i); + break; + + case B_MAPS: + for (Map::const_iterator i = _map_from_usr.begin(); i != _map_from_usr.end(); i++) + vals.push_back(i->first); + break; + + case B_RANGE: + { + if (_kind != K_NUMBER) + return; + + // is there any fraction? + bool has_fraction = + (!Restriction::equalNumber(_init, rint(_init))) || + (!Restriction::equalNumber(_fini, rint(_fini))) || + (!Restriction::equalNumber(_step, rint(_step))); + + const char * format = (has_fraction ? "%.2f" : "%02.0f"); + + for (double i = _init; i <= _fini; i += _step) + { + char tmp[32]; + snprintf(tmp, sizeof(tmp), format, i); + vals.push_back(std::string(tmp)); + } + break; + } + + default: + break; + } +} + +void Restriction::init_class() +{ + _value._unique.clear(); + _value._multiple.clear(); +} diff --git a/src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.hpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.hpp new file mode 100644 index 0000000000..576560dbd4 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/restriction.hpp @@ -0,0 +1,269 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include + +#include +#include +#include +#include + +#include + +#ifndef _CONFIG_RESTRICTION_HPP_ +#define _CONFIG_RESTRICTION_HPP_ + +struct Restriction: public ConstThis < Restriction > +{ + /* generic types */ + + // TODO: change this type name for something different + // to avoid conflicting with "format.hpp". + enum Format + { + F_USER, + F_FILE + }; + + enum Kind + { + K_STRING, + K_NUMBER // = K_INTEGER // compatibility + }; + + enum Bounds + { + B_FREE, + B_RANGE, + B_LIST, + B_MAPS + }; + + enum Numeral + { + N_UNIQUE, + N_MULTIPLE + }; + + typedef std::string Value; + + /* types used for data input */ + struct Pair + { + const char *pretty; + const char *value; + }; + + typedef std::pair < Value, Value > PairMap; + typedef std::list < PairMap > ListMap; + + /* types used internally */ + typedef std::map < Value, Value > Map; + typedef std::vector < Value > Vector; + + typedef std::list < Value > List; + typedef std::pair < Value, Value > MapPair; + + struct Generic + { + Value _unique; + List _multiple; + }; + + Restriction(Kind kind, Numeral num) + : _kind(kind), _bounds(B_FREE), _numeral(num), _unit(""), + _init(-1), _fini(-1), _step(-1) + { + init_class(); + } + + Restriction(Kind kind, Numeral num, + double init, double fini, double step = 1) + : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(""), + _init(init), _fini(fini), _step(step) + { + init_class(); + } + + Restriction(Kind kind, Numeral num, + const char *unit, double init, double fini, double step = 1.0) + : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), + _init(init), _fini(fini), _step(step) + { + init_class(); + } + + Restriction(Kind kind, Numeral num, + std::string unit, double init, double fini, double step = 1.0) + : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), + _init(init), _fini(fini), _step(step) + { + init_class(); + } + + Restriction(Kind kind, Numeral num, + const char *first, ...) + : _kind(kind), _bounds(B_LIST), _numeral(num), _unit(""), + _init(-1), _fini(-1), _step(-1) + { + _list.push_back(std::string(first)); + + va_list ap; + va_start(ap, first); + + while (true) + { + const char *arg = va_arg(ap, const char *); + + if (arg == NULL) break; + + _list.push_back(std::string(arg)); + } + + init_class(); + } + + Restriction(Kind kind, const char *unit, Numeral num, + const char *first, ...) + : _kind(kind), _bounds(B_LIST), _numeral(num), _unit(unit), + _init(-1), _fini(-1), _step(-1) + { + _list.push_back(std::string(first)); + + va_list ap; + va_start(ap, first); + + while (true) + { + const char *arg = va_arg(ap, const char *); + + if (arg == NULL) break; + + _list.push_back(std::string(arg)); + } + + init_class(); + } + + Restriction(Kind kind, Numeral num, + const struct Pair first, ...) + : _kind(kind), _bounds(B_MAPS), _numeral(num), _unit(""), + _init(-1), _fini(-1), _step(-1) + { + _map_from_usr.insert(MapPair(Value(first.pretty), Value(first.value))); + _map_from_cfg.insert(MapPair(Value(first.value), Value(first.pretty))); + + va_list ap; + va_start(ap, first); + + while (true) + { + Pair arg = va_arg(ap, Pair); + + if (arg.pretty == NULL) break; + + _map_from_usr.insert(MapPair(Value(arg.pretty), Value(arg.value))); + _map_from_cfg.insert(MapPair(Value(arg.value), Value(arg.pretty))); + } + + init_class(); + } + + Restriction(Kind kind, Numeral num, List list) + : _kind(kind), _bounds(B_LIST), _numeral(num), _unit(""), + _init(-1), _fini(-1), _step(-1), _list(list) + { + init_class(); + } + + Restriction(Kind kind, Numeral num, ListMap map) + : _kind(kind), _bounds(B_MAPS), _numeral(num), _unit(""), + _init(-1), _fini(-1), _step(-1) + { + for (ListMap::iterator i = map.begin(); i != map.end(); i++) + { + _map_from_usr.insert(MapPair(Value((*i).first), Value((*i).second))); + _map_from_cfg.insert(MapPair(Value((*i).second), Value((*i).first))); + } + + init_class(); + } + + const Kind kind() const { return _kind; }; + const Bounds bounds() const { return _bounds; }; + const Numeral numeral() const { return _numeral; }; + + const std::string & unit() const { return _unit; }; + + bool set(Format, const Vector &); + bool set(Format, const Value &); + + bool get(Format, Vector &) const; + bool get(Format, Value &) const; + + void allowed(Vector &) const; + + private: + bool process(const Format, const Value &, Value &) const; + bool unprocess(const Format, const Value &, Value &) const; + + void init_class(); + + static bool equalNumber(const double, const double); + + protected: + const Kind _kind; + const Bounds _bounds; + const Numeral _numeral; + + Value _unit; + + const double _init, _fini, _step; + + Map _map_from_usr, + _map_from_cfg; + + List _list; + + Generic _value; +}; + +#endif /* _CONFIG_RESTRICTION_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/section.cpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/section.cpp similarity index 59% rename from src/mod/endpoints/mod_khomp/commons/configurator/section.cpp rename to src/mod/endpoints/mod_khomp/commons/base/configurator/section.cpp index 5d26858054..9ed775b044 100644 --- a/src/mod/endpoints/mod_khomp/commons/configurator/section.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/section.cpp @@ -1,7 +1,7 @@ -/* +/* KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & Com. - + Copyright (C) 2007-2009 Khomp Ind. & 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/ @@ -23,108 +23,114 @@ The LGPL header follows below: - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include -void Section::options(Section::OptionVector & vec) +void Section::options(Section::OptionVector & vec) const { - for (OptionMap::iterator it = _options.begin(); it != _options.end();) - { - vec.push_back(&((*it).second)); - ++it; - } + for (OptionMap::const_iterator it = _options.begin(); it != _options.end();) + { + vec.push_back(const_cast< Option * >(&(it->second))); + ++it; + } } -void Section::sections(Section::SectionVector & vec) +void Section::sections(Section::SectionVector & vec) const { - for (SectionMap::iterator it = _sections.begin(); it != _sections.end();) - { - vec.push_back((*it).second); - ++it; - } + for (SectionMap::const_iterator it = _sections.begin(); it != _sections.end();) + { + vec.push_back(const_cast< Section * >(it->second)); + ++it; + } } /*********/ -Option * Section::option_find(std::string & str, bool recurse) +Option * Section::option_find(const std::string & str, bool recurse) const { - OptionMap::iterator i = _options.find(str); + OptionMap::const_iterator i = _options.find(str); - if (i == _options.end()) + if (i == _options.end()) { if (!recurse) - throw not_found(); + throw OptionNotFound(str, _name); +// throw not_found(); - for (SectionMap::iterator i = _sections.begin(); i != _sections.end(); i++) + for (SectionMap::const_iterator i = _sections.begin(); i != _sections.end(); i++) { try { return i->second->option_find(str, recurse); } - catch (not_found & e) + catch (NotFound & e) { /* keep looping! */ }; } - throw not_found(); +// throw not_found(); + throw OptionNotFound(str, _name); } - return &((*i).second); + return const_cast< Option * >(&(i->second)); } +/* Option * Section::option_find(const char * str, bool recurse) { - std::string sstr(str); - return option_find(sstr, recurse); + std::string sstr(str); + return option_find(sstr, recurse); } +*/ /*********/ -Section * Section::section_find(std::string & str, bool recurse) +Section * Section::section_find(const std::string & str, bool recurse) const { - SectionMap::iterator i = _sections.find(str); + SectionMap::const_iterator i = _sections.find(str); - if (i == _sections.end()) + if (i == _sections.end()) { if (!recurse) - throw not_found(); + throw SectionNotFound(str, _name); - for (SectionMap::iterator i = _sections.begin(); i != _sections.end(); i++) + for (SectionMap::const_iterator i = _sections.begin(); i != _sections.end(); i++) { try { return i->second->section_find(str, recurse); } - catch (not_found & e) + catch (NotFound & e) { /* keep looping! */ }; } - throw not_found(); + throw SectionNotFound(str, _name); } - return ((*i).second); + return const_cast< Section * >(i->second); } +/* Section * Section::section_find(const char * str, bool recurse) { - std::string sstr(str); - return section_find(sstr, recurse); + std::string sstr(str); + return section_find(sstr, recurse); } +*/ diff --git a/src/mod/endpoints/mod_khomp/commons/base/configurator/section.hpp b/src/mod/endpoints/mod_khomp/commons/base/configurator/section.hpp new file mode 100644 index 0000000000..d5a8c95688 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/configurator/section.hpp @@ -0,0 +1,260 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef _CONFIG_SECTION_HPP_ +#define _CONFIG_SECTION_HPP_ + +#include +#include +#include +#include +#include + +#include + +#include + +struct Section +{ + typedef std::map < std::string, Option > OptionMap; + typedef std::vector< Option * > OptionVector; + + typedef std::map < std::string, Section * > SectionMap; + typedef std::vector < Section * > SectionVector; + + struct NotFound: public std::runtime_error + { + NotFound(const std::string & type, const std::string & name, const std::string & me) + : std::runtime_error(STG(FMT("%s '%s' not found on section '%s'") % type % name % me)) {}; + }; + + struct OptionNotFound: public NotFound + { + OptionNotFound(const std::string & name, const std::string & me) + : NotFound("option", name, me) {}; + }; + + struct SectionNotFound: public NotFound + { + SectionNotFound(const std::string & name, const std::string & me) + : NotFound("section", name, me) {}; + }; + + typedef NotFound not_found; /* backward compatibility */ + +// protected: + Section(const std::string & name, const std::string & desc, bool recursive = true) + : _name(name), _description(desc), _recursive(recursive) {}; + + void add(const Option & o) + { + _options.insert(std::pair(o.name(), o)); + }; + + void del(const std::string & name) + { + _options.erase(name); + }; + + void add(Section * s) + { + _sections.insert(std::pair< std::string, Section * >(s->name(), s)); + }; + + public: + const std::string & name() const { return _name; }; + const std::string & description() const { return _description; }; + + const bool recursive() const { return _recursive; }; + + OptionMap::const_iterator option_begin() const { return _options.begin(); }; + OptionMap::const_iterator option_end() const { return _options.end(); }; + + SectionMap::const_iterator section_begin() const { return _sections.begin(); }; + SectionMap::const_iterator section_end() const { return _sections.end(); }; + + /**/ + +// Option * option_find(const char *, bool recurse = false) const; +// Section * section_find(const char *, bool recurse = false) const; + + Option * option_find(const std::string &, bool recurse = false) const; + Section * section_find(const std::string &, bool recurse = false) const; + + /**/ + + void options(OptionVector &) const; + void sections(SectionVector &) const; + + /**/ + + template < typename T, typename F > + bool search_and_apply(const std::string & key, T & value, F f) + { + OptionMap::iterator i = _options.find(key); + + if (i != _options.end()) + return f(i->second); + + if (!_recursive) + return false; + + return (find_if(_sections.begin(), _sections.end(), f) != _sections.end()); + } + + private: + struct ConstKeyValue + { + ConstKeyValue(const std::string & k, const std::string &v) + : _k(k), _v(v) {}; + + const std::string & _k; + const std::string & _v; + }; + + struct KeyValue + { + KeyValue(const std::string & k, std::string &v) + : _k(k), _v(v) {}; + + const std::string & _k; + std::string & _v; + }; + + struct load_section: protected ConstKeyValue + { + load_section(const std::string & k, const std::string & v): ConstKeyValue(k,v) {}; + + bool operator()(Option & o) { return o.load(_v); }; + bool operator()(SectionMap::value_type & v) { return v.second->load(_k,_v); }; + }; + + struct change_section: protected ConstKeyValue + { + change_section(const std::string & k, const std::string & v): ConstKeyValue(k,v) {}; + + bool operator()(Option & o) { return o.change(_v); }; + bool operator()(SectionMap::value_type & v) { return v.second->change(_k,_v); }; + }; + + struct store_section: protected KeyValue + { + store_section(const std::string & k, std::string & v): KeyValue(k,v) {}; + + bool operator()(Option & o) { return o.store(_v); }; + bool operator()(SectionMap::value_type & v) { return v.second->store(_k,_v); }; + }; + + struct set_section: protected ConstKeyValue + { + set_section(const std::string & k, const std::string & v): ConstKeyValue(k,v) {}; + + bool operator()(Option & o) { return (o.set(_v))[Option::F_ADJUSTED]; }; + bool operator()(SectionMap::value_type & v) { return v.second->set(_k,_v); }; + }; + + struct get_section: protected KeyValue + { + get_section(const std::string & k, std::string & v): KeyValue(k,v) {}; + + bool operator()(Option & o) { return o.get(_v); }; + bool operator()(SectionMap::value_type & v) { return v.second->get(_k,_v); }; + }; + + struct modified_section + { + bool operator()(const OptionMap::value_type & v) { return v.second.modified(); }; + bool operator()(const SectionMap::value_type & v) { return v.second->modified(); }; + }; + + public: +/* + bool load(const char * key, const std::string value) + { + std::string skey(key); + return search_and_apply(skey, value, load_section(skey, value)); + } +*/ + bool load(const std::string & key, const std::string & value) + { + return search_and_apply(key, value, load_section(key, value)); + } + + bool change(const std::string & key, const std::string & value) + { + return search_and_apply(key, value, change_section(key, value)); + } + + bool store(const std::string & key, std::string & value) + { + return search_and_apply(key, value, store_section(key, value)); + } + + bool set(const std::string & key, const std::string & value) + { + return search_and_apply(key, value, set_section(key, value)); + } + + bool get(const std::string & key, std::string & value) + { + return search_and_apply(key, value, get_section(key, value)); + } + + bool modified() const + { + return ((find_if(_options.begin(), _options.end(), modified_section()) != _options.end()) || + (find_if(_sections.begin(), _sections.end(), modified_section()) != _sections.end())); + } + + private: + Section(): _name(""), _description(""), _recursive(false) {}; + + protected: + const std::string _name; + const std::string _description; + + OptionMap _options; + SectionMap _sections; + + const bool _recursive; +}; + +#endif /* _CONFIG_SECTION_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/base/const_this.hpp b/src/mod/endpoints/mod_khomp/commons/base/const_this.hpp new file mode 100644 index 0000000000..48e3c1e32f --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/const_this.hpp @@ -0,0 +1,15 @@ + +#ifndef _CONST_THIS_H_ +#define _CONST_THIS_H_ + +template < typename T > +struct ConstThis +{ + T const & constThis() const + { + // TODO: will this return the right reference? + return static_cast(*this); + } +}; + +#endif /* _CONST_THIS_H_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/flagger.hpp b/src/mod/endpoints/mod_khomp/commons/base/flagger.hpp similarity index 100% rename from src/mod/endpoints/mod_khomp/commons/flagger.hpp rename to src/mod/endpoints/mod_khomp/commons/base/flagger.hpp diff --git a/src/mod/endpoints/mod_khomp/commons/format.cpp b/src/mod/endpoints/mod_khomp/commons/base/format.cpp similarity index 89% rename from src/mod/endpoints/mod_khomp/commons/format.cpp rename to src/mod/endpoints/mod_khomp/commons/base/format.cpp index 20f79204ec..74223cc406 100644 --- a/src/mod/endpoints/mod_khomp/commons/format.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/format.cpp @@ -42,27 +42,7 @@ #include "format.hpp" //#include -Format::Format(const char * format_string, bool raise_exception) -: _format(format_string), _valid(true), _raise(raise_exception) -{ - initialize(format_string); -} - -/* -Format::Format(std::string & format_string, bool raise_exception) -: _format(NULL), _valid(true), _raise(raise_exception) -{ - initialize(format_string.c_str()); -} -*/ - -Format::Format(std::string format_string, bool raise_exception) -: _format(format_string), _valid(true), _raise(raise_exception) -{ - initialize(format_string.c_str()); -} - -void Format::initialize(const char * format_string) +void FormatTraits::initialize(const char * format_string) { std::string txt; @@ -82,7 +62,6 @@ void Format::initialize(const char * format_string) if (*ptr2 == '%') { txt += *ptr; - ptr += 2; continue; } @@ -238,36 +217,20 @@ void Format::initialize(const char * format_string) push_argument(txt, T_LITERAL); } -void Format::mark_invalid(std::string & msg) +void FormatTraits::push_argument(std::string & data, FormatTraits::Type type) { - if (_valid) - { - _valid = false; +// std::cerr << "pushing type (" << type << ") with format (" << data << ")" << std::endl; - std::string finalmsg; - - finalmsg += "** INVALID FORMAT: "; - finalmsg += msg; - finalmsg += " **"; - - _result = finalmsg; - } + _args.push(Argument(data, type)); + data.clear(); } -void Format::raise_check(void) +void FormatTraits::pop_argument(void) { - if (!_valid && _raise) - throw InvalidFormat(_result); + _args.pop(); } -bool Format::validity_check(void) -{ - raise_check(); - - return _valid; -} - -const Format::Argument * Format::next_argument(void) +const FormatTraits::Argument * FormatTraits::next_argument(void) { // std::cerr << "size: " << _args.size() << std::endl; @@ -294,38 +257,81 @@ const Format::Argument * Format::next_argument(void) } } -void Format::pop_argument(void) +/******************************************************************/ + +#if 0 +Format::Format(const char * format_string, bool raise_exception) +: _format(format_string), _valid(true), _raise(raise_exception) { - _args.pop(); + FormatTraits::initialize(format_string); } -void Format::push_argument(std::string & data, Format::Type type) +Format::Format(std::string format_string, bool raise_exception) +: _format(format_string), _valid(true), _raise(raise_exception) { -// std::cerr << "pushing type (" << type << ") with format (" << data << ")" << std::endl; + FormatTraits::initialize(format_string.c_str()); +} - _args.push(Argument(data, type)); - data.clear(); +/* +Format::Format(std::string & format_string, bool raise_exception) +: _format(NULL), _valid(true), _raise(raise_exception) +{ + initialize(format_string.c_str()); +} +*/ + +void Format::mark_invalid(std::string & msg) +{ + if (_valid) + { + _valid = false; + + _result = "** INVALID FORMAT: "; + _result += msg; + _result += " **"; + } +} + +void Format::raise(void) const +{ + if (!_valid) + { + // call specialized class + FormatException::raise(_result); + } +} + +bool Format::valid(void) const +{ +// raise(); + return _valid; } std::string Format::str() { - if (!validity_check()) + if (!valid()) return _result; - if (next_argument() == NULL) +// try +// { + if (next_argument() != NULL) + { + std::string msg; + + msg += "too few arguments passed for format '"; + msg += _format; + msg += "' ("; + msg += _format; + msg += ")"; + + mark_invalid(msg); + return _result; - - std::string msg; - - msg += "too few arguments passed for format '"; - msg += _format; - msg += "' ("; - msg += _format; - msg += ")"; - - mark_invalid(msg); - - return _result; + } +// catch (NoArgumentLeft e) +// { +// return _result; +// } } - +#endif diff --git a/src/mod/endpoints/mod_khomp/commons/format.hpp b/src/mod/endpoints/mod_khomp/commons/base/format.hpp similarity index 81% rename from src/mod/endpoints/mod_khomp/commons/format.hpp rename to src/mod/endpoints/mod_khomp/commons/base/format.hpp index b1ebe74396..0469e4fdf9 100644 --- a/src/mod/endpoints/mod_khomp/commons/format.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/format.hpp @@ -52,37 +52,35 @@ #include #ifdef WIN32 // WINDOWS -#include +# include #endif - -/* macros used for shortening lines and making the code clearer */ -#define STG(x) (x).str() -#define FMT(x) Format(x) - -struct Format +struct InvalidFormat { - static const unsigned int strings_base_length = 64; - static const unsigned int generic_base_length = 64; + InvalidFormat(std::string _msg) : msg(_msg) {} + const std::string msg; +}; - struct InvalidFormat +template < bool E > +struct FormatException +{ + void raise(const std::string & msg) const { - InvalidFormat(std::string msg) : _msg(msg) {} - - std::string _msg; + /* DO NOTHING */ }; +}; - explicit Format(const char * format_string, bool raise_exception = false); - explicit Format(std::string format_string, bool raise_exception = false); - - void initialize(const char *); - - std::string str(void); - - //////////////////////////////////////////////////////////// - - protected: +template < > +struct FormatException < true > +{ + void raise(const std::string & msg) const + { + throw InvalidFormat(msg); + }; +}; +struct FormatTraits +{ enum Type { T_ANYTHING = 1, @@ -113,24 +111,240 @@ struct Format Argument(std::string fmts, Type type) : _fmts(fmts), _type(type) {}; - Type type(void) const { return _type; } + const Type type(void) const { return _type; } const std::string & fmts(void) const { return _fmts; } protected: - std::string _fmts; - Type _type; + const std::string _fmts; + const Type _type; }; typedef std::queue < Argument > ArgumentQueue; - //////////////////////////////////////////////////////////// - - public: + ////////////////////////////////// template < typename V > - Format & operator%( V value ) + bool number_verify_signed_short( V value ) const { - if (!validity_check()) + return + ((typeid(V) == typeid(short int) || + typeid(V) == typeid(short) || + typeid(V) == typeid(const short int) || + typeid(V) == typeid(const short) || + typeid(V) == typeid(volatile short int) || + typeid(V) == typeid(volatile short)) && + sizeof(V) == sizeof(short)); + } + + template < typename V > + bool number_verify_unsigned_short( V value ) const + { + return + ((typeid(V) == typeid(unsigned short int) || + typeid(V) == typeid(unsigned short) || + typeid(V) == typeid(const unsigned short int) || + typeid(V) == typeid(const unsigned short) || + typeid(V) == typeid(volatile unsigned short int) || + typeid(V) == typeid(volatile unsigned short)) && + sizeof(V) == sizeof(unsigned short)); + } + + template < typename V > + bool number_verify_signed_long( V value ) const + { + return + ((typeid(V) == typeid(long int) || + typeid(V) == typeid(long) || + typeid(V) == typeid(const long int) || + typeid(V) == typeid(const long) || + typeid(V) == typeid(volatile long int) || + typeid(V) == typeid(volatile long)) && + sizeof(V) == sizeof(long)); + } + + template < typename V > + bool number_verify_unsigned_long( V value ) const + { + return + ((typeid(V) == typeid(unsigned long int) || + typeid(V) == typeid(unsigned long) || + typeid(V) == typeid(const unsigned long int) || + typeid(V) == typeid(const unsigned long) || + typeid(V) == typeid(volatile unsigned long int) || + typeid(V) == typeid(volatile unsigned long)) && + sizeof(V) == sizeof(long long)); + } + + template < typename V > + bool number_verify_signed_long_long( V value ) const + { + return + ((typeid(V) == typeid(long long int) || + typeid(V) == typeid(long long) || + typeid(V) == typeid(const long long int) || + typeid(V) == typeid(const long long) || + typeid(V) == typeid(volatile long long) || + typeid(V) == typeid(volatile long long int)) && + sizeof(V) == sizeof(long long)); + } + + template < typename V > + bool number_verify_unsigned_long_long( V value ) const + { + return + ((typeid(V) == typeid(unsigned long long int) || + typeid(V) == typeid(unsigned long long) || + typeid(V) == typeid(const unsigned long long int) || + typeid(V) == typeid(const unsigned long long) || + typeid(V) == typeid(volatile unsigned long long) || + typeid(V) == typeid(volatile unsigned long long int)) && + sizeof(V) == sizeof(unsigned long long)); + } + + template < typename V > + bool number_verify_signed_int( V value ) const + { + return + (sizeof(V) <= sizeof(int) || + typeid(V) == typeid(int) || + typeid(V) == typeid(const int) || + typeid(V) == typeid(volatile int)); + } + + template < typename V > + bool number_verify_unsigned_int( V value ) const + { + return + (sizeof(V) <= sizeof(unsigned int) || + typeid(V) == typeid(unsigned int) || + typeid(V) == typeid(const unsigned int) || + typeid(V) == typeid(volatile unsigned int)); + } + + template < typename V > + bool generic_verify( V value, const Type type ) const + { + switch (type) + { + /* EXCEPTION: consider any number an valid input. */ + case T_SIGNED_INT: + case T_UNSIGNED_INT: + return + (number_verify_signed_int(value) || + number_verify_unsigned_int(value) || + number_verify_signed_long(value) || + number_verify_unsigned_long(value) || + number_verify_signed_short(value) || + number_verify_unsigned_short(value)); + + case T_SIGNED_SHORT_SHORT: + return (typeid(V) == typeid(char) || typeid(V) == typeid(const char)); + + case T_SIGNED_SHORT: + return number_verify_signed_short(value); + + case T_SIGNED_LONG: + return number_verify_signed_long(value); + + case T_SIGNED_LONG_LONG: + return number_verify_signed_long_long(value); + + case T_UNSIGNED_SHORT_SHORT: + return (typeid(V) == typeid(unsigned char) || typeid(V) == typeid(unsigned char)); + + case T_UNSIGNED_SHORT: + return number_verify_unsigned_short(value); + + case T_UNSIGNED_LONG: + return number_verify_unsigned_long(value); + + case T_UNSIGNED_LONG_LONG: + return number_verify_unsigned_long_long(value); + + case T_FLOAT: + return (typeid(V) == typeid(float)) || (typeid(V) == typeid(double) || + typeid(V) == typeid(const float)) || (typeid(V) == typeid(const double)); + + case T_CHAR: + return (typeid(V) == typeid(char)) || (typeid(V) == typeid(unsigned char) || + typeid(V) == typeid(const char)) || (typeid(V) == typeid(const unsigned char)); + + case T_POINTER: + case T_STRING: + return false; + + case T_ANYTHING: + return true; + + case T_LITERAL: + return false; + } + + return false; + }; + + const Argument * next_argument(void); + + void push_argument(std::string & data, const Type type); + void pop_argument(void); + + void initialize(const char *); + + protected: + ArgumentQueue _args; + std::string _result; + +}; + +template < bool E = false > +struct FormatBase: protected FormatTraits, protected FormatException < E > +{ + static const unsigned int strings_base_length = 64; + static const unsigned int generic_base_length = 64; + + explicit FormatBase(const char * format_string) + : _format(format_string), _valid(true) + { + FormatTraits::initialize(format_string); + }; + + explicit FormatBase(std::string format_string) + : _format(format_string), _valid(true) + { + FormatTraits::initialize(format_string.c_str()); + }; + + bool valid(void) const + { + return _valid; + } + + const std::string str() + { + if (valid() && (next_argument() != NULL)) + { + std::string msg; + + // TODO: why format appears two times? + msg += "too few arguments passed for format '"; + msg += _format; + msg += "' ("; + msg += _format; + msg += ")"; + + mark_invalid(msg); + } + + raise(); + return _result; + }; + + //////////////////////////////////////////////////////////// + + template < typename V > + FormatBase & operator%( V value ) + { + if (!valid()) return *this; const Argument * top = next_argument(); @@ -149,7 +363,7 @@ struct Format { char temp[generic_base_length]; - if (!generic_verify(value, top->type())) + if (!FormatTraits::generic_verify(value, top->type())) { std::string msg; @@ -171,14 +385,14 @@ struct Format pop_argument(); } - raise_check(); + raise(); return *this; } template < typename V > - Format & operator%( V * value ) + FormatBase & operator%( V * value ) { - if (!validity_check()) + if (!valid()) return *this; const Argument * top = next_argument(); @@ -256,20 +470,13 @@ struct Format pop_argument(); } - raise_check(); + raise(); return *this; } -/* - Format & operator%( std::string value ) + FormatBase & operator%( const std::string value ) { - return operator%(value); - } -*/ - - Format & operator%( const std::string value ) - { - if (!validity_check()) + if (!valid()) return *this; const Argument * top = next_argument(); @@ -313,200 +520,42 @@ struct Format pop_argument(); } - raise_check(); + raise(); return *this; } - protected: - - template < typename V > - bool number_verify_signed_short( V value ) + protected: + void mark_invalid(std::string & msg) { - return - ((typeid(V) == typeid(short int) || - typeid(V) == typeid(short) || - typeid(V) == typeid(const short int) || - typeid(V) == typeid(const short) || - typeid(V) == typeid(volatile short int) || - typeid(V) == typeid(volatile short)) && - sizeof(V) == sizeof(short)); - } - - template < typename V > - bool number_verify_unsigned_short( V value ) - { - return - ((typeid(V) == typeid(unsigned short int) || - typeid(V) == typeid(unsigned short) || - typeid(V) == typeid(const unsigned short int) || - typeid(V) == typeid(const unsigned short) || - typeid(V) == typeid(volatile unsigned short int) || - typeid(V) == typeid(volatile unsigned short)) && - sizeof(V) == sizeof(unsigned short)); - } - - template < typename V > - bool number_verify_signed_long( V value ) - { - return - ((typeid(V) == typeid(long int) || - typeid(V) == typeid(long) || - typeid(V) == typeid(const long int) || - typeid(V) == typeid(const long) || - typeid(V) == typeid(volatile long int) || - typeid(V) == typeid(volatile long)) && - sizeof(V) == sizeof(long)); - } - - template < typename V > - bool number_verify_unsigned_long( V value ) - { - return - ((typeid(V) == typeid(unsigned long int) || - typeid(V) == typeid(unsigned long) || - typeid(V) == typeid(const unsigned long int) || - typeid(V) == typeid(const unsigned long) || - typeid(V) == typeid(volatile unsigned long int) || - typeid(V) == typeid(volatile unsigned long)) && - sizeof(V) == sizeof(long long)); - } - - template < typename V > - bool number_verify_signed_long_long( V value ) - { - return - ((typeid(V) == typeid(long long int) || - typeid(V) == typeid(long long) || - typeid(V) == typeid(const long long int) || - typeid(V) == typeid(const long long) || - typeid(V) == typeid(volatile long long) || - typeid(V) == typeid(volatile long long int)) && - sizeof(V) == sizeof(long long)); - } - - template < typename V > - bool number_verify_unsigned_long_long( V value ) - { - return - ((typeid(V) == typeid(unsigned long long int) || - typeid(V) == typeid(unsigned long long) || - typeid(V) == typeid(const unsigned long long int) || - typeid(V) == typeid(const unsigned long long) || - typeid(V) == typeid(volatile unsigned long long) || - typeid(V) == typeid(volatile unsigned long long int)) && - sizeof(V) == sizeof(unsigned long long)); - } - - template < typename V > - bool number_verify_signed_int( V value ) - { - return - (sizeof(V) <= sizeof(int) || - typeid(V) == typeid(int) || - typeid(V) == typeid(const int) || - typeid(V) == typeid(volatile int)); - } - - template < typename V > - bool number_verify_unsigned_int( V value ) - { - return - (sizeof(V) <= sizeof(unsigned int) || - typeid(V) == typeid(unsigned int) || - typeid(V) == typeid(const unsigned int) || - typeid(V) == typeid(volatile unsigned int)); - } - - template < typename V > - bool generic_verify( V value, Type type ) - { - switch (type) + if (_valid) { - /* EXCEPTION: consider any number an valid input. */ - case T_SIGNED_INT: - case T_UNSIGNED_INT: - return - (number_verify_signed_int(value) || - number_verify_unsigned_int(value) || - number_verify_signed_long(value) || - number_verify_unsigned_long(value) || - number_verify_signed_short(value) || - number_verify_unsigned_short(value)); + _valid = false; - case T_SIGNED_SHORT_SHORT: - return (typeid(V) == typeid(char) || typeid(V) == typeid(const char)); - - case T_SIGNED_SHORT: - return number_verify_signed_short(value); - - case T_SIGNED_LONG: - return number_verify_signed_long(value); - - case T_SIGNED_LONG_LONG: - return number_verify_signed_long_long(value); - - case T_UNSIGNED_SHORT_SHORT: - return (typeid(V) == typeid(unsigned char) || typeid(V) == typeid(unsigned char)); - - case T_UNSIGNED_SHORT: - return number_verify_unsigned_short(value); - - case T_UNSIGNED_LONG: - return number_verify_unsigned_long(value); - - case T_UNSIGNED_LONG_LONG: - return number_verify_unsigned_long_long(value); - - case T_FLOAT: - return (typeid(V) == typeid(float)) || (typeid(V) == typeid(double) || - typeid(V) == typeid(const float)) || (typeid(V) == typeid(const double)); - - case T_CHAR: - return (typeid(V) == typeid(char)) || (typeid(V) == typeid(unsigned char) || - typeid(V) == typeid(const char)) || (typeid(V) == typeid(const unsigned char)); - - case T_POINTER: - case T_STRING: - return false; - - case T_ANYTHING: - return true; - - case T_LITERAL: - return false; + _result = "** INVALID FORMAT: "; + _result += msg; + _result += " **"; } + } - return false; - }; - - void mark_invalid(std::string &); - - bool validity_check(void); - void raise_check(void); - -/* - struct NoArgumentLeft + void raise(void) const { - NoArgumentLeft(): empty(0) {}; - - unsigned int empty; - }; -*/ - - const Argument * next_argument(void); - - void pop_argument(void); - void push_argument(std::string & data, Type type); + if (!_valid) + { + // call specialized class + FormatException< E >::raise(_result); + } + } private: - std::string _format; - - bool _valid; - bool _raise; - - std::string _result; - ArgumentQueue _args; + const std::string _format; + bool _valid; }; -#endif /* _FORMAT_H_ */ +/* useful typedef for general usage (not generating exceptions) */ +typedef FormatBase<> Format; +/* macros used for shortening lines and making the code clearer */ +#define STG(x) (x).str() +#define FMT(x) Format(x) + +#endif /* _FORMAT_H_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/function.hpp b/src/mod/endpoints/mod_khomp/commons/base/function.hpp similarity index 65% rename from src/mod/endpoints/mod_khomp/commons/function.hpp rename to src/mod/endpoints/mod_khomp/commons/base/function.hpp index c448299acd..7470bf245d 100644 --- a/src/mod/endpoints/mod_khomp/commons/function.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/function.hpp @@ -46,12 +46,13 @@ namespace Function { - struct EmptyFunction {}; + struct EmptyFunction {}; + struct NonMemberFunction {}; /**/ template < typename FunctionTraits > - struct StorageBase: NEW_REFCOUNTER(StorageBase < FunctionTraits >) + struct StorageBase: COUNTER_SUPER(StorageBase < FunctionTraits >) { typedef typename FunctionTraits::BaseType BaseType; @@ -59,27 +60,33 @@ namespace Function typedef typename FunctionTraits::ObjType ObjType; template < typename Functor > - StorageBase(Functor f) - : _object(reinterpret_cast(new Functor(f))), - _function(reinterpret_cast(&(Functor::operator()))), + StorageBase(const Functor f) + : _object(reinterpret_cast< ObjType >(new Functor(f))), + _function(reinterpret_cast< FunType >(&Functor::operator())), _malloced(true) {}; template < typename Functor > StorageBase(Functor & f, bool malloced) - : _object(reinterpret_cast((malloced ? new Functor(f) : &f))), - _function(reinterpret_cast(&(Functor::operator()))), + : _object(reinterpret_cast< ObjType >((malloced ? new Functor(f) : &f))), + _function(reinterpret_cast< FunType >(&Functor::operator())), _malloced(malloced) {}; + StorageBase(FunType const * member) + : _object(reinterpret_cast< ObjType >(0)), + _function(reinterpret_cast< FunType >(member)), + _malloced(false) + {}; + StorageBase() - : _object(reinterpret_cast(0)), - _function(reinterpret_cast(0)), + : _object(reinterpret_cast< ObjType >(0)), + _function(reinterpret_cast< FunType >(0)), _malloced(false) {}; StorageBase(const StorageBase & o) - : INC_REFCOUNTER(o, StorageBase < FunctionTraits >), + : COUNTER_REFER(o, StorageBase < FunctionTraits >), _object(o._object), _function(o._function), _malloced(o._malloced) {}; @@ -95,9 +102,9 @@ namespace Function template < typename Functor > void operator=(Functor f) { - _object = reinterpret_cast(new Functor(f)), - _function = reinterpret_cast(&(Functor::operator())); - _malloced = false; + _object = reinterpret_cast< ObjType >(new Functor(f)), + _function = reinterpret_cast< FunType >(&Functor::operator()); + _malloced = true; } protected: @@ -229,10 +236,15 @@ namespace Function typedef StorageBase < Function0Traits < R > > Storage; template < typename Functor > - Function0(Functor f): Storage(f) {}; + Function0(const Functor f) + : Storage(f) {}; template < typename Functor > - Function0(Functor & f, bool m): Storage(f, m) {}; + Function0(Functor & f, bool m) + : Storage(f, m) {}; + + Function0(const typename Function0Traits < R >::FunType * m) + : Storage(m) {}; Function0() {}; @@ -243,6 +255,18 @@ namespace Function return ((Storage::_object)->*(Storage::_function))(); } + + template < typename Object > + R operator()(Object * object) + { + if (reinterpret_cast(Storage::_function) == 0) + throw EmptyFunction(); + + if (reinterpret_cast(Storage::_object) != 0) + throw NonMemberFunction(); + + return (reinterpret_cast< typename Function0Traits < R >::ObjType *>(object)->*(Storage::_function))(); + } }; template < typename R, typename A0 > @@ -251,10 +275,15 @@ namespace Function typedef StorageBase < Function1Traits < R, A0 > > Storage; template < typename Functor > - Function1(Functor f): Storage(f) {}; + Function1(const Functor f) + : Storage(f) {}; template < typename Functor > - Function1(Functor & f, bool m): Storage(f, m) {}; + Function1(Functor & f, bool m) + : Storage(f, m) {}; + + Function1(const typename Function1Traits < R, A0 >::FunType * m) + : Storage(m) {}; Function1() {}; @@ -265,6 +294,18 @@ namespace Function return ((Storage::_object)->*(Storage::_function))(a0); } + + template < typename Object > + R operator()(Object * object, A0 a0) + { + if (reinterpret_cast(Storage::_function) == 0) + throw EmptyFunction(); + + if (reinterpret_cast(Storage::_object) != 0) + throw NonMemberFunction(); + + return (reinterpret_cast< typename Function1Traits < R, A0 >::ObjType *>(object)->*(Storage::_function))(a0); + } }; template < typename R, typename A0, typename A1 > @@ -273,10 +314,15 @@ namespace Function typedef StorageBase < Function2Traits < R, A0, A1 > > Storage; template < typename Functor > - Function2(Functor f): Storage(f) {}; + Function2(const Functor f) + : Storage(f) {}; template < typename Functor > - Function2(Functor & f, bool m): Storage(f, m) {}; + Function2(Functor & f, bool m) + : Storage(f, m) {}; + + Function2(const typename Function2Traits < R, A0, A1 >::FunType * m) + : Storage(m) {}; Function2() {}; @@ -287,6 +333,18 @@ namespace Function return ((Storage::_object)->*(Storage::_function))(a0, a1); } + + template < typename Object > + R operator()(Object * object, A0 a0, A1 a1) + { + if (reinterpret_cast(Storage::_function) == 0) + throw EmptyFunction(); + + if (reinterpret_cast(Storage::_object) != 0) + throw NonMemberFunction(); + + return (reinterpret_cast< typename Function2Traits < R, A0, A1 >::ObjType *>(object)->*(Storage::_function))(a0, a1); + } }; template < typename R, typename A0, typename A1, typename A2 > @@ -295,20 +353,37 @@ namespace Function typedef StorageBase < Function3Traits < R, A0, A1, A2 > > Storage; template < typename Functor > - Function3(Functor f): Storage(f) {}; + Function3(const Functor f) + : Storage(f) {}; template < typename Functor > - Function3(Functor & f, bool m): Storage(f, m) {}; + Function3(Functor & f, bool m) + : Storage(f, m) {}; + + Function3(const typename Function3Traits < R, A0, A1, A2 >::FunType * m) + : Storage(m) {}; Function3() {}; R operator()(A0 a0, A1 a1, A2 a2) { - if (reinterpret_cast(Storage::_object) == 0) + if (reinterpret_cast(Storage::_object) == 0) throw EmptyFunction(); return ((Storage::_object)->*(Storage::_function))(a0, a1, a2); } + + template < typename Object > + R operator()(Object * object, A0 a0, A1 a1, A2 a2) + { + if (reinterpret_cast(Storage::_function) == 0) + throw EmptyFunction(); + + if (reinterpret_cast(Storage::_object) != 0) + throw NonMemberFunction(); + + return (reinterpret_cast< typename Function3Traits < R, A0, A1, A2 >::ObjType *>(object)->*(Storage::_function))(a0, a1, a2); + } }; template < typename R, typename A0, typename A1, typename A2, typename A3 > @@ -317,10 +392,15 @@ namespace Function typedef StorageBase < Function4Traits < R, A0, A1, A2, A3 > > Storage; template < typename Functor > - Function4(Functor f): Storage(f) {}; + Function4(const Functor f) + : Storage(f) {}; template < typename Functor > - Function4(Functor & f, bool m): Storage(f, m) {}; + Function4(Functor & f, bool m) + : Storage(f, m) {}; + + Function4(const typename Function4Traits < R, A0, A1, A2, A3 >::FunType * m) + : Storage(m) {}; Function4() {}; @@ -331,6 +411,18 @@ namespace Function return ((Storage::_object)->*(Storage::_function))(a0, a1, a2, a3); } + + template < typename Object > + R operator()(Object * object, A0 a0, A1 a1, A2 a2, A3 a3) + { + if (reinterpret_cast(Storage::_function) == 0) + throw EmptyFunction(); + + if (reinterpret_cast(Storage::_object) != 0) + throw NonMemberFunction(); + + return (reinterpret_cast< typename Function4Traits < R, A0, A1, A2, A3 >::ObjType *>(object)->*(Storage::_function))(a0, a1, a2, a3); + } }; }; diff --git a/src/mod/endpoints/mod_khomp/commons/initializer.hpp b/src/mod/endpoints/mod_khomp/commons/base/initializer.hpp similarity index 86% rename from src/mod/endpoints/mod_khomp/commons/initializer.hpp rename to src/mod/endpoints/mod_khomp/commons/base/initializer.hpp index e0e110d49c..16359e8c97 100644 --- a/src/mod/endpoints/mod_khomp/commons/initializer.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/initializer.hpp @@ -47,32 +47,32 @@ template < typename Type > struct Initializer: public std::vector< Type > { - typedef std::vector< Type > super; + typedef std::vector< Type > Super; - Initializer(Type e) { push_back(e); }; - Initializer(Type & e) { push_back(e); }; + Initializer(Type e) { Super::push_back(e); }; + Initializer(Type & e) { Super::push_back(e); }; - Initializer & operator&(Initializer v) + Initializer & operator&(const Initializer v) { - insert(super::end(), v.begin(), v.end()); + Super::insert(Super::end(), v.begin(), v.end()); return *this; }; Initializer & operator&(Initializer & v) { - insert(super::end(), v.begin(), v.end()); + Super::insert(Super::end(), v.begin(), v.end()); return *this; }; Initializer & operator&(Type v) { - insert(super::end(), v); + Super::insert(Super::end(), v); return *this; }; Initializer & operator&(Type & v) { - insert(super::end(), v); + Super::insert(Super::end(), v); return *this; }; }; diff --git a/src/mod/endpoints/mod_khomp/commons/k3lapi.cpp b/src/mod/endpoints/mod_khomp/commons/base/k3lapi.cpp similarity index 77% rename from src/mod/endpoints/mod_khomp/commons/k3lapi.cpp rename to src/mod/endpoints/mod_khomp/commons/base/k3lapi.cpp index f5afa1348f..09f5c81c0e 100644 --- a/src/mod/endpoints/mod_khomp/commons/k3lapi.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/k3lapi.cpp @@ -41,18 +41,16 @@ #include -#include -#include +#include -K3LAPI::K3LAPI(bool has_exceptions) -: _has_exceptions(has_exceptions), - _device_count(0), _channel_count(0), _link_count(0), +K3LAPIBase::K3LAPIBase() +: _device_count(0), _channel_count(0), _link_count(0), _device_config(0), _channel_config(0), _link_config(0) {}; /* initialize the whole thing! */ -void K3LAPI::start(void) +void K3LAPIBase::start(void) { /* tie the used k3l to the compiled k3l version */ char *ret = k3lStart(k3lApiMajorVersion, k3lApiMinorVersion, 0); //k3lApiBuildVersion); @@ -64,7 +62,7 @@ void K3LAPI::start(void) init(); } -void K3LAPI::stop(void) +void K3LAPIBase::stop(void) { k3lStop(); fini(); @@ -72,7 +70,7 @@ void K3LAPI::stop(void) /* envio de comandos para placa */ -void K3LAPI::mixer(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) +void K3LAPIBase::mixer(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) const { KMixerCommand mix; @@ -83,7 +81,7 @@ void K3LAPI::mixer(int32 dev, int32 obj, byte track, KMixerSource src, int32 ind command(dev, obj, CM_MIXER, (const char *) &mix); } -void K3LAPI::mixerRecord(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) +void K3LAPIBase::mixerRecord(int32 dev, KDeviceType type, int32 obj, byte track, KMixerSource src, int32 index) const { /* estes buffers *NAO PODEM SER ESTATICOS*! */ char cmd[] = { 0x3f, 0x03, (char)obj, (char)track, 0xff, 0xff }; @@ -131,12 +129,12 @@ void K3LAPI::mixerRecord(int32 dev, int32 obj, byte track, KMixerSource src, int break; } - int32 dsp = get_dsp(dev, DSP_AUDIO); + int32 dsp = get_dsp(type, DSP_AUDIO); raw_command(dev, dsp, cmd, sizeof(cmd)); } -void K3LAPI::mixerCTbus(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) +void K3LAPIBase::mixerCTbus(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) const { KMixerCommand mix; @@ -147,12 +145,12 @@ void K3LAPI::mixerCTbus(int32 dev, int32 obj, byte track, KMixerSource src, int3 command(dev, obj, CM_MIXER_CTBUS, (const char *) &mix); } -void K3LAPI::command(int32 dev, int32 obj, int32 code, std::string & str) +void K3LAPIBase::command(int32 dev, int32 obj, int32 code, std::string & str) const { command(dev, obj, code, str.c_str()); } -void K3LAPI::command (int32 dev, int32 obj, int32 code, const char * parms) +void K3LAPIBase::command (int32 dev, int32 obj, int32 code, const char * parms) const { K3L_COMMAND cmd; @@ -166,12 +164,12 @@ void K3LAPI::command (int32 dev, int32 obj, int32 code, const char * parms) throw failed_command(code, dev, obj, rc); } -void K3LAPI::raw_command(int32 dev, int32 dsp, std::string & str) +void K3LAPIBase::raw_command(int32 dev, int32 dsp, std::string & str) const { raw_command(dev, dsp, str.data(), str.size()); } -void K3LAPI::raw_command(int32 dev, int32 dsp, const char * cmds, int32 size) +void K3LAPIBase::raw_command(int32 dev, int32 dsp, const char * cmds, int32 size) const { std::string str(cmds, size); @@ -181,7 +179,7 @@ void K3LAPI::raw_command(int32 dev, int32 dsp, const char * cmds, int32 size) throw failed_raw_command(dev, dsp, rc); } -KLibraryStatus K3LAPI::get_param(K3L_EVENT *ev, const char *name, std::string &res) +KLibraryStatus K3LAPIBase::get_param(K3L_EVENT *ev, const char *name, std::string &res) const { char tmp_param[256]; memset((void*)tmp_param, 0, sizeof(tmp_param)); @@ -195,7 +193,7 @@ KLibraryStatus K3LAPI::get_param(K3L_EVENT *ev, const char *name, std::string &r return ksSuccess; } -std::string K3LAPI::get_param(K3L_EVENT *ev, const char *name) +std::string K3LAPIBase::get_param(K3L_EVENT *ev, const char *name) const { std::string res; @@ -207,7 +205,7 @@ std::string K3LAPI::get_param(K3L_EVENT *ev, const char *name) return res; } -void K3LAPI::init(void) +void K3LAPIBase::init(void) { if (_device_count != 0) return; @@ -217,20 +215,16 @@ void K3LAPI::init(void) _device_config = new device_conf_type[_device_count]; _channel_config = new channel_ptr_conf_type[_device_count]; _link_config = new link_ptr_conf_type[_device_count]; - _channel_count = new unsigned int[_device_count]; - _link_count = new unsigned int[_device_count]; + _channel_count = new unsigned int[_device_count]; + _link_count = new unsigned int[_device_count]; for (unsigned int dev = 0; dev < _device_count; dev++) { - KLibraryStatus ret = ksSuccess; - _device_type[dev] = (KDeviceType) k3lGetDeviceType(dev); /* caches each device config */ - ret = (KLibraryStatus)k3lGetDeviceConfig(dev, ksoDevice + dev, &(_device_config[dev]), sizeof(_device_config[dev])); - - if (ret != ksSuccess) - throw start_failed(STG(FMT("k3lGetDeviceConfig(dev=%d): %s") % dev % Verbose::status(ret))); + if (k3lGetDeviceConfig(dev, ksoDevice + dev, &(_device_config[dev]), sizeof(_device_config[dev])) != ksSuccess) + throw start_failed("k3lGetDeviceConfig(device)"); /* adjust channel/link count for device */ _channel_count[dev] = _device_config[dev].ChannelCount; @@ -241,10 +235,9 @@ void K3LAPI::init(void) for (unsigned int obj = 0; obj < _channel_count[dev]; obj++) { - ret = (KLibraryStatus)k3lGetDeviceConfig(dev, ksoChannel + obj, &(_channel_config[dev][obj]), sizeof(_channel_config[dev][obj])); - - if (ret != ksSuccess) - throw start_failed(STG(FMT("k3lGetDeviceConfig(dev=%d,chan=%d): %s") % dev % obj % Verbose::status(ret))); + if (k3lGetDeviceConfig(dev, ksoChannel + obj, &(_channel_config[dev][obj]), + sizeof(_channel_config[dev][obj])) != ksSuccess) + throw start_failed("k3lGetDeviceConfig(channel)"); } /* adjust link count for device */ @@ -255,15 +248,14 @@ void K3LAPI::init(void) for (unsigned int obj = 0; obj < _link_count[dev]; obj++) { - ret = (KLibraryStatus)k3lGetDeviceConfig(dev, ksoLink + obj, &(_link_config[dev][obj]), sizeof(_link_config[dev][obj])); - - if (ret != ksSuccess) - throw start_failed(STG(FMT("k3lGetDeviceConfig(dev=%d,link=%d): %s") % dev % obj % Verbose::status(ret))); + if (k3lGetDeviceConfig(dev, ksoLink + obj, &(_link_config[dev][obj]), + sizeof(_link_config[dev][obj])) != ksSuccess) + throw start_failed("k3lGetDeviceConfig(link)"); } } } -void K3LAPI::fini(void) +void K3LAPIBase::fini(void) { for (unsigned int dev = 0; dev < _device_count; dev++) { @@ -290,9 +282,9 @@ void K3LAPI::fini(void) if (_link_count) { delete[] _link_count; _link_count = NULL; } } -int32 K3LAPI::get_dsp(int32 dev, K3LAPI::DspType type) +int32 K3LAPIBase::get_dsp(KDeviceType devtype, K3LAPI::DspType type) const { - switch (device_type(dev)) + switch (devtype) { case kdtFXO: case kdtFXOVoIP: @@ -311,3 +303,7 @@ int32 K3LAPI::get_dsp(int32 dev, K3LAPI::DspType type) } } +int32 K3LAPIBase::get_dsp(const K3LAPIBase::GenericTarget & tgt, K3LAPI::DspType type) const +{ + return get_dsp(_device_type[tgt.device], type); +} diff --git a/src/mod/endpoints/mod_khomp/commons/k3lapi.hpp b/src/mod/endpoints/mod_khomp/commons/base/k3lapi.hpp similarity index 50% rename from src/mod/endpoints/mod_khomp/commons/k3lapi.hpp rename to src/mod/endpoints/mod_khomp/commons/base/k3lapi.hpp index 596548405b..ef12a3f676 100644 --- a/src/mod/endpoints/mod_khomp/commons/k3lapi.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/k3lapi.hpp @@ -40,6 +40,9 @@ */ #include +#include + +#include #include @@ -59,15 +62,110 @@ #ifndef _K3LAPI_HPP_ #define _K3LAPI_HPP_ -struct K3LAPI +struct K3LAPITraits { + struct invalid_device; + struct invalid_channel; + struct invalid_link; + + struct invalid_target: public std::runtime_error + { + friend class invalid_device; + friend class invalid_channel; + friend class invalid_link; + + const int32 device, object; + + protected: + invalid_target(int32 _device, int32 _object, const std::string & msg) + : std::runtime_error(msg), device(_device), object(_object) {}; + }; + + struct invalid_device: public invalid_target + { + invalid_device(int32 _device) + : invalid_target(_device, -1, STG(FMT("invalid device number '%d'") % _device)) {}; + }; + + struct invalid_channel: public invalid_target + { + invalid_channel(int32 _device, int32 _channel) + : invalid_target(_device, _channel, STG(FMT("invalid channel number '%d' on device '%d'") % _channel % _device)) {}; + }; + + struct invalid_link: public invalid_target + { + invalid_link(int32 _device, int32 _link) + : invalid_target(_device, _link, STG(FMT("invalid link number '%d' on device '%d'") % _link % _device)) {}; + }; +}; + +struct K3LAPIBase +{ + /* High level checked object identifier. */ + + struct GenericTarget + { + typedef enum { DEVICE, CHANNEL, MIXER, LINK } Type; + + GenericTarget(const K3LAPIBase & k3lapi, Type _type, int32 _device, int32 _object) + : type(_type), device((unsigned int)_device), object((unsigned int)_object) + { + switch (_type) + { + case DEVICE: + if (!k3lapi.valid_device(_device)) + throw K3LAPITraits::invalid_device(_device); + break; + + case CHANNEL: + case MIXER: + if (!k3lapi.valid_channel(_device, _object)) + throw K3LAPITraits::invalid_channel(_device, _object); + break; + + case LINK: + if (!k3lapi.valid_link(_device, _object)) + throw K3LAPITraits::invalid_link(_device, _object); + break; + } + }; + + const Type type; + + const unsigned int device; + const unsigned int object; + }; + +/* + struct LinkTarget : public GenericTarget + { + LinkTarget(const K3LAPIBase & k3lapi, int32 _device, int32 _object) + : GenericTarget(k3lapi, GenericTarget::LINK, _device, _object) {}; + }; + + struct ChannelTarget : public GenericTarget + { + ChannelTarget(const K3LAPIBase & k3lapi, int32 _device, int32 _object) + : GenericTarget(k3lapi, GenericTarget::CHANNEL, _device, _object) {}; + }; + +*/ + template < GenericTarget::Type T > + struct Target: public GenericTarget + { + Target(const K3LAPIBase & k3lapi, int32 _device, int32 _object) + : GenericTarget(k3lapi, T, _device, _object) {}; + +// operator const GenericTarget&() const { return static_cast(*this); }; + }; + /* exceptions */ - struct start_failed + struct start_failed: public std::runtime_error { - start_failed(const char * _msg) : msg(_msg) {}; - start_failed(std::string _msg) : msg(_msg) {}; - std::string msg; + start_failed(const char * msg) + : std::runtime_error(msg) {}; }; struct failed_command @@ -91,30 +189,6 @@ struct K3LAPI int32 rc; }; - struct invalid_device - { - invalid_device(int32 _device) - : device(_device) {}; - - int32 device; - }; - - struct invalid_channel - { - invalid_channel(int32 _device, int32 _channel) - : device(_device), channel(_channel) {}; - - int32 device, channel; - }; - - struct invalid_link - { - invalid_link(unsigned int _device, unsigned int _link) - : device(_device), link(_link) {}; - - int32 device, link; - }; - struct get_param_failed { get_param_failed(std::string _name, int32 _rc) @@ -124,6 +198,8 @@ struct K3LAPI KLibraryStatus rc; }; + /* typedefs essenciais */ + typedef K3L_DEVICE_CONFIG device_conf_type; typedef K3L_CHANNEL_CONFIG channel_conf_type; typedef K3L_CHANNEL_CONFIG * channel_ptr_conf_type; @@ -132,8 +208,8 @@ struct K3LAPI /* constructors/destructors */ - K3LAPI(bool has_exceptions = false); - virtual ~K3LAPI() {}; + K3LAPIBase(); + virtual ~K3LAPIBase() {}; /* (init|final)ialize the whole thing! */ @@ -142,239 +218,106 @@ struct K3LAPI /* verificacao de intervalos */ - inline bool valid_device(int32 dev) + inline bool valid_device(int32 dev) const { return (dev >= 0 && dev < ((int32)_device_count)); } - inline bool valid_channel(int32 dev, int32 obj) + inline bool valid_channel(int32 dev, int32 obj) const { return (valid_device(dev) && obj >= 0 && obj < ((int32)_channel_count[dev])); } - inline bool valid_link(int32 dev, int32 obj) + inline bool valid_link(int32 dev, int32 obj) const { return (valid_device(dev) && obj >= 0 && obj < ((int32)_link_count[dev])); } - /*! - \brief High level object identifier - Since Khomp works with an object concept, this is used to map the - object id with its proper type. - */ - struct target - { - /*! The types a target can have */ - typedef enum { DEVICE, CHANNEL, MIXER, LINK } target_type; - - target(K3LAPI & k3lapi, target_type type_init, int32 device_value, int32 object_value) - : type(type_init), - device((unsigned short)device_value), - object((unsigned short)object_value) - { - switch (type_init) - { - case DEVICE: - if (!k3lapi.valid_device(device_value)) - throw invalid_device(device_value); - break; - - case CHANNEL: - case MIXER: - if (!k3lapi.valid_channel(device_value, object_value)) - throw invalid_channel(device_value, object_value); - break; - - case LINK: - if (!k3lapi.valid_link(device_value, object_value)) - throw invalid_link(device_value, object_value); - break; - } - - }; - - const target_type type; - - const unsigned short device; - const unsigned short object; - }; - /* envio de comandos para placa (geral) */ - void raw_command(int32 dev, int32 dsp, std::string & str); - void raw_command(int32 dev, int32 dsp, const char * cmds, int32 size); + void raw_command(int32 dev, int32 dsp, std::string & str) const; + void raw_command(int32 dev, int32 dsp, const char * cmds, int32 size) const; /* obter dados 'cacheados' (geral) */ - inline unsigned int device_count(void) + inline unsigned int device_count(void) const { return _device_count; } /* envio de comandos para placa (sem identificadores) */ - void mixer(int32 dev, int32 obj, byte track, KMixerSource src, int32 index); - void mixerRecord(int32 dev, int32 obj, byte track, KMixerSource src, int32 index); - void mixerCTbus(int32 dev, int32 obj, byte track, KMixerSource src, int32 index); + void mixer(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) const; + void mixerRecord(int32 dev, KDeviceType type, int32 obj, byte track, KMixerSource src, int32 index) const; + void mixerCTbus(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) const; - void command (int32 dev, int32 obj, int32 code, std::string & str); - void command (int32 dev, int32 obj, int32 code, const char * parms = NULL); + void command (int32 dev, int32 obj, int32 code, std::string & str) const; + void command (int32 dev, int32 obj, int32 code, const char * parms = NULL) const; - /* obter dados 'cacheados' (sem identificadores) */ - - inline unsigned int channel_count(int32 dev) - { - if (!valid_device(dev)) - { - if (_has_exceptions) - throw invalid_device(dev); - else - return 0; - } - - return _channel_count[dev]; - } - - inline unsigned int link_count(int32 dev) - { - if (!valid_device(dev)) - { - if (_has_exceptions) - throw invalid_device(dev); - else - return 0; - } - - return _link_count[dev]; - } - - inline uint32 channel_stats(int32 dev, int32 obj, uint32 index) - { - if (!valid_channel(dev, obj)) - { - if (_has_exceptions) - throw invalid_channel(dev, obj); - else - return 0; - } - - uint32 res_value = (uint32)-1; - stt_code stt_res = ksFail; - -#if K3L_AT_LEAST(2,1,0) - stt_res = k3lGetChannelStats(dev, obj, index, &res_value); -#endif - - if(stt_res != ksSuccess) - { - return (uint32)-1; - } - - return res_value; - } - - KDeviceType device_type(int32 dev) - { - if (!valid_device(dev)) - { - if (_has_exceptions) - throw invalid_device(dev); - else - return kdtDevTypeCount; - } - - return _device_type[dev]; - } - - - K3L_DEVICE_CONFIG & device_config(int32 dev) - { - if (!valid_device(dev)) - throw invalid_device(dev); - - return _device_config[dev]; - } - - K3L_CHANNEL_CONFIG & channel_config(int32 dev, int32 obj) - { - if (!valid_channel(dev, obj)) - throw invalid_channel(dev, obj); - - return _channel_config[dev][obj]; - } - - K3L_LINK_CONFIG & link_config(int32 dev, int32 obj) - { - if (!valid_link(dev, obj)) - throw invalid_channel(dev, obj); - - return _link_config[dev][obj]; - } /* envio de comandos para placa (com identificadores) */ - void mixer(target & tgt, byte track, KMixerSource src, int32 index) + void mixer(const GenericTarget & tgt, byte track, KMixerSource src, int32 index) const { - mixer((int32)tgt.device, (int32)tgt.object, track, src, index); + mixer(tgt.device, tgt.object, track, src, index); } - void mixerRecord(target & tgt, byte track, KMixerSource src, int32 index) + void mixerRecord(const GenericTarget & tgt, byte track, KMixerSource src, int32 index) const { - mixerRecord((int32)tgt.device, (int32)tgt.object, track, src, index); + mixerRecord((int32)tgt.device, _device_type[tgt.device], (int32)tgt.object, track, src, index); } - void mixerCTbus(target & tgt, byte track, KMixerSource src, int32 index) + void mixerCTbus(const GenericTarget & tgt, byte track, KMixerSource src, int32 index) const { mixerCTbus((int32)tgt.device, (int32)tgt.object, track, src, index); } - void command (target & tgt, int32 code, std::string & str) + void command(const GenericTarget & tgt, int32 code, std::string & str) const { command((int32)tgt.device, (int32)tgt.object, code, str); }; - void command (target & tgt, int32 code, const char * parms = NULL) + void command(const GenericTarget & tgt, int32 code, const char * parms = NULL) const { command((int32)tgt.device, (int32)tgt.object, code, parms); }; /* obter dados 'cacheados' (com indentificadores) */ - inline unsigned int channel_count(target & tgt) + inline unsigned int channel_count(const GenericTarget & tgt) const { return _channel_count[tgt.device]; } - inline unsigned int link_count(target & tgt) + inline unsigned int link_count(const GenericTarget & tgt) const { return _link_count[tgt.device]; } - KDeviceType device_type(target & tgt) + KDeviceType device_type(const GenericTarget & tgt) const { return _device_type[tgt.device]; } - - K3L_DEVICE_CONFIG & device_config(target & tgt) + const K3L_DEVICE_CONFIG & device_config(const GenericTarget & tgt) const { return _device_config[tgt.device]; } - K3L_CHANNEL_CONFIG & channel_config(target & tgt) + const K3L_CHANNEL_CONFIG & channel_config(const Target & tgt) const { return _channel_config[tgt.device][tgt.object]; } - K3L_LINK_CONFIG & link_config(target & tgt) + const K3L_LINK_CONFIG & link_config(const Target & tgt) const { return _link_config[tgt.device][tgt.object]; } /* pega valores em strings de eventos */ - KLibraryStatus get_param(K3L_EVENT *ev, const char *name, std::string &res); - std::string get_param(K3L_EVENT *ev, const char *name); + KLibraryStatus get_param(K3L_EVENT *ev, const char *name, std::string &res) const; + std::string get_param(K3L_EVENT *ev, const char *name) const; /* inicializa valores em cache */ @@ -389,12 +332,12 @@ struct K3LAPI DSP_SIGNALING, }; - int32 get_dsp(int32, DspType); + int32 get_dsp(KDeviceType, DspType) const; + + int32 get_dsp(const GenericTarget &, DspType) const; protected: - const bool _has_exceptions; - unsigned int _device_count; unsigned int * _channel_count; unsigned int * _link_count; @@ -405,4 +348,145 @@ struct K3LAPI KDeviceType * _device_type; }; +/* exceptions */ +template < bool E = false > +struct K3LAPIException +{ + void invalid_device(const int32 device) const + { + /* NOTHING */ + } + + void invalid_channel(const int32 device, const int32 channel) const + { + /* NOTHING */ + } + + void invalid_link(const int32 device, const int32 link) const + { + /* NOTHING */ + } +}; + +template < > +struct K3LAPIException < true > +{ + void invalid_device(const int32 device) const + { + throw K3LAPITraits::invalid_device(device); + } + + void invalid_channel(const int32 device, const int32 channel) const + { + throw K3LAPITraits::invalid_channel(device, channel); + } + + void invalid_link(const int32 device, const int32 link) const + { + throw K3LAPITraits::invalid_link(device, link); + } +}; + +template < bool E = false > +struct K3LAPITemplate: public K3LAPIBase, protected K3LAPIException < E > +{ + using K3LAPIBase::device_config; + using K3LAPIBase::channel_config; + using K3LAPIBase::link_config; + + using K3LAPIBase::device_type; + using K3LAPIBase::get_dsp; + + using K3LAPIBase::mixerRecord; + + /* obter dados 'cacheados' (sem identificadores) */ + + inline unsigned int channel_count(int32 dev) const + { + if (!valid_device(dev)) + { + K3LAPIException< E >::invalid_device(dev); + return 0; + } + + return _channel_count[dev]; + } + + inline unsigned int link_count(int32 dev) const + { + if (!valid_device(dev)) + { + K3LAPIException< E >::invalid_device(dev); + return 0; + } + + return _link_count[dev]; + } + + inline uint32 channel_stats(int32 dev, int32 obj, uint32 index) const + { + if (!valid_channel(dev, obj)) + { + K3LAPIException< E >::invalid_channel(dev, obj); + return 0u; + } + + uint32 res_value = 0u; + +#if K3L_AT_LEAST(2,1,0) + if (k3lGetChannelStats(dev, obj, index, &res_value) != ksSuccess) + return 0u; + + return res_value; +#endif + } + + KDeviceType device_type(int32 dev) const + { + if (!valid_device(dev)) + { + K3LAPIException< E >::invalid_device(dev); + return kdtDevTypeCount; + } + + return _device_type[dev]; + } + + const K3L_DEVICE_CONFIG & device_config(int32 dev) const + { + if (!valid_device(dev)) + throw K3LAPITraits::invalid_device(dev); + + return _device_config[dev]; + } + + const K3L_CHANNEL_CONFIG & channel_config(int32 dev, int32 obj) const + { + if (!valid_channel(dev, obj)) + throw K3LAPITraits::invalid_channel(dev, obj); + + return _channel_config[dev][obj]; + } + + const K3L_LINK_CONFIG & link_config(int32 dev, int32 obj) const + { + if (!valid_link(dev, obj)) + throw K3LAPITraits::invalid_link(dev, obj); + + return _link_config[dev][obj]; + } + + int32 get_dsp(int32 dev, DspType type) const + { + return get_dsp(device_type(dev), type); + } + + void mixerRecord(int32 dev, int32 obj, byte track, KMixerSource src, int32 index) const + { + mixerRecord(dev, device_type(dev), obj, track, src, index); + } +}; + +typedef K3LAPITemplate<> K3LAPI; + #endif /* _K3LAPI_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/k3lutil.cpp b/src/mod/endpoints/mod_khomp/commons/base/k3lutil.cpp similarity index 83% rename from src/mod/endpoints/mod_khomp/commons/k3lutil.cpp rename to src/mod/endpoints/mod_khomp/commons/base/k3lutil.cpp index 83ac82efae..3fda813a03 100644 --- a/src/mod/endpoints/mod_khomp/commons/k3lutil.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/k3lutil.cpp @@ -46,7 +46,8 @@ std::string K3LUtil::channelStatus(int32 dev, int32 channel, { try { - K3L_CHANNEL_CONFIG & config = _k3lapi.channel_config(dev, channel); + const K3L_CHANNEL_CONFIG & config = _k3lapi.channel_config(dev, channel); + K3L_CHANNEL_STATUS status; KLibraryStatus ret = (KLibraryStatus) k3lGetDeviceStatus (dev, @@ -60,7 +61,7 @@ std::string K3LUtil::channelStatus(int32 dev, int32 channel, : "Unknown (fail)"); } } - catch(K3LAPI::invalid_channel & e) + catch(K3LAPITraits::invalid_channel & e) { return (fmt == Verbose::EXACT ? "" : "Unknown (fail)"); } @@ -83,64 +84,35 @@ std::string K3LUtil::callStatus(int32 dev, int32 channel, } std::string K3LUtil::linkStatus(int32 dev, int32 link, - Verbose::Presentation fmt, KSignaling sig) + Verbose::Presentation fmt, KSignaling signaling, bool simpleStatus) { try { - if (sig == ksigInactive) + if (signaling == ksigInactive) { - K3L_LINK_CONFIG & config = _k3lapi.link_config(dev, link); - sig = config.Signaling; + const K3L_LINK_CONFIG & config = _k3lapi.link_config(dev, link); + signaling = config.Signaling; } - K3L_LINK_STATUS status; + K3L_LINK_STATUS status; KLibraryStatus ret = (KLibraryStatus) k3lGetDeviceStatus (dev, link + ksoLink, &status, sizeof(status)); switch (ret) { - case ksSuccess: return Verbose::linkStatus(sig, status.E1, fmt); + case ksSuccess: return Verbose::linkStatus(signaling, status.E1, fmt, simpleStatus); default: return (fmt == Verbose::EXACT ? "" : "Unknown (failure)"); } } - catch(K3LAPI::invalid_channel & e) + catch(K3LAPITraits::invalid_channel & e) { return (fmt == Verbose::EXACT ? "" : "Unknown (failure)"); } } -std::string K3LUtil::getLinkStatus(int32 dev, int32 link, - Verbose::Presentation fmt) -{ - switch (_k3lapi.device_type(dev)) - { -#if K3L_AT_LEAST(1,6,0) - case kdtFXS: - case kdtFXSSpx: - return linkStatus(dev, link, fmt, ksigAnalogTerminal); - -#if K3L_AT_LEAST(2,1,0) - case kdtE1FXSSpx: - if (link == 1) - return linkStatus(dev, link, fmt, ksigAnalogTerminal); -#endif -#endif - default: - break; - } - - K3L_LINK_CONFIG & conf = _k3lapi.link_config(dev, link); - - std::string res = linkStatus(dev, link, fmt); - - if (conf.ReceivingClock & 0x01) - res += (fmt == Verbose::EXACT ? ",sync" : " (sync)"); - - return res; -} unsigned int K3LUtil::physicalLinkCount(int32 dev, bool count_virtual) { @@ -199,7 +171,7 @@ unsigned int K3LUtil::physicalLinkCount(int32 dev, bool count_virtual) break; } } - catch(K3LAPI::invalid_device & e) + catch(K3LAPITraits::invalid_device & e) { return 0; } diff --git a/src/mod/endpoints/mod_khomp/commons/k3lutil.hpp b/src/mod/endpoints/mod_khomp/commons/base/k3lutil.hpp similarity index 95% rename from src/mod/endpoints/mod_khomp/commons/k3lutil.hpp rename to src/mod/endpoints/mod_khomp/commons/base/k3lutil.hpp index e547f3df6e..9d87d8b0f6 100644 --- a/src/mod/endpoints/mod_khomp/commons/k3lutil.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/k3lutil.hpp @@ -64,10 +64,8 @@ struct K3LUtil std::string linkStatus(int32, int32, Verbose::Presentation fmt = Verbose::HUMAN, - KSignaling sig = ksigInactive); - - std::string getLinkStatus(int32, int32, - Verbose::Presentation fmt = Verbose::HUMAN); + KSignaling sig = ksigInactive, + bool simpleStatus = false); unsigned int physicalLinkCount(int32 dev, bool count_virtual = false); diff --git a/src/mod/endpoints/mod_khomp/commons/logger.hpp b/src/mod/endpoints/mod_khomp/commons/base/logger.hpp similarity index 89% rename from src/mod/endpoints/mod_khomp/commons/logger.hpp rename to src/mod/endpoints/mod_khomp/commons/base/logger.hpp index 6fcf7bffe3..6c333e7b87 100644 --- a/src/mod/endpoints/mod_khomp/commons/logger.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/logger.hpp @@ -55,6 +55,7 @@ #if defined(COMMONS_LIBRARY_USING_ASTERISK) extern "C" { + #include #include } #elif defined(COMMONS_LIBRARY_USING_CALLWEAVER) @@ -443,35 +444,17 @@ struct Logger localtime_r (&tv, <); #endif - out_msg += STG(FMT("[%04d-%02d-%02d %02d:%02d:%02d] ") - % (lt.tm_year + 1900) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour - % lt.tm_min % lt.tm_sec); - -#elif defined(COMMONS_LIBRARY_USING_CALLWEAVER) +#elif defined(COMMONS_LIBRARY_USING_CALLWEAVER) || defined(COMMONS_LIBRARY_USING_FREESWITCH) time_t tv; struct tm lt; time (&tv); localtime_r (&tv, <); - - out_msg += STG(FMT("[%04d-%02d-%02d %02d:%02d:%02d] ") - % (lt.tm_year + 1900) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour - % lt.tm_min % lt.tm_sec); - -#elif defined(COMMONS_LIBRARY_USING_FREESWITCH) - time_t tv; - struct tm lt; - - time (&tv); - - localtime_r (&tv, <); - - out_msg += STG(FMT("[%04d-%02d-%02d %02d:%02d:%02d] ") - % (lt.tm_year + 1900) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour - % lt.tm_min % lt.tm_sec); - #endif + out_msg += STG(FMT("[%02d-%02d-%02d %02d:%02d:%02d] ") + % (lt.tm_year % 100) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour + % lt.tm_min % lt.tm_sec); } if (opt._flags[Option::DATETIMEMS]) @@ -497,16 +480,16 @@ struct Logger #endif #if ASTERISK_AT_LEAST(1,6,0) - out_msg += STG(FMT("[%04d-%02d-%02d %02d:%02d:%02d:%04d] ") - % (lt.tm_year + 1900) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour % lt.tm_min + out_msg += STG(FMT("[%02d-%02d-%02d %02d:%02d:%02d:%04d] ") + % (lt.tm_year % 100) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour % lt.tm_min % lt.tm_sec % (tv.tv_usec / 1000)); #else - out_msg += STG(FMT("[%04d-%02d-%02d %02d:%02d:%02d:%04d] ") - % (lt.tm_year + 1900) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour % lt.tm_min + out_msg += STG(FMT("[%02d-%02d-%02d %02d:%02d:%02d:%04d] ") + % (lt.tm_year % 100) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour % lt.tm_min % lt.tm_sec % (tv * 1000)); #endif -#elif defined(COMMONS_LIBRARY_USING_CALLWEAVER) +#elif defined(COMMONS_LIBRARY_USING_CALLWEAVER) || defined(COMMONS_LIBRARY_USING_FREESWITCH) time_t tv; struct tm lt; @@ -514,22 +497,9 @@ struct Logger localtime_r (&tv, <); - out_msg += STG(FMT("[%04d-%02d-%02d %02d:%02d:%02d:%04d] ") - % (lt.tm_year + 1900) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour % lt.tm_min + out_msg += STG(FMT("[%02d-%02d-%02d %02d:%02d:%02d:%04d] ") + % (lt.tm_year % 100) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour % lt.tm_min % lt.tm_sec % (tv * 1000)); - -#elif defined(COMMONS_LIBRARY_USING_FREESWITCH) - time_t tv; - struct tm lt; - - time (&tv); - - localtime_r (&tv, <); - - out_msg += STG(FMT("[%04d-%02d-%02d %02d:%02d:%02d:%04d] ") - % (lt.tm_year + 1900) % (lt.tm_mon + 1) % lt.tm_mday % lt.tm_hour % lt.tm_min - % lt.tm_sec % (tv * 1000)); - #endif } @@ -538,7 +508,7 @@ struct Logger if (opt._flags[Option::THREADID]) { #if defined (COMMONS_LIBRARY_USING_ASTERISK) || defined(COMMONS_LIBRARY_USING_CALLWEAVER) || defined(COMMONS_LIBRARY_USING_FREESWITCH) - out_msg += STG(FMT("t=%08p ") % ((void*)pthread_self())); + out_msg += STG(FMT("%08x ") % ((unsigned long)pthread_self())); #endif } diff --git a/src/mod/endpoints/mod_khomp/commons/noncopyable.hpp b/src/mod/endpoints/mod_khomp/commons/base/noncopyable.hpp similarity index 100% rename from src/mod/endpoints/mod_khomp/commons/noncopyable.hpp rename to src/mod/endpoints/mod_khomp/commons/base/noncopyable.hpp diff --git a/src/mod/endpoints/mod_khomp/commons/refcounter.hpp b/src/mod/endpoints/mod_khomp/commons/base/refcounter.hpp similarity index 94% rename from src/mod/endpoints/mod_khomp/commons/refcounter.hpp rename to src/mod/endpoints/mod_khomp/commons/base/refcounter.hpp index 6ba8ae8b2f..d1738185bb 100644 --- a/src/mod/endpoints/mod_khomp/commons/refcounter.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/refcounter.hpp @@ -45,6 +45,11 @@ #ifndef _REFCOUNTER_HPP_ #define _REFCOUNTER_HPP_ +#define COUNTER_CLASS(...) ReferenceCounter< __VA_ARGS__ > +#define COUNTER_SUPER(...) public COUNTER_CLASS( __VA_ARGS__ ) +#define COUNTER_REFER(o, ...) COUNTER_CLASS( __VA_ARGS__ )(static_cast< const COUNTER_CLASS( __VA_ARGS__ ) & >(o)) + +// DEPRECATED DECLARATIONS /// #define NEW_REFCOUNTER(...) public ReferenceCounter< __VA_ARGS__ > #define INC_REFCOUNTER(o, ...) ReferenceCounter< __VA_ARGS__ >(static_cast< const ReferenceCounter < __VA_ARGS__ > & >(o)) @@ -179,13 +184,13 @@ struct ReferenceCounter }; template < typename T > -struct ReferenceContainer: NEW_REFCOUNTER(ReferenceContainer< T >) +struct ReferenceContainer: COUNTER_SUPER(ReferenceContainer< T >) { /* type */ typedef T Type; /* shorthand */ - typedef ReferenceCounter < ReferenceContainer< Type > > Counter; + typedef COUNTER_CLASS(ReferenceContainer< Type >) Counter; // TODO: make this a generic exception someday struct NotFound {}; @@ -249,7 +254,7 @@ struct ReferenceContainer: NEW_REFCOUNTER(ReferenceContainer< T >) }; // return value (pointer)! - Type * operator()(void) + Type * operator()(void) const { return _reference_value; }; diff --git a/src/mod/endpoints/mod_khomp/commons/regex.cpp b/src/mod/endpoints/mod_khomp/commons/base/regex.cpp similarity index 94% rename from src/mod/endpoints/mod_khomp/commons/regex.cpp rename to src/mod/endpoints/mod_khomp/commons/base/regex.cpp index 61f941c214..d2b8cd0469 100644 --- a/src/mod/endpoints/mod_khomp/commons/regex.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/regex.cpp @@ -74,7 +74,7 @@ void Regex::Expression::initialize(void) _errorstate = regcomp(&_comp_regex, _expression, _flags); } -std::string Regex::Expression::regerror_as_string(void) +std::string Regex::Expression::regerror_as_string(void) const { unsigned int count = regerror(_errorstate, &_comp_regex, 0, 0) + 1; @@ -95,6 +95,7 @@ void Regex::Match::initialize(void) { _subcounter = (_expression.subcount() + 2); // 0 + N.. + invalid _submatches = new regmatch_t[_subcounter]; + _subcaching = new std::string[_subcounter]; _have_match = (regexec(_expression.repr(), _basestring.c_str(), _subcounter, _submatches, _flags) == 0); } @@ -117,7 +118,7 @@ std::string Regex::Match::replace(Regex::ReplaceMap & map) try { if (_submatches[0].rm_so != 0 && (map.find(0) != map.end())) - return _basestring.replace(_submatches[0].rm_so, _submatches[0].rm_eo - _submatches[0].rm_so, map.find(0)->second); + return buffer.replace(_submatches[0].rm_so, _submatches[0].rm_eo - _submatches[0].rm_so, map.find(0)->second); for (unsigned int n = 1; (_submatches[n].rm_so != -1) && (n < _subcounter); n++) { diff --git a/src/mod/endpoints/mod_khomp/commons/regex.hpp b/src/mod/endpoints/mod_khomp/commons/base/regex.hpp similarity index 78% rename from src/mod/endpoints/mod_khomp/commons/regex.hpp rename to src/mod/endpoints/mod_khomp/commons/base/regex.hpp index daf20147a8..61325238b8 100644 --- a/src/mod/endpoints/mod_khomp/commons/regex.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/regex.hpp @@ -111,12 +111,12 @@ struct Regex } } - bool valid(void) { return (_errorstate == 0); } + bool valid(void) const { return (_errorstate == 0); } - unsigned int subcount(void) { return _subcounter; } - const regex_t * repr(void) { return &_comp_regex; } + unsigned int subcount(void) const { return _subcounter; } + const regex_t * repr(void) const { return &_comp_regex; } - std::string error(void) + std::string error(void) const { switch (_errorstate) { @@ -127,31 +127,33 @@ struct Regex } private: - void initialize(void); - std::string regerror_as_string(void); + std::string regerror_as_string(void) const; + + private: + void initialize(void); protected: const char * _expression; - bool _alloced; + const bool _alloced; unsigned int _subcounter; int _errorstate; regex_t _comp_regex; - unsigned int _flags; + const unsigned int _flags; }; - struct Match: NEW_REFCOUNTER(Match) + struct Match: COUNTER_SUPER(Match) { - Match(const char * basestring, Expression & expression, unsigned int flags = 0) + Match(const char * basestring, const Expression & expression, unsigned int flags = 0) : _basestring(basestring), _expression(expression), _subcounter(0), _submatches(0), _have_match(false), _flags(flags) { initialize(); } - Match(std::string & basestring, Expression & expression, unsigned int flags = 0) + Match(const std::string & basestring, const Expression & expression, unsigned int flags = 0) : _basestring(basestring), _expression(expression), _subcounter(0), _submatches(0), _have_match(false), _flags(flags) { @@ -159,7 +161,7 @@ struct Regex } Match(const Match & o) - : INC_REFCOUNTER(o, Match), + : COUNTER_REFER(o, Match), _basestring(o._basestring), _expression(o._expression), _subcounter(o._subcounter), _submatches(o._submatches), _have_match(o._have_match), _flags(o._flags) @@ -169,6 +171,10 @@ struct Regex void unreference() { delete[] _submatches; + delete[] _subcaching; + + _submatches = 0; + _subcaching = 0; } bool matched(void) @@ -184,34 +190,23 @@ struct Regex return false; } - std::string submatch(int number) + const std::string & submatch(int number) { if (!matched(number)) - return ""; + return _subcaching[_subcounter - 1 /* invalid, always empty! */ ]; - return _basestring.substr(_submatches[number].rm_so, - _submatches[number].rm_eo - _submatches[number].rm_so); - } - - /** - * \brief gets a map with all matches - * \return std::map with all matches - * \note index 0 in map, is the complete string - * \author Eduardo Nunes Pereira - * - * If fails the empty map is returned - */ - std::map obtain_match_map() - { - int match_counter = 0; - std::map tmp_map; - while(matched(match_counter)) + if (_subcaching[number].empty()) { - tmp_map.insert(std::make_pair(match_counter,submatch(match_counter))); - match_counter++; + _subcaching[number].assign(_basestring, _submatches[number].rm_so, + _submatches[number].rm_eo - _submatches[number].rm_so); } - return tmp_map; + return _subcaching[number]; + } + + const std::string & operator[](int number) + { + return submatch(number); } /** @@ -226,25 +221,21 @@ struct Regex std::string replace(ReplaceMap &); std::string replace(std::string, unsigned int index = REP_BASE); - std::string operator[](int number) - { - return submatch(number); - } - // NOTE: there is already a way to get subcount defined on EXPRESSION class! private: void initialize(void); protected: - std::string _basestring; - Expression & _expression; + const std::string _basestring; + const Expression & _expression; unsigned int _subcounter; regmatch_t * _submatches; - + std::string * _subcaching; bool _have_match; - unsigned int _flags; + + const unsigned int _flags; }; }; diff --git a/src/mod/endpoints/mod_khomp/commons/base/ringbuffer.cpp b/src/mod/endpoints/mod_khomp/commons/base/ringbuffer.cpp new file mode 100644 index 0000000000..42056307e0 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/ringbuffer.cpp @@ -0,0 +1,485 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include + +// #include + + + /* Documentation of the formula used in the buffer arithmetic. + * + * [0|1|2|3|4|5|6|7] => size=8 + * | | + * reader | + * writer + * + * => writer has places [5,6,7,0,1] to write (5 places). + * + * => 8 - (4-2+1) = 8 - (2+1) = 8 - 3 = 5 + * + * > writer goes 1 up, amount goes 1 down. + * > reader goes 1 up, amount goes 1 up. + * > size goes 1 down, amount goes 1 down. + * + */ + +/********** BUFFER FUNCTIONS **********/ + +/* writes everything or nothing */ +bool Ringbuffer_traits::traits_provide(char * buffer, const char * value, unsigned int amount, bool do_not_overwrite) +{ + /* avoid using different values */ + Buffer_table cache = _pointers; + + bool need_overwrite = false; + + if (amount > free_blocks(cache)) + { + if (do_not_overwrite) + return false; + + /* if we are allowed to overwrite, just the buffer size matters for us */ + if (amount >= _size) + return false; + + /* we need to change reader pointer below... */ + need_overwrite = true; + } + + const unsigned int wr = cache.writer.complete; + const unsigned int wp = cache.writer.complete - 1; + + /* should we go around the buffer for writing? */ + if ((wr + amount) > _size) + { +// fprintf(stderr, "%p> first if matched\n", this); + + if (need_overwrite) + { + do + { + Buffer_pointer extra(cache.reader); + extra.complete = ((wr + amount) % _size); // (extra.complete + amount) % _size; +// extra.complete = (extra.complete + amount) % _size; + + if (update(cache.reader, extra)) + break; + } + while (true); + } + + unsigned int wr1 = _size - wr + 1; /* writer is already 1 position after */ + unsigned int wr2 = amount - wr1; + +// fprintf(stderr, "%p> partial write: (%d/%d) %d/%d [%d/%d]\n", this, wr1, wr2, amount, _size, reader, writer); + + /* two partial writes (one at the end, another at the beginning) */ + memcpy((void *) &(buffer[wp]), (const void *) (value), _block * wr1); + memcpy((void *) (buffer), (const void *) &(value[wr1]), _block * wr2); + } + else + { +// fprintf(stderr, "%p> second if matched\n", this); + + if (need_overwrite) + { + do + { + Buffer_pointer extra(cache.reader); + extra.complete = ((wr + amount) % _size); // (extra.complete + amount) % _size; + + if (update(cache.reader, extra)) + break; + } + while (true); + } + +// fprintf(stderr, "%p> full write: a=%d/s=%d [r=%d/w=%d]\n", this, amount, _size, reader, writer); + + /* we are talking about buffers here, man! */ + memcpy((void *) &(buffer[wp]), (const void *) value, _block * amount); + } + + _pointers.writer.complete = ((wp + amount) % _size) + 1; + _pointers.writer.partial = 1; + +// if (need_overwrite) +// fprintf(stdout, "%p> write end: w=%d/r=%d\n", this, _pointers.writer.complete, _pointers.reader.complete); + + return true; +} + +/* returns the number of itens that have been read */ +unsigned int Ringbuffer_traits::traits_consume(const char * buffer, char * value, unsigned int amount, bool atomic_mode) +{ + /* avoid using different values */ + Buffer_table cache = _pointers; + + const unsigned int available = used_blocks(cache); + + if (atomic_mode && amount > available) + return false; + + const unsigned int rd = _pointers.reader.complete; + + unsigned int total = std::min(amount, available); + + /* should we go around the buffer for reading? */ + if ((rd + total) >= _size) + { + unsigned int rd1 = _size - rd; + unsigned int rd2 = total - rd1; + +// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); + + /* two partial consumes (one at the end, another at the beginning) */ + memcpy((void *) (value), (const void *) &(buffer[rd]), _block * rd1); + memcpy((void *) &(value[rd1]), (const void *) (buffer), _block * rd2); + } + else + { +// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); + + /* we are talking about buffers here, man! */ + memcpy((void *) value, (const void *) &(buffer[rd]), _block * total); + } + + do + { + /* jump the reader forward */ + Buffer_pointer index((cache.reader.complete + total) % _size, 0); + + if (update(cache.reader, index)) + break; + } + while (true); + +// fprintf(stderr, "%p> read end: %d [block=%d]\n", this, reader, _block); + + return total; +} + +/********** TWO-PHASE BUFFER FUNCTIONS ***********/ + +/* returns the number of itens that have been read */ +unsigned int Ringbuffer_traits::traits_consume_begins(const char * buffer, char * value, unsigned int amount, bool atomic_mode) +{ + /* avoid using different values */ + Buffer_table cache = _pointers; + + const unsigned int available = used_blocks(cache); + + if (amount > available) + { + if (atomic_mode) + return false; + } + + const unsigned int rd = _pointers.reader.complete; + + unsigned int total = std::min(amount, available); + + /* should we go around the buffer for reading? */ + if ((rd + total) >= _size) + { + unsigned int rd1 = _size - rd; + unsigned int rd2 = total - rd1; + +// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); + + /* two partial consumes (one at the end, another at the beginning) */ + memcpy((void *) (value), (const void *) &(buffer[rd]), _block * rd1); + memcpy((void *) &(value[rd1]), (const void *) (buffer), _block * rd2); + } + else + { +// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); + + /* we are talking about buffers here, man! */ + memcpy((void *) value, (const void *) &(buffer[rd]), _block * total); + } + + return total; +} + +bool Ringbuffer_traits::traits_consume_commit(unsigned int amount) +{ + if (amount == 0) + return true; + + /* avoid using different values */ + Buffer_table cache = _pointers; + + const unsigned int available = used_blocks(cache); + + /* cannot commit more than available! */ + if (amount > available) + return false; + + unsigned int total = std::min(amount, available); + + do + { + /* jump the reader forward */ + Buffer_pointer index((cache.reader.complete + total) % _size, 0); + + if (update(cache.reader, index)) + break; + } + while (true); + +// fprintf(stderr, "%p> read end: %d [block=%d]\n", this, reader, _block); + + return true; +} + +/********** PARTIAL BUFFER FUNCTIONS (bytes) ***********/ + +/* writes everything or nothing */ +bool Ringbuffer_traits::traits_provide_partial(char * buffer, const char * value, unsigned int amount) +{ + /* avoid using different values */ + Buffer_table cache = _pointers; + + const unsigned int memsize = (_size * _block); + + if (amount > (free_blocks(cache) * _block)) + return false; + + const unsigned int wr = ((cache.writer.complete - 1) * _block) + cache.writer.partial; + const unsigned int wp = wr - 1; + + /* should we go around the buffer for writing? */ + if ((wr + amount) > memsize) + { +// fprintf(stderr, "%p> first if matched\n", this); + + unsigned int wr1 = memsize - wr + 1; /* writer is already 1 position after */ + unsigned int wr2 = amount - wr1; + +// fprintf(stderr, "%p> partial write: (%d/%d) %d/%d [%d/%d]\n", this, wr1, wr2, amount, _size, reader, writer); + + /* two partial writes (one at the end, another at the beginning) */ + memcpy((void *) &(buffer[wp]), (const void *) (value), wr1); + memcpy((void *) (buffer), (const void *) &(value[wr1]), wr2); + } + else + { +// fprintf(stderr, "%p> second if matched\n", this); + +// fprintf(stderr, "%p> full write: a=%d/s=%d [r=%d/w=%d]\n", this, amount, _size, reader, writer); + + /* we are talking about buffers here, man! */ + memcpy((void *) &(buffer[wp]), (const void *) value, amount); + } + + const unsigned int new_wp = (wp + amount) % memsize; + + _pointers.writer.complete = (unsigned int)(floor((double)new_wp / (double)_block) + 1); + _pointers.writer.partial = (new_wp % _block) + 1; + +// if (need_overwrite) +// fprintf(stdout, "%p> write end: w=%d/r=%d\n", this, _pointers.writer.complete, _pointers.reader.complete); + + return true; +} + +/* returns the number of bytes that have been read */ +unsigned int Ringbuffer_traits::traits_consume_partial(const char * buffer, char * value, unsigned int amount) +{ + /* avoid using different values */ + Buffer_table cache = _pointers; + + const unsigned int available = used_blocks(cache) * _block; + + const unsigned int rd = (_pointers.reader.complete * _block) + _pointers.reader.partial; + + const unsigned int memsize = _size * _block; + + unsigned int total = std::min(amount, available); + + /* should we go around the buffer for reading? */ + if ((rd + total) >= _size) + { + unsigned int rd1 = memsize - rd; + unsigned int rd2 = total - rd1; + +// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); + + /* two partial consumes (one at the end, another at the beginning) */ + memcpy((void *) (value), (const void *) &(buffer[rd]), rd1); + memcpy((void *) &(value[rd1]), (const void *) (buffer), rd2); + } + else + { +// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); + + /* we are talking about buffers here, man! */ + memcpy((void *) value, (const void *) &(buffer[rd]), total); + } + + do + { + const unsigned int new_rd = (((cache.reader.complete * _block) + cache.reader.partial) + total) % memsize; + + /* jump the reader forward */ + Buffer_pointer index((unsigned int)floor((double)new_rd / (double)_block), (unsigned short)(new_rd % _block)); + + if (update(cache.reader, index)) + break; + } + while (true); + +// fprintf(stderr, "%p> read end: %d [block=%d]\n", this, reader, _block); + + return total; +} + +/********** IO FUNCTIONS **********/ + +/* returns the number of items written to from buffer to stream */ +unsigned int Ringbuffer_traits::traits_put(const char * buffer, std::ostream &fd, unsigned int amount) +{ + /* avoid using different values */ + Buffer_table cache = _pointers; + + const unsigned int available = used_blocks(cache); + + if (amount > available) + return false; + + const unsigned int wr = _pointers.writer.complete; + const unsigned int rd = _pointers.reader.complete; + + unsigned int total = std::min(amount, available); + + /* should we go around the buffer for reading? */ + if ((rd + total) >= _size) + { + unsigned int rd1 = _size - rd; + unsigned int rd2 = total - rd1; + +// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); + + /* two partial consumes (one at the end, another at the beginning) */ + fd.write((const char *) &(buffer[rd]), _block * rd1); + fd.write((const char *) (buffer), _block * rd2); + } + else + { +// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); + fd.write((const char *) &(buffer[rd]), _block * total); + } + + do + { + /* jump the reader forward */ + Buffer_pointer index((cache.reader.complete + total) % _size, 0); + + if (update(cache.reader, index)) + break; + } + while (true); + +// fprintf(stderr, "%p> read end: %d [block=%d]\n", this, reader, _block); + + return total; +} + +/* returns number of items read from stream to buffer */ +unsigned int Ringbuffer_traits::traits_get(char * buffer, std::istream &fd, unsigned int amount) +{ + /* avoid using different values */ + Buffer_table cache = _pointers; + + if (amount > free_blocks(cache)) + return false; + + const unsigned int wr = cache.writer.complete; + const unsigned int wp = cache.writer.complete - 1; + + unsigned int real_amount = 0; + + /* should we go around the buffer for writing? */ + if ((wr + amount) > _size) + { +// fprintf(stderr, "%p> first if matched\n", this); + + unsigned int wr1 = _size - wr + 1; /* writer is already 1 position after */ + unsigned int wr2 = amount - wr1; + +// fprintf(stderr, "%p> partial write: (%d/%d) %d/%d [%d/%d]\n", this, wr1, wr2, amount, _size, reader, writer); + + /* two partial writes (one at the end, another at the beginning) */ + unsigned int char_amount = 0; + + /* one partial write on the buffer (at the end) */ + fd.read((char *) &(buffer[wp]), _block * wr1); + char_amount += fd.gcount(); + + if (fd.gcount() == (int)(_block * wr1)) + { + /* another partial write on the buffer (at the beginning) */ + fd.read((char *) (buffer), _block * wr2); + char_amount += fd.gcount(); + } + + real_amount = char_amount / _block; + } + else + { +// fprintf(stderr, "%p> second if matched\n", this); + +// fprintf(stderr, "%p> full write: a=%d/s=%d [r=%d/w=%d]\n", this, amount, _size, reader, writer); + + /* we are talking about buffers here, man! */ + fd.read((char *) &(buffer[wp]), _block * amount); + + real_amount = fd.gcount() / _block; + } + + _pointers.writer.complete = ((wp + amount) % _size) + 1; + _pointers.writer.partial = 1; + +// fprintf(stdout, "%p> write end: %d\n", this, _pointers.writer.complete); + + return real_amount; +} diff --git a/src/mod/endpoints/mod_khomp/commons/ringbuffer.hpp b/src/mod/endpoints/mod_khomp/commons/base/ringbuffer.hpp similarity index 88% rename from src/mod/endpoints/mod_khomp/commons/ringbuffer.hpp rename to src/mod/endpoints/mod_khomp/commons/base/ringbuffer.hpp index 39f8ffe8fb..b9ecd7e6bd 100644 --- a/src/mod/endpoints/mod_khomp/commons/ringbuffer.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/ringbuffer.hpp @@ -46,6 +46,12 @@ Also, it works only for single-reader + single-writer, since it does not depends on external mutex functions. + + NOTE: for single element provide/consume, this abstraction has standard C++ semantics. + + for multiple and partial element provide/consume, memcpy is used - thus complex C++ + objects which need correct copy constructor semantics should not copied this way. + */ #include @@ -61,7 +67,7 @@ struct Buffer_pointer { - Buffer_pointer(unsigned int _complete = 0u, unsigned short _partial = 0u) + Buffer_pointer(unsigned int _complete, unsigned short _partial) : complete(_complete), partial(_partial) {}; @@ -134,6 +140,10 @@ __attribute__((packed)); struct Ringbuffer_traits { + struct BufferFull {}; + struct BufferEmpty {}; + + protected: Ringbuffer_traits(unsigned int block, unsigned int size) : _block(block), _size(size) {}; @@ -155,6 +165,28 @@ struct Ringbuffer_traits return Atomic::doCAS(&(_pointers.reader), &cache, update); } + inline unsigned int free_blocks(const Buffer_table & cache) const + { + const unsigned int r = cache.reader.complete; + const unsigned int w = cache.writer.complete; + + if (r >= w) + return (r - w); + + return _size - (w - r); + } + + inline unsigned int used_blocks(const Buffer_table & cache) const + { + const unsigned int r = cache.reader.complete; + const unsigned int w = cache.writer.complete; + + if (r >= w) + return (_size - (r - w)) - 1; + + return (w - r) - 1; + } + protected: const unsigned int _block; const unsigned int _size; @@ -163,11 +195,8 @@ struct Ringbuffer_traits }; template -struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable +struct Ringbuffer: public Ringbuffer_traits, public NonCopyable { - struct BufferFull {}; - struct BufferEmpty {}; - Ringbuffer(unsigned int size) : Ringbuffer_traits(sizeof(T), size) { @@ -189,15 +218,17 @@ struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable } /***** GENERIC RANGE/INDEX CALCULATION FUNCTIONS *****/ - bool may_write(Buffer_table & cache) + + protected: + inline bool may_write(const Buffer_table & cache) const { const unsigned int r = cache.reader.complete; const unsigned int w = cache.writer.complete; - return (((r - w) != 1) && (!(r == 0 && w == _size))); + return (((r - w) != 0) && (!(r == 0 && w == _size))); } - bool may_read(Buffer_table & cache) + inline bool may_read(const Buffer_table & cache) const { if ((cache.writer.complete - cache.reader.complete) == 1) return false; @@ -205,7 +236,7 @@ struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable return true; } - unsigned int writer_next(Buffer_pointer & cache, Buffer_pointer & index) + inline unsigned int writer_next(const Buffer_pointer & cache, Buffer_pointer & index) const { unsigned int dest = cache.complete - 1, temp = cache.complete + 1; @@ -218,7 +249,7 @@ struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable return dest; }; - void reader_next(Buffer_pointer & cache, Buffer_pointer & index) + inline void reader_next(const Buffer_pointer & cache, Buffer_pointer & index) const { unsigned int temp = cache.complete + 1; @@ -230,6 +261,7 @@ struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable /***** BUFFER FUNCTIONS *****/ + public: bool provide(const T & value) { Buffer_table cache = _pointers; @@ -280,9 +312,9 @@ struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable } /* writes everything or nothing */ - inline bool provide(const T * value, unsigned int amount, bool skip_overwrite = true) + inline bool provide(const T * value, unsigned int amount, bool do_not_overwrite = true) { - return traits_provide((char *)_buffer, (const char *) value, amount, skip_overwrite); + return traits_provide((char *)_buffer, (const char *) value, amount, do_not_overwrite); } /* returns the number of items that have been read (atomic_mode == true means 'all or nothing') */ @@ -337,7 +369,7 @@ struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable // fprintf(stderr, "%p> write: %d/%d [%d/%d]\n", this, _pointers.reader, _pointers.writer, _pointers.reader_partial, _pointers.writer_partial); } - T & consumer_start(void) + const T & consumer_start(void) { Buffer_table cache = _pointers; @@ -391,13 +423,13 @@ struct Ringbuffer: protected Ringbuffer_traits, public NonCopyable /* returns the number of items written to from buffer to stream */ inline unsigned int put(std::ostream &fd, unsigned int amount) { - return traits_put((char *)_buffer, fd, amount); + return traits_put((const char *)_buffer, fd, amount); } /* returns number of items read from stream to buffer */ inline unsigned int get(std::istream &fd, unsigned int amount) { - return traits_get((const char *)_buffer, fd, amount); + return traits_get((char *)_buffer, fd, amount); } void clear() diff --git a/src/mod/endpoints/mod_khomp/commons/saved_condition.cpp b/src/mod/endpoints/mod_khomp/commons/base/saved_condition.cpp similarity index 100% rename from src/mod/endpoints/mod_khomp/commons/saved_condition.cpp rename to src/mod/endpoints/mod_khomp/commons/base/saved_condition.cpp diff --git a/src/mod/endpoints/mod_khomp/commons/saved_condition.hpp b/src/mod/endpoints/mod_khomp/commons/base/saved_condition.hpp similarity index 100% rename from src/mod/endpoints/mod_khomp/commons/saved_condition.hpp rename to src/mod/endpoints/mod_khomp/commons/base/saved_condition.hpp diff --git a/src/mod/endpoints/mod_khomp/commons/scoped_lock.hpp b/src/mod/endpoints/mod_khomp/commons/base/scoped_lock.hpp similarity index 100% rename from src/mod/endpoints/mod_khomp/commons/scoped_lock.hpp rename to src/mod/endpoints/mod_khomp/commons/base/scoped_lock.hpp diff --git a/src/mod/endpoints/mod_khomp/commons/simple_lock.hpp b/src/mod/endpoints/mod_khomp/commons/base/simple_lock.hpp similarity index 96% rename from src/mod/endpoints/mod_khomp/commons/simple_lock.hpp rename to src/mod/endpoints/mod_khomp/commons/base/simple_lock.hpp index 4f6619f456..8f22fe6bdb 100644 --- a/src/mod/endpoints/mod_khomp/commons/simple_lock.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/simple_lock.hpp @@ -55,7 +55,7 @@ * implement the "unreference()" method for releasing resources. */ template < typename Implementor > -struct SimpleLockCommon: NEW_REFCOUNTER( SimpleLockCommon < Implementor > ) +struct SimpleLockCommon: COUNTER_SUPER( SimpleLockCommon < Implementor > ) { friend class ReferenceCounter < SimpleLockCommon < Implementor > >; @@ -71,7 +71,7 @@ struct SimpleLockCommon: NEW_REFCOUNTER( SimpleLockCommon < Implementor > ) {}; SimpleLockCommon(const SimpleLockCommon & o) - : INC_REFCOUNTER(o, SimpleLockCommon) + : COUNTER_REFER(o, SimpleLockCommon) {}; virtual ~SimpleLockCommon() diff --git a/src/mod/endpoints/mod_khomp/commons/strings.cpp b/src/mod/endpoints/mod_khomp/commons/base/strings.cpp similarity index 87% rename from src/mod/endpoints/mod_khomp/commons/strings.cpp rename to src/mod/endpoints/mod_khomp/commons/base/strings.cpp index 5e1cbc7004..b7b84025a8 100644 --- a/src/mod/endpoints/mod_khomp/commons/strings.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/strings.cpp @@ -141,6 +141,38 @@ unsigned int Strings::tokenize(const std::string & str, Strings::vector_type & t return (cur_token - 1); } +long Strings::tolong(const std::string & str, int base) +{ + return tolong(str.c_str(), base); +} + +unsigned long Strings::toulong(const std::string & str, int base) +{ + return toulong(str.c_str(), base); +} + +unsigned long long Strings::toulonglong(const std::string & str, int base) +{ + return toulonglong(str.c_str(), base); +} + +double Strings::todouble(const std::string & str) +{ + return todouble(str.c_str()); +} + +long Strings::tolong(const char * str, int base) +{ + char *str_end = 0; + + unsigned long value = strtol(str, &str_end, base); + + if (str_end && *str_end == 0) + return value; + + throw invalid_value(str); +} + bool Strings::toboolean(std::string str) { std::string tmp(str); @@ -153,11 +185,11 @@ bool Strings::toboolean(std::string str) throw invalid_value(str); } -long Strings::tolong(std::string str, int base) +unsigned long Strings::toulong(const char * str, int base) { char *str_end = 0; - unsigned long value = strtol(str.c_str(), &str_end, base); + unsigned long value = strtoul(str, &str_end, base); if (str_end && *str_end == 0) return value; @@ -165,26 +197,14 @@ long Strings::tolong(std::string str, int base) throw invalid_value(str); } -unsigned long Strings::toulong(std::string str, int base) -{ - char *str_end = 0; - - unsigned long value = strtoul(str.c_str(), &str_end, base); - - if (str_end && *str_end == 0) - return value; - - throw invalid_value(str); -} - -unsigned long long Strings::toulonglong(std::string str, int base) +unsigned long long Strings::toulonglong(const char * str, int base) { #if defined(_WINDOWS) || defined(_Windows) || defined(_WIN32) || defined(WIN32) throw not_implemented(); #else char *str_end = 0; - unsigned long long value = strtoull(str.c_str(), &str_end, base); + unsigned long long value = strtoull(str, &str_end, base); if (str_end && *str_end == 0) return value; @@ -193,11 +213,11 @@ unsigned long long Strings::toulonglong(std::string str, int base) #endif } -double Strings::todouble(std::string str) +double Strings::todouble(const char * str) { char *str_end = 0; - double value = strtod(str.c_str(), &str_end); + double value = strtod(str, &str_end); if (str_end && *str_end == 0) return value; diff --git a/src/mod/endpoints/mod_khomp/commons/strings.hpp b/src/mod/endpoints/mod_khomp/commons/base/strings.hpp similarity index 81% rename from src/mod/endpoints/mod_khomp/commons/strings.hpp rename to src/mod/endpoints/mod_khomp/commons/base/strings.hpp index 056b9335c6..947da384d9 100644 --- a/src/mod/endpoints/mod_khomp/commons/strings.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/strings.hpp @@ -68,6 +68,8 @@ struct Strings bool empty() { return _list.empty(); }; + const list_type & list() { return _list; }; + protected: list_type _list; }; @@ -75,8 +77,8 @@ struct Strings public: struct invalid_value { - invalid_value(const char * value): _value(value) {}; - invalid_value(std::string value): _value(value) {}; + invalid_value(const char * value): _value(value) {}; + invalid_value(const std::string & value): _value(value) {}; std::string & value() { return _value; } @@ -92,10 +94,15 @@ struct Strings static bool toboolean(std::string); static std::string fromboolean(bool); - static long tolong(std::string, int base = 10); - static unsigned long toulong(std::string, int base = 10); - static unsigned long long toulonglong(std::string, int base = 10); - static double todouble(std::string); + static long tolong(const std::string &, int base = 10); + static unsigned long toulong(const std::string &, int base = 10); + static unsigned long long toulonglong(const std::string &, int base = 10); + static double todouble(const std::string &); + + static long tolong(const char *, int base = 10); + static unsigned long toulong(const char *, int base = 10); + static unsigned long long toulonglong(const char *, int base = 10); + static double todouble(const char *); static std::string lower(std::string); static std::string hexadecimal(std::string); diff --git a/src/mod/endpoints/mod_khomp/commons/freeswitch/saved_condition.cpp b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/saved_condition.cpp similarity index 83% rename from src/mod/endpoints/mod_khomp/commons/freeswitch/saved_condition.cpp rename to src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/saved_condition.cpp index 29169f3d54..d4d9861f5c 100644 --- a/src/mod/endpoints/mod_khomp/commons/freeswitch/saved_condition.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/saved_condition.cpp @@ -1,7 +1,7 @@ -/* +/* KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & Com. - + Copyright (C) 2007-2009 Khomp Ind. & 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/ @@ -23,40 +23,40 @@ The LGPL header follows below: - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "saved_condition.hpp" bool SavedCondition::wait(unsigned int msec) { - bool ret = true; + bool ret = true; switch_mutex_lock(_mutex); if (!_signaled) - { + { /* msec * 1000 = The amount of time in microseconds to wait. */ - if (switch_thread_cond_timedwait(_condition, _mutex, (switch_interval_time_t)msec * 1000) != 0) - ret = false; - } - + if (switch_thread_cond_timedwait(_condition, _mutex, (switch_interval_time_t)msec * 1000) != 0) + ret = false; + } + _signaled = false; - switch_mutex_unlock(_mutex); + switch_mutex_unlock(_mutex); - return ret; + return ret; } diff --git a/src/mod/endpoints/mod_khomp/commons/freeswitch/saved_condition.hpp b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/saved_condition.hpp similarity index 94% rename from src/mod/endpoints/mod_khomp/commons/freeswitch/saved_condition.hpp rename to src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/saved_condition.hpp index 8acf0f3e0b..b34e40b0c0 100644 --- a/src/mod/endpoints/mod_khomp/commons/freeswitch/saved_condition.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/saved_condition.hpp @@ -1,7 +1,7 @@ -/* +/* KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & Com. - + Copyright (C) 2007-2009 Khomp Ind. & 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/ @@ -23,20 +23,20 @@ The LGPL header follows below: - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef _SAVED_CONDITION_ @@ -104,7 +104,7 @@ struct SavedCondition : public SavedConditionCommon// : public RefCounter < Save if (!_signaled) switch_thread_cond_wait(_condition, _mutex); - + _signaled = false; switch_mutex_unlock(_mutex); diff --git a/src/mod/endpoints/mod_khomp/commons/freeswitch/simple_lock.hpp b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/simple_lock.hpp similarity index 96% rename from src/mod/endpoints/mod_khomp/commons/freeswitch/simple_lock.hpp rename to src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/simple_lock.hpp index 530d912ee1..acae57648d 100644 --- a/src/mod/endpoints/mod_khomp/commons/freeswitch/simple_lock.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/simple_lock.hpp @@ -1,7 +1,7 @@ -/* +/* KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & Com. - + Copyright (C) 2007-2009 Khomp Ind. & 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/ @@ -23,20 +23,20 @@ The LGPL header follows below: - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef _SIMPLE_LOCK_HPP_ @@ -72,7 +72,7 @@ struct SimpleLockBasic: public SimpleLockCommon < Implementor > { /* do nothing */ }; - + void unreference() { switch_mutex_destroy(_mutex); diff --git a/src/mod/endpoints/mod_khomp/commons/freeswitch/thread.hpp b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/thread.hpp similarity index 94% rename from src/mod/endpoints/mod_khomp/commons/freeswitch/thread.hpp rename to src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/thread.hpp index af50240307..9e5abc4372 100644 --- a/src/mod/endpoints/mod_khomp/commons/freeswitch/thread.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/system/freeswitch/thread.hpp @@ -1,7 +1,7 @@ -/* +/* KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & Com. - + Copyright (C) 2007-2009 Khomp Ind. & 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/ @@ -23,20 +23,20 @@ The LGPL header follows below: - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef _THREAD_HPP_ @@ -66,7 +66,7 @@ struct Thread : ThreadCommon T _data; A _arg; }; - + template struct ThreadData < T, R, void > : ThreadDataCommon { @@ -79,7 +79,7 @@ struct Thread : ThreadCommon T _data; }; - + template struct ThreadData < T, void, A > : ThreadDataCommon { @@ -111,7 +111,7 @@ struct Thread : ThreadCommon }; template - Thread(T obj, switch_memory_pool_t *pool=NULL) : + Thread(T obj, switch_memory_pool_t *pool=NULL) : _thread_info(new ThreadData::Return, void>(obj)), _pool(pool), _can_delete_pool(false) @@ -134,7 +134,7 @@ struct Thread : ThreadCommon } switch_threadattr_stacksize_set( - (switch_threadattr_t *)_thread_info->_attribute, + (switch_threadattr_t *)_thread_info->_attribute, SWITCH_THREAD_STACKSIZE); if(!priority()) @@ -143,9 +143,9 @@ struct Thread : ThreadCommon } } - + template - Thread(T obj, A arg, switch_memory_pool_t *pool=NULL) : + Thread(T obj, A arg, switch_memory_pool_t *pool=NULL) : _thread_info(new ThreadData::Return, A>(obj, arg)), _pool(pool), _can_delete_pool(false) @@ -168,7 +168,7 @@ struct Thread : ThreadCommon } switch_threadattr_stacksize_set( - (switch_threadattr_t *)_thread_info->_attribute, + (switch_threadattr_t *)_thread_info->_attribute, SWITCH_THREAD_STACKSIZE); if(!priority()) @@ -178,11 +178,11 @@ struct Thread : ThreadCommon } - ~Thread() + ~Thread() { if(_thread_info) delete _thread_info; - + if (_can_delete_pool) switch_core_destroy_memory_pool(&_pool); } @@ -202,10 +202,10 @@ struct Thread : ThreadCommon if(!_pool || !_thread_info->_attribute) return false; - switch_thread_create((switch_thread_t**)&_thread_info->_self, - (switch_threadattr_t *)_thread_info->_attribute, - run, - _thread_info, + switch_thread_create((switch_thread_t**)&_thread_info->_self, + (switch_threadattr_t *)_thread_info->_attribute, + run, + _thread_info, _pool); if(!_thread_info->_self) @@ -223,13 +223,13 @@ struct Thread : ThreadCommon * * SWITCH_DECLARE(switch_status_t) switch_thread_join(switch_status_t *retval, switch_thread_t *thd); */ - + if(!_thread_info->_self) return -2; int retval = 0; - if(switch_thread_join((switch_status_t*)&retval, + if(switch_thread_join((switch_status_t*)&retval, (switch_thread_t *)_thread_info->_self) != 0) return -1; @@ -267,7 +267,7 @@ private: { #ifndef WIN32 struct sched_param param; - + struct apr_threadattr_t *myattr = (struct apr_threadattr_t *)_thread_info->_attribute; if (pthread_attr_setschedpolicy( @@ -307,13 +307,13 @@ protected: static void *SWITCH_THREAD_FUNC run(BaseThreadType *thread, void * obj) { - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, // "Starting new Thread\n"); ThreadDataCommon * data = (ThreadDataCommon *)obj; int retval = data->run(); - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, // "Stopping new Thread = %d\n", retval); ((Thread *)(data->_thread))->exit(retval); diff --git a/src/mod/endpoints/mod_khomp/commons/tagged_union.hpp b/src/mod/endpoints/mod_khomp/commons/base/tagged_union.hpp similarity index 84% rename from src/mod/endpoints/mod_khomp/commons/tagged_union.hpp rename to src/mod/endpoints/mod_khomp/commons/base/tagged_union.hpp index 1616268c5f..f46aab0b75 100644 --- a/src/mod/endpoints/mod_khomp/commons/tagged_union.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/tagged_union.hpp @@ -42,11 +42,14 @@ #ifndef _TAGGED_UNION_HPP_ #define _TAGGED_UNION_HPP_ -#include - -#include #include +#include +#include +#include + +#include + namespace Tagged { struct EmptyUnion @@ -69,7 +72,7 @@ namespace Tagged ~EmptyUnion() { _adjusted = false; }; - bool operator==(const EmptyUnion & o) + bool operator==(const EmptyUnion & o) const { return true; }; @@ -80,24 +83,24 @@ namespace Tagged void setup(void) { _adjusted = true; }; protected: - bool value_set(void) { return false; }; - bool value_get(void) { return false; }; + bool value_set(void) const { return false; }; + bool value_get(void) const { return false; }; - bool value_check(void) { return false; }; + bool value_check(void) const { return false; }; template < typename S > - bool value_visit(S & visitor, typename S::ReturnType & ret) + bool value_visit(S & visitor, typename S::ReturnType & ret) const { return false; }; template < typename S > - bool value_visit_void(S & visitor) + bool value_visit_void(S & visitor) const { return false; }; - bool adjusted() { return _adjusted; }; + bool adjusted() const { return _adjusted; }; private: bool _adjusted; @@ -114,7 +117,7 @@ namespace Tagged // constructor with initializer template < typename U > - Union( U value ) + Union(U value) : _value(0) { set(value); @@ -123,7 +126,7 @@ namespace Tagged // copy constructor Union(const Union & o) : E(static_cast(o)), - _value( (o._value ? new const V(*(o._value)) : 0) ) + _value( (o._value ? new V(*(o._value)) : 0) ) {}; // copy assignment operator @@ -137,7 +140,7 @@ namespace Tagged if (o._value) { - _value = new const V(*(o._value)); + _value = new V(*(o._value)); } E::operator=(static_cast(o)); @@ -163,18 +166,21 @@ namespace Tagged } template < typename U > - bool check(void) + bool check(void) const { - return value_check(static_cast(0)); + return value_check(static_cast< const U * const>(0)); }; template < typename U > - const U & get(void) + U & get(void) const { - const U * res = 0; + U * res = 0; + + if (!E::adjusted()) + throw std::runtime_error("tagged union empty!"); if (!value_get(&res) || !res) - throw std::runtime_error("type mismatch"); + throw std::runtime_error(STG(FMT("type mismatch when asked for '%s'") % typeid(U).name())); return *res; }; @@ -190,7 +196,7 @@ namespace Tagged }; template < typename S > - typename S::ReturnType visit(S visitor) + typename S::ReturnType visit(S visitor) const { typename S::ReturnType ret; @@ -201,7 +207,7 @@ namespace Tagged }; template < typename S > - void visit_void(S visitor) + void visit_void(S visitor) const { if (!value_visit_void(visitor)) throw std::runtime_error("unable to visit empty value"); @@ -219,7 +225,7 @@ namespace Tagged }; // compare (equal) operator - bool operator==(const Union & o) + bool operator==(const Union & o) const { bool are_equal = false; @@ -236,7 +242,7 @@ namespace Tagged }; // compare types - bool sameType(const Union & o) + bool sameType(const Union & o) const { if ((!(_value) && !(o._value)) || (_value && o._value)) return E::operator==(static_cast(o)); @@ -254,13 +260,13 @@ namespace Tagged bool value_set(V val) { - _value = new const V(val); + _value = new V(val); E::setup(); return true; }; - bool value_get(const V ** val) + bool value_get(V ** val) const { if (!_value) return false; @@ -269,14 +275,14 @@ namespace Tagged return true; } - bool value_check(const V * const junk) + bool value_check(const V * const junk) const { (void)junk; return (_value != 0); }; template < typename S > - bool value_visit(S & visitor, typename S::ReturnType & ret) + bool value_visit(S & visitor, typename S::ReturnType & ret) const { if (_value) { @@ -288,7 +294,7 @@ namespace Tagged }; template < typename S > - bool value_visit_void(S & visitor) + bool value_visit_void(S & visitor) const { if (_value) { @@ -300,7 +306,7 @@ namespace Tagged }; private: - const V * _value; + V * _value; }; }; diff --git a/src/mod/endpoints/mod_khomp/commons/thread.hpp b/src/mod/endpoints/mod_khomp/commons/base/thread.hpp similarity index 100% rename from src/mod/endpoints/mod_khomp/commons/thread.hpp rename to src/mod/endpoints/mod_khomp/commons/base/thread.hpp diff --git a/src/mod/endpoints/mod_khomp/commons/timer.cpp b/src/mod/endpoints/mod_khomp/commons/base/timer.cpp similarity index 96% rename from src/mod/endpoints/mod_khomp/commons/timer.cpp rename to src/mod/endpoints/mod_khomp/commons/base/timer.cpp index 36e32f521a..0cb0ac4340 100644 --- a/src/mod/endpoints/mod_khomp/commons/timer.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/timer.cpp @@ -276,6 +276,20 @@ bool TimerTraits::traits_restart (TimerTraits::Index & idx, bool force) return ret; } +void TimerTraits::traits_setup(TimerTraits::Index * idx, unsigned int msecs, const void * func, void * data, unsigned int value) +{ + _mutex.lock(); + + if (idx->valid) + { + (void)traits_del_unlocked(*idx); + } + + *idx = traits_add_unlocked(msecs, func, data, value); + + _mutex.unlock(); +} + bool TimerTraits::traits_del_unlocked (TimerTraits::Index & idx) { bool ret = false; diff --git a/src/mod/endpoints/mod_khomp/commons/timer.hpp b/src/mod/endpoints/mod_khomp/commons/base/timer.hpp similarity index 93% rename from src/mod/endpoints/mod_khomp/commons/timer.hpp rename to src/mod/endpoints/mod_khomp/commons/base/timer.hpp index 382efa1645..24d115d991 100644 --- a/src/mod/endpoints/mod_khomp/commons/timer.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/timer.hpp @@ -125,6 +125,8 @@ struct TimerTraits bool traits_del (Index & idx); bool traits_del (const void * func, const void * data = 0, unsigned int value = 0); + void traits_setup(Index * idx, unsigned int msecs, const void * func, void * data = 0, unsigned int value = 0); + /* timer start/stop functions */ bool start(void); bool stop(void); @@ -169,7 +171,7 @@ struct TimerTraits }; template < typename F, typename D > -struct TimerTemplate: NEW_REFCOUNTER(TimerTemplate< F, D >) +struct TimerTemplate: COUNTER_SUPER(TimerTemplate< F, D >) { typedef TimerTraits::Index Index; typedef TimerTraits::Control Control; @@ -179,7 +181,7 @@ struct TimerTemplate: NEW_REFCOUNTER(TimerTemplate< F, D >) {}; TimerTemplate(const TimerTemplate< F, D > & o) - : INC_REFCOUNTER(o, TimerTemplate< F, D >), + : COUNTER_REFER(o, TimerTemplate< F, D >), _timer(o._timer) {}; @@ -192,6 +194,11 @@ struct TimerTemplate: NEW_REFCOUNTER(TimerTemplate< F, D >) bool start() { return _timer->start(); } bool stop() { return _timer->stop(); } + inline void setup(Index * idx, unsigned int msecs, F * func, D data = 0, unsigned int value = 0) + { + _timer->traits_setup(idx, msecs, (const void *)func, (void *)(data), value); + } + inline Index add(unsigned int msecs, F * func, D data = 0, unsigned int value = 0) { return _timer->traits_add(msecs, (const void *)func, (void *)(data), value); diff --git a/src/mod/endpoints/mod_khomp/commons/types.hpp b/src/mod/endpoints/mod_khomp/commons/base/types.hpp similarity index 88% rename from src/mod/endpoints/mod_khomp/commons/types.hpp rename to src/mod/endpoints/mod_khomp/commons/base/types.hpp index adbd8abe36..5ab6d292c6 100644 --- a/src/mod/endpoints/mod_khomp/commons/types.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/types.hpp @@ -55,15 +55,33 @@ /*** Used for checking information on classes and stuff.. ***/ template< typename T > -class IsClass +struct IsClass { protected: - template< typename X > static char ( &A( void(X::*)() ) )[1]; - template< typename X > static char ( &A( X ) )[2]; + template < typename X > static char ( &A( void(X::*)() ) )[1]; + template < typename X > static char ( &A( X ) )[2]; public: static bool const Result = sizeof( A< T >(0) ) == 1; }; +template < typename T > +struct IsConst +{ + static bool const Result = false; +}; + +template < typename T > +struct IsConst< const T > +{ + static bool const Result = true; +}; + +template < typename T > +struct IsConst< T const * > +{ + static bool const Result = true; +}; + /*** Used for template metaprogramming ***/ template < bool Value, typename Then, typename Else > diff --git a/src/mod/endpoints/mod_khomp/commons/variant.hpp b/src/mod/endpoints/mod_khomp/commons/base/variable.hpp similarity index 53% rename from src/mod/endpoints/mod_khomp/commons/variant.hpp rename to src/mod/endpoints/mod_khomp/commons/base/variable.hpp index 410a770a6e..efeb0f53b7 100644 --- a/src/mod/endpoints/mod_khomp/commons/variant.hpp +++ b/src/mod/endpoints/mod_khomp/commons/base/variable.hpp @@ -11,7 +11,7 @@ the specific language governing rights and limitations under the License. Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + "GNU Lesser General Public License 2.1" license (the "LGPL" License), in which case the provisions of "LGPL License" are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of @@ -41,87 +41,84 @@ #include -#include +#ifndef _VARIABLE_HPP_ +#define _VARIABLE_HPP_ -#ifndef _VARIANT_H_ -#define _VARIANT_H_ - -/* this is internal, should not be used by the user */ -struct NoArgumentDefined {}; - -template < typename UserReturnType, typename UserArgumentType = NoArgumentDefined > -struct VariantBaseType +template < typename R > +struct VariableBaseTable { - typedef UserReturnType ReturnType; - typedef UserArgumentType ArgumentType; - - virtual ~VariantBaseType() {}; - - virtual int which() = 0; - - virtual ReturnType visit(void) { return ReturnType(); }; - virtual ReturnType visit(ArgumentType) { return ReturnType(); }; + R value; }; -template < typename BaseType = VariantBaseType < void > > -struct Variant: NEW_REFCOUNTER(Variant < BaseType >) +struct EmptyVariable {}; + +template < typename R > +struct Variable { - typedef typename BaseType::ReturnType ReturnType; - typedef typename BaseType::ArgumentType ArgumentType; + protected: + typedef VariableBaseTable< R > BaseType; - struct InvalidType {}; + typedef const BaseType * ConstObjType; + typedef BaseType * ObjType; + typedef R BaseType::* VarType; - Variant(BaseType * value, bool is_owner = false) - : _value(value), _is_owner(is_owner) {}; + public: + template < typename ConstructorObjType > + Variable(R ConstructorObjType::* v) + : _adjusted(true), + _variable(reinterpret_cast(v)) + {}; - Variant(const Variant & v) - : INC_REFCOUNTER(v, Variant < BaseType >), - _value(v._value), _is_owner(v._is_owner) {}; + Variable() + : _adjusted(false) + {}; - virtual ~Variant() {}; - - void unreference() + template < typename MemberType > + void operator=(const MemberType v) { - if (_is_owner && _value) - { - delete _value; - _value = 0; - } - }; - - template < typename ValueType > - ValueType & get(void) - { - try - { - ValueType & ret = dynamic_cast < ValueType & > (*_value); - return ret; - } - catch (std::bad_cast & e) - { - throw InvalidType(); - } - }; - - int which() - { - return _value->which(); + _adjusted = true; + _variable = reinterpret_cast(v); } - ReturnType visit(void) + template < typename Type > + R & operator()(Type * obj) const { - return _value->visit(); + if (!_adjusted) + throw EmptyVariable(); + + return (reinterpret_cast< ObjType >(obj))->*(_variable); } - ReturnType visit(ArgumentType arg) + template < typename Type > + R & operator()(Type & obj) const { - return _value->visit(arg); + if (!_adjusted) + throw EmptyVariable(); + + return (reinterpret_cast< ObjType >(&obj))->*(_variable); } - protected: - BaseType * _value; - bool _is_owner; + template < typename Type > + const R & operator()(const Type * obj) const + { + if (!_adjusted) + throw EmptyVariable(); + + return (reinterpret_cast< ConstObjType >(obj))->*(_variable); + } + + template < typename Type > + const R & operator()(const Type & obj) const + { + if (!_adjusted) + throw EmptyVariable(); + + return (reinterpret_cast< ConstObjType >(&obj))->*(_variable); + } + + protected: + bool _adjusted; + VarType _variable; }; -#endif /* _VARIANT_H_ */ - +#endif /* _VARIABLE_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/verbose.cpp b/src/mod/endpoints/mod_khomp/commons/base/verbose.cpp similarity index 82% rename from src/mod/endpoints/mod_khomp/commons/verbose.cpp rename to src/mod/endpoints/mod_khomp/commons/base/verbose.cpp index 182d159ca1..bdc412e231 100644 --- a/src/mod/endpoints/mod_khomp/commons/verbose.cpp +++ b/src/mod/endpoints/mod_khomp/commons/base/verbose.cpp @@ -54,11 +54,11 @@ /********************************************/ -std::string Verbose::channelStatus(int32 dev, int32 obj, int32 cs, Verbose::Presentation fmt) +std::string Verbose::channelStatus(const int32 dev, const int32 obj, const int32 cs, const Verbose::Presentation fmt) const { try { - K3L_CHANNEL_CONFIG & config = _api.channel_config(dev, obj); + const K3L_CHANNEL_CONFIG & config = _api.channel_config(dev, obj); return Verbose::channelStatus(config.Signaling, cs, fmt); } catch (...) @@ -68,14 +68,14 @@ std::string Verbose::channelStatus(int32 dev, int32 obj, int32 cs, Verbose::Pres } #if K3L_AT_LEAST(2,0,0) -std::string Verbose::event(int32 obj, K3L_EVENT *ev, R2CountryType r2_country, Verbose::Presentation fmt) +std::string Verbose::event(const int32 obj, const K3L_EVENT * const ev, const R2CountryType r2_country, const Verbose::Presentation fmt) const #else -std::string Verbose::event(int32 obj, K3L_EVENT *ev, Verbose::Presentation fmt) +std::string Verbose::event(const int32 obj, const K3L_EVENT * const ev, const Verbose::Presentation fmt) const #endif { try { - K3L_CHANNEL_CONFIG & config = _api.channel_config(ev->DeviceId, obj); + const K3L_CHANNEL_CONFIG & config = _api.channel_config(ev->DeviceId, obj); #if K3L_AT_LEAST(2,0,0) return Verbose::event(config.Signaling, obj, ev, r2_country, fmt); #else @@ -94,7 +94,7 @@ std::string Verbose::event(int32 obj, K3L_EVENT *ev, Verbose::Presentation fmt) /********************************************/ -std::string Verbose::echoLocation(KEchoLocation ec, Verbose::Presentation fmt) +std::string Verbose::echoLocation(const KEchoLocation ec, const Verbose::Presentation fmt) { switch (ec) { @@ -109,7 +109,7 @@ std::string Verbose::echoLocation(KEchoLocation ec, Verbose::Presentation fmt) return presentation(fmt, "", "Unknown"); }; -std::string Verbose::echoCancellerConfig(KEchoCancellerConfig ec, Verbose::Presentation fmt) +std::string Verbose::echoCancellerConfig(KEchoCancellerConfig ec, const Verbose::Presentation fmt) { switch (ec) { @@ -124,21 +124,24 @@ std::string Verbose::echoCancellerConfig(KEchoCancellerConfig ec, Verbose::Prese return presentation(fmt, "", "Unknown"); }; -// TODO: internal_deviceType / internal_deviceModel +std::string Verbose::deviceName(const KDeviceType dt, const int32 model, const Verbose::Presentation fmt) +{ + return deviceName(dt, model, 0, fmt); +} -std::string Verbose::deviceName(KDeviceType dt, int32 model, Verbose::Presentation fmt) +std::string Verbose::deviceName(const KDeviceType dt, const int32 model, const int32 count, const Verbose::Presentation fmt) { try { std::string value; - value += internal_deviceType(dt); + value += internal_deviceType(dt, count); value += "-"; - value += internal_deviceModel(dt, model); + value += internal_deviceModel(dt, model, count); return value; } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[type/model='%d/%d']") % (int)dt % (int)model), @@ -146,13 +149,18 @@ std::string Verbose::deviceName(KDeviceType dt, int32 model, Verbose::Presentati } } -std::string Verbose::deviceType(KDeviceType dt, Verbose::Presentation fmt) +std::string Verbose::deviceType(const KDeviceType dt, const Verbose::Presentation fmt) +{ + return deviceType(dt, 0, fmt); +} + +std::string Verbose::deviceType(const KDeviceType dt, const int32 count, const Verbose::Presentation fmt) { try { - return internal_deviceType(dt); + return internal_deviceType(dt, count); } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[type='%d']") % (int)dt), @@ -160,11 +168,11 @@ std::string Verbose::deviceType(KDeviceType dt, Verbose::Presentation fmt) } } -std::string Verbose::internal_deviceType(KDeviceType dt) +std::string Verbose::internal_deviceType(const KDeviceType dt, const int32 count) { switch (dt) { - case kdtE1: return "K2E1"; + case kdtE1: return (count > 34 || count == 0 ? "K2E1" : "K1E1"); #if K3L_AT_LEAST(1,6,0) case kdtFXO: return "KFXO"; @@ -183,10 +191,10 @@ std::string Verbose::internal_deviceType(KDeviceType dt) #endif #if K3L_AT_LEAST(1,5,0) - case kdtE1IP: return "K2E1"; + case kdtE1IP: return (count > 90 || count == 0 ? "K2E1" : "K1E1"); #endif #if K3L_AT_LEAST(1,5,1) - case kdtE1Spx: return "K2E1"; + case kdtE1Spx: return (count > 30 || count == 0 ? "K2E1" : "K1E1"); case kdtGWIP: return "KGWIP"; #endif @@ -202,7 +210,6 @@ std::string Verbose::internal_deviceType(KDeviceType dt) case kdtGSMUSBSpx: return "KGSMUSB"; case kdtE1FXSSpx: return "KE1FXS"; - case kdtDevTypeCount: return "DevTypeCount"; #endif #if K3L_EXACT(2,1,0) @@ -212,18 +219,24 @@ std::string Verbose::internal_deviceType(KDeviceType dt) #if K3L_AT_LEAST(2,2,0) case kdtE1AdHoc: return "KE1AdHoc"; #endif + case kdtDevTypeCount: break; } throw internal_not_found(); } -std::string Verbose::deviceModel(KDeviceType dt, int32 model, Verbose::Presentation fmt) +std::string Verbose::deviceModel(const KDeviceType dt, const int32 model, const Verbose::Presentation fmt) +{ + return deviceModel(dt, model, 0, fmt); +}; + +std::string Verbose::deviceModel(const KDeviceType dt, const int32 model, const int32 count, const Verbose::Presentation fmt) { try { - return internal_deviceModel(dt, model); + return internal_deviceModel(dt, model, count); } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[model='%d']") % (int)model), @@ -231,17 +244,17 @@ std::string Verbose::deviceModel(KDeviceType dt, int32 model, Verbose::Presentat } } -std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) +std::string Verbose::internal_deviceModel(const KDeviceType dt, const int32 model, const int32 count) { switch (dt) { case kdtE1: switch ((KE1DeviceModel)model) { - case kdmE1600: return "600"; - case kdmE1600E: return "600E"; + case kdmE1600: return (count > 34 || count == 0 ? "600" : "300"); + case kdmE1600E: return (count > 34 || count == 0 ? "600" : "300"); #if K3L_AT_LEAST(2,0,0) - case kdmE1600EX: return "600EX"; + case kdmE1600EX: return (count > 34 || count == 0 ? "600" : "300"); #endif } throw internal_not_found(); @@ -255,14 +268,38 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) #endif { #if K3L_AT_LEAST(1,6,0) - case kdmFXO80: return "80"; - case kdmFXOHI: return "HI"; + case kdmFXO80: + switch (count) + { + case 0: /* default */ + case 8: return "80"; + case 4: return "40"; + } + break; + + case kdmFXOHI: + switch (count) + { + case 0: /* default */ + case 8: return "80-HI"; + case 4: return "40-HI"; + } + break; + case kdmFXO160HI: return "160HI"; #if K3L_AT_LEAST(2,1,0) - case kdmFXO240HI: return "240HI"; + case kdmFXO240HI: return "240HI"; #endif #else - case kdmFXO80: return "80"; + case kdmFXO80: + switch (count) + { + case 0: /* default */ + case 8: return "80"; + case 4: return "40"; + } + break; + #endif } @@ -300,13 +337,13 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) switch ((KE1GWDeviceModel)model) { #if K3L_AT_LEAST(1,6,0) - case kdmE1GW640: return "640"; + case kdmE1GW640: return "640"; #if K3L_AT_LEAST(2,0,0) case kdmE1GW640EX: return "640EX"; #endif #else - case kdmE1600V: return "600V"; - case kdmE1600EV: return "600EV"; + case kdmE1600V: return (count > 34 || count == 0 ? "600V" : "300V" ); + case kdmE1600EV: return (count > 34 || count == 0 ? "600EV" : "600EV"); #endif } @@ -337,12 +374,12 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) switch ((KE1IPDeviceModel)model) { #if K3L_AT_LEAST(1,6,0) - case kdmE1IP: return "E1IP"; + case kdmE1IP: return "E1IP"; #if K3L_AT_LEAST(2,0,0) case kdmE1IPEX: return "E1IPEX"; #endif #else - case kdmE1600EG: return "600EG"; + case kdmE1600EG: return (count > 90 || count == 0 ? "600EG" : "300EG"); #endif } @@ -353,8 +390,8 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) case kdtE1Spx: switch ((KE1SpxDeviceModel)model) { - case kdmE1Spx: return "SPX"; - case kdm2E1Based: return "SPX-2E1"; + case kdmE1Spx: return "SPX"; + case kdm2E1Based: return "SPX-2E1"; #if K3L_AT_LEAST(2,0,0) case kdmE1SpxEX: return "SPXEX"; #endif @@ -367,7 +404,7 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) #if K3L_AT_LEAST(1,6,0) case kdmGWIP: return "GWIP"; #if K3L_AT_LEAST(2,0,0) - case kdmGWIPEX: return "GWIPEX"; + case kdmGWIPEX: return "GWIPEX"; #endif #else case kdmGW600G: return "600G"; @@ -382,9 +419,9 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) case kdtFXS: switch ((KFXSDeviceModel)model) { - case kdmFXS300: return "300"; + case kdmFXS300: return (count > 30 || count == 0 ? "300" : "150"); #if K3L_AT_LEAST(2,0,0) - case kdmFXS300EX: return "300EX"; + case kdmFXS300EX: return (count > 30 || count == 0 ? "300EX" : "150EX"); #endif } @@ -393,10 +430,10 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) case kdtFXSSpx: switch ((KFXSSpxDeviceModel)model) { - case kdmFXSSpx300: return "SPX"; - case kdmFXSSpx2E1Based: return "SPX-2E1"; + case kdmFXSSpx300: return (count > 30 || count == 0 ? "300-SPX" : "150-SPX"); + case kdmFXSSpx2E1Based: return "SPX-2E1"; #if K3L_AT_LEAST(2,0,0) - case kdmFXSSpx300EX: return "SPXEX"; + case kdmFXSSpx300EX: return (count > 30 || count == 0 ? "300-SPXEX" : "150-SPXEX"); #endif } @@ -405,9 +442,27 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) case kdtGSM: switch ((KGSMDeviceModel)model) { - case kdmGSM: return "40"; + case kdmGSM: + switch (count) + { + case 0: /* default */ + case 4: return "40"; + case 3: return "30"; + case 2: return "20"; + case 1: return "10"; + } + break; #if K3L_AT_LEAST(2,0,0) - case kdmGSMEX: return "40EX"; + case kdmGSMEX: + switch (count) + { + case 0: /* default */ + case 4: return "40EX"; + case 3: return "80EX"; + case 2: return "20EX"; + case 1: return "10EX"; + } + break; #endif } @@ -416,9 +471,27 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) case kdtGSMSpx: switch ((KGSMSpxDeviceModel)model) { - case kdmGSMSpx: return "SPX"; + case kdmGSMSpx: + switch (count) + { + case 0: /* default */ + case 4: return "40"; + case 3: return "30"; + case 2: return "20"; + case 1: return "10"; + } + break; #if K3L_AT_LEAST(2,0,0) - case kdmGSMSpxEX: return "SPXEX"; + case kdmGSMSpxEX: + switch (count) + { + case 0: /* default */ + case 4: return "40-SPXEX"; + case 3: return "80-SPXEX"; + case 2: return "20-SPXEX"; + case 1: return "10-SPXEX"; + } + break; #endif } @@ -444,8 +517,8 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) case kdtE1FXSSpx: switch ((KGSMSpxDeviceModel)model) { - case kdmE1FXSSpx: return "SPX"; - case kdmE1FXSSpxEX: return "SPXEX"; + case kdmE1FXSSpx: return "450-SPX"; + case kdmE1FXSSpxEX: return "450-SPXEX"; } throw internal_not_found(); @@ -476,7 +549,7 @@ std::string Verbose::internal_deviceModel(KDeviceType dt, int32 model) throw internal_not_found(); } -std::string Verbose::signaling(KSignaling sig, Verbose::Presentation fmt) +std::string Verbose::signaling(const KSignaling sig, const Verbose::Presentation fmt) { switch (sig) { @@ -523,7 +596,7 @@ std::string Verbose::signaling(KSignaling sig, Verbose::Presentation fmt) STG(FMT("Unknown signaling (%d)") % (int)sig)); } -std::string Verbose::systemObject(KSystemObject so, Verbose::Presentation fmt) +std::string Verbose::systemObject(const KSystemObject so, const Verbose::Presentation fmt) { switch (so) { @@ -544,7 +617,7 @@ std::string Verbose::systemObject(KSystemObject so, Verbose::Presentation fmt) STG(FMT("Unknown object (%d)") % (int)so)); } -std::string Verbose::mixerTone(KMixerTone mt, Verbose::Presentation fmt) +std::string Verbose::mixerTone(const KMixerTone mt, const Verbose::Presentation fmt) { switch (mt) { @@ -567,7 +640,7 @@ std::string Verbose::mixerTone(KMixerTone mt, Verbose::Presentation fmt) STG(FMT("Unknonwn tone (%d)") % (int)mt)); } -std::string Verbose::mixerSource(KMixerSource ms, Verbose::Presentation fmt) +std::string Verbose::mixerSource(const KMixerSource ms, const Verbose::Presentation fmt) { switch (ms) { @@ -588,7 +661,7 @@ std::string Verbose::mixerSource(KMixerSource ms, Verbose::Presentation fmt) STG(FMT("Unknonwn source (%d)") % (int)ms)); } -std::string Verbose::channelFeatures(int32 flags, Verbose::Presentation fmt) +std::string Verbose::channelFeatures(const int32 flags, const Verbose::Presentation fmt) { if (0x00 != flags) { @@ -603,9 +676,7 @@ std::string Verbose::channelFeatures(int32 flags, Verbose::Presentation fmt) if (kcfHighImpEvents & flags) strs.add(presentation(fmt, "HighImpEvents", "High Impedance Events")); #if K3L_AT_LEAST(1,6,0) if (kcfCallAnswerInfo & flags) strs.add(presentation(fmt, "CallAnswerInfo", "Call Answer Info")); -#if !K3L_AT_LEAST(2,2,0) if (kcfOutputVolume & flags) strs.add(presentation(fmt, "OutputVolume", "Output Volume")); -#endif if (kcfPlayerAGC & flags) strs.add(presentation(fmt, "PlayerAGC", "Player AGC")); #endif @@ -617,7 +688,7 @@ std::string Verbose::channelFeatures(int32 flags, Verbose::Presentation fmt) PRESENTATION_CHECK_RETURN(fmt, "", "No features"); } -std::string Verbose::seizeFail(KSeizeFail sf, Verbose::Presentation fmt) +std::string Verbose::seizeFail(const KSeizeFail sf, const Verbose::Presentation fmt) { switch (sf) { @@ -635,7 +706,7 @@ std::string Verbose::seizeFail(KSeizeFail sf, Verbose::Presentation fmt) } #if K3L_AT_LEAST(1,5,0) -std::string Verbose::internal_sipFailures(KSIP_Failures code, Verbose::Presentation fmt) +std::string Verbose::internal_sipFailures(const KSIP_Failures code, const Verbose::Presentation fmt) { switch (code) { @@ -691,13 +762,13 @@ std::string Verbose::internal_sipFailures(KSIP_Failures code, Verbose::Presentat throw internal_not_found(); } -std::string Verbose::sipFailures(KSIP_Failures code, Verbose::Presentation fmt) +std::string Verbose::sipFailures(const KSIP_Failures code, const Verbose::Presentation fmt) { try { return internal_sipFailures(code, fmt); } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[KSIP_Failures='%d']") % (int)code), @@ -708,7 +779,7 @@ std::string Verbose::sipFailures(KSIP_Failures code, Verbose::Presentation fmt) #endif #if K3L_AT_LEAST(1,5,1) -std::string Verbose::internal_isdnCause(KQ931Cause code, Verbose::Presentation fmt) +std::string Verbose::internal_isdnCause(const KQ931Cause code, const Verbose::Presentation fmt) { switch (code) { @@ -810,13 +881,13 @@ std::string Verbose::internal_isdnCause(KQ931Cause code, Verbose::Presentation f throw internal_not_found(); } -std::string Verbose::isdnCause(KQ931Cause code, Verbose::Presentation fmt) +std::string Verbose::isdnCause(const KQ931Cause code, const Verbose::Presentation fmt) { try { return internal_isdnCause(code); } - catch (internal_not_found & e) + catch (internal_not_found e) { return STG(FMT("[KQ931Cause='%d']") % (int)code); } @@ -824,7 +895,7 @@ std::string Verbose::isdnCause(KQ931Cause code, Verbose::Presentation fmt) #endif #if K3L_AT_LEAST(1,5,2) -std::string Verbose::isdnDebug(int32 flags, Verbose::Presentation fmt) +std::string Verbose::isdnDebug(const int32 flags, const Verbose::Presentation fmt) { if (0x00 != flags) { @@ -844,9 +915,9 @@ std::string Verbose::isdnDebug(int32 flags, Verbose::Presentation fmt) #endif #if K3L_AT_LEAST(2,0,0) -std::string Verbose::internal_signGroupB(KSignGroupB group, R2CountryType country, Verbose::Presentation fmt) +std::string Verbose::internal_signGroupB(const KSignGroupB group, const R2CountryType country, const Verbose::Presentation fmt) #else -std::string Verbose::internal_signGroupB(KSignGroupB group, Verbose::Presentation fmt) +std::string Verbose::internal_signGroupB(const KSignGroupB group, const Verbose::Presentation fmt) #endif { #if K3L_AT_LEAST(2,0,0) @@ -955,9 +1026,9 @@ std::string Verbose::internal_signGroupB(KSignGroupB group, Verbose::Presentatio } #if K3L_AT_LEAST(2,0,0) -std::string Verbose::signGroupB(KSignGroupB group, R2CountryType r2_country, Verbose::Presentation fmt) +std::string Verbose::signGroupB(const KSignGroupB group, const R2CountryType r2_country, const Verbose::Presentation fmt) #else -std::string Verbose::signGroupB(KSignGroupB group, Verbose::Presentation fmt) +std::string Verbose::signGroupB(const KSignGroupB group, const Verbose::Presentation fmt) #endif { try @@ -968,7 +1039,7 @@ std::string Verbose::signGroupB(KSignGroupB group, Verbose::Presentation fmt) return internal_signGroupB(group, fmt); #endif } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[KSignGroupB='%d']") % (int)group), @@ -977,9 +1048,9 @@ std::string Verbose::signGroupB(KSignGroupB group, Verbose::Presentation fmt) } #if K3L_AT_LEAST(2,0,0) -std::string Verbose::internal_signGroupII(KSignGroupII group, R2CountryType country, Verbose::Presentation fmt) +std::string Verbose::internal_signGroupII(const KSignGroupII group, const R2CountryType country, const Verbose::Presentation fmt) #else -std::string Verbose::internal_signGroupII(KSignGroupII group, Verbose::Presentation fmt) +std::string Verbose::internal_signGroupII(const KSignGroupII group, const Verbose::Presentation fmt) #endif { #if K3L_AT_LEAST(2,0,0) @@ -1085,9 +1156,9 @@ std::string Verbose::internal_signGroupII(KSignGroupII group, Verbose::Presentat } #if K3L_AT_LEAST(2,0,0) -std::string Verbose::signGroupII(KSignGroupII group, R2CountryType r2_country, Verbose::Presentation fmt) +std::string Verbose::signGroupII(const KSignGroupII group, const R2CountryType r2_country, const Verbose::Presentation fmt) #else -std::string Verbose::signGroupII(KSignGroupII group, Verbose::Presentation fmt) +std::string Verbose::signGroupII(const KSignGroupII group, const Verbose::Presentation fmt) #endif { try @@ -1098,7 +1169,7 @@ std::string Verbose::signGroupII(KSignGroupII group, Verbose::Presentation fmt) return internal_signGroupII(group); #endif } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[KSignGroupII='%d']") % (int)group), @@ -1107,9 +1178,9 @@ std::string Verbose::signGroupII(KSignGroupII group, Verbose::Presentation fmt) } #if K3L_AT_LEAST(2,0,0) -std::string Verbose::callFail(KSignaling sig, R2CountryType country, int32 info, Verbose::Presentation fmt) +std::string Verbose::callFail(const KSignaling sig, const R2CountryType country, const int32 info, const Verbose::Presentation fmt) #else -std::string Verbose::callFail(KSignaling sig, int32 info, Verbose::Presentation fmt) +std::string Verbose::callFail(const KSignaling sig, const int32 info, const Verbose::Presentation fmt) #endif { try @@ -1130,8 +1201,10 @@ std::string Verbose::callFail(KSignaling sig, int32 info, Verbose::Presentation #endif #if K3L_EXACT(2,1,0) case ksigISUP: +#if !K3L_AT_LEAST(2,2,0) case ksigFax: #endif +#endif #if K3L_AT_LEAST(1,6,0) case ksigCAS_EL7: case ksigE1LC: @@ -1181,7 +1254,7 @@ std::string Verbose::callFail(KSignaling sig, int32 info, Verbose::Presentation #endif } } - catch (internal_not_found & e) + catch (internal_not_found e) { /* this exception is used for breaking the control flow */ } @@ -1191,7 +1264,7 @@ std::string Verbose::callFail(KSignaling sig, int32 info, Verbose::Presentation STG(FMT("Unknown call fail code for '%s' (%d)") % signaling(sig, fmt) % (int)info)); } -std::string Verbose::channelFail(KSignaling sig, int32 code, Verbose::Presentation fmt) +std::string Verbose::channelFail(const KSignaling sig, const int32 code, const Verbose::Presentation fmt) { try { @@ -1202,7 +1275,9 @@ std::string Verbose::channelFail(KSignaling sig, int32 code, Verbose::Presentati case ksigSIP: #if K3L_EXACT(2,1,0) case ksigISUP: +#if !K3L_AT_LEAST(2,2,0) case ksigFax: +#endif #endif throw internal_not_found(); @@ -1248,7 +1323,7 @@ std::string Verbose::channelFail(KSignaling sig, int32 code, Verbose::Presentati #endif } } - catch (internal_not_found & e) + catch (internal_not_found e) { /* this exception is used for breaking the control flow */ } @@ -1258,7 +1333,7 @@ std::string Verbose::channelFail(KSignaling sig, int32 code, Verbose::Presentati STG(FMT("Unknown channel fail code for '%s' (%d)") % signaling(sig, fmt) % (int)code)); } -std::string Verbose::internalFail(KInternalFail inf, Verbose::Presentation fmt) +std::string Verbose::internalFail(const KInternalFail inf, const Verbose::Presentation fmt) { switch (inf) { @@ -1277,7 +1352,7 @@ std::string Verbose::internalFail(KInternalFail inf, Verbose::Presentation fmt) STG(FMT("Unknown internal failure (%d)") % (int)inf)); } -std::string Verbose::linkErrorCounter(KLinkErrorCounter ec, Verbose::Presentation fmt) +std::string Verbose::linkErrorCounter(const KLinkErrorCounter ec, const Verbose::Presentation fmt) { switch (ec) { @@ -1304,7 +1379,7 @@ std::string Verbose::linkErrorCounter(KLinkErrorCounter ec, Verbose::Presentatio STG(FMT("Unknown link error counter (%d)") % (int)ec)); } -std::string Verbose::callStatus(KCallStatus code, Verbose::Presentation fmt) +std::string Verbose::callStatus(const KCallStatus code, const Verbose::Presentation fmt) { switch (code) { @@ -1319,7 +1394,7 @@ std::string Verbose::callStatus(KCallStatus code, Verbose::Presentation fmt) STG(FMT("Unknown call status (%d)") % (int)code)); } -std::string Verbose::linkStatus(KSignaling sig, int32 code, Verbose::Presentation fmt) +std::string Verbose::linkStatus(const KSignaling sig, const int32 code, const Verbose::Presentation fmt, const bool simpleStatus) { switch (sig) { @@ -1340,7 +1415,9 @@ std::string Verbose::linkStatus(KSignaling sig, int32 code, Verbose::Presentatio #endif #if K3L_EXACT(2,1,0) - case ksigFax: +#if !K3L_AT_LEAST(2,2,0) + case ksigFax: +#endif return presentation(fmt, "[ksigFax]", "FAX"); #endif case ksigContinuousEM: @@ -1386,9 +1463,18 @@ std::string Verbose::linkStatus(KSignaling sig, int32 code, Verbose::Presentatio if (kesUnknownAlarm & code) strs.add(presentation(fmt, "UnknownAlarm", "Slip alarm")); if (kesE1Error & code) strs.add(presentation(fmt, "E1Error", "E1 error")); - PRESENTATION_CHECK_RETURN(fmt, - STG(FMT("kes{%s}") % strs.merge(",")), - strs.merge(", ")); + if (simpleStatus) + { + PRESENTATION_CHECK_RETURN(fmt, + STG(FMT("kes{%s}") % *(strs.list().begin())), + *(strs.list().begin())); + } + else + { + PRESENTATION_CHECK_RETURN(fmt, + STG(FMT("kes{%s}") % strs.merge(",")), + strs.merge(", ")); + } } } @@ -1397,7 +1483,7 @@ std::string Verbose::linkStatus(KSignaling sig, int32 code, Verbose::Presentatio STG(FMT("Unknown link status for '%s' (%d)") % signaling(sig) % (int)code)); } -std::string Verbose::channelStatus(KSignaling sig, int32 flags, Verbose::Presentation fmt) +std::string Verbose::channelStatus(const KSignaling sig, const int32 flags, const Verbose::Presentation fmt) { try { @@ -1413,8 +1499,10 @@ std::string Verbose::channelStatus(KSignaling sig, int32 flags, Verbose::Present #if K3L_EXACT(2,1,0) case ksigISUP: return presentation(fmt, "[ksigISUP]", "ISUP trunk"); +#if !K3L_AT_LEAST(2,2,0) case ksigFax: return presentation(fmt, "[ksigFax]", "FAX"); +#endif #endif case ksigAnalog: @@ -1532,7 +1620,7 @@ std::string Verbose::channelStatus(KSignaling sig, int32 flags, Verbose::Present } } } - catch (internal_not_found & e) + catch (internal_not_found e) { /* we use this exception to break the control flow */ } @@ -1542,7 +1630,7 @@ std::string Verbose::channelStatus(KSignaling sig, int32 flags, Verbose::Present STG(FMT("Unknown channel status for '%s' (%d)") % signaling(sig) % flags)); } -std::string Verbose::status(KLibraryStatus code, Verbose::Presentation fmt) +std::string Verbose::status(const KLibraryStatus code, const Verbose::Presentation fmt) { switch (code) { @@ -1569,7 +1657,7 @@ std::string Verbose::status(KLibraryStatus code, Verbose::Presentation fmt) STG(FMT("Unknown library status (%d)") % (int)code)); } -std::string Verbose::h100configIndex(KH100ConfigIndex code, Verbose::Presentation fmt) +std::string Verbose::h100configIndex(const KH100ConfigIndex code, const Verbose::Presentation fmt) { switch (code) { @@ -1584,7 +1672,7 @@ std::string Verbose::h100configIndex(KH100ConfigIndex code, Verbose::Presentatio case khciCTbusFreq07_04: return presentation(fmt, "khciCTbusFreq07_04", "CTBus Frequency 07 04"); // TODO: find better name case khciCTbusFreq11_08: return presentation(fmt, "khciCTbusFreq11_08", "CTBus Frequency 11 08"); // TODO: find better name case khciCTbusFreq15_12: return presentation(fmt, "khciCTbusFreq15_12", "CTBus Frequency 15 12"); // TODO: find better name - case khciMax: return presentation(fmt, "khciMax", "Max"); // TODO: find better name + case khciMax: return presentation(fmt, "khciMax", "Max"); // TODO: find better name case khciMasterDevId: return presentation(fmt, "khciMasterDevId", "Master Device Number"); case khciSecMasterDevId: return presentation(fmt, "khciSecMasterDevId", "Secondary Master Device Number"); case khciCtNetrefDevId: return presentation(fmt, "khciCtNetrefDevId", "CTBus Network Reference Device Number"); @@ -1599,7 +1687,7 @@ std::string Verbose::h100configIndex(KH100ConfigIndex code, Verbose::Presentatio } #if K3L_AT_LEAST(1,6,0) -std::string Verbose::callStartInfo(KCallStartInfo code, Verbose::Presentation fmt) +std::string Verbose::callStartInfo(const KCallStartInfo code, const Verbose::Presentation fmt) { switch (code) { @@ -1615,13 +1703,13 @@ std::string Verbose::callStartInfo(KCallStartInfo code, Verbose::Presentation fm STG(FMT("Unknown call answer info (%d)") % (int)code)); } -std::string Verbose::gsmCallCause(KGsmCallCause code, Verbose::Presentation fmt) +std::string Verbose::gsmCallCause(const KGsmCallCause code, const Verbose::Presentation fmt) { try { return internal_gsmCallCause(code, fmt); } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[KGsmCallCause='%d']") % (int)code), @@ -1629,7 +1717,7 @@ std::string Verbose::gsmCallCause(KGsmCallCause code, Verbose::Presentation fmt) } } -std::string Verbose::internal_gsmCallCause(KGsmCallCause code, Verbose::Presentation fmt) +std::string Verbose::internal_gsmCallCause(const KGsmCallCause code, const Verbose::Presentation fmt) { switch (code) { @@ -1686,13 +1774,13 @@ std::string Verbose::internal_gsmCallCause(KGsmCallCause code, Verbose::Presenta throw internal_not_found(); } -std::string Verbose::gsmMobileCause(KGsmMobileCause code, Verbose::Presentation fmt) +std::string Verbose::gsmMobileCause(const KGsmMobileCause code, const Verbose::Presentation fmt) { try { return internal_gsmMobileCause(code, fmt); } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[KGsmMobileCause='%d']") % (int)code), @@ -1700,7 +1788,7 @@ std::string Verbose::gsmMobileCause(KGsmMobileCause code, Verbose::Presentation } } -std::string Verbose::internal_gsmMobileCause(KGsmMobileCause code, Verbose::Presentation fmt) +std::string Verbose::internal_gsmMobileCause(const KGsmMobileCause code, const Verbose::Presentation fmt) { switch (code) { @@ -1792,13 +1880,13 @@ std::string Verbose::internal_gsmMobileCause(KGsmMobileCause code, Verbose::Pres throw internal_not_found(); } -std::string Verbose::gsmSmsCause(KGsmSmsCause code, Verbose::Presentation fmt) +std::string Verbose::gsmSmsCause(const KGsmSmsCause code, const Verbose::Presentation fmt) { try { return internal_gsmSmsCause(code, fmt); } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[KGsmSmsCause='%d']") % (int)code), @@ -1806,7 +1894,7 @@ std::string Verbose::gsmSmsCause(KGsmSmsCause code, Verbose::Presentation fmt) } } -std::string Verbose::internal_gsmSmsCause(KGsmSmsCause code, Verbose::Presentation fmt) +std::string Verbose::internal_gsmSmsCause(const KGsmSmsCause code, const Verbose::Presentation fmt) { switch (code) { @@ -1890,13 +1978,13 @@ std::string Verbose::internal_gsmSmsCause(KGsmSmsCause code, Verbose::Presentati throw internal_not_found(); } -std::string Verbose::q931ProgressIndication(KQ931ProgressIndication code, Verbose::Presentation fmt) +std::string Verbose::q931ProgressIndication(const KQ931ProgressIndication code, const Verbose::Presentation fmt) { try { return internal_q931ProgressIndication(code); } - catch (internal_not_found & e) + catch (internal_not_found e) { PRESENTATION_CHECK_RETURN(fmt, STG(FMT("[KQ931ProgressIndication='%d']") % (int)code), @@ -1904,7 +1992,7 @@ std::string Verbose::q931ProgressIndication(KQ931ProgressIndication code, Verbos } } -std::string Verbose::internal_q931ProgressIndication(KQ931ProgressIndication code, Verbose::Presentation fmt) +std::string Verbose::internal_q931ProgressIndication(const KQ931ProgressIndication code, const Verbose::Presentation fmt) { switch (code) { @@ -1924,7 +2012,7 @@ std::string Verbose::internal_q931ProgressIndication(KQ931ProgressIndication cod #if K3L_AT_LEAST(2,1,0) -std::string Verbose::faxResult(KFaxResult code, Verbose::Presentation fmt) +std::string Verbose::faxResult(const KFaxResult code, const Verbose::Presentation fmt) { switch (code) { @@ -1945,7 +2033,7 @@ std::string Verbose::faxResult(KFaxResult code, Verbose::Presentation fmt) STG(FMT("Unknown fax result (%d)") % (int)code)); } -std::string Verbose::faxFileErrorCause(KFaxFileErrorCause code, Verbose::Presentation fmt) +std::string Verbose::faxFileErrorCause(const KFaxFileErrorCause code, const Verbose::Presentation fmt) { switch (code) { @@ -1969,307 +2057,12 @@ std::string Verbose::faxFileErrorCause(KFaxFileErrorCause code, Verbose::Present #endif - /********/ -std::string Verbose::commandName(int32 code) -{ - switch ((kcommand)code) - { - case K_CM_SEIZE: return "CM_SEIZE"; - case K_CM_SYNC_SEIZE: return "CM_SYNC_SEIZE"; - case K_CM_DIAL_DTMF: return "CM_DIAL_DTMF"; -#if K3L_AT_LEAST(1,6,0) - case K_CM_SIP_REGISTER: return "CM_SIP_REGISTER"; -#endif - case K_CM_DISCONNECT: return "CM_DISCONNECT"; - case K_CM_CONNECT: return "CM_CONNECT"; - case K_CM_PRE_CONNECT: return "CM_PRE_CONNECT"; - case K_CM_CAS_CHANGE_LINE_STT: return "CM_CAS_CHANGE_LINE_STT"; - case K_CM_CAS_SEND_MFC: return "CM_CAS_SEND_MFC"; - case K_CM_SET_FORWARD_CHANNEL: return "CM_SET_FORWARD_CHANNEL"; - case K_CM_CAS_SET_MFC_DETECT_MODE: return "CM_CAS_SET_MFC_DETECT_MODE"; - case K_CM_DROP_COLLECT_CALL: return "CM_DROP_COLLECT_CALL"; - -#if K3L_AT_LEAST(1,5,0) - case K_CM_MAKE_CALL: return "CM_MAKE_CALL"; -#endif - -#if K3L_AT_LEAST(1,4,0) - case K_CM_RINGBACK: return "CM_RINGBACK"; -#endif - -#if K3L_AT_LEAST(1,5,1) - case K_CM_USER_INFORMATION: return "CM_USER_INFORMATION"; -#endif - -#if K3L_AT_LEAST(1,4,0) && !K3L_AT_LEAST(2,2,0) - case K_CM_VOIP_SEIZE: return "CM_VOIP_SEIZE"; - -#if !K3L_AT_LEAST(2,0,0) - /* internal commands */ - case K_CM_VOIP_START_DEBUG: return "CM_VOIP_START_DEBUG"; - case K_CM_VOIP_STOP_DEBUG: return "CM_VOIP_STOP_DEBUG"; - case K_CM_VOIP_DUMP_STAT: return "CM_VOIP_DUMP_STAT"; -#endif -#endif - -#if K3L_AT_LEAST(1,5,2) && !K3L_AT_LEAST(2,0,0) - /* internal command */ - case K_CM_ISDN_DEBUG: return "CM_ISDN_DEBUG"; -#endif - - case K_CM_LOCK_INCOMING: return "CM_LOCK_INCOMING"; - case K_CM_UNLOCK_INCOMING: return "CM_UNLOCK_INCOMING"; - case K_CM_LOCK_OUTGOING: return "CM_LOCK_OUTGOING"; - case K_CM_UNLOCK_OUTGOING: return "CM_UNLOCK_OUTGOING"; - - case K_CM_START_SEND_FAIL: return "CM_START_SEND_FAIL"; - case K_CM_STOP_SEND_FAIL: return "CM_STOP_SEND_FAIL"; - -#if K3L_AT_LEAST(1,5,3) - case K_CM_END_OF_NUMBER: return "CM_END_OF_NUMBER"; -#endif - -#if K3L_AT_LEAST(1,6,0) - case K_CM_SS_TRANSFER: return "CM_SS_TRANSFER"; - case K_CM_GET_SMS: return "CM_GET_SMS"; - case K_CM_PREPARE_SMS: return "CM_PREPARE_SMS"; - case K_CM_SEND_SMS: return "CM_SEND_SMS"; -#endif -#if K3L_HAS_MPTY_SUPPORT - case K_CM_HOLD_SWITCH: return "CM_HOLD_SWITCH"; - case K_CM_MPTY_CONF: return "CM_MPTY_CONF"; - case K_CM_MPTY_SPLIT: return "CM_MPTY_SPLIT"; -#endif - - case K_CM_ENABLE_DTMF_SUPPRESSION: return "CM_ENABLE_DTMF_SUPPRESSION"; - case K_CM_DISABLE_DTMF_SUPPRESSION: return "CM_DISABLE_DTMF_SUPPRESSION"; - case K_CM_ENABLE_AUDIO_EVENTS: return "CM_ENABLE_AUDIO_EVENTS"; - case K_CM_DISABLE_AUDIO_EVENTS: return "CM_DISABLE_AUDIO_EVENTS"; - case K_CM_ENABLE_CALL_PROGRESS: return "CM_ENABLE_CALL_PROGRESS"; - case K_CM_DISABLE_CALL_PROGRESS: return "CM_DISABLE_CALL_PROGRESS"; - case K_CM_FLASH: return "CM_FLASH"; - case K_CM_ENABLE_PULSE_DETECTION: return "CM_ENABLE_PULSE_DETECTION"; - case K_CM_DISABLE_PULSE_DETECTION: return "CM_DISABLE_PULSE_DETECTION"; - case K_CM_ENABLE_ECHO_CANCELLER: return "CM_ENABLE_ECHO_CANCELLER"; - case K_CM_DISABLE_ECHO_CANCELLER: return "CM_DISABLE_ECHO_CANCELLER"; - case K_CM_ENABLE_AGC: return "CM_ENABLE_AGC"; - case K_CM_DISABLE_AGC: return "CM_DISABLE_AGC"; - case K_CM_ENABLE_HIGH_IMP_EVENTS: return "CM_ENABLE_HIGH_IMP_EVENTS"; - case K_CM_DISABLE_HIGH_IMP_EVENTS: return "CM_DISABLE_HIGH_IMP_EVENTS"; - -#if K3L_AT_LEAST(1,6,0) - case K_CM_ENABLE_CALL_ANSWER_INFO: return "CM_ENABLE_CALL_ANSWER_INFO"; - case K_CM_DISABLE_CALL_ANSWER_INFO: return "CM_DISABLE_CALL_ANSWER_INFO"; -#endif - - case K_CM_RESET_LINK: return "CM_RESET_LINK"; - -#if K3L_AT_LEAST(1,6,0) - case K_CM_CLEAR_LINK_ERROR_COUNTER: return "CM_CLEAR_LINK_ERROR_COUNTER"; -#endif - - case K_CM_SEND_DTMF: return "CM_SEND_DTMF"; - case K_CM_STOP_AUDIO: return "CM_STOP_AUDIO"; - case K_CM_HARD_RESET: return "CM_HARD_RESET"; - - case K_CM_SEND_TO_CTBUS: return "CM_SEND_TO_CTBUS"; - case K_CM_RECV_FROM_CTBUS: return "CM_RECV_FROM_CTBUS"; - case K_CM_SETUP_H100: return "CM_SETUP_H100"; - - case K_CM_MIXER: return "CM_MIXER"; - case K_CM_CLEAR_MIXER: return "CM_CLEAR_MIXER"; - case K_CM_PLAY_FROM_FILE: return "CM_PLAY_FROM_FILE"; - case K_CM_RECORD_TO_FILE: return "CM_RECORD_TO_FILE"; - case K_CM_PLAY_FROM_STREAM: return "CM_PLAY_FROM_STREAM"; - case K_CM_STOP_PLAY: return "CM_STOP_PLAY"; - case K_CM_STOP_RECORD: return "CM_STOP_RECORD"; - case K_CM_PAUSE_PLAY: return "CM_PAUSE_PLAY"; - case K_CM_PAUSE_RECORD: return "CM_PAUSE_RECORD"; - case K_CM_INCREASE_VOLUME: return "CM_INCREASE_VOLUME"; - case K_CM_DECREASE_VOLUME: return "CM_DECREASE_VOLUME"; - case K_CM_LISTEN: return "CM_LISTEN"; - case K_CM_STOP_LISTEN: return "CM_STOP_LISTEN"; - case K_CM_PREPARE_FOR_LISTEN: return "CM_PREPARE_FOR_LISTEN"; - - case K_CM_PLAY_SOUND_CARD: return "CM_PLAY_SOUND_CARD"; - case K_CM_STOP_SOUND_CARD: return "CM_STOP_SOUND_CARD"; - - case K_CM_MIXER_CTBUS: return "CM_MIXER_CTBUS"; - case K_CM_PLAY_FROM_STREAM_EX: return "CM_PLAY_FROM_STREAM_EX"; - case K_CM_ENABLE_PLAYER_AGC: return "CM_ENABLE_PLAYER_AGC"; - case K_CM_DISABLE_PLAYER_AGC: return "CM_DISABLE_PLAYER_AGC"; - case K_CM_START_STREAM_BUFFER: return "CM_START_STREAM_BUFFER"; - case K_CM_ADD_STREAM_BUFFER: return "CM_ADD_STREAM_BUFFER"; - case K_CM_STOP_STREAM_BUFFER: return "CM_STOP_STREAM_BUFFER"; - case K_CM_SEND_BEEP: return "CM_SEND_BEEP"; - case K_CM_SEND_BEEP_CONF: return "CM_SEND_BEEP_CONF"; - case K_CM_ADD_TO_CONF: return "CM_ADD_TO_CONF"; - case K_CM_REMOVE_FROM_CONF: return "CM_REMOVE_FROM_CONF"; - case K_CM_RECORD_TO_FILE_EX: return "CM_RECORD_TO_FILE_EX"; - -#if K3L_AT_LEAST(1,5,4) - case K_CM_SET_VOLUME: return "CM_SET_VOLUME"; -#endif - case K_CM_SET_LINE_CONDITION: return "CM_SET_LINE_CONDITION"; - case K_CM_SEND_LINE_CONDITION: return "CM_SEND_LINE_CONDITION"; - case K_CM_SET_CALLER_CATEGORY: return "CM_SET_CALLER_CATEGORY"; - case K_CM_DIAL_MFC: return "CM_DIAL_MFC"; - - case K_CM_INTERNAL_PLAY: return "CM_INTERNAL_PLAY"; - case K_CM_RESUME_PLAY: return "CM_RESUME_PLAY"; - case K_CM_RESUME_RECORD: return "CM_RESUME_RECORD"; - case K_CM_INTERNAL_PLAY_EX: return "CM_INTERNAL_PLAY_EX"; -#if !K3L_AT_LEAST(2,0,0) - case K_CM_PING: return "CM_PING"; -#if K3L_AT_LEAST(1,6,0) - case K_CM_LOG_REQUEST: return "CM_LOG_REQUEST"; - case K_CM_LOG_CREATE_DISPATCHER: return "CM_LOG_CREATE_DISPATCHER"; - case K_CM_LOG_DESTROY_DISPATCHER: return "CM_LOG_DESTROY_DISPATCHER"; -#endif -#endif - -#if K3L_AT_LEAST(1,6,0) - case K_CM_START_CADENCE: return "CM_START_CADENCE"; - case K_CM_STOP_CADENCE: return "CM_STOP_CADENCE"; - case K_CM_CHECK_NEW_SMS: return "CM_CHECK_NEW_SMS"; - case K_CM_SEND_TO_MODEM: return "CM_SEND_TO_MODEM"; -#endif -#if K3L_AT_LEAST(2,1,0) - case K_CM_START_FAX_TX: return "CM_START_FAX_TX"; - case K_CM_STOP_FAX_TX: return "CM_STOP_FAX_TX"; - case K_CM_ADD_FAX_FILE: return "CM_ADD_FAX_FILE"; - case K_CM_ADD_FAX_PAGE_BREAK: return "CM_ADD_FAX_PAGE_BREAK"; - case K_CM_START_FAX_RX: return "CM_START_FAX_RX"; - case K_CM_STOP_FAX_RX: return "CM_STOP_FAX_RX"; - case K_CM_SIM_CARD_SELECT: return "CM_SIM_CARD_SELECT"; -#endif - -#if K3L_AT_LEAST(2,1,0) - case K_CM_NOTIFY_WATCHDOG: return "CM_NOTIFY_WATCHDOG"; - case K_CM_STOP_WATCHDOG: return "CM_STOP_WATCHDOG"; - case K_CM_WATCHDOG_COUNT: return "CM_WATCHDOG_COUNT"; - case K_CM_START_WATCHDOG: return "CM_START_WATCHDOG"; -#endif - - } - - return STG(FMT("[command='%d']") % code); -} - -std::string Verbose::eventName(int32 code) -{ - switch ((kevent)code) - { - case K_EV_CHANNEL_FREE: return "EV_CHANNEL_FREE"; - case K_EV_CONNECT: return "EV_CONNECT"; - case K_EV_DISCONNECT: return "EV_DISCONNECT"; - case K_EV_CALL_SUCCESS: return "EV_CALL_SUCCESS"; - case K_EV_CALL_FAIL: return "EV_CALL_FAIL"; - case K_EV_NO_ANSWER: return "EV_NO_ANSWER"; - case K_EV_BILLING_PULSE: return "EV_BILLING_PULSE"; - case K_EV_SEIZE_SUCCESS: return "EV_SEIZE_SUCCESS"; - case K_EV_SEIZE_FAIL: return "EV_SEIZE_FAIL"; - case K_EV_SEIZURE_START: return "EV_SEIZURE_START"; - case K_EV_CAS_LINE_STT_CHANGED: return "EV_CAS_LINE_STT_CHANGED"; - case K_EV_CAS_MFC_RECV: return "EV_CAS_MFC_RECV"; - -#if K3L_AT_LEAST(1,5,0) - case K_EV_NEW_CALL: return "EV_NEW_CALL"; -#endif - -#if K3L_AT_LEAST(1,5,1) - case K_EV_USER_INFORMATION: return "EV_USER_INFORMATION"; -#endif - -#if K3L_AT_LEAST(1,5,3) - case K_EV_DIALED_DIGIT: return "EV_DIALED_DIGIT"; -#endif - -#if K3L_AT_LEAST(1,6,0) - case K_EV_SIP_REGISTER_INFO: return "EV_SIP_REGISTER_INFO"; -#endif - -#if K3L_AT_LEAST(1,4,0) - case K_EV_CALL_HOLD_START: return "EV_CALL_HOLD_START"; - case K_EV_CALL_HOLD_STOP: return "EV_CALL_HOLD_STOP"; -#endif - -#if K3L_AT_LEAST(1,6,0) - case K_EV_SS_TRANSFER_FAIL: return "EV_SS_TRANSFER_FAIL"; - case K_EV_FLASH: return "EV_FLASH"; -#endif - - case K_EV_DTMF_DETECTED: return "EV_DTMF_DETECTED"; - case K_EV_DTMF_SEND_FINISH: return "EV_DTMF_SEND_FINISH"; - case K_EV_AUDIO_STATUS: return "EV_AUDIO_STATUS"; - case K_EV_CADENCE_RECOGNIZED: return "EV_CADENCE_RECOGNIZED"; - - case K_EV_END_OF_STREAM: return "EV_END_OF_STREAM"; - case K_EV_PULSE_DETECTED: return "EV_PULSE_DETECTED"; - -#if K3L_AT_LEAST(1,5,1) - case K_EV_POLARITY_REVERSAL: return "EV_POLARITY_REVERSAL"; -#endif - -#if K3L_AT_LEAST(1,6,0) - case K_EV_ISDN_PROGRESS_INDICATOR: return "EV_ISDN_PROGRESS_INDICATOR"; - case K_EV_CALL_ANSWER_INFO: return "EV_CALL_ANSWER_INFO"; - case K_EV_COLLECT_CALL: return "EV_COLLECT_CALL"; - case K_EV_SIP_DTMF_DETECTED: return "EV_SIP_DTMF_DETECTED"; - - case K_EV_RECV_FROM_MODEM: return "EV_RECV_FROM_MODEM"; - case K_EV_NEW_SMS: return "EV_NEW_SMS"; - case K_EV_SMS_INFO: return "EV_SMS_INFO"; - case K_EV_SMS_DATA: return "EV_SMS_DATA"; - case K_EV_SMS_SEND_RESULT: return "EV_SMS_SEND_RESULT"; - case K_EV_RING_DETECTED: return "EV_RING_DETECTED"; - case K_EV_PHYSICAL_LINK_DOWN: return "EV_PHYSICAL_LINK_DOWN"; - case K_EV_PHYSICAL_LINK_UP: return "EV_PHYSICAL_LINK_UP"; -#endif -#if K3L_HAS_MPTY_SUPPORT - case K_EV_CALL_MPTY_START: return "EV_CALL_MPTY_START"; - case K_EV_CALL_MPTY_STOP: return "EV_CALL_MPTY_STOP"; - case K_EV_GSM_COMMAND_STATUS: return "EV_GSM_COMMAND_STATUS"; -#endif -#if !K3L_AT_LEAST(2,0,0) - case K_EV_PONG: return "EV_PONG"; -#endif - case K_EV_CHANNEL_FAIL: return "EV_CHANNEL_FAIL"; - case K_EV_REFERENCE_FAIL: return "EV_REFERENCE_FAIL"; - case K_EV_INTERNAL_FAIL: return "EV_INTERNAL_FAIL"; - case K_EV_HARDWARE_FAIL: return "EV_HARDWARE_FAIL"; - case K_EV_LINK_STATUS: return "EV_LINK_STATUS"; - -#if K3L_AT_LEAST(1,4,0) - case K_EV_CLIENT_RECONNECT: return "EV_CLIENT_RECONNECT"; - case K_EV_VOIP_SEIZURE: return "EV_VOIP_SEIZURE"; -#endif - case K_EV_SEIZURE: return "EV_SEIZURE"; -#if K3L_AT_LEAST(2,1,0) - case K_EV_FAX_CHANNEL_FREE: return "EV_FAX_CHANNEL_FREE"; - case K_EV_FAX_FILE_SENT: return "EV_FAX_FILE_SENT"; - case K_EV_FAX_FILE_FAIL: return "EV_FAX_FILE_FAIL"; - /*case K_EV_FAX_MESSAGE_CONFIRMATION:return "EV_FAX_MESSAGE_CONFIRMATION";*/ - case K_EV_FAX_TX_TIMEOUT: return "EV_FAX_TX_TIMEOUT"; - case K_EV_FAX_PAGE_CONFIRMATION:return "EV_FAX_PAGE_CONFIRMATION"; - case K_EV_FAX_REMOTE_INFO: return "EV_FAX_REMOTE_INFO"; -#endif - -#if K3L_AT_LEAST(2,1,0) - case K_EV_WATCHDOG_COUNT: return "EV_WATCHDOG_COUNT"; -#endif - } - - return STG(FMT("[event='%d']") % code); -} - - #if K3L_AT_LEAST(2,0,0) -std::string Verbose::command(int32 dev, K3L_COMMAND *k3lcmd, R2CountryType r2_country, Verbose::Presentation fmt) +std::string Verbose::command(const int32 dev, const K3L_COMMAND * const k3lcmd, const R2CountryType r2_country, const Verbose::Presentation fmt) #else -std::string Verbose::command(int32 dev, K3L_COMMAND *k3lcmd, Verbose::Presentation fmt) +std::string Verbose::command(const int32 dev, const K3L_COMMAND * const k3lcmd, const Verbose::Presentation fmt) #endif { #if K3L_AT_LEAST(2,0,0) @@ -2280,106 +2073,107 @@ std::string Verbose::command(int32 dev, K3L_COMMAND *k3lcmd, Verbose::Presentati } #if K3L_AT_LEAST(2,0,0) -std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const char * params, R2CountryType r2_country, Verbose::Presentation fmt) +std::string Verbose::command(const int32 cmd_code, const int32 dev_idx, const int32 obj_idx, const char * const params, const R2CountryType r2_country, const Verbose::Presentation fmt) #else -std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const char * params, Verbose::Presentation fmt) +std::string Verbose::command(const int32 cmd_code, const int32 dev_idx, const int32 obj_idx, const char * const params, const Verbose::Presentation fmt) #endif { unsigned short int dev = (unsigned short int) dev_idx; unsigned short int obj = (unsigned short int) obj_idx; - kcommand code = (kcommand) cmd_code; + VerboseTraits::Command code = (VerboseTraits::Command) cmd_code; std::string buf, extra; switch (code) { - case K_CM_SEIZE: - case K_CM_SYNC_SEIZE: - //case K_CM_VOIP_SEIZE://deprecated - case K_CM_DIAL_MFC: - case K_CM_DIAL_DTMF: + case VerboseTraits::K_CM_SEIZE: + case VerboseTraits::K_CM_SYNC_SEIZE: + case VerboseTraits::K_CM_VOIP_SEIZE: + case VerboseTraits::K_CM_DIAL_MFC: + case VerboseTraits::K_CM_DIAL_DTMF: - case K_CM_CONNECT: - case K_CM_PRE_CONNECT: - case K_CM_DISCONNECT: - case K_CM_DROP_COLLECT_CALL: + case VerboseTraits::K_CM_CONNECT: + case VerboseTraits::K_CM_PRE_CONNECT: + case VerboseTraits::K_CM_DISCONNECT: + case VerboseTraits::K_CM_DROP_COLLECT_CALL: - case K_CM_START_SEND_FAIL: - case K_CM_STOP_SEND_FAIL: + case VerboseTraits::K_CM_START_SEND_FAIL: + case VerboseTraits::K_CM_STOP_SEND_FAIL: - case K_CM_ENABLE_DTMF_SUPPRESSION: - case K_CM_DISABLE_DTMF_SUPPRESSION: - case K_CM_ENABLE_AUDIO_EVENTS: - case K_CM_DISABLE_AUDIO_EVENTS: - case K_CM_ENABLE_CALL_PROGRESS: - case K_CM_DISABLE_CALL_PROGRESS: - case K_CM_ENABLE_PULSE_DETECTION: - case K_CM_DISABLE_PULSE_DETECTION: - case K_CM_ENABLE_ECHO_CANCELLER: - case K_CM_DISABLE_ECHO_CANCELLER: - case K_CM_ENABLE_AGC: - case K_CM_DISABLE_AGC: - case K_CM_ENABLE_HIGH_IMP_EVENTS: - case K_CM_DISABLE_HIGH_IMP_EVENTS: + case VerboseTraits::K_CM_ENABLE_DTMF_SUPPRESSION: + case VerboseTraits::K_CM_DISABLE_DTMF_SUPPRESSION: + case VerboseTraits::K_CM_ENABLE_AUDIO_EVENTS: + case VerboseTraits::K_CM_DISABLE_AUDIO_EVENTS: + case VerboseTraits::K_CM_ENABLE_CALL_PROGRESS: + case VerboseTraits::K_CM_DISABLE_CALL_PROGRESS: + case VerboseTraits::K_CM_ENABLE_PULSE_DETECTION: + case VerboseTraits::K_CM_DISABLE_PULSE_DETECTION: + case VerboseTraits::K_CM_ENABLE_ECHO_CANCELLER: + case VerboseTraits::K_CM_DISABLE_ECHO_CANCELLER: + case VerboseTraits::K_CM_ENABLE_AGC: + case VerboseTraits::K_CM_DISABLE_AGC: + case VerboseTraits::K_CM_ENABLE_HIGH_IMP_EVENTS: + case VerboseTraits::K_CM_DISABLE_HIGH_IMP_EVENTS: - case K_CM_FLASH: - case K_CM_RESET_LINK: - case K_CM_CLEAR_MIXER: + case VerboseTraits::K_CM_FLASH: + case VerboseTraits::K_CM_RESET_LINK: + case VerboseTraits::K_CM_CLEAR_MIXER: - case K_CM_LOCK_INCOMING: - case K_CM_UNLOCK_INCOMING: - case K_CM_LOCK_OUTGOING: - case K_CM_UNLOCK_OUTGOING: + case VerboseTraits::K_CM_LOCK_INCOMING: + case VerboseTraits::K_CM_UNLOCK_INCOMING: + case VerboseTraits::K_CM_LOCK_OUTGOING: + case VerboseTraits::K_CM_UNLOCK_OUTGOING: - case K_CM_INCREASE_VOLUME: - case K_CM_DECREASE_VOLUME: + case VerboseTraits::K_CM_INCREASE_VOLUME: + case VerboseTraits::K_CM_DECREASE_VOLUME: - case K_CM_STOP_RECORD: - case K_CM_PAUSE_RECORD: - case K_CM_RESUME_RECORD: + case VerboseTraits::K_CM_STOP_RECORD: + case VerboseTraits::K_CM_PAUSE_RECORD: + case VerboseTraits::K_CM_RESUME_RECORD: - case K_CM_STOP_LISTEN: + case VerboseTraits::K_CM_STOP_LISTEN: - case K_CM_PLAY_SOUND_CARD: - case K_CM_STOP_SOUND_CARD: - case K_CM_RINGBACK: + case VerboseTraits::K_CM_PLAY_SOUND_CARD: + case VerboseTraits::K_CM_STOP_SOUND_CARD: + case VerboseTraits::K_CM_RINGBACK: #if K3L_AT_LEAST(1,4,0) && !K3L_AT_LEAST(2,0,0) - case K_CM_VOIP_START_DEBUG: - case K_CM_VOIP_STOP_DEBUG: - case K_CM_VOIP_DUMP_STAT: + case VerboseTraits::K_CM_VOIP_START_DEBUG: + case VerboseTraits::K_CM_VOIP_STOP_DEBUG: + case VerboseTraits::K_CM_VOIP_DUMP_STAT: #endif #if K3L_AT_LEAST(1,5,3) - case K_CM_END_OF_NUMBER: + case VerboseTraits::K_CM_END_OF_NUMBER: #endif #if K3L_AT_LEAST(1,5,4) - case K_CM_SET_VOLUME: + case VerboseTraits::K_CM_SET_VOLUME: #endif #if K3L_AT_LEAST(1,6,0) - case K_CM_ENABLE_CALL_ANSWER_INFO: - case K_CM_DISABLE_CALL_ANSWER_INFO: + case VerboseTraits::K_CM_ENABLE_CALL_ANSWER_INFO: + case VerboseTraits::K_CM_DISABLE_CALL_ANSWER_INFO: - case K_CM_SS_TRANSFER: + case VerboseTraits::K_CM_SS_TRANSFER: - case K_CM_CHECK_NEW_SMS: - case K_CM_GET_SMS: - case K_CM_PREPARE_SMS: - case K_CM_SEND_SMS: + case VerboseTraits::K_CM_CHECK_NEW_SMS: + case VerboseTraits::K_CM_GET_SMS: + case VerboseTraits::K_CM_PREPARE_SMS: + case VerboseTraits::K_CM_SEND_SMS: - case K_CM_START_CADENCE: - case K_CM_STOP_CADENCE: - case K_CM_SEND_TO_MODEM: + case VerboseTraits::K_CM_START_CADENCE: + case VerboseTraits::K_CM_STOP_CADENCE: + case VerboseTraits::K_CM_SEND_TO_MODEM: #endif #if K3L_HAS_MPTY_SUPPORT - case K_CM_HOLD_SWITCH: - case K_CM_MPTY_CONF: - case K_CM_MPTY_SPLIT: + case VerboseTraits::K_CM_HOLD_SWITCH: + case VerboseTraits::K_CM_MPTY_CONF: + case VerboseTraits::K_CM_MPTY_SPLIT: #endif #if K3L_AT_LEAST(2,1,0) - case K_CM_SIM_CARD_SELECT: + case VerboseTraits::K_CM_SIM_CARD_SELECT: + case VerboseTraits::K_CM_CT_TRANSFER: #endif if (params != NULL) { @@ -2394,12 +2188,12 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj)); } - case K_CM_SEND_DTMF: /* ?? */ + case VerboseTraits::K_CM_SEND_DTMF: /* ?? */ return show(buf, commandName(code), Target(CHANNEL, dev, obj)); /****/ - case K_CM_STOP_AUDIO: + case VerboseTraits::K_CM_STOP_AUDIO: extra = "stop='"; switch ((params ? (int)(*params) : -1)) { @@ -2415,7 +2209,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const /****/ #if K3L_AT_LEAST(1,5,2) && !K3L_AT_LEAST(2,0,0) - case K_CM_ISDN_DEBUG: + case VerboseTraits::K_CM_ISDN_DEBUG: extra = "flags='"; extra += isdnDebug((unsigned long)params); extra += "'"; @@ -2426,7 +2220,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const /****/ #if K3L_AT_LEAST(1,5,1) - case K_CM_USER_INFORMATION: + case VerboseTraits::K_CM_USER_INFORMATION: #endif if (params != NULL) { @@ -2448,7 +2242,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const - case K_CM_CAS_CHANGE_LINE_STT: + case VerboseTraits::K_CM_CAS_CHANGE_LINE_STT: { const char status = (params ? *params : 0x00); @@ -2462,7 +2256,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); } - case K_CM_CAS_SEND_MFC: + case VerboseTraits::K_CM_CAS_SEND_MFC: { char mfc = (params ? *params : 0xff); @@ -2471,7 +2265,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); } - case K_CM_CAS_SET_MFC_DETECT_MODE: + case VerboseTraits::K_CM_CAS_SET_MFC_DETECT_MODE: { int mode = (params ? *((int *)params) : -1); @@ -2480,7 +2274,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); } - case K_CM_SET_FORWARD_CHANNEL: + case VerboseTraits::K_CM_SET_FORWARD_CHANNEL: { int channel = (params ? *((int*) params) : -1); @@ -2490,7 +2284,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const } #if K3L_AT_LEAST(1,5,0) - case K_CM_MAKE_CALL: + case VerboseTraits::K_CM_MAKE_CALL: extra = "options='"; extra += (params ? params : ""); extra += "'"; @@ -2498,8 +2292,8 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); #endif - case K_CM_MIXER: - case K_CM_MIXER_CTBUS: + case VerboseTraits::K_CM_MIXER: + case VerboseTraits::K_CM_MIXER_CTBUS: { if (params) { @@ -2537,29 +2331,29 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(MIXER, dev, obj), extra); }; - case K_CM_PLAY_FROM_FILE: + case VerboseTraits::K_CM_PLAY_FROM_FILE: extra = "file='"; extra += (params ? params : ""); extra += "'"; return show(buf, commandName(code), Target(PLAYER, dev, obj), extra); - case K_CM_RECORD_TO_FILE: + case VerboseTraits::K_CM_RECORD_TO_FILE: extra = "file='"; extra += (params ? params : ""); extra += "'"; return show(buf, commandName(code), Target(PLAYER, dev, obj), extra); - case K_CM_RECORD_TO_FILE_EX: + case VerboseTraits::K_CM_RECORD_TO_FILE_EX: extra = "params='"; extra += (params ? params : ""); extra += "'"; return show(buf, commandName(code), Target(PLAYER, dev, obj), extra); - case K_CM_PLAY_FROM_STREAM: - case K_CM_ADD_STREAM_BUFFER: + case VerboseTraits::K_CM_PLAY_FROM_STREAM: + case VerboseTraits::K_CM_ADD_STREAM_BUFFER: { struct buffer_param { @@ -2576,7 +2370,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(PLAYER, dev, obj), extra); } - case K_CM_PLAY_FROM_STREAM_EX: + case VerboseTraits::K_CM_PLAY_FROM_STREAM_EX: { struct buffer_param { @@ -2604,24 +2398,24 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(PLAYER, dev, obj), extra); } - case K_CM_STOP_PLAY: - case K_CM_PAUSE_PLAY: - case K_CM_RESUME_PLAY: + case VerboseTraits::K_CM_STOP_PLAY: + case VerboseTraits::K_CM_PAUSE_PLAY: + case VerboseTraits::K_CM_RESUME_PLAY: - case K_CM_START_STREAM_BUFFER: - case K_CM_STOP_STREAM_BUFFER: + case VerboseTraits::K_CM_START_STREAM_BUFFER: + case VerboseTraits::K_CM_STOP_STREAM_BUFFER: - case K_CM_ENABLE_PLAYER_AGC: - case K_CM_DISABLE_PLAYER_AGC: + case VerboseTraits::K_CM_ENABLE_PLAYER_AGC: + case VerboseTraits::K_CM_DISABLE_PLAYER_AGC: - case K_CM_SEND_BEEP: - case K_CM_SEND_BEEP_CONF: + case VerboseTraits::K_CM_SEND_BEEP: + case VerboseTraits::K_CM_SEND_BEEP_CONF: - case K_CM_INTERNAL_PLAY: - case K_CM_INTERNAL_PLAY_EX: + case VerboseTraits::K_CM_INTERNAL_PLAY: + case VerboseTraits::K_CM_INTERNAL_PLAY_EX: return show(buf, commandName(code), Target(PLAYER, dev, obj)); - case K_CM_ADD_TO_CONF: + case VerboseTraits::K_CM_ADD_TO_CONF: extra += "conference='"; extra += (params ? (int) (*params) : -1); extra += "'"; @@ -2631,8 +2425,8 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const case CM_REMOVE_FROM_CONF: return show(buf, commandName(code), Target(MIXER, dev, obj)); - case K_CM_LISTEN: - case K_CM_PREPARE_FOR_LISTEN: + case VerboseTraits::K_CM_LISTEN: + case VerboseTraits::K_CM_PREPARE_FOR_LISTEN: { int msecs = (params ? *((int*)params) : -1); @@ -2641,8 +2435,8 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(PLAYER, dev, obj), extra); } - case K_CM_SEND_TO_CTBUS: - case K_CM_RECV_FROM_CTBUS: + case VerboseTraits::K_CM_SEND_TO_CTBUS: + case VerboseTraits::K_CM_RECV_FROM_CTBUS: { KCtbusCommand *p = (KCtbusCommand*)(params); @@ -2652,8 +2446,8 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); } - case K_CM_SET_LINE_CONDITION: - case K_CM_SEND_LINE_CONDITION: + case VerboseTraits::K_CM_SET_LINE_CONDITION: + case VerboseTraits::K_CM_SEND_LINE_CONDITION: extra = "condition='"; #if K3L_AT_LEAST(2,0,0) extra += signGroupB((KSignGroupB) *((int *) params), r2_country); @@ -2664,7 +2458,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); - case K_CM_SET_CALLER_CATEGORY: + case VerboseTraits::K_CM_SET_CALLER_CATEGORY: extra = "category='"; #if K3L_AT_LEAST(2,0,0) extra += signGroupII((KSignGroupII) *((int *) params), r2_country); @@ -2676,10 +2470,10 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); #if K3L_AT_LEAST(1,6,0) - case K_CM_CLEAR_LINK_ERROR_COUNTER: + case VerboseTraits::K_CM_CLEAR_LINK_ERROR_COUNTER: return show(buf, commandName(code), Target(LINK, dev, obj)); - case K_CM_SIP_REGISTER: + case VerboseTraits::K_CM_SIP_REGISTER: if (params != NULL) { extra += "param='"; @@ -2694,7 +2488,7 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const } #endif - case K_CM_SETUP_H100: + case VerboseTraits::K_CM_SETUP_H100: extra += "option='"; extra += h100configIndex((KH100ConfigIndex)obj_idx); extra += "'value='"; @@ -2703,38 +2497,38 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const return show(buf, commandName(code), Target(DEVICE, dev), extra); - case K_CM_HARD_RESET: + case VerboseTraits::K_CM_HARD_RESET: return show(buf, commandName(code), Target(LINK, dev, obj)); #if !K3L_AT_LEAST(2,0,0) /* como funciona? */ - case K_CM_LOG_REQUEST: - case K_CM_LOG_CREATE_DISPATCHER: - case K_CM_LOG_DESTROY_DISPATCHER: + case VerboseTraits::K_CM_LOG_REQUEST: + case VerboseTraits::K_CM_LOG_CREATE_DISPATCHER: + case VerboseTraits::K_CM_LOG_DESTROY_DISPATCHER: - case K_CM_PING: + case VerboseTraits::K_CM_PING: #endif return show(buf, commandName(code), Target(NONE)); #if K3L_AT_LEAST(2,1,0) - case K_CM_START_FAX_TX: - case K_CM_START_FAX_RX: - case K_CM_ADD_FAX_FILE: + case VerboseTraits::K_CM_START_FAX_TX: + case VerboseTraits::K_CM_START_FAX_RX: + case VerboseTraits::K_CM_ADD_FAX_FILE: extra = "params='"; extra += (params ? params : ""); extra += "'"; return show(buf, commandName(code), Target(CHANNEL, dev, obj), extra); - case K_CM_STOP_FAX_TX: - case K_CM_STOP_FAX_RX: - case K_CM_ADD_FAX_PAGE_BREAK: + case VerboseTraits::K_CM_STOP_FAX_TX: + case VerboseTraits::K_CM_STOP_FAX_RX: + case VerboseTraits::K_CM_ADD_FAX_PAGE_BREAK: return show(buf, commandName(code), Target(CHANNEL, dev, obj)); #endif #if K3L_AT_LEAST(2,1,0) - case K_CM_NOTIFY_WATCHDOG: - case K_CM_STOP_WATCHDOG: - case K_CM_START_WATCHDOG: + case VerboseTraits::K_CM_NOTIFY_WATCHDOG: + case VerboseTraits::K_CM_STOP_WATCHDOG: + case VerboseTraits::K_CM_START_WATCHDOG: return show(buf, commandName(code) , Target(DEVICE, obj)); - case K_CM_WATCHDOG_COUNT: + case VerboseTraits::K_CM_WATCHDOG_COUNT: return show(buf, commandName(code) , Target(NONE)); #endif @@ -2745,65 +2539,66 @@ std::string Verbose::command(int32 cmd_code, int32 dev_idx, int32 obj_idx, const } #if K3L_AT_LEAST(2,0,0) -std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, R2CountryType r2_country, Verbose::Presentation fmt) +std::string Verbose::event(const KSignaling sig, const int32 obj_idx, const K3L_EVENT * const ev, const R2CountryType r2_country, const Verbose::Presentation fmt) #else -std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose::Presentation fmt) +std::string Verbose::event(const KSignaling sig, const int32 obj_idx, const K3L_EVENT * const ev, const Verbose::Presentation fmt) #endif { unsigned short int dev = (unsigned short int) ev->DeviceId; unsigned short int obj = (unsigned short int) obj_idx; - kevent code = (kevent) ev->Code; + VerboseTraits::Event code = (VerboseTraits::Event) ev->Code; - std::string buf, extra; + std::string buf; + std::string extra; switch (code) { - case K_EV_CHANNEL_FREE: - case K_EV_SEIZE_SUCCESS: - case K_EV_CALL_SUCCESS: - case K_EV_NO_ANSWER: - case K_EV_CONNECT: - case K_EV_DTMF_SEND_FINISH: - case K_EV_SEIZURE_START: - case K_EV_BILLING_PULSE: - case K_EV_REFERENCE_FAIL: + case VerboseTraits::VerboseTraits::K_EV_CHANNEL_FREE: + case VerboseTraits::VerboseTraits::K_EV_SEIZE_SUCCESS: + case VerboseTraits::VerboseTraits::K_EV_CALL_SUCCESS: + case VerboseTraits::VerboseTraits::K_EV_NO_ANSWER: + case VerboseTraits::VerboseTraits::K_EV_CONNECT: + case VerboseTraits::VerboseTraits::K_EV_DTMF_SEND_FINISH: + case VerboseTraits::VerboseTraits::K_EV_SEIZURE_START: + case VerboseTraits::VerboseTraits::K_EV_BILLING_PULSE: + case VerboseTraits::VerboseTraits::K_EV_REFERENCE_FAIL: #if K3L_AT_LEAST(1,4,0) - case K_EV_CALL_HOLD_START: - case K_EV_CALL_HOLD_STOP: + case VerboseTraits::VerboseTraits::K_EV_CALL_HOLD_START: + case VerboseTraits::VerboseTraits::K_EV_CALL_HOLD_STOP: #endif #if K3L_AT_LEAST(1,5,0) - case K_EV_NEW_CALL: + case VerboseTraits::VerboseTraits::K_EV_NEW_CALL: #endif #if K3L_AT_LEAST(1,6,0) - case K_EV_FLASH: - case K_EV_POLARITY_REVERSAL: - case K_EV_COLLECT_CALL: - case K_EV_SS_TRANSFER_FAIL: - case K_EV_RING_DETECTED: + case VerboseTraits::VerboseTraits::K_EV_FLASH: + case VerboseTraits::VerboseTraits::K_EV_POLARITY_REVERSAL: + case VerboseTraits::VerboseTraits::K_EV_COLLECT_CALL: + case VerboseTraits::VerboseTraits::K_EV_RING_DETECTED: + case VerboseTraits::VerboseTraits::K_EV_SS_TRANSFER_FAIL: #endif #if K3L_HAS_MPTY_SUPPORT - case K_EV_CALL_MPTY_START: - case K_EV_CALL_MPTY_STOP: + case VerboseTraits::VerboseTraits::K_EV_CALL_MPTY_START: + case VerboseTraits::VerboseTraits::K_EV_CALL_MPTY_STOP: #endif break; #if K3L_AT_LEAST(1,6,0) - case K_EV_RECV_FROM_MODEM: - case K_EV_SMS_INFO: - case K_EV_SMS_DATA: + case VerboseTraits::VerboseTraits::K_EV_RECV_FROM_MODEM: + case VerboseTraits::VerboseTraits::K_EV_SMS_INFO: + case VerboseTraits::VerboseTraits::K_EV_SMS_DATA: +#endif extra = "data='"; extra += (ev->Params ? (const char *)(ev->Params) : ""); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); -#endif #if K3L_AT_LEAST(1,6,0) - case K_EV_SMS_SEND_RESULT: + case VerboseTraits::VerboseTraits::K_EV_SMS_SEND_RESULT: extra = "result='"; #if K3L_AT_LEAST(2,0,0) extra += gsmSmsCause((KGsmSmsCause)ev->AddInfo); @@ -2814,20 +2609,20 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); #if K3L_HAS_MPTY_SUPPORT - case K_EV_GSM_COMMAND_STATUS: + case VerboseTraits::VerboseTraits::K_EV_GSM_COMMAND_STATUS: extra = "result='"; extra += gsmMobileCause((KGsmMobileCause)ev->AddInfo); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); #endif - case K_EV_CALL_ANSWER_INFO: + case VerboseTraits::VerboseTraits::K_EV_CALL_ANSWER_INFO: extra = "info='"; extra += callStartInfo((KCallStartInfo)ev->AddInfo); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_NEW_SMS: + case VerboseTraits::VerboseTraits::K_EV_NEW_SMS: if (ev->AddInfo != 0) { extra = "messages='"; @@ -2840,7 +2635,7 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose return show(buf, eventName(code), Target(CHANNEL, dev, obj)); } - case K_EV_ISDN_PROGRESS_INDICATOR: + case VerboseTraits::VerboseTraits::K_EV_ISDN_PROGRESS_INDICATOR: if (ev->AddInfo != 0) { extra = "indication='"; @@ -2854,19 +2649,19 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose } #endif - case K_EV_CAS_LINE_STT_CHANGED: + case VerboseTraits::VerboseTraits::K_EV_CAS_LINE_STT_CHANGED: extra = STG(FMT("[a=%d,b=%d,c=%d,d=%d]") % ((ev->AddInfo & 0x8) >> 3) % ((ev->AddInfo & 0x4) >> 2) % ((ev->AddInfo & 0x2) >> 1) % (ev->AddInfo & 0x1)); return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_CAS_MFC_RECV: + case VerboseTraits::VerboseTraits::K_EV_CAS_MFC_RECV: extra = STG(FMT("digit='%d'") % ev->AddInfo); return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_CALL_FAIL: + case VerboseTraits::VerboseTraits::K_EV_CALL_FAIL: extra = "cause='"; #if K3L_AT_LEAST(2,0,0) extra += callFail(sig, r2_country, ev->AddInfo); @@ -2887,7 +2682,7 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_DISCONNECT: + case VerboseTraits::VerboseTraits::K_EV_DISCONNECT: switch (sig) { #if K3L_AT_LEAST(1,5,1) @@ -2921,16 +2716,16 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose break; #if K3L_AT_LEAST(1,6,0) - case K_EV_SIP_DTMF_DETECTED: + case VerboseTraits::VerboseTraits::K_EV_SIP_DTMF_DETECTED: #endif - case K_EV_DTMF_DETECTED: - case K_EV_PULSE_DETECTED: - case K_EV_DIALED_DIGIT: + case VerboseTraits::VerboseTraits::K_EV_DTMF_DETECTED: + case VerboseTraits::VerboseTraits::K_EV_PULSE_DETECTED: + case VerboseTraits::VerboseTraits::K_EV_DIALED_DIGIT: extra = STG(FMT("digit='%c'") % (char)ev->AddInfo); return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_SEIZURE: + case VerboseTraits::VerboseTraits::K_EV_SEIZURE: { KIncomingSeizeParams *n = (KIncomingSeizeParams *) ( ((char*)ev) + sizeof(K3L_EVENT) ); @@ -2945,7 +2740,7 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose } #if K3L_AT_LEAST(1,4,0) - case K_EV_VOIP_SEIZURE: + case VerboseTraits::VerboseTraits::K_EV_VOIP_SEIZURE: { char *numB = ((char*)ev) + sizeof(K3L_EVENT); char *numA = numB + 61; @@ -2961,43 +2756,43 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose #endif - case K_EV_END_OF_STREAM: + case VerboseTraits::VerboseTraits::K_EV_END_OF_STREAM: return show(buf, eventName(code), Target(PLAYER, dev, obj)); - case K_EV_AUDIO_STATUS: + case VerboseTraits::VerboseTraits::K_EV_AUDIO_STATUS: extra = "tone='"; extra += mixerTone((KMixerTone)ev->AddInfo); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_CADENCE_RECOGNIZED: + case VerboseTraits::VerboseTraits::K_EV_CADENCE_RECOGNIZED: extra = STG(FMT("cadence='%c'") % (char)(ev->AddInfo)); return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_CHANNEL_FAIL: + case VerboseTraits::VerboseTraits::K_EV_CHANNEL_FAIL: extra = "reason='"; extra += channelFail(sig, ev->AddInfo); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_SEIZE_FAIL: + case VerboseTraits::VerboseTraits::K_EV_SEIZE_FAIL: extra = "reason='"; extra += seizeFail((KSeizeFail) ev->AddInfo); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_INTERNAL_FAIL: + case VerboseTraits::VerboseTraits::K_EV_INTERNAL_FAIL: extra = "reason='"; extra += internalFail((KInternalFail) ev->AddInfo); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_HARDWARE_FAIL: + case VerboseTraits::VerboseTraits::K_EV_HARDWARE_FAIL: extra = "component='"; extra += systemObject((KSystemObject) ev->AddInfo); extra += "'"; @@ -3018,18 +2813,18 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose } - case K_EV_LINK_STATUS: + case VerboseTraits::VerboseTraits::K_EV_LINK_STATUS: // EV_LINK_STATUS has always zero in ObjectInfo (and AddInfo!) /* fall throught... */ #if K3L_AT_LEAST(1,6,0) - case K_EV_PHYSICAL_LINK_UP: - case K_EV_PHYSICAL_LINK_DOWN: + case VerboseTraits::VerboseTraits::K_EV_PHYSICAL_LINK_UP: + case VerboseTraits::VerboseTraits::K_EV_PHYSICAL_LINK_DOWN: return show(buf, eventName(code), Target(LINK, dev, obj)); #endif #if K3L_AT_LEAST(1,5,1) - case K_EV_USER_INFORMATION: + case VerboseTraits::VerboseTraits::K_EV_USER_INFORMATION: { KUserInformation *info = (KUserInformation *)(ev->Params); @@ -3044,7 +2839,7 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose #endif #if K3L_AT_LEAST(1,6,0) - case K_EV_SIP_REGISTER_INFO: + case VerboseTraits::VerboseTraits::K_EV_SIP_REGISTER_INFO: extra = "params='"; extra += (ev->Params ? (const char *) (ev->Params) : ""); extra += "',status='"; @@ -3055,28 +2850,28 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose #endif #if !K3L_AT_LEAST(2,0,0) - case K_EV_PONG: + case VerboseTraits::VerboseTraits::K_EV_PONG: #endif #if K3L_AT_LEAST(1,4,0) - case K_EV_CLIENT_RECONNECT: + case VerboseTraits::VerboseTraits::K_EV_CLIENT_RECONNECT: #endif return show(buf, eventName(code), Target(NONE)); #if K3L_AT_LEAST(2,1,0) - case K_EV_FAX_CHANNEL_FREE: + case VerboseTraits::VerboseTraits::K_EV_FAX_CHANNEL_FREE: extra = "status='"; extra += faxResult((KFaxResult)ev->AddInfo); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_FAX_FILE_SENT: + case VerboseTraits::VerboseTraits::K_EV_FAX_FILE_SENT: extra = "filename='"; extra += (ev->Params ? (const char *) (ev->Params) : ""); extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_FAX_FILE_FAIL: + case VerboseTraits::VerboseTraits::K_EV_FAX_FILE_FAIL: extra = "cause='"; extra += faxFileErrorCause((KFaxFileErrorCause)ev->AddInfo); extra += "',filename='"; @@ -3084,22 +2879,29 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose extra += "'"; return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - case K_EV_FAX_REMOTE_INFO: + case VerboseTraits::VerboseTraits::K_EV_FAX_REMOTE_INFO: extra = ((ev->Params && ev->ParamSize != 0) ? (const char *) ev->Params : ""); return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); - /*case K_EV_FAX_MESSAGE_CONFIRMATION:*/ - case K_EV_FAX_PAGE_CONFIRMATION: - case K_EV_FAX_TX_TIMEOUT: + case VerboseTraits::VerboseTraits::K_EV_FAX_PAGE_CONFIRMATION: + case VerboseTraits::VerboseTraits::K_EV_FAX_TX_TIMEOUT: return show(buf, eventName(code), Target(CHANNEL, dev, obj)); #endif #if K3L_AT_LEAST(2,1,0) - case K_EV_WATCHDOG_COUNT: + case VerboseTraits::VerboseTraits::K_EV_WATCHDOG_COUNT: extra = STG(FMT("count='%d'") % (char)ev->AddInfo); return show(buf , eventName(code), Target(NONE), extra); #endif +#if K3L_AT_LEAST(2,1,0) + case VerboseTraits::VerboseTraits::K_EV_CT_TRANSFER_FAIL: + extra = "cause='"; + extra += isdnCause((KQ931Cause)ev->AddInfo); + extra += "'"; + + return show(buf, eventName(code), Target(CHANNEL, dev, obj), extra); +#endif } // default handler... @@ -3117,7 +2919,7 @@ std::string Verbose::event(KSignaling sig, int32 obj_idx, K3L_EVENT *ev, Verbose /********************************************/ -std::string Verbose::show(std::string & buf, std::string name, Target tgt, std::string & extra) +std::string Verbose::show(std::string & buf, const std::string & name, const Target tgt, const std::string & extra) { if (tgt.type == NONE) { @@ -3134,7 +2936,7 @@ std::string Verbose::show(std::string & buf, std::string name, Target tgt, std:: return buf; } -std::string Verbose::show(std::string & buf, std::string name, Target tgt) +std::string Verbose::show(std::string & buf, const std::string & name, const Target tgt) { std::string tmp(""); @@ -3142,7 +2944,7 @@ std::string Verbose::show(std::string & buf, std::string name, Target tgt) return buf; } -void Verbose::generate(std::string &buf, std::string &name, Target tgt, std::string &extra) +void Verbose::generate(std::string & buf, const std::string & name, const Target tgt, const std::string & extra) { switch (tgt.type) { diff --git a/src/mod/endpoints/mod_khomp/commons/base/verbose.hpp b/src/mod/endpoints/mod_khomp/commons/base/verbose.hpp new file mode 100644 index 0000000000..a0ea290b7e --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/base/verbose.hpp @@ -0,0 +1,303 @@ +/* + KHOMP generic endpoint/channel library. + Copyright (C) 2007-2009 Khomp Ind. & 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. + + Alternatively, the contents of this file may be used under the terms of the + "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which + case the provisions of "LGPL License" are applicable instead of those above. + + If you wish to allow use of your version of this file only under the terms of + the LGPL License and not to allow others to use your version of this file under + the MPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the LGPL License. If you do not + delete the provisions above, a recipient may use your version of this file under + either the MPL or the LGPL License. + + The LGPL header follows below: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#ifndef _VERBOSE_HPP_ +#define _VERBOSE_HPP_ + +#include +#include +#include + +#include + +// k3lApiMajorVersion +#ifndef CM_PING +# include +# include +#endif + +#include +#include +#include + +#include + +struct Verbose +{ + typedef enum + { + R2_COUNTRY_BRA = 1, + R2_COUNTRY_ARG = 2, + R2_COUNTRY_CHI = 3, + R2_COUNTRY_MEX = 4, + R2_COUNTRY_URY = 5, + R2_COUNTRY_VEN = 6 + } + R2CountryType; + + typedef enum + { + HUMAN, + EXACT + } + Presentation; + + /* dynamic (object) stuff */ + + Verbose(const K3LAPI & api) + : _api(api) {}; + +#if K3L_AT_LEAST(2,0,0) + std::string event(const int32, const K3L_EVENT * const, + const R2CountryType r2_country = R2_COUNTRY_BRA, + const Presentation fmt = HUMAN) const; +#else + std::string event(const int32, const K3L_EVENT * const, + const Presentation fmt = HUMAN) const; +#endif + + std::string channelStatus(const int32, const int32, const int32, + const Presentation fmt = HUMAN) const; + + /* end of dynamic (object) stuff */ + + protected: + const K3LAPI & _api; + + /* used internally */ + struct internal_not_found {}; + + public: + + /* static (class) stuff */ + + static std::string echoLocation(const KEchoLocation, const Presentation fmt = HUMAN); + static std::string echoCancellerConfig(const KEchoCancellerConfig, const Presentation fmt = HUMAN); + +#if K3L_AT_LEAST(2,0,0) + static std::string event(const KSignaling, const int32, const K3L_EVENT * const, + const R2CountryType = R2_COUNTRY_BRA, Presentation fmt = HUMAN); +#else + static std::string event(const KSignaling, const int32, const K3L_EVENT * const, + const Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(2,0,0) + static std::string command(const int32, const K3L_COMMAND * const, + const R2CountryType = R2_COUNTRY_BRA, + const Presentation fmt = HUMAN); + + static std::string command(const int32, const int32, const int32, const char * const, + const R2CountryType = R2_COUNTRY_BRA, + const Presentation fmt = HUMAN); +#else + static std::string command(const int32, const K3L_COMMAND * const, + const Presentation fmt = HUMAN); + + static std::string command(const int32, const int32, const int32, const char * const, + const Presentation fmt = HUMAN); +#endif + + static std::string deviceName(const KDeviceType, const int32, const int32 count = 0, const Presentation fmt = HUMAN); + static std::string deviceName(const KDeviceType, const int32, const Presentation fmt); + + static std::string deviceType(const KDeviceType, const int32 count = 0, const Presentation fmt = HUMAN); + static std::string deviceType(const KDeviceType, const Presentation fmt); + + static std::string deviceModel(const KDeviceType, const int32, const int32 count = 0, const Presentation fmt = HUMAN); + static std::string deviceModel(const KDeviceType, const int32, const Presentation fmt); + + static std::string channelFeatures(const int32, const Presentation fmt = HUMAN); + static std::string signaling(const KSignaling, const Presentation fmt = HUMAN); + static std::string systemObject(const KSystemObject, const Presentation fmt = HUMAN); + static std::string mixerTone(const KMixerTone, const Presentation fmt = HUMAN); + static std::string mixerSource(const KMixerSource, const Presentation fmt = HUMAN); + + static std::string seizeFail(const KSeizeFail, const Presentation fmt = HUMAN); + +#if K3L_AT_LEAST(2,0,0) + static std::string callFail(const KSignaling, const R2CountryType, const int32, const Presentation fmt = HUMAN); +#else + static std::string callFail(const KSignaling, const int32, const Presentation fmt = HUMAN); +#endif + + static std::string channelFail(const KSignaling, const int32, const Presentation fmt = HUMAN); + static std::string internalFail(const KInternalFail, const Presentation fmt = HUMAN); + + static std::string linkErrorCounter(const KLinkErrorCounter, const Presentation fmt = HUMAN); + + static std::string linkStatus(const KSignaling, const int32, const Presentation fmt = HUMAN, const bool simpleStatus = false); + static std::string channelStatus(const KSignaling, const int32, const Presentation fmt = HUMAN); + static std::string callStatus(const KCallStatus, const Presentation fmt = HUMAN); + static std::string status(const KLibraryStatus, const Presentation fmt = HUMAN); + +#if K3L_AT_LEAST(2,0,0) + static std::string signGroupB(const KSignGroupB, const R2CountryType contry = R2_COUNTRY_BRA, + Presentation fmt = HUMAN); +#else + static std::string signGroupB(const KSignGroupB, const Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(2,0,0) + static std::string signGroupII(const KSignGroupII, const R2CountryType contry = R2_COUNTRY_BRA, + Presentation fmt = HUMAN); +#else + static std::string signGroupII(const KSignGroupII, const Presentation fmt = HUMAN); +#endif + + static std::string h100configIndex(const KH100ConfigIndex, const Presentation fmt = HUMAN); + + static std::string eventName(const int32 value) + { + return VerboseTraits::eventName((VerboseTraits::Event)value); + }; + + static std::string commandName(const int32 value) + { + return VerboseTraits::commandName((VerboseTraits::Command)value); + }; + +#if K3L_AT_LEAST(1,5,0) + static std::string sipFailures(const KSIP_Failures, const Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(1,5,1) + static std::string isdnCause(const KQ931Cause, const Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(1,5,2) + static std::string isdnDebug(const int32, const Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(1,6,0) + static std::string callStartInfo(const KCallStartInfo, const Presentation fmt = HUMAN); + + static std::string gsmCallCause(const KGsmCallCause, const Presentation fmt = HUMAN); + static std::string gsmMobileCause(const KGsmMobileCause, const Presentation fmt = HUMAN); + static std::string gsmSmsCause(const KGsmSmsCause, const Presentation fmt = HUMAN); + + static std::string q931ProgressIndication(const KQ931ProgressIndication, + Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(2,1,0) + static std::string faxResult(const KFaxResult code, const Presentation fmt = HUMAN); + static std::string faxFileErrorCause(const KFaxFileErrorCause code, const Presentation fmt = HUMAN); +#endif + + /* end of static (class) stuff */ + + private: + static std::string internal_deviceType(const KDeviceType, const int32); + static std::string internal_deviceModel(const KDeviceType, const int32, const int32); + +#if K3L_AT_LEAST(1,5,0) + static std::string internal_sipFailures(const KSIP_Failures, const Presentation fmt = HUMAN); +#endif +#if K3L_AT_LEAST(1,5,1) + static std::string internal_isdnCause(const KQ931Cause, const Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(2,0,0) + static std::string internal_signGroupB(const KSignGroupB, const R2CountryType contry, const Presentation fmt = HUMAN); + static std::string internal_signGroupII(const KSignGroupII, const R2CountryType contry, const Presentation fmt = HUMAN); +#else + static std::string internal_signGroupB(const KSignGroupB, const Presentation fmt = HUMAN); + static std::string internal_signGroupII(const KSignGroupII, const Presentation fmt = HUMAN); +#endif + +#if K3L_AT_LEAST(1,6,0) + static std::string internal_gsmCallCause(const KGsmCallCause, const Presentation fmt = HUMAN); + static std::string internal_gsmMobileCause(const KGsmMobileCause, const Presentation fmt = HUMAN); + static std::string internal_gsmSmsCause(const KGsmSmsCause, const Presentation fmt = HUMAN); + + static std::string internal_q931ProgressIndication(const KQ931ProgressIndication, const Presentation fmt = HUMAN); +#endif + + private: + enum Type + { + DEVICE, + CHANNEL, + PLAYER, + MIXER, + LINK, + NONE + }; + + struct Target + { + Target(Type _type) + : type(_type), device(-1), object(-1) + {}; + + Target(Type _type, int32 _device) + : type(_type), device(_device), object(-1) + {}; + + Target(Type _type, int32 _device, int32 _object) + : type(_type), device(_device), object(_object) + {}; + + const Type type; + const int32 device; + const int32 object; + }; + + static void generate(std::string &, const std::string &, const Target, const std::string &); + + static std::string show(std::string &, const std::string &, const Target, const std::string &); + static std::string show(std::string &, const std::string &, const Target); + + template < typename ReturnType > + static ReturnType presentation(const Presentation fmt, ReturnType str_exact, ReturnType str_human) + { + switch (fmt) + { + case HUMAN: return str_human; + case EXACT: return str_exact; + }; + + return str_exact; + } +}; + +#endif /* _VERBOSE_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/config_options.cpp b/src/mod/endpoints/mod_khomp/commons/config_options.cpp deleted file mode 100644 index 5383855f65..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/config_options.cpp +++ /dev/null @@ -1,710 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include - -ConfigOption::ConfigOption(std::string name, const ConfigOption::StringType & value, const ConfigOption::StringType defvalue, string_allowed_type allowed, bool list_me) -: _my_name(name), _value_data(new StringData(const_cast(value), defvalue, allowed), true), - _list_me(list_me), _values(NULL), _loaded(false) -{}; - -ConfigOption::ConfigOption(std::string name, const ConfigOption::StringType & value, const ConfigOption::StringType defvalue, bool list_me) -: _my_name(name), _value_data(new StringData(const_cast(value), defvalue, string_allowed_type()), true), - _list_me(list_me), _values(NULL), _loaded(false) -{}; - -ConfigOption::ConfigOption(std::string name, const ConfigOption::SignedIntType & value, const ConfigOption::SignedIntType defvalue, - ConfigOption::SignedIntType min, ConfigOption::SignedIntType max, ConfigOption::SignedIntType step, bool list_me) -: _my_name(name), _value_data(new SignedIntData(const_cast(value), defvalue, Range(min, max, step)), true), - _list_me(list_me), _values(NULL), _loaded(false) -{}; - -ConfigOption::ConfigOption(std::string name, const ConfigOption::UnsignedIntType & value, const ConfigOption::UnsignedIntType defvalue, - ConfigOption::UnsignedIntType min, ConfigOption::UnsignedIntType max, ConfigOption::UnsignedIntType step, bool list_me) -: _my_name(name), _value_data(new UnsignedIntData(const_cast(value), defvalue, Range(min, max, step)), true), - _list_me(list_me), _values(NULL), _loaded(false) -{}; - -ConfigOption::ConfigOption(std::string name, const ConfigOption::BooleanType & value, const ConfigOption::BooleanType defvalue, bool list_me) -: _my_name(name), _value_data(new BooleanData(const_cast(value), defvalue), true), - _list_me(list_me), _values(NULL), _loaded(false) -{}; - -ConfigOption::ConfigOption(std::string name, ConfigOption::FunctionType fun, std::string defvalue, string_allowed_type allowed, bool list_me) -: _my_name(name), _value_data(new FunctionData(fun, defvalue, allowed), true), - _list_me(list_me), _values(NULL), _loaded(false) -{}; - -ConfigOption::ConfigOption(std::string name, ConfigOption::FunctionType fun, std::string defvalue, bool list_me) -: _my_name(name), _value_data(new FunctionData(fun, defvalue, string_allowed_type()), true), - _list_me(list_me), _values(NULL), _loaded(false) -{}; - -ConfigOption::ConfigOption(const ConfigOption & o) -: _my_name(o._my_name), _value_data(o._value_data), - _list_me(o._list_me), _values(o._values), _loaded(o._loaded) -{}; - -ConfigOption::~ConfigOption(void) -{ - if (_values) - { - for (unsigned int i = 0; _values[i] != NULL; i++) - delete _values[i]; - - delete[] _values; - _values = NULL; - } -}; - -void ConfigOption::set(ConfigOption::StringType value) -{ - switch (_value_data.which()) - { - case ID_STRING: - { - try - { - StringData & tmp = _value_data.get(); - - if (tmp.string_allowed.empty()) - { - tmp.string_val = value; - _loaded = true; - } - else - { - if (tmp.string_allowed.find(value) != tmp.string_allowed.end()) - { - tmp.string_val = value; - _loaded = true; - return; - } - - std::string allowed_string; - - for (string_allowed_type::iterator i = tmp.string_allowed.begin(); i != tmp.string_allowed.end(); i++) - { - allowed_string += " '"; - allowed_string += (*i); - allowed_string += "'"; - } - - throw ConfigProcessFailure(STG(FMT("value '%s' not allowed for option '%s' (allowed values:%s)") - % value % _my_name % allowed_string)); - } - break; - } - catch(ValueType::InvalidType & e) - { - throw; - } - } - - case ID_FUN: - { - try - { - FunctionData & tmp = _value_data.get(); - tmp.fun_val(value); - _loaded = true; - break; - } - catch(ValueType::InvalidType & e) - { - throw; - } - - } - - default: - { - throw ConfigProcessFailure(STG(FMT("option '%s' is not of type string, nor function defined") % _my_name)); - } - } -} - -void ConfigOption::set(ConfigOption::SignedIntType value) -{ - try - { - SignedIntData & tmp = _value_data.get(); - - if (value < tmp.sint_Range.minimum) - throw ConfigProcessFailure(STG(FMT("value '%d' out-of-Range for option '%s' (too low)") % value % _my_name)); - - if (value > tmp.sint_Range.maximum) - throw ConfigProcessFailure(STG(FMT("value '%d' out-of-Range for option '%s' (too high)") % value % _my_name)); - - if (((value - tmp.sint_Range.minimum) % tmp.sint_Range.step) != 0) - throw ConfigProcessFailure(STG(FMT("value '%d' out-of-Range for option '%s' (outside allowed step)") % value % _my_name)); - - tmp.sint_val = value; - _loaded = true; - } - catch(ValueType::InvalidType & e) - { - throw; - } -} - -void ConfigOption::set(ConfigOption::UnsignedIntType value) -{ - try - { - UnsignedIntData & tmp = _value_data.get(); - - if (value < tmp.uint_Range.minimum) - throw ConfigProcessFailure(STG(FMT("value '%d' out-of-Range for option '%s' (too low)") % value % _my_name)); - - if (value > tmp.uint_Range.maximum) - throw ConfigProcessFailure(STG(FMT("value '%d' out-of-Range for option '%s' (too high)") % value % _my_name)); - - if (((value - tmp.uint_Range.minimum) % tmp.uint_Range.step) != 0) - throw ConfigProcessFailure(STG(FMT("value '%d' out-of-Range for option '%s' (outside allowed step)") % value % _my_name)); - - tmp.uint_val = value; - _loaded = true; - } - catch(ValueType::InvalidType & e) - { - throw; - } -} - -void ConfigOption::set(ConfigOption::BooleanType value) -{ - try - { - BooleanData & tmp = _value_data.get(); - tmp.bool_val = value; - _loaded = true; - } - catch(ValueType::InvalidType & e) - { - throw; - } -} - -std::string & ConfigOption::name(void) { return _my_name; }; - -ConfigOption::value_id_type ConfigOption::type(void) -{ - return (value_id_type) _value_data.which(); -}; - -const char ** ConfigOption::values(void) -{ - if (_values != NULL) - return _values; - - switch ((value_id_type) _value_data.which()) - { - case ConfigOption::ID_BOOL: - { - _values = new const char*[3]; - - _values[0] = strdup("yes"); - _values[1] = strdup("no"); - _values[2] = NULL; - - return _values; - } - - case ConfigOption::ID_SINT: - { - try - { - SignedIntData & tmp = _value_data.get(); - - - unsigned int count = ((tmp.sint_Range.maximum - tmp.sint_Range.minimum) / tmp.sint_Range.step) + 1; - unsigned int index = 0; - - _values = new const char*[count + 1]; - - for (SignedIntType i = tmp.sint_Range.minimum; i <= tmp.sint_Range.maximum; i += tmp.sint_Range.step, index++) - _values[index] = strdup(STG(FMT("%d") % i).c_str()); - - _values[index] = NULL; - - return _values; - } - catch(ValueType::InvalidType & e) - { - throw; - } - } - - case ConfigOption::ID_UINT: - { - try - { - UnsignedIntData & tmp = _value_data.get(); - - unsigned int count = ((tmp.uint_Range.maximum - tmp.uint_Range.minimum) / tmp.uint_Range.step) + 1; - unsigned int index = 0; - - _values = new const char*[count + 1]; - - for (UnsignedIntType i = tmp.uint_Range.minimum; i <= tmp.uint_Range.maximum; i += tmp.uint_Range.step, index++) - _values[index] = strdup(STG(FMT("%d") % i).c_str()); - - _values[index] = NULL; - - return _values; - } - catch(ValueType::InvalidType & e) - { - throw; - } - } - - case ConfigOption::ID_STRING: - { - try - { - StringData & tmp = _value_data.get(); - - _values = new const char*[ tmp.string_allowed.size() + 1 ]; - - unsigned int index = 0; - - for (string_allowed_type::iterator i = tmp.string_allowed.begin(); i != tmp.string_allowed.end(); i++, index++) - _values[index] = strdup((*i).c_str()); - - _values[index] = NULL; - - return _values; - } - catch(ValueType::InvalidType & e) - { - throw; - } - } - - case ConfigOption::ID_FUN: - { - try - { - FunctionData & tmp = _value_data.get(); - - _values = new const char*[ tmp.fun_allowed.size() + 1 ]; - - unsigned int index = 0; - - for (string_allowed_type::iterator i = tmp.fun_allowed.begin(); i != tmp.fun_allowed.end(); i++, index++) - _values[index] = strdup((*i).c_str()); - - _values[index] = NULL; - return _values; - } - catch(ValueType::InvalidType & e) - { - throw; - } - - } - - default: - throw ConfigProcessFailure(STG(FMT("unknown type identifier '%d'") % _value_data.which())); - } -}; - -void ConfigOption::reset(void) -{ - _loaded = false; -}; - -void ConfigOption::commit(void) -{ - if (_loaded) - return; - - switch ((value_id_type) _value_data.which()) - { - case ConfigOption::ID_BOOL: - { - try - { - BooleanData & tmp = _value_data.get(); - tmp.bool_val = tmp.bool_default; - } - catch(ValueType::InvalidType & e) - { - throw; - } - - break; - } - - case ConfigOption::ID_SINT: - { - try - { - SignedIntData & tmp = _value_data.get(); - tmp.sint_val = tmp.sint_default; - } - catch(ValueType::InvalidType & e) - { - throw; - } - break; - } - - case ConfigOption::ID_UINT: - { - try - { - UnsignedIntData & tmp = _value_data.get(); - tmp.uint_val = tmp.uint_default; - } - catch(ValueType::InvalidType & e) - { - throw; - } - break; - } - - case ConfigOption::ID_STRING: - { - try - { - StringData & tmp = _value_data.get(); - tmp.string_val = tmp.string_default; - } - catch(ValueType::InvalidType & e) - { - throw; - } - break; - } - - case ConfigOption::ID_FUN: - { - try - { - FunctionData & tmp = _value_data.get(); - tmp.fun_val(tmp.fun_default); - } - catch(ValueType::InvalidType & e) - { - throw; - } - break; - } - - default: - throw ConfigProcessFailure(STG(FMT("unknown type identifier '%d'") % _value_data.which())); - } - - _loaded = true; -}; - -void ConfigOption::copy_from(ConfigOption & src) -{ - if (src._value_data.which() != _value_data.which()) - throw ConfigProcessFailure(STG(FMT("unable to copy options, source type differs from destination."))); - - if (!src._loaded) - return; - - switch ((value_id_type) _value_data.which()) - { - case ConfigOption::ID_BOOL: - { - try - { - BooleanData & stmp = src._value_data.get(); - BooleanData & dtmp = _value_data.get(); - /* do not copy references, but values.. */ - bool tmpval = stmp.bool_val; - dtmp.bool_val = tmpval; - } - catch(ValueType::InvalidType & e) - { - throw; - } - - break; - } - - case ConfigOption::ID_SINT: - { - try - { - SignedIntData & stmp = src._value_data.get(); - SignedIntData & dtmp = _value_data.get(); - /* do not copy references, but values.. */ - int tmpval = stmp.sint_val; - dtmp.sint_val = tmpval; - } - catch(ValueType::InvalidType & e) - { - throw; - } - - break; - } - - case ConfigOption::ID_UINT: - { - try - { - UnsignedIntData & stmp = src._value_data.get(); - UnsignedIntData & dtmp = _value_data.get(); - /* do not copy references, but values.. */ - unsigned int tmpval = stmp.uint_val; - dtmp.uint_val = tmpval; - } - catch(ValueType::InvalidType & e) - { - throw; - } - - - break; - } - - case ConfigOption::ID_STRING: - { - try - { - StringData & stmp = src._value_data.get(); - StringData & dtmp = _value_data.get(); - /* do not copy references, but values.. */ - std::string tmpval = stmp.string_val; - dtmp.string_val = tmpval; - } - catch(ValueType::InvalidType & e) - { - throw; - } - - break; - } - - case ConfigOption::ID_FUN: - { - /* TO IMPLEMENT (NEEDS ANOTHER METHOD ON FUNCTION FOR GETTING VALUE) */ - -// FunctionData & tmp = boost::get(_value_data); -// -// if (!tmp.loaded) -// { -// tmp.fun_val(tmp.fun_default); -// tmp.loaded = true; -// } - break; - } - - default: - throw ConfigProcessFailure(STG(FMT("unknown type identifier '%d'") % _value_data.which())); - } - - _loaded = true; -}; - -/*********************************/ - -bool ConfigOptions::add(ConfigOption option) -{ - //option_map_type::iterator iter2 = _map.begin(); - - //boost::tie(iter2, ok2) - std::pair ret = _map.insert(option_pair_type(option.name(), option)); - - return ret.second; -} - -bool ConfigOptions::synonym(std::string equiv_opt, std::string main_opt) -{ - //syn_option_map_type::iterator iter = _syn_map.begin(); - - //boost::tie(iter, ok) - std::pair ret = _syn_map.insert(syn_option_pair_type(equiv_opt, main_opt)); - - return ret.second; -} - -ConfigOptions::string_set ConfigOptions::options(void) -{ - string_set res; - - for (option_map_type::iterator i = _map.begin(); i != _map.end(); i++) - res.insert((*i).first); - - return res; -} - -void ConfigOptions::process(const char * name, const char * value) -{ - option_map_type::iterator iter = find_option(name); - - if (iter == _map.end()) - throw ConfigProcessFailure(STG(FMT("unknown option '%s'") % name)); - - try - { - switch ((*iter).second.type()) - { - case ConfigOption::ID_SINT: - set((*iter).first, Strings::toulong(value)); - return; - case ConfigOption::ID_UINT: - set((*iter).first, Strings::tolong(value)); - return; - case ConfigOption::ID_BOOL: - set((*iter).first, Strings::toboolean(value)); - return; - case ConfigOption::ID_STRING: - case ConfigOption::ID_FUN: - set((*iter).first, std::string(value)); - return; - default: - throw ConfigProcessFailure(STG(FMT("unknown type identifier '%d'") % (*iter).second.type())); - } - } - catch (Strings::invalid_value & e) - { - throw ConfigProcessFailure(STG(FMT("invalid value '%s' for option '%s'") % value % name)); - } -} - -const char ** ConfigOptions::values(const char * name) -{ - option_map_type::iterator iter = find_option(name); - - if (iter == _map.end()) - throw ConfigProcessFailure(STG(FMT("unknown option '%s'") % name)); - - return (*iter).second.values(); -} - -const char ** ConfigOptions::values(void) -{ - if (_values != NULL) - return _values; - - unsigned int count = 0; - - for (option_map_type::iterator i = _map.begin(); i != _map.end(); i++) - if ((*i).second.list_me()) - ++count; - - _values = new const char*[ count + 1 ]; - - unsigned int index = 0; - - for (option_map_type::iterator i = _map.begin(); i != _map.end(); i++) - { - if ((*i).second.list_me()) - { - _values[index] = strdup((*i).first.c_str()); - ++index; - } - } - - _values[index] = NULL; - - return _values; -} - -void ConfigOptions::reset(void) -{ - for (option_map_type::iterator i = _map.begin(); i != _map.end(); i++) - (*i).second.reset(); -} - -ConfigOptions::messages_type ConfigOptions::commit(void) -{ - messages_type msgs; - - for (option_map_type::iterator i = _map.begin(); i != _map.end(); i++) - { - try - { - (*i).second.commit(); - } - catch (ConfigProcessFailure & e) - { - msgs.push_back(e.msg); - } - } - - return msgs; -} - -bool ConfigOptions::loaded(std::string name) -{ - option_map_type::iterator iter = find_option(name); - - if (iter == _map.end()) - return false; - - return iter->second.loaded(); -} - -void ConfigOptions::copy_from(ConfigOptions & source, std::string name) -{ - option_map_type::iterator iter_src = source.find_option(name); - option_map_type::iterator iter_dst = find_option(name); - - if (iter_src == source._map.end()) - throw ConfigProcessFailure(STG(FMT("unknown option '%s' on source") % name)); - - if (iter_dst == _map.end()) - throw ConfigProcessFailure(STG(FMT("unknown option '%s' on destination") % name)); - - iter_dst->second.copy_from(iter_src->second); -} - -ConfigOptions::option_map_type::iterator ConfigOptions::find_option(std::string name) -{ - syn_option_map_type::iterator syn_iter = _syn_map.find(name); - - if (syn_iter != _syn_map.end()) - name = syn_iter->second; - - option_map_type::iterator iter = _map.find(name); - - return iter; -} diff --git a/src/mod/endpoints/mod_khomp/commons/config_options.hpp b/src/mod/endpoints/mod_khomp/commons/config_options.hpp deleted file mode 100644 index 3cfe2e1c78..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/config_options.hpp +++ /dev/null @@ -1,286 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include -#include -#include - -#include - -#include -#include -#include - -#ifndef _CONFIG_OPTIONS_HPP_ -#define _CONFIG_OPTIONS_HPP_ - -struct ConfigProcessFailure -{ - ConfigProcessFailure(std::string _msg): msg(_msg) {}; - std::string msg; -}; - -struct ConfigOption -{ - typedef int SignedIntType; - typedef unsigned int UnsignedIntType; - typedef bool BooleanType; - typedef std::string StringType; - - typedef Function::Function1 < void, std::string > FunctionType; - - typedef std::set < StringType > string_allowed_type; - - /* this should reflect 'variant.which()'! */ - typedef enum - { - ID_SINT = 0, - ID_UINT = 1, - ID_BOOL = 2, - ID_STRING = 3, - ID_FUN = 4, - } - value_id_type; - - template < typename number_type > - struct Range - { - Range(number_type _minimum, number_type _maximum, number_type _step) - : minimum(_minimum), maximum(_maximum), step(_step) {}; - - number_type minimum, maximum, step; - }; - - struct SignedIntData : public VariantBaseType < void > - { - SignedIntData(SignedIntType & _sint_val, SignedIntType _sint_default, Range< SignedIntType > _sint_Range) - : sint_val(_sint_val), sint_default(_sint_default), sint_Range(_sint_Range) {}; - - int which() - { - return ID_SINT; - } - - SignedIntType & sint_val; - SignedIntType sint_default; - Range sint_Range; - }; - - struct UnsignedIntData : public VariantBaseType < void > - { - UnsignedIntData(UnsignedIntType & _uint_val, UnsignedIntType _uint_default, Range< UnsignedIntType > _uint_Range) - : uint_val(_uint_val), uint_default(_uint_default), uint_Range(_uint_Range) {}; - - int which() - { - return ID_UINT; - } - - UnsignedIntType & uint_val; - UnsignedIntType uint_default; - Range uint_Range; - }; - - struct BooleanData : public VariantBaseType < void > - { - BooleanData(BooleanType & _bool_val, BooleanType _bool_default) - : bool_val(_bool_val), bool_default(_bool_default) {}; - - int which() - { - return ID_BOOL; - } - - BooleanType & bool_val; - BooleanType bool_default; - }; - - struct StringData : public VariantBaseType < void > - { - StringData(std::string & _string_val, std::string _string_default, string_allowed_type _string_allowed) - : string_val(_string_val), string_default(_string_default), string_allowed(_string_allowed) {}; - - int which() - { - return ID_STRING; - } - - std::string & string_val; - std::string string_default; - string_allowed_type string_allowed; - }; - - struct FunctionData : public VariantBaseType < void > - { - FunctionData(FunctionType _fun_val, std::string _fun_default, string_allowed_type _fun_allowed) - : fun_val(_fun_val), fun_default(_fun_default), fun_allowed(_fun_allowed) {}; - - int which() - { - return ID_FUN; - } - - FunctionType fun_val; - std::string fun_default; - string_allowed_type fun_allowed; - }; - - - typedef Variant < VariantBaseType < void > > ValueType; - - ConfigOption(std::string, const StringType &, const StringType, string_allowed_type allowed, bool list_me = true); - ConfigOption(std::string, const StringType &, const StringType = "", bool list_me = true); - ConfigOption(std::string, const SignedIntType &, const SignedIntType = 0, SignedIntType min = -INT_MAX, SignedIntType max = INT_MAX, SignedIntType step = 1, bool list_me = true); - ConfigOption(std::string, const UnsignedIntType &, const UnsignedIntType = 0, UnsignedIntType min = 0, UnsignedIntType max = UINT_MAX, UnsignedIntType step = 1, bool list_me = true); - ConfigOption(std::string, const BooleanType &, const BooleanType = false, bool list_me = true); - ConfigOption(std::string, FunctionType, std::string defvalue, string_allowed_type allowed, bool list_me = true); - ConfigOption(std::string, FunctionType, std::string defvalue = "", bool list_me = true); - - ConfigOption(const ConfigOption & o); - - ~ConfigOption(void); - - void set(StringType value); - - void set(SignedIntType value); - void set(UnsignedIntType value); - void set(BooleanType value); - - BooleanType get_bool(){ return _value_data.get().bool_val; } - std::string get_str(){ return _value_data.get().string_val; } - SignedIntType get_sint(){ return _value_data.get().sint_val; } - UnsignedIntType get_uint(){ return _value_data.get().uint_val; } - - std::string & name(void); - value_id_type type(void); - - const char ** values(void); - - void reset(void); - void commit(void); - - bool list_me(void) { return _list_me; }; - bool loaded(void) { return _loaded; }; - - void copy_from(ConfigOption &); - - protected: - std::string _my_name; - ValueType _value_data; - - bool _list_me; - const char ** _values; - bool _loaded; -}; - -struct ConfigOptions -{ - typedef std::vector < std::string > messages_type; - - ConfigOptions(void): _values(NULL) {}; - - typedef std::set < std::string > string_set; - - typedef std::map < std::string, ConfigOption > option_map_type; - typedef std::pair < std::string, ConfigOption > option_pair_type; - - typedef std::map < std::string, std::string > syn_option_map_type; - typedef std::pair < std::string, std::string > syn_option_pair_type; - - bool add(ConfigOption option); - - /* only valid in "process" (for backwards compatibility config files) */ - bool synonym(std::string, std::string); - - template - void set(std::string name, ValueType value) - { - option_map_type::iterator iter = _map.find(name); - - if (iter == _map.end()) - throw ConfigProcessFailure(STG(FMT("unknown option: %s") % name)); - - (*iter).second.set(value); - } - - std::string get(std::string name) - { - option_map_type::iterator iter = _map.find(name); - - if (iter == _map.end()) - throw ConfigProcessFailure(STG(FMT("unknown option: %s") % name)); - - switch((*iter).second.type()) - { - case ConfigOption::ID_BOOL: return (*iter).second.get_bool() ? "yes" : "no"; - case ConfigOption::ID_STRING: return (*iter).second.get_str(); - case ConfigOption::ID_UINT: return STG(FMT("%d") % (*iter).second.get_uint()); - case ConfigOption::ID_SINT: return STG(FMT("%d") % (*iter).second.get_sint()); - case ConfigOption::ID_FUN: return ""; - } - } - - string_set options(void); - - void process(const char *, const char *); /* process option from file */ - - void reset(void); /* reset loaded opts */ - messages_type commit(void); /* set defaults */ - - const char ** values(const char *); /* option value */ - const char ** values(void); /* values from options */ - - bool loaded(std::string); /* return if config was loaded */ - - void copy_from(ConfigOptions &, std::string); - - protected: - option_map_type::iterator find_option(std::string); - - protected: - option_map_type _map; - syn_option_map_type _syn_map; - - const char ** _values; -}; - -#endif /* _CONFIG_OPTIONS_HPP_ */ - diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/configfile.cpp b/src/mod/endpoints/mod_khomp/commons/configurator/configfile.cpp deleted file mode 100644 index 6aa2e59201..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/configurator/configfile.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ -#include - -#include - -#if _MSC_VER >= 1400 -#undef close -#endif - -void Configfile::ignore(std::string str) -{ - _ignores.insert(str); -}; - -bool Configfile::select(Section **ptr, std::string str) -{ - /* default section == this! */ - *ptr = this; - - /* always success by default */ - return true; -}; - -bool Configfile::adjust(Section * section, std::string & opt, std::string & val) -{ - return section->load(opt, val); -}; - -bool Configfile::deserialize(std::ifstream& fd) -{ - Section * section = NULL; - - /* default selection! */ - if (!select(§ion)) - { - _errors.push_back("default selection has failed!"); - return false; - } - - size_t count = 0; - - while (fd.good()) - { - std::string str; - - /* read one line! */ - std::getline(fd, str); - - size_t lst = str.size() - 1; - - if (str.size() >= 1 && str[lst] == '\r') //cuida das quebras de linha do tipo \r\n - { - str.erase(lst,1); - --lst; - } - - /* empty line! */ - if (str.size() == 0) - continue; - - /* comment! */ - if (str[0] == '#') - continue; - - ++count; - - if (str[0] == '[' && str[lst] == ']') - { - str.erase(0,1); --lst; - str.erase(lst,1); --lst; - - if (!select(§ion, str)) - { - _errors.push_back(STG(FMT("erroneous section '%s'") % str)); - - /* ignore this section */ - section = NULL; - continue; - } - } - else - { - std::string::size_type pos = str.find('='); - - if (pos == std::string::npos) - { - _errors.push_back(STG(FMT("erroneous separator '%s'") % str)); - continue; - }; - - if (section == NULL) - { - _errors.push_back(STG(FMT("no section for option '%s'") % str)); - continue; - } - - std::string opt(str.substr(0,pos)); - std::string val(str.substr(pos+1)); - - if (_ignores.find(opt) != _ignores.end()) - continue; - - if (val == "@") val = ""; - - if (adjust(section, opt, val)) - continue; - - _errors.push_back(STG(FMT("option '%s' does " - "not exist or '%s' is not a valid value (at section '%s')") - % opt % val % section->name())); - } - } - - // retorna 'true' se arquivo tinha alguma coisa valida. - return (count != 0); -} - -bool Configfile::obtain() -{ - std::ifstream fd(_filename.c_str()); - - if (!fd.is_open()) - { - _errors.push_back(STG(FMT("unable to open file '%s': %s") - % _filename % strerror(errno))); - return false; - }; - - if (!deserialize(fd)) - { - fd.close(); - return false; - } - - fd.close(); - return true; -}; - -void Configfile::recurse(std::ofstream& fd, Section * section) -{ - typedef Section::SectionMap::iterator section_iter; - typedef Section::OptionMap::iterator option_iter; - - for (option_iter i = section->option_begin(); i != section->option_end(); i++) - { - std::string res; - - if ((*i).second.store(res)) - { - if (res == "") res = "@"; - fd << (*i).first << "=" << res << std::endl; - } - } - - if (!section->recursive()) - return; - - for (section_iter j = section->section_begin(); j != section->section_end(); j++) - recurse(fd, (*j).second); -} - -bool Configfile::serialize(std::ofstream& fd) -{ - recurse(fd, this); - return true; -} - -bool Configfile::provide() -{ - std::string tmp(_filename); - tmp += ".new"; - - std::ofstream fd(tmp.c_str()); - - if (!fd.good()) - { - _errors.push_back(STG(FMT("unable to open file '%s': %s") - % tmp % strerror(errno))); - return false; - } - - if (!serialize(fd)) - { - fd.close(); - return false; - } - - fd.close(); - - if (rename(tmp.c_str(), _filename.c_str()) != 0) - { - _errors.push_back(STG(FMT("unable to replace config file '%s': %s") - % _filename % strerror(errno))); - return false; - } - - return true; -} - -#if _MSC_VER >= 1400 -#define close _close -#endif \ No newline at end of file diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/option.cpp b/src/mod/endpoints/mod_khomp/commons/configurator/option.cpp deleted file mode 100644 index 083883e63f..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/configurator/option.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include - -bool Option::equals(std::string & value) -{ - switch (_restriction.numeral()) - { - case Restriction::N_UNIQUE: - { - Restriction::Value my_value; - - if (!_restriction.get(Restriction::F_USER, my_value)) - return false; - - return (my_value == value); - } - case Restriction::N_MULTIPLE: - { - Restriction::Vector my_values; - - if (!_restriction.get(Restriction::F_USER, my_values)) - return false; - - for (Restriction::Vector::iterator i = my_values.begin(); i != my_values.end(); i++) - { - if ((*i) == value) - return true; - } - - return false; - } - } - - return false; -} - -bool Option::load(std::string & value) -{ - bool ret = _restriction.set(Restriction::F_FILE, value); - - if (ret) _modified = false; - - return ret; -} - -bool Option::change(std::string & value) -{ - bool ret = _restriction.set(Restriction::F_FILE, value); - - if (ret) _modified = true; - - return ret; -} - -bool Option::store(std::string & value) -{ - switch (_restriction.numeral()) - { - case Restriction::N_UNIQUE: - return _restriction.get(Restriction::F_FILE, value); - - case Restriction::N_MULTIPLE: - { - Restriction::Vector values; - - if (!_restriction.get(Restriction::F_FILE, values)) - return false; - - Strings::Merger strs; - - for (Restriction::Vector::iterator i = values.begin(); i != values.end(); i++) - strs.add(*i); - - value = strs.merge(","); - - return true; - } - - default: - return false; - } -} - -Option::Flags Option::set(const char * value) -{ - std::string str_value(value); - return set(str_value); -} - - -Option::Flags Option::set(Restriction::Value & value) -{ - Restriction::Value last_value, curr_value; - Flags flags; - - bool ret1 = _restriction.get(Restriction::F_USER, last_value); - - if (!_restriction.set(Restriction::F_USER, value)) - return flags; - - flags[F_ADJUSTED] = true; - - bool ret2 = _restriction.get(Restriction::F_USER, curr_value); - - if (!ret1 || (ret2 && (last_value != curr_value))) - { - flags[F_MODIFIED] = true; - _modified = true; - } - - return flags; -} - -Option::Flags Option::set(Restriction::Vector & values) -{ - Restriction::Vector last_values, curr_values; - Flags flags; - - bool ret1 = _restriction.get(Restriction::F_USER, last_values); - - if (!_restriction.set(Restriction::F_USER, values)) - return flags; - - flags[F_ADJUSTED] = true; - - bool ret2 = _restriction.get(Restriction::F_USER, curr_values); - - if (!ret1 || (ret2 && (last_values != curr_values))) - { - flags[F_MODIFIED] = true; - _modified = true; - } - - return flags; -} - -bool Option::get(Restriction::Value & value) -{ - return _restriction.get(Restriction::F_USER, value); -} - -bool Option::get(Restriction::Vector & values) -{ - return _restriction.get(Restriction::F_USER, values); -} diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/restriction.cpp b/src/mod/endpoints/mod_khomp/commons/configurator/restriction.cpp deleted file mode 100644 index 9653a7c608..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/configurator/restriction.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include -#include - -#include -#include - -#include - -/* internal helper! */ -bool Restriction::equalNumber(const double a, const double b) -{ - char tmp1[64]; - char tmp2[64]; - - snprintf(tmp1, sizeof(tmp1), "%.3f", a); - snprintf(tmp2, sizeof(tmp2), "%.3f", b); - - if (strncmp(tmp1, tmp2, sizeof(tmp1))) - return false; - - return true; -} - -/* process value to our internal representation */ - -bool Restriction::process(Restriction::Format fmt, - const Restriction::Value & value, Restriction::Value & final) -{ - switch (_bounds) - { - case B_RANGE: - { - if (_kind != K_NUMBER) - return false; - - std::string tmpvalue; - - Restriction::Value::const_iterator itr = value.begin(); - Restriction::Value::const_iterator end = value.end(); - - tmpvalue.reserve(value.size()); - - // f*cking dot/comma notation! - for (; itr != end; ++itr) - tmpvalue += ((*itr) != ',' ? (*itr) : '.'); - - try - { - double newvalue = Strings::todouble(tmpvalue); - - if (newvalue < _init && newvalue > _fini) - return false; - - double res = (newvalue - _init) / _step; - - if (!equalNumber(res, rint(res))) - return false; - - final = value; - return true; - } - catch (...) - { - return false; - } - } - - case B_LIST: - for (List::iterator i = _list.begin(); i != _list.end(); i++) - { - Value & tmp = (*i); - - if (tmp == value) - { - final = value; - return true; - } - } - return false; - - case B_MAPS: - switch (fmt) - { - case F_USER: - { - Map::iterator i = _map_from_usr.find(std::string(value)); - - if (i == _map_from_usr.end()) - return false; - - Value & tmp = (*i).second; - - final = tmp; - return true; - } - - case F_FILE: - { - Map::iterator i = _map_from_cfg.find(std::string(value)); - - if (i == _map_from_cfg.end()) - return false; - - final = value; - return true; - } - - default: - break; - } - return false; - - case B_FREE: - final = value; - return true; - - default: - break; - } - - return false; -} - -/* unprocess the value (outputs the external representation) */ - -bool Restriction::unprocess(Restriction::Format fmt, - const Restriction::Value & value, Restriction::Value & final) -{ - switch (_bounds) - { - case B_MAPS: - - switch (fmt) - { - case F_USER: - { - Map::iterator i = _map_from_cfg.find(std::string(value)); - - if (i == _map_from_cfg.end()) - return false; - - final = (*i).second; - return true; - } - default: - break; - } - - default: - final = value; - return true; - } -} - -/***************************** *****************************/ - -bool Restriction::get(Restriction::Format fmt, Restriction::Value & value) -{ - if (_numeral != N_UNIQUE) - return false; - - if (!unprocess(fmt, _value._unique, value)) - return false; - - return true; -} - -bool Restriction::get(Restriction::Format fmt, Restriction::Vector & values) -{ - if (_numeral != N_MULTIPLE) - return false; - - List & my_values = _value._multiple; - - for (List::iterator i = my_values.begin(); i != my_values.end(); i++) - { - Value & value = (*i); - Value final; - - if (!unprocess(fmt, value, final)) - return false; - - values.push_back(final); - }; - - return true; -} - -/***************************** *****************************/ - -bool Restriction::set(Restriction::Format fmt, Restriction::Value &value) -{ - switch (_numeral) - { - case N_UNIQUE: - { - Value final; - - if (!process(fmt, value, final)) - return false; - - _value._unique = final; - return true; - } - - case N_MULTIPLE: - { - if (value == "@" || value == "#" || value == "") - { - _value._multiple.clear(); - return true; - } - - Strings::vector_type values; - Strings::tokenize(value, values, ","); - - return set(fmt, values); - } - - default: - return false; - } -} - -bool Restriction::set(Restriction::Format fmt, Restriction::Vector & values) -{ - if (_numeral != N_MULTIPLE) - return false; - - if (values.empty()) - { - _value._multiple.clear(); - } - else - { - /* list needed to store temporary values */ - List finals; - - for (Vector::iterator i = values.begin(); i != values.end(); i++) - { - Value & value = (*i); - Value final; - - if (!process(fmt, value, final)) - return false; - - finals.push_back(final); - } - - List & lst = _value._multiple; - - /* need to clear values set before */ - lst.clear(); - - for (List::iterator i = finals.begin(); i != finals.end(); i++) - { - Value value = (*i); - lst.push_back(value); - } - }; - - return true; -} - -/***************************** *****************************/ - -void Restriction::allowed(Restriction::Vector &vals) -{ - switch (_bounds) - { - case B_FREE: - return; - - case B_LIST: - for (List::iterator i = _list.begin(); i != _list.end(); i++) - vals.push_back((*i)); - break; - - case B_MAPS: - for (Map::iterator i = _map_from_usr.begin(); i != _map_from_usr.end(); i++) - vals.push_back((*i).first); - break; - - case B_RANGE: - { - if (_kind != K_NUMBER) - return; - - // is there any fraction? - bool has_fraction = (!equalNumber(_init, rint(_init))) || (!equalNumber(_fini, rint(_fini))) || (!equalNumber(_step, rint(_step))); - - const char * format = (has_fraction ? "%.2f" : "%02.0f"); - - for (double i = _init; i <= _fini; i += _step) - { - char tmp[32]; - snprintf(tmp, sizeof(tmp), format, i); - vals.push_back(std::string(tmp)); - } - break; - } - - default: - break; - } -} - -void Restriction::init_class() -{ - _value._unique.clear(); - _value._multiple.clear(); -} diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/restriction.hpp b/src/mod/endpoints/mod_khomp/commons/configurator/restriction.hpp deleted file mode 100644 index 0815ede3db..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/configurator/restriction.hpp +++ /dev/null @@ -1,321 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include - -#include -#include -#include -#include - -#ifndef _CONFIG_RESTRICTION_HPP_ -#define _CONFIG_RESTRICTION_HPP_ - -struct Restriction -{ - /* generic types */ - enum Format - { - F_USER, - F_FILE - }; - - enum Kind - { -// K_INTEGER, -// K_FLOAT, - K_STRING, - K_NUMBER // = K_INTEGER // compatibility - }; - - enum Bounds - { - B_FREE, - B_RANGE, - B_LIST, - B_MAPS - }; - - enum Numeral - { - N_UNIQUE, - N_MULTIPLE - }; - - typedef std::string Value; - - /* types used for data input */ - struct Pair - { - const char *pretty; - const char *value; - }; - - typedef std::pair < Value, Value > PairMap; - typedef std::list < PairMap > ListMap; - - /* types used internally */ - typedef std::map < Value, Value > Map; - typedef std::vector < Value > Vector; - - typedef std::list < Value > List; - typedef std::pair < Value, Value > MapPair; - - struct Generic - { - Value _unique; - List _multiple; - }; - - Restriction(Kind kind, Numeral num) - : _kind(kind), _bounds(B_FREE), _numeral(num), _unit(""), - _init(-1), _fini(-1), _step(-1) - { - init_class(); - } - -/* - Restriction(Kind kind, Numeral num, - int init, int fini, int step = 1) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _iinit(init), _ifini(fini), _istep(step), - _finit(-1), _ffini(-1), _fstep(-1) - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - const char *unit, int init, int fini, int step = 1) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _iinit(init), _ifini(fini), _istep(step), - _finit(-1), _ffini(-1), _fstep(-1) - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - std::string unit, int init, int fini, int step = 1) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _iinit(init), _ifini(fini), _istep(step), - _finit(-1), _ffini(-1), _fstep(-1) - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - float init, float fini, float step = 1) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _iinit(-1), _ifini(-1), _istep(-1) - _finit(init), _ffini(fini), _fstep(step), - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - const char *unit, float init, float fini, float step = 1.0) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _iinit(-1), _ifini(-1), _istep(-1) - _finit(init), _ffini(fini), _fstep(step), - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - std::string unit, float init, float fini, float step = 1.0) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _iinit(-1), _ifini(-1), _istep(-1) - _finit(init), _ffini(fini), _fstep(step), - { - init_class(); - } -*/ - - Restriction(Kind kind, Numeral num, - double init, double fini, double step = 1) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(""), - _init(init), _fini(fini), _step(step) - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - const char *unit, double init, double fini, double step = 1.0) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _init(init), _fini(fini), _step(step) - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - std::string unit, double init, double fini, double step = 1.0) - : _kind(kind), _bounds(B_RANGE), _numeral(num), _unit(unit), - _init(init), _fini(fini), _step(step) - { - init_class(); - } - - Restriction(Kind kind, Numeral num, - const char *first, ...) - : _kind(kind), _bounds(B_LIST), _numeral(num), _unit(""), - _init(-1), _fini(-1), _step(-1) - { - _list.push_back(std::string(first)); - - va_list ap; - va_start(ap, first); - - while (true) - { - const char *arg = va_arg(ap, const char *); - - if (arg == NULL) break; - - _list.push_back(std::string(arg)); - } - - init_class(); - } - - Restriction(Kind kind, const char *unit, Numeral num, - const char *first, ...) - : _kind(kind), _bounds(B_LIST), _numeral(num), _unit(unit), - _init(-1), _fini(-1), _step(-1) - { - _list.push_back(std::string(first)); - - va_list ap; - va_start(ap, first); - - while (true) - { - const char *arg = va_arg(ap, const char *); - - if (arg == NULL) break; - - _list.push_back(std::string(arg)); - } - - init_class(); - } - - Restriction(Kind kind, Numeral num, - const struct Pair first, ...) - : _kind(kind), _bounds(B_MAPS), _numeral(num), _unit(""), - _init(-1), _fini(-1), _step(-1) - { - _map_from_usr.insert(MapPair(Value(first.pretty), Value(first.value))); - _map_from_cfg.insert(MapPair(Value(first.value), Value(first.pretty))); - - va_list ap; - va_start(ap, first); - - while (true) - { - Pair arg = va_arg(ap, Pair); - - if (arg.pretty == NULL) break; - - _map_from_usr.insert(MapPair(Value(arg.pretty), Value(arg.value))); - _map_from_cfg.insert(MapPair(Value(arg.value), Value(arg.pretty))); - } - - init_class(); - } - - Restriction(Kind kind, Numeral num, List list) - : _kind(kind), _bounds(B_LIST), _numeral(num), _unit(""), - _init(-1), _fini(-1), _step(-1), _list(list) - { - init_class(); - } - - Restriction(Kind kind, Numeral num, ListMap map) - : _kind(kind), _bounds(B_MAPS), _numeral(num), _unit(""), - _init(-1), _fini(-1), _step(-1) - { - for (ListMap::iterator i = map.begin(); i != map.end(); i++) - { - _map_from_usr.insert(MapPair(Value((*i).first), Value((*i).second))); - _map_from_cfg.insert(MapPair(Value((*i).second), Value((*i).first))); - } - - init_class(); - } - - Kind kind() { return _kind; }; - Bounds bounds() { return _bounds; }; - Numeral numeral() { return _numeral; }; - - Value unit() { return _unit; }; - - bool set(Format, Vector &); - bool set(Format, Value &); - - bool get(Format, Vector &); - bool get(Format, Value &); - - void allowed(Vector &); - - private: - bool process(Format, const Value &, Value &); - bool unprocess(Format, const Value &, Value &); - void init_class(); - - bool equalNumber(const double, const double); - - protected: - Kind _kind; - Bounds _bounds; - Numeral _numeral; - - Value _unit; - - double _init, _fini, _step; - - Map _map_from_usr, - _map_from_cfg; - - List _list; - - Generic _value; -}; - -#endif /* _CONFIG_RESTRICTION_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/configurator/section.hpp b/src/mod/endpoints/mod_khomp/commons/configurator/section.hpp deleted file mode 100644 index fdb782308a..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/configurator/section.hpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include -#include -#include -#include -#include - -#include - -#ifndef _CONFIG_SECTION_HPP_ -#define _CONFIG_SECTION_HPP_ - -struct Section -{ - typedef std::map < std::string, Option > OptionMap; - typedef std::vector< Option * > OptionVector; - - typedef std::map < std::string, Section * > SectionMap; - typedef std::vector < Section * > SectionVector; - - struct not_found {}; /* exception */ - -// protected: - Section(std::string name, std::string desc, bool recursive = true) - : _name(name), _description(desc), _recursive(recursive) {}; - - void add(Option o) - { - _options.insert(std::pair(o.name(), o)); - }; - - void del(std::string name) - { - _options.erase(name); - }; - - void add(Section *s) - { - _sections.insert(std::pair(s->name(), s)); - }; - - public: - const std::string & name() { return _name; }; - const std::string & description() { return _description; }; - const bool & recursive() { return _recursive; }; - - OptionMap::iterator option_begin() { return _options.begin(); }; - OptionMap::iterator option_end() { return _options.end(); }; - - SectionMap::iterator section_begin() { return _sections.begin(); }; - SectionMap::iterator section_end() { return _sections.end(); }; - - /**/ - - Option * option_find(const char *, bool recurse = false); - Section * section_find(const char *, bool recurse = false); - - Option * option_find(std::string &, bool recurse = false); - Section * section_find(std::string &, bool recurse = false); - - /**/ - - void options(OptionVector &); - void sections(SectionVector &); - - /**/ - - template - bool search_and_apply(std::string &key, std::string &value, F f) - { - OptionMap::iterator i = _options.find(key); - - if (i != _options.end()) - return f((*i).second); - - if (!_recursive) - return false; - - return (find_if(_sections.begin(), _sections.end(), f) != _sections.end()); - } - - private: - struct key_value - { - key_value(std::string &k, std::string &v): _k(k), _v(v) {}; - std::string & _k, & _v; - }; - - struct load_section: protected key_value - { - load_section(std::string &k, std::string &v): key_value(k,v) {}; - - bool operator()(Option &o) { return o.load(_v); }; - bool operator()(SectionMap::value_type &v) { return v.second->load(_k,_v); }; - }; - - struct change_section: protected key_value - { - change_section(std::string &k, std::string &v): key_value(k,v) {}; - - bool operator()(Option &o) { return o.change(_v); }; - bool operator()(SectionMap::value_type &v) { return v.second->change(_k,_v); }; - }; - - struct store_section: protected key_value - { - store_section(std::string &k, std::string &v): key_value(k,v) {}; - - bool operator()(Option &o) { return o.store(_v); }; - bool operator()(SectionMap::value_type &v) { return v.second->store(_k,_v); }; - }; - - struct set_section: protected key_value - { - set_section(std::string &k, std::string &v): key_value(k,v) {}; - - bool operator()(Option &o) { return (o.set(_v))[Option::F_ADJUSTED]; }; - bool operator()(SectionMap::value_type &v) { return v.second->set(_k,_v); }; - }; - - struct get_section: protected key_value - { - get_section(std::string &k, std::string &v): key_value(k,v) {}; - - bool operator()(Option &o) { return o.get(_v); }; - bool operator()(SectionMap::value_type &v) { return v.second->get(_k,_v); }; - }; - - struct modified_section - { - bool operator()(OptionMap::value_type &v) { return v.second.modified(); }; - bool operator()(SectionMap::value_type &v) { return v.second->modified(); }; - }; - - public: - bool load(const char * key, std::string value) - { - std::string skey(key); - return search_and_apply(skey, value, load_section(skey, value)); - } - - bool load(std::string &key, std::string &value) - { - return search_and_apply(key, value, load_section(key, value)); - } - - bool change(std::string &key, std::string &value) - { - return search_and_apply(key, value, change_section(key, value)); - } - - bool store(std::string &key, std::string &value) - { - return search_and_apply(key, value, store_section(key, value)); - } - - bool set(std::string &key, std::string &value) - { - return search_and_apply(key, value, set_section(key, value)); - } - - bool get(std::string &key, std::string &value) - { - return search_and_apply(key, value, get_section(key, value)); - } - - bool modified() - { - return ((find_if(_options.begin(), _options.end(), modified_section()) != _options.end()) || - (find_if(_sections.begin(), _sections.end(), modified_section()) != _sections.end())); - } - - private: - Section() {}; - - protected: - std::string _name; - std::string _description; - - OptionMap _options; - SectionMap _sections; - - bool _recursive; -}; - -#endif /* _CONFIG_SECTION_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/commons/ringbuffer.cpp b/src/mod/endpoints/mod_khomp/commons/ringbuffer.cpp deleted file mode 100644 index 428bd29221..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/ringbuffer.cpp +++ /dev/null @@ -1,575 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include - -/********** BUFFER FUNCTIONS **********/ - -/* writes everything or nothing */ -bool Ringbuffer_traits::traits_provide(char * buffer, const char * value, unsigned int amount, bool skip_overwrite) -{ - /* avoid using different values */ - Buffer_table cache = _pointers; - - const unsigned int reader = cache.reader.complete; - const unsigned int writer = cache.writer.complete; - - const unsigned int dest = cache.writer.complete - 1; - - const bool reader_less = cache.reader.complete < cache.writer.complete; - - if (amount >= _size) - return false; - - bool ret = true; - - /* should we go around the buffer for writing? */ - if (((writer + amount) > _size) && (reader_less || !skip_overwrite)) - { - /* Documentation of the formula used in the 'if' below. - * - * [0|1|2|3|4|5|6|7] => size=8 - * | | - * reader | - * writer - * - * => writer has places [5,6,7,0,1] to write (5 places). - * - * => 8 - (4-2+1) = 8 - (2+1) = 8 - 3 = 5 - * - * > writer goes 1 up, amount goes 1 down. - * > reader goes 1 up, amount goes 1 up. - * > size goes 1 down, amount goes 1 down. - * - */ - - if ((_size - (writer - reader + 1)) <= amount) - { - if (skip_overwrite) - return false; - - do - { - Buffer_pointer extra(cache.reader); - extra.complete = (extra.complete + amount) % _size; - - if (update(cache.reader, extra)) - break; - } - while (true); - - ret = false; - } - - unsigned int wr1 = _size - writer + 1; /* writer is already 1 position after */ - unsigned int wr2 = amount - wr1; - -// fprintf(stderr, "%p> partial write: (%d/%d) %d/%d [%d/%d]\n", this, wr1, wr2, amount, _size, reader, writer); - - /* two partial writes (one at the end, another at the beginning) */ - memcpy((void *) &(buffer[dest]), (const void *) (value), _block * wr1); - memcpy((void *) (buffer), (const void *) &(value[wr1]), _block * wr2); - } - else - { - if (!reader_less && ((reader - writer) <= amount)) - { - if (skip_overwrite) - return false; - - do - { - Buffer_pointer extra(cache.reader); - extra.complete = (extra.complete + amount) % _size; - - if (update(cache.reader, extra)) - break; - } - while (true); - - ret = false; - } - -// fprintf(stderr, "%p> full write: a=%d/s=%d [r=%d/w=%d]\n", this, amount, _size, reader, writer); - - /* we are talking about buffers here, man! */ - memcpy((void *) &(buffer[dest]), (const void *) value, _block * amount); - } - - _pointers.writer.complete = ((dest + amount) % _size) + 1; - _pointers.writer.partial = 1; - -// fprintf(stderr, "%p> write end: %d [block=%d]\n", this, writer, _block); - - return ret; -} - -/* returns the number of itens that have been read */ -unsigned int Ringbuffer_traits::traits_consume(const char * buffer, char * value, unsigned int amount, bool atomic_mode) -{ - /* avoid using different values */ - Buffer_table cache = _pointers; - - const unsigned int writer = _pointers.writer.complete; - const unsigned int reader = _pointers.reader.complete; - - const bool writer_less = writer < reader; - - unsigned int total = 0; - - /* should we go around the buffer for reading? */ - if (writer_less && (reader + amount >= _size)) - { - total = std::min(_size - (reader - writer + 1), amount); - - if ((total == 0) || (atomic_mode && (total < amount))) - return 0; - - unsigned int rd1 = _size - reader; - unsigned int rd2 = total - rd1; - -// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); - - /* two partial consumes (one at the end, another at the beginning) */ - memcpy((void *) (value), (const void *) &(buffer[reader]), _block * rd1); - memcpy((void *) &(value[rd1]), (const void *) (buffer), _block * rd2); - } - else - { - total = std::min((!writer_less ? writer - (reader + 1) : amount), amount); - - if ((total == 0) || (atomic_mode && (total < amount))) - return 0; - -// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); - - /* we are talking about buffers here, man! */ - memcpy((void *) value, (const void *) &(buffer[reader]), _block * total); - } - - do - { - /* jump the reader forward */ - Buffer_pointer index((cache.reader.complete + total) % _size); - - if (update(cache.reader, index)) - break; - } - while (true); - -// fprintf(stderr, "%p> read end: %d [block=%d]\n", this, reader, _block); - - return total; -} - -/********** TWO-PHASE BUFFER FUNCTIONS ***********/ - -/* returns the number of itens that have been read */ -unsigned int Ringbuffer_traits::traits_consume_begins(const char * buffer, char * value, unsigned int amount, bool atomic_mode) -{ - Buffer_table cache = _pointers; - - /* avoid using different values */ - const unsigned int reader = cache.reader.complete; - const unsigned int writer = cache.writer.complete; - - const bool writer_less = writer < reader; - - unsigned int total = 0; - - /* should we go around the buffer for reading? */ - if (writer_less && (reader + amount >= _size)) - { - total = std::min(_size - (reader - writer + 1), amount); - - if ((total == 0) || (atomic_mode && (total < amount))) - return 0; - - unsigned int rd1 = _size - reader; - unsigned int rd2 = total - rd1; - -// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); - - /* two partial consumes (one at the end, another at the beginning) */ - memcpy((void *) (value), (const void *) &(buffer[reader]), _block * rd1); - memcpy((void *) &(value[rd1]), (const void *) (buffer), _block * rd2); - } - else - { - total = std::min((!writer_less ? writer - (reader + 1) : amount), amount); - - if ((total == 0) || (atomic_mode && (total < amount))) - return 0; - -// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); - - /* we are talking about buffers here, man! */ - memcpy((void *) value, (const void *) &(buffer[reader]), _block * total); - } - -// fprintf(stderr, "%p> read end: %d [%d]\n", this, _reader, _reader_partial); - - return total; -} - -bool Ringbuffer_traits::traits_consume_commit(unsigned int amount) -{ - /* avoid using different values */ - Buffer_table cache = _pointers; - - const unsigned int writer = cache.writer.complete; - const unsigned int reader = cache.reader.complete; - - const bool writer_less = writer < reader; - - unsigned int total = 0; - - /* should we go around the buffer for reading? */ - if (writer_less && (reader + amount >= _size)) - { - total = std::min(_size - (reader - writer + 1), amount); - - if (total < amount) - return false; - -// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); - } - else - { - total = std::min((!writer_less ? writer - (reader + 1) : amount), amount); - - if (total < amount) - return false; - -// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); - } - - do - { - /* jump the reader forward */ - Buffer_pointer index(cache.reader); - index.complete = (index.complete + total) % _size; - - if (update(cache.reader, index)) - break; - } - while (true); - -// fprintf(stderr, "%p> read end: %d [%d]\n", this, _reader, _reader_partial); - - return true; -} - -/********** PARTIAL BUFFER FUNCTIONS (bytes) ***********/ - -/* writes everything or nothing */ -bool Ringbuffer_traits::traits_provide_partial(char * buffer, const char * value, unsigned int amount) -{ - /* avoid using different values */ - Buffer_table cache = _pointers; - - const unsigned int reader = (cache.reader.complete * _block) + cache.reader.partial; - const unsigned int writer = ((cache.writer.complete - 1) * _block) + cache.writer.partial; - - const unsigned int size = _size * _block; - const unsigned int dest = writer - 1; - -// fprintf(stderr, "%p> provide partial: %d/%d [%d/%d]\n", this, reader, writer, amount, size); - - const bool reader_less = reader < writer; - - /* should we go around the buffer for writing? */ - if (reader_less && ((writer + amount) > size)) - { - /* Documentation of the formula used in the 'if' below. - * - * [0|1|2|3|4|5|6|7] => size=8 - * | | - * reader | - * writer - * - * => writer has places [5,6,7,0,1] to write (5 places). - * - * => 8 - (4-2+1) = 8 - (2+1) = 8 - 3 = 5 - * - * > writer goes 1 up, amount goes 1 down. - * > reader goes 1 up, amount goes 1 up. - * > size goes 1 down, amount goes 1 down. - * - */ - - if ((size - (writer - reader + 1)) <= amount) - return false; - - unsigned int wr1 = size - writer + 1; /* writer is already 1 position after */ - unsigned int wr2 = amount - wr1; - -// fprintf(stderr, "%p> p partial write: (%d/%d) %d/%d [%d/%d]\n", this, wr1, wr2, amount, size, reader, writer); - - /* two partial writes (one at the end, another at the beginning) */ - memcpy((void *) &(buffer[dest]), (const void *) (value), wr1); - memcpy((void *) (buffer), (const void *) &(value[wr1]), wr2); - } - else - { - if (!reader_less && ((reader - writer) <= amount)) - return false; - -// fprintf(stderr, "%p> p full write: %d/%d [r=%d/w=%d]\n", this, amount, size, reader, writer); - - /* we are talking about buffers here, man! */ - memcpy((void *) &(buffer[dest]), (const void *) value, amount); - } - - unsigned int new_writer = ((dest + amount) % size) + 1; - - /* update "full length position" */ - _pointers.writer.complete = (unsigned int)floor((double) new_writer / (double)_block)+1; - _pointers.writer.partial = (unsigned short)(new_writer % _block); - -// fprintf(stderr, "%p> p write end: %d [block=%d]\n", this, new_writer, _block); - - return true; -} - -/* returns the number of bytes that have been read */ -unsigned int Ringbuffer_traits::traits_consume_partial(const char * buffer, char * value, unsigned int amount) -{ - /* avoid using different values */ - Buffer_table cache = _pointers; - - const unsigned int writer = ((cache.writer.complete - 1) * _block) + cache.writer.partial; - const unsigned int reader = (cache.reader.complete * _block) + cache.reader.partial; - - const unsigned int size = _size * _block; - -// fprintf(stderr, "%p> consume partial: %d/%d [%d/%d]\n", this, reader, writer, amount, size); - - const bool writer_less = writer < reader; - - unsigned int total = 0; - - /* should we go around the buffer for reading? */ - if (writer_less && (reader + amount >= size)) - { - total = std::min(size - (reader - writer + 1), amount); - - if (total == 0) - return 0; - - unsigned int rd1 = size - reader; - unsigned int rd2 = total - rd1; - -// fprintf(stderr, "%p> p partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, size, reader, writer); - - /* two partial consumes (one at the end, another at the beginning) */ - memcpy((void *) (value), (const void *) &(buffer[reader]), rd1); - memcpy((void *) &(value[rd1]), (const void *) (buffer), rd2); - } - else - { - total = std::min((writer_less ? amount : writer - (reader + 1)), amount); - - if (total == 0) - return 0; - -// fprintf(stderr, "%p> p full read: %d/%d [r=%d/w=%d]\n", this, total, size, reader, writer); - - /* we are talking about buffers here, man! */ - memcpy((void *) value, (const void *) &(buffer[reader]), total); - } - - do - { - unsigned int new_reader = (((cache.reader.complete * _block) + cache.reader.partial) + total) % size; - - /* jump the reader forward */ - Buffer_pointer index((unsigned int)floor((double)new_reader / (double)_block), - (unsigned short)(new_reader % _block)); - - if (update(cache.reader, index)) - { -// fprintf(stderr, "%p> p read end: %d [block=%d]\n", this, new_reader, _block); - break; - } - } - while (true); - - return total; -} - - - -/********** IO FUNCTIONS **********/ - -/* returns the number of items written to from buffer to stream */ -unsigned int Ringbuffer_traits::traits_put(const char * buffer, std::ostream &fd, unsigned int amount) -{ - /* avoid using different values */ - Buffer_table cache = _pointers; - - const unsigned int reader = cache.reader.complete; - const unsigned int writer = cache.writer.complete; - - const bool writer_less = writer < reader; - - unsigned int total = 0; - - /* should we go around the buffer for reading? */ - if (writer_less && (reader + amount >= _size)) - { - total = std::min(_size - (reader - writer + 1), amount); - - if (total == 0) - return 0; - - unsigned int rd1 = _size - reader; - unsigned int rd2 = total - rd1; - -// fprintf(stderr, "%p> partial read: (%d/%d) %d/%d [%d/%d]\n", this, rd1, rd2, total, _size, reader, writer); - - /* two partial consumes (one at the end, another at the beginning) */ - fd.write((const char *) &(buffer[reader]), _block * rd1); - fd.write((const char *) (buffer), _block * rd2); - } - else - { - total = std::min((!writer_less ? writer - (reader + 1) : amount), amount); - - if (total == 0) - return 0; - -// fprintf(stderr, "%p> full read: %d/%d [%d/%d]\n", this, total, _size, reader, writer); - - /* we are talking about buffers here, man! */ - fd.write((const char *) &(buffer[reader]), _block * total); - } - - do - { - /* jump the reader forward */ - Buffer_pointer index(cache.reader); - index.complete = (index.complete + total) % _size; - - if (update(cache.reader, index)) - break; - } - while (true); - - return total; -} - -/* returns number of items read from stream to buffer */ -unsigned int Ringbuffer_traits::traits_get(char * buffer, std::istream &fd, unsigned int amount) -{ - /* avoid using different values */ - Buffer_table cache = _pointers; - - const unsigned int reader = cache.reader.complete; - const unsigned int writer = cache.writer.complete; - - const unsigned int dest = writer - 1; - - const bool reader_less = reader < writer; - - unsigned int real_amount = 0; - - /* should we go around the buffer for writing? */ - if (reader_less && ((writer + amount) > _size)) - { - /* Documentation of the formula used in the 'if' below. - * - * [0|1|2|3|4|5|6|7] => size=8 - * | | - * reader | - * writer - * - * => writer has places [5,6,7,0,1] to write (5 places). - * - * => 8 - (4-2+1) = 8 - (2+1) = 8 - 3 = 5 - * - * > writer goes 1 up, amount goes 1 down. - * > reader goes 1 up, amount goes 1 up. - * > size goes 1 down, amount goes 1 down. - * - */ - - if ((_size - (writer - reader + 1)) <= amount) - return false; - - unsigned int wr1 = _size - writer + 1; /* writer is already 1 position after */ - unsigned int wr2 = amount - wr1; - -// fprintf(stderr, "%p> partial write: (%d/%d) %d/%d [%d/%d]\n", this, wr1, wr2, amount, _size, reader, writer); - - unsigned int char_amount = 0; - - /* one partial write on the buffer (at the end) */ - fd.read((char *) &(buffer[dest]), _block * wr1); - char_amount += fd.gcount(); - - if (fd.gcount() == (int)(_block * wr1)) - { - /* another partial write on the buffer (at the beginning) */ - fd.read((char *) (buffer), _block * wr2); - char_amount += fd.gcount(); - } - - real_amount = char_amount / _block; - } - else - { - if (!reader_less && ((reader - writer) <= amount)) - return false; - -// fprintf(stderr, "%p> full write: %d/%d [%d/%d]\n", this, amount, _size, reader, writer); - - /* we are talking about buffers here, man! */ - fd.read((char *) &(buffer[dest]), _block * amount); - - real_amount = fd.gcount() / _block; - } - - _pointers.writer.complete = ((dest + real_amount) % _size) + 1; - _pointers.writer.partial = 1; - - return real_amount; -} diff --git a/src/mod/endpoints/mod_khomp/commons/tools/generate-verbose-headers.sh b/src/mod/endpoints/mod_khomp/commons/tools/generate-verbose-headers.sh new file mode 100755 index 0000000000..7b9012baea --- /dev/null +++ b/src/mod/endpoints/mod_khomp/commons/tools/generate-verbose-headers.sh @@ -0,0 +1,183 @@ +#!/bin/sh + +cut_defines () +{ + cut -b9- | cut -f1 | cut -d' ' -f1 +} + +list_commands () +{ + egrep -h 'define.+CM_' "$@" | cut_defines +} + +list_events () +{ + # list and remove deprecations + egrep -h 'define.+EV_' "$@" | cut_defines | \ + grep -v 'EV_CALL_PROGRESS\|EV_FAX_MESSAGE_CONFIRMATION' +} + +make_enumeration_one_by_one () +{ + while read line + do + local size=$[50 - $(expr length "${line}")] + + echo -n " K_${line}" + + for ((i=0;i" + echo + echo "#include " + echo + echo "#include " + echo + echo "struct VerboseTraits" + echo "{" + make_enumeration "Command" list_commands "$@" || return 1 + echo + make_enumeration "Event" list_events "$@" || return 1 + echo + echo " static std::string eventName(const Event);" + echo " static std::string commandName(const Command);" + echo "};" + echo + echo "#endif /* _VERBOSE_TRAITS_H_ */" +} + +make_source () +{ + make_license + + echo "#include " + echo + + make_switch_case "Event" "event" list_events "$@" || return 1 + echo + make_switch_case "Command" "command" list_commands "$@" || return 1 +} + +make_run () +{ + local destdir="$1"; shift + + if [ ! -d "${destdir}" ] + then + echo "ERROR: First argument is not a directory!" + return 1 + fi + + make_header "$@" > "${destdir}/verbose_traits.hpp" + make_source "$@" > "${destdir}/verbose_traits.cpp" +} + +make_run "$@" diff --git a/src/mod/endpoints/mod_khomp/commons/verbose.hpp b/src/mod/endpoints/mod_khomp/commons/verbose.hpp deleted file mode 100644 index 4668ea6a9f..0000000000 --- a/src/mod/endpoints/mod_khomp/commons/verbose.hpp +++ /dev/null @@ -1,505 +0,0 @@ -/* - KHOMP generic endpoint/channel library. - Copyright (C) 2007-2009 Khomp Ind. & 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. - - Alternatively, the contents of this file may be used under the terms of the - "GNU Lesser General Public License 2.1" license (the “LGPL" License), in which - case the provisions of "LGPL License" are applicable instead of those above. - - If you wish to allow use of your version of this file only under the terms of - the LGPL License and not to allow others to use your version of this file under - the MPL, indicate your decision by deleting the provisions above and replace them - with the notice and other provisions required by the LGPL License. If you do not - delete the provisions above, a recipient may use your version of this file under - either the MPL or the LGPL License. - - The LGPL header follows below: - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this library; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include -#include -#include - -#include - -// k3lApiMajorVersion -#ifndef CM_PING -# include -# include -#endif - -#include -#include -#include - -#ifndef _VERBOSE_HPP_ -#define _VERBOSE_HPP_ - -struct Verbose -{ - typedef enum - { - K_CM_SEIZE = CM_SEIZE, - K_CM_SYNC_SEIZE = CM_SYNC_SEIZE, -#if K3L_AT_LEAST(1,6,0) - K_CM_SIP_REGISTER = CM_SIP_REGISTER, -#endif - K_CM_DIAL_DTMF = CM_DIAL_DTMF, - K_CM_DISCONNECT = CM_DISCONNECT, - K_CM_CONNECT = CM_CONNECT, - K_CM_PRE_CONNECT = CM_PRE_CONNECT, - K_CM_CAS_CHANGE_LINE_STT = CM_CAS_CHANGE_LINE_STT, - K_CM_CAS_SEND_MFC = CM_CAS_SEND_MFC, - K_CM_SET_FORWARD_CHANNEL = CM_SET_FORWARD_CHANNEL, - K_CM_CAS_SET_MFC_DETECT_MODE = CM_CAS_SET_MFC_DETECT_MODE, - K_CM_DROP_COLLECT_CALL = CM_DROP_COLLECT_CALL, - K_CM_MAKE_CALL = CM_MAKE_CALL, - K_CM_RINGBACK = CM_RINGBACK, - K_CM_USER_INFORMATION = CM_USER_INFORMATION, -#if !K3L_AT_LEAST(2,2,0) - K_CM_VOIP_SEIZE = CM_VOIP_SEIZE, //deprecated -#endif - K_CM_LOCK_INCOMING = CM_LOCK_INCOMING, - K_CM_UNLOCK_INCOMING = CM_UNLOCK_INCOMING, - K_CM_LOCK_OUTGOING = CM_LOCK_OUTGOING, - K_CM_UNLOCK_OUTGOING = CM_UNLOCK_OUTGOING, - K_CM_START_SEND_FAIL = CM_START_SEND_FAIL, - K_CM_STOP_SEND_FAIL = CM_STOP_SEND_FAIL, - K_CM_END_OF_NUMBER = CM_END_OF_NUMBER, -#if K3L_AT_LEAST(1,6,0) - K_CM_SS_TRANSFER = CM_SS_TRANSFER, - K_CM_GET_SMS = CM_GET_SMS, - K_CM_PREPARE_SMS = CM_PREPARE_SMS, - K_CM_SEND_SMS = CM_SEND_SMS, -#endif -#if K3L_HAS_MPTY_SUPPORT - K_CM_HOLD_SWITCH = CM_HOLD_SWITCH, - K_CM_MPTY_CONF = CM_MPTY_CONF, - K_CM_MPTY_SPLIT = CM_MPTY_SPLIT, -#endif - K_CM_ENABLE_DTMF_SUPPRESSION = CM_ENABLE_DTMF_SUPPRESSION, - K_CM_DISABLE_DTMF_SUPPRESSION = CM_DISABLE_DTMF_SUPPRESSION, - K_CM_ENABLE_AUDIO_EVENTS = CM_ENABLE_AUDIO_EVENTS, - K_CM_DISABLE_AUDIO_EVENTS = CM_DISABLE_AUDIO_EVENTS, - K_CM_ENABLE_CALL_PROGRESS = CM_ENABLE_CALL_PROGRESS, - K_CM_DISABLE_CALL_PROGRESS = CM_DISABLE_CALL_PROGRESS, - K_CM_FLASH = CM_FLASH, - K_CM_ENABLE_PULSE_DETECTION = CM_ENABLE_PULSE_DETECTION, - K_CM_DISABLE_PULSE_DETECTION = CM_DISABLE_PULSE_DETECTION, - K_CM_ENABLE_ECHO_CANCELLER = CM_ENABLE_ECHO_CANCELLER, - K_CM_DISABLE_ECHO_CANCELLER = CM_DISABLE_ECHO_CANCELLER, - K_CM_ENABLE_AGC = CM_ENABLE_AGC, - K_CM_DISABLE_AGC = CM_DISABLE_AGC, - K_CM_ENABLE_HIGH_IMP_EVENTS = CM_ENABLE_HIGH_IMP_EVENTS, - K_CM_DISABLE_HIGH_IMP_EVENTS = CM_DISABLE_HIGH_IMP_EVENTS, -#if K3L_AT_LEAST(1,6,0) - K_CM_ENABLE_CALL_ANSWER_INFO = CM_ENABLE_CALL_ANSWER_INFO, - K_CM_DISABLE_CALL_ANSWER_INFO = CM_DISABLE_CALL_ANSWER_INFO, -#endif - K_CM_RESET_LINK = CM_RESET_LINK, -#if K3L_AT_LEAST(1,6,0) - K_CM_CLEAR_LINK_ERROR_COUNTER = CM_CLEAR_LINK_ERROR_COUNTER, -#endif - K_CM_SEND_DTMF = CM_SEND_DTMF, - K_CM_STOP_AUDIO = CM_STOP_AUDIO, - K_CM_HARD_RESET = CM_HARD_RESET, - K_CM_SEND_TO_CTBUS = CM_SEND_TO_CTBUS, - K_CM_RECV_FROM_CTBUS = CM_RECV_FROM_CTBUS, - K_CM_SETUP_H100 = CM_SETUP_H100, - K_CM_MIXER = CM_MIXER, - K_CM_CLEAR_MIXER = CM_CLEAR_MIXER, - K_CM_PLAY_FROM_FILE = CM_PLAY_FROM_FILE, - K_CM_RECORD_TO_FILE = CM_RECORD_TO_FILE, - K_CM_PLAY_FROM_STREAM = CM_PLAY_FROM_STREAM, - K_CM_INTERNAL_PLAY = CM_INTERNAL_PLAY, - K_CM_STOP_PLAY = CM_STOP_PLAY, - K_CM_STOP_RECORD = CM_STOP_RECORD, - K_CM_PAUSE_PLAY = CM_PAUSE_PLAY, - K_CM_PAUSE_RECORD = CM_PAUSE_RECORD, - K_CM_RESUME_PLAY = CM_RESUME_PLAY, - K_CM_RESUME_RECORD = CM_RESUME_RECORD, - K_CM_INCREASE_VOLUME = CM_INCREASE_VOLUME, - K_CM_DECREASE_VOLUME = CM_DECREASE_VOLUME, - K_CM_LISTEN = CM_LISTEN, - K_CM_STOP_LISTEN = CM_STOP_LISTEN, - K_CM_PREPARE_FOR_LISTEN = CM_PREPARE_FOR_LISTEN, - K_CM_PLAY_SOUND_CARD = CM_PLAY_SOUND_CARD, - K_CM_STOP_SOUND_CARD = CM_STOP_SOUND_CARD, - K_CM_MIXER_CTBUS = CM_MIXER_CTBUS, - K_CM_PLAY_FROM_STREAM_EX = CM_PLAY_FROM_STREAM_EX, - K_CM_INTERNAL_PLAY_EX = CM_INTERNAL_PLAY_EX, - K_CM_ENABLE_PLAYER_AGC = CM_ENABLE_PLAYER_AGC, - K_CM_DISABLE_PLAYER_AGC = CM_DISABLE_PLAYER_AGC, - K_CM_START_STREAM_BUFFER = CM_START_STREAM_BUFFER, - K_CM_ADD_STREAM_BUFFER = CM_ADD_STREAM_BUFFER, - K_CM_STOP_STREAM_BUFFER = CM_STOP_STREAM_BUFFER, - K_CM_SEND_BEEP = CM_SEND_BEEP, - K_CM_SEND_BEEP_CONF = CM_SEND_BEEP_CONF, - K_CM_ADD_TO_CONF = CM_ADD_TO_CONF, - K_CM_REMOVE_FROM_CONF = CM_REMOVE_FROM_CONF, - K_CM_RECORD_TO_FILE_EX = CM_RECORD_TO_FILE_EX, - K_CM_SET_VOLUME = CM_SET_VOLUME, - K_CM_SET_LINE_CONDITION = CM_SET_LINE_CONDITION, - K_CM_SEND_LINE_CONDITION = CM_SEND_LINE_CONDITION, - K_CM_SET_CALLER_CATEGORY = CM_SET_CALLER_CATEGORY, - K_CM_DIAL_MFC = CM_DIAL_MFC, -#if !K3L_AT_LEAST(2,0,0) - K_CM_VOIP_START_DEBUG = CM_VOIP_START_DEBUG, - K_CM_VOIP_STOP_DEBUG = CM_VOIP_STOP_DEBUG, - K_CM_VOIP_DUMP_STAT = CM_VOIP_DUMP_STAT, - K_CM_ISDN_DEBUG = CM_ISDN_DEBUG, - K_CM_PING = CM_PING, - K_CM_LOG_REQUEST = CM_LOG_REQUEST, - K_CM_LOG_CREATE_DISPATCHER = CM_LOG_CREATE_DISPATCHER, - K_CM_LOG_DESTROY_DISPATCHER = CM_LOG_DESTROY_DISPATCHER, -#endif -#if K3L_AT_LEAST(1,6,0) - K_CM_START_CADENCE = CM_START_CADENCE, - K_CM_STOP_CADENCE = CM_STOP_CADENCE, - K_CM_CHECK_NEW_SMS = CM_CHECK_NEW_SMS, - K_CM_SEND_TO_MODEM = CM_SEND_TO_MODEM, -#endif -#if K3L_AT_LEAST(2,1,0) - K_CM_START_FAX_TX = CM_START_FAX_TX, - K_CM_STOP_FAX_TX = CM_STOP_FAX_TX, - K_CM_ADD_FAX_FILE = CM_ADD_FAX_FILE, - K_CM_ADD_FAX_PAGE_BREAK = CM_ADD_FAX_PAGE_BREAK, - K_CM_START_FAX_RX = CM_START_FAX_RX, - K_CM_STOP_FAX_RX = CM_STOP_FAX_RX, - K_CM_SIM_CARD_SELECT = CM_SIM_CARD_SELECT, -#endif - -#if K3L_AT_LEAST(2,1,0) - K_CM_NOTIFY_WATCHDOG = CM_NOTIFY_WATCHDOG, - K_CM_STOP_WATCHDOG = CM_STOP_WATCHDOG, - K_CM_WATCHDOG_COUNT = CM_WATCHDOG_COUNT, - K_CM_START_WATCHDOG = CM_START_WATCHDOG, -#endif - - } - kcommand; - - typedef enum - { - K_EV_CHANNEL_FREE = EV_CHANNEL_FREE, - K_EV_CONNECT = EV_CONNECT, - K_EV_DISCONNECT = EV_DISCONNECT, - K_EV_CALL_SUCCESS = EV_CALL_SUCCESS, - K_EV_CALL_FAIL = EV_CALL_FAIL, - K_EV_NO_ANSWER = EV_NO_ANSWER, - K_EV_BILLING_PULSE = EV_BILLING_PULSE, - K_EV_SEIZE_SUCCESS = EV_SEIZE_SUCCESS, - K_EV_SEIZE_FAIL = EV_SEIZE_FAIL, - K_EV_SEIZURE_START = EV_SEIZURE_START, - K_EV_CAS_LINE_STT_CHANGED = EV_CAS_LINE_STT_CHANGED, - K_EV_CAS_MFC_RECV = EV_CAS_MFC_RECV, - K_EV_NEW_CALL = EV_NEW_CALL, - K_EV_USER_INFORMATION = EV_USER_INFORMATION, - K_EV_DIALED_DIGIT = EV_DIALED_DIGIT, -#if K3L_AT_LEAST(1,6,0) - K_EV_SIP_REGISTER_INFO = EV_SIP_REGISTER_INFO, - K_EV_RING_DETECTED = EV_RING_DETECTED, -#endif - K_EV_CALL_HOLD_START = EV_CALL_HOLD_START, - K_EV_CALL_HOLD_STOP = EV_CALL_HOLD_STOP, -#if K3L_AT_LEAST(1,6,0) - K_EV_SS_TRANSFER_FAIL = EV_SS_TRANSFER_FAIL, - K_EV_FLASH = EV_FLASH, -#endif - K_EV_DTMF_DETECTED = EV_DTMF_DETECTED, - K_EV_DTMF_SEND_FINISH = EV_DTMF_SEND_FINISH, - K_EV_AUDIO_STATUS = EV_AUDIO_STATUS, - K_EV_CADENCE_RECOGNIZED = EV_CADENCE_RECOGNIZED, - K_EV_END_OF_STREAM = EV_END_OF_STREAM, - K_EV_PULSE_DETECTED = EV_PULSE_DETECTED, - K_EV_POLARITY_REVERSAL = EV_POLARITY_REVERSAL, -#if K3L_AT_LEAST(1,6,0) - K_EV_ISDN_PROGRESS_INDICATOR = EV_ISDN_PROGRESS_INDICATOR, - K_EV_CALL_ANSWER_INFO = EV_CALL_ANSWER_INFO, - K_EV_COLLECT_CALL = EV_COLLECT_CALL, - K_EV_SIP_DTMF_DETECTED = EV_SIP_DTMF_DETECTED, - K_EV_RECV_FROM_MODEM = EV_RECV_FROM_MODEM, - K_EV_NEW_SMS = EV_NEW_SMS, - K_EV_SMS_INFO = EV_SMS_INFO, - K_EV_SMS_DATA = EV_SMS_DATA, - K_EV_SMS_SEND_RESULT = EV_SMS_SEND_RESULT, -#endif -#if K3L_HAS_MPTY_SUPPORT - K_EV_CALL_MPTY_START = EV_CALL_MPTY_START, - K_EV_CALL_MPTY_STOP = EV_CALL_MPTY_STOP, - K_EV_GSM_COMMAND_STATUS = EV_GSM_COMMAND_STATUS, -#endif - K_EV_CHANNEL_FAIL = EV_CHANNEL_FAIL, - K_EV_REFERENCE_FAIL = EV_REFERENCE_FAIL, - K_EV_INTERNAL_FAIL = EV_INTERNAL_FAIL, - K_EV_HARDWARE_FAIL = EV_HARDWARE_FAIL, - K_EV_LINK_STATUS = EV_LINK_STATUS, -#if K3L_AT_LEAST(1,6,0) - K_EV_PHYSICAL_LINK_UP = EV_PHYSICAL_LINK_UP, - K_EV_PHYSICAL_LINK_DOWN = EV_PHYSICAL_LINK_DOWN, -#endif - K_EV_CLIENT_RECONNECT = EV_CLIENT_RECONNECT, - K_EV_VOIP_SEIZURE = EV_VOIP_SEIZURE, - K_EV_SEIZURE = EV_SEIZURE, - -#if K3L_AT_LEAST(2,1,0) - K_EV_FAX_CHANNEL_FREE = EV_FAX_CHANNEL_FREE, - K_EV_FAX_FILE_SENT = EV_FAX_FILE_SENT, - K_EV_FAX_FILE_FAIL = EV_FAX_FILE_FAIL, - K_EV_FAX_MESSAGE_CONFIRMATION = EV_FAX_MESSAGE_CONFIRMATION, - K_EV_FAX_TX_TIMEOUT = EV_FAX_TX_TIMEOUT, - K_EV_FAX_PAGE_CONFIRMATION = EV_FAX_PAGE_CONFIRMATION, - K_EV_FAX_REMOTE_INFO = EV_FAX_REMOTE_INFO, -#endif - -#if K3L_AT_LEAST(2,1,0) - K_EV_WATCHDOG_COUNT = EV_WATCHDOG_COUNT, -#endif - -#if !K3L_AT_LEAST(2,0,0) - K_EV_PONG = EV_PONG, -#endif - } - kevent; - - typedef enum - { - R2_COUNTRY_ARG = 1, - R2_COUNTRY_BRA = 2, - R2_COUNTRY_CHI = 3, - R2_COUNTRY_MEX = 4, - R2_COUNTRY_URY = 5, - R2_COUNTRY_VEN = 6 - } - R2CountryType; - - typedef enum - { - HUMAN, - EXACT - } - Presentation; - - /* dynamic (object) stuff */ - - Verbose(K3LAPI & api): _api(api) {}; - -#if K3L_AT_LEAST(2,0,0) - std::string event(int32, K3L_EVENT*, R2CountryType r2_country = R2_COUNTRY_BRA, - Presentation fmt = HUMAN); -#else - std::string event(int32, K3L_EVENT*, Presentation fmt = HUMAN); -#endif - - std::string channelStatus(int32, int32, int32, Presentation fmt = HUMAN); - - /* end of dynamic (object) stuff */ - - protected: - K3LAPI & _api; - - /* used internally */ - struct internal_not_found {}; - - public: - - /* static (class) stuff */ - - static std::string echoLocation(KEchoLocation, Presentation fmt = HUMAN); - static std::string echoCancellerConfig(KEchoCancellerConfig, Presentation fmt = HUMAN); - -#if K3L_AT_LEAST(2,0,0) - static std::string event(KSignaling, int32, K3L_EVENT*, R2CountryType = R2_COUNTRY_BRA, - Presentation fmt = HUMAN); -#else - static std::string event(KSignaling, int32, K3L_EVENT*, Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(2,0,0) - static std::string command(int32, K3L_COMMAND*, R2CountryType = R2_COUNTRY_BRA, - Presentation fmt = HUMAN); - static std::string command(int32, int32, int32, const char *, R2CountryType = R2_COUNTRY_BRA, - Presentation fmt = HUMAN); -#else - static std::string command(int32, K3L_COMMAND*, Presentation fmt = HUMAN); - static std::string command(int32, int32, int32, const char *, Presentation fmt = HUMAN); -#endif - - - static std::string deviceName(KDeviceType, int32, Presentation fmt = HUMAN); - - static std::string deviceType(KDeviceType, Presentation fmt = HUMAN); - static std::string deviceModel(KDeviceType, int32, Presentation fmt = HUMAN); - - static std::string channelFeatures(int32, Presentation fmt = HUMAN); - static std::string signaling(KSignaling, Presentation fmt = HUMAN); - static std::string systemObject(KSystemObject, Presentation fmt = HUMAN); - static std::string mixerTone(KMixerTone, Presentation fmt = HUMAN); - static std::string mixerSource(KMixerSource, Presentation fmt = HUMAN); - - static std::string seizeFail(KSeizeFail, Presentation fmt = HUMAN); - -#if K3L_AT_LEAST(2,0,0) - static std::string callFail(KSignaling, R2CountryType, int32, Presentation fmt = HUMAN); -#else - static std::string callFail(KSignaling, int32, Presentation fmt = HUMAN); -#endif - - static std::string channelFail(KSignaling, int32, Presentation fmt = HUMAN); - static std::string internalFail(KInternalFail, Presentation fmt = HUMAN); - - static std::string linkErrorCounter(KLinkErrorCounter, Presentation fmt = HUMAN); - - static std::string linkStatus(KSignaling, int32, Presentation fmt = HUMAN); - static std::string channelStatus(KSignaling, int32, Presentation fmt = HUMAN); - static std::string callStatus(KCallStatus, Presentation fmt = HUMAN); - static std::string status(KLibraryStatus, Presentation fmt = HUMAN); - -#if K3L_AT_LEAST(2,0,0) - static std::string signGroupB(KSignGroupB, R2CountryType contry = R2_COUNTRY_BRA, - Presentation fmt = HUMAN); -#else - static std::string signGroupB(KSignGroupB, Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(2,0,0) - static std::string signGroupII(KSignGroupII, R2CountryType contry = R2_COUNTRY_BRA, - Presentation fmt = HUMAN); -#else - static std::string signGroupII(KSignGroupII, Presentation fmt = HUMAN); -#endif - - static std::string h100configIndex(KH100ConfigIndex, Presentation fmt = HUMAN); - - static std::string eventName(int32); - static std::string commandName(int32); - -#if K3L_AT_LEAST(1,5,0) - static std::string sipFailures(KSIP_Failures, Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(1,5,1) - static std::string isdnCause(KQ931Cause, Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(1,5,2) - static std::string isdnDebug(int32, Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(1,6,0) - static std::string callStartInfo(KCallStartInfo, Presentation fmt = HUMAN); - - static std::string gsmCallCause(KGsmCallCause, Presentation fmt = HUMAN); - static std::string gsmMobileCause(KGsmMobileCause, Presentation fmt = HUMAN); - static std::string gsmSmsCause(KGsmSmsCause, Presentation fmt = HUMAN); - - static std::string q931ProgressIndication(KQ931ProgressIndication, - Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(2,1,0) - static std::string faxResult(KFaxResult code, Presentation fmt = HUMAN); - static std::string faxFileErrorCause(KFaxFileErrorCause code, Presentation fmt = HUMAN); -#endif - - /* end of static (class) stuff */ - - private: - static std::string internal_deviceType(KDeviceType); - static std::string internal_deviceModel(KDeviceType, int32); - -#if K3L_AT_LEAST(1,5,0) - static std::string internal_sipFailures(KSIP_Failures, Presentation fmt = HUMAN); -#endif -#if K3L_AT_LEAST(1,5,1) - static std::string internal_isdnCause(KQ931Cause, Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(2,0,0) - static std::string internal_signGroupB(KSignGroupB, R2CountryType contry, Presentation fmt = HUMAN); - static std::string internal_signGroupII(KSignGroupII, R2CountryType contry, Presentation fmt = HUMAN); -#else - static std::string internal_signGroupB(KSignGroupB, Presentation fmt = HUMAN); - static std::string internal_signGroupII(KSignGroupII, Presentation fmt = HUMAN); -#endif - -#if K3L_AT_LEAST(1,6,0) - static std::string internal_gsmCallCause(KGsmCallCause, Presentation fmt = HUMAN); - static std::string internal_gsmMobileCause(KGsmMobileCause, Presentation fmt = HUMAN); - static std::string internal_gsmSmsCause(KGsmSmsCause, Presentation fmt = HUMAN); - - static std::string internal_q931ProgressIndication(KQ931ProgressIndication, Presentation fmt = HUMAN); -#endif - - private: - enum Type - { - DEVICE, - CHANNEL, - PLAYER, - MIXER, - LINK, - NONE - }; - - struct Target - { - Target(Type _type) - : type(_type), device(-1), object(-1) - {}; - - Target(Type _type, int32 _device) - : type(_type), device(_device), object(-1) - {}; - - Target(Type _type, int32 _device, int32 _object) - : type(_type), device(_device), object(_object) - {}; - - Type type; - int32 device; - int32 object; - }; - - static void generate(std::string &, std::string &, Target, std::string &); - - static std::string show(std::string &, std::string, Target, std::string &); - static std::string show(std::string &, std::string, Target); - - template < typename ReturnType > - static ReturnType presentation(Presentation fmt, ReturnType str_exact, ReturnType str_human) - { - switch (fmt) - { - case HUMAN: return str_human; - case EXACT: return str_exact; - }; - - return str_exact; - } -}; - -#endif /* _VERBOSE_HPP_ */ diff --git a/src/mod/endpoints/mod_khomp/docs/Manual.html b/src/mod/endpoints/mod_khomp/docs/Manual.html index 863ef76847..c4745700b1 100644 --- a/src/mod/endpoints/mod_khomp/docs/Manual.html +++ b/src/mod/endpoints/mod_khomp/docs/Manual.html @@ -37,17 +37,22 @@
  • context-fxs: Contexto de entrada para placas FXS (o padrão é "khomp-DD-CC", onde "DD" será substituído, no momento da ligação, pelo número do dispositivo, "CC" pelo número do canal, e "SSSS" pelo número serial do dispositivo);
  • context-gsm-call (ou "context-gsm"): Contexto de entrada para ligações GSM (o padrão é "khomp-DD-CC", onde "DD" será substituído no momento da ligação pelo número do dispositivo, "CC" pelo número do canal, e "SSSS" pelo número serial do dispositivo);
  • context-gsm-sms: Contexto de entrada para SMSs (o padrão é "khomp-sms-DD-CC", onde "DD" será substituído pelo número de dispositivo, "CC" pelo número do canal, e "SSSS" pelo número serial do dispositivo); -
  • context-pr: Contexto de entrada para ligações em placas KPR (o padrão é "khomp-DD-CC", onde "DD" será substituído, no momento da ligação, pelo número do dispositivo, "CC" pelo número do canal); +
  • context-pr: Contexto de entrada para ligações em placas KPR (o padrão é "khomp-DD-CC", onde "DD" será substituído, no momento da ligação, pelo número do dispositivo, "CC" pelo número do canal); +
  • delay-ringback-co: Define o tempo de delay para ativar a geração de tom de controle de chamada (ringback) pelo Endpoint da Khomp quando há uma indicação de ringback, e não há áudio sendo enviado por quem indicou a situação de controle da chamada; +
  • delay-ringback-pbx: Define o tempo de delay para ativar a geração de controle de chamada (ringback) pelo Endpoint da Khomp quando há uma indicação de ringback, e o áudio de controle enviado não possui nenhum tom (ou seja, está em silêncio);
  • disconnect-delay: Define o tempo em milissegundos para realizar o processamento de um evento de desconexão, para ignorar situações onde outros equipamentos realizam o duplo atendimento para derrubar chamadas a cobrar; +
  • drop-collect-call: Ativa ("yes") ou desativa ("no") o derrubamento de chamadas à cobrar. Caso ativo, todas as chamadas à cobrar serão derrubadas não importando o que foi ajustado na variável KDropCollectCall (o valor padrão é "no");
  • echo-canceller: Ativa ("yes") ou desativa ("no") o cancelamento de eco automático pelo Endpoint; +
  • flash-to-digits: Define os dígitos para serem enviados quando o FLASH é detectado na FXS;
  • fxo-send-pre-audio: Quando ativada ("yes") libera canal de áudio sainte antes da conexão da chamada em placas KFXO (o valor padrão é "yes"); +
  • fxs-digit-timeout: Define o timeout, em segundos, entre dígitos na FXS;
  • fxs-global-orig: Número inicial para numeração seqüencial de ramais das placas KFXS que não estiverem listadas na seção <fxs-branches> (a numeração segue ordem crescente por número da placa e número do canal físico) (o padrão é "0");
  • fxs-co-dialtone: Seqüências de números, separados por vírgula, que disparam um tom contínuo (de central pública) em ramais FXS (ex: "0,99" faz com que, ao discar "0" ou "99", o usuário receba o tom de linha contínuo) (o padrão é vazio);
  • fxs-bina: Quando ativada ("yes"), ligações para ramais FXS enviarão os dígitos correspondentes ao telefone de origem em sinalização BINA DTMF (o valor padrão é "no"); +
  • ignore-letter-dtmfs: Define se o canal deve ignorar DTMFs incomuns detectados pela placa (A, B, C e D). Entretanto, se você necessita passar esses dígitos pela placa, você deve ajustar esta opção para "no" (o valor padrão é "yes");
  • input-volume: Define o volume de entrada das ligações, varia de -10 a +10 ;
  • kommuter-activation: Define se a ativação de dispositivos kommuter encontrados no sistema será feita de forma automática ("auto"), ou de forma manual ("manual") pelo usuário, através do comando "khomp kommuter on/off";
  • kommuter-timeout: Define o timeout (em segundos) com que os kommuters serão inicializados. Se chegarem a este timeout sem receberem notificação do channel, os dispositivos irão comutar para o estado "desligado". O valor mínimo é "0" , onde os links permanecerão sempre comutados no estado "ligado", e o valor máximo é "255"; -
  • language: Define idioma para ligações nas placas Khomp;
  • log-to-console: Define mensagens de log que devem ser impressas na console;
  • log-to-disk: Define mensagens de log que devem ser salvar em disco;
  • out-of-band-dtmfs: Ativa ("yes") ou desativa ("no") a supressão DTMF e o envio destes out-of-band; @@ -55,12 +60,9 @@
  • pulse-forwarding: Ativa ("yes") ou desativa ("no") a detecção de pulsos e a conversão dos mesmos em DTMFs;
  • r2-preconnect-wait: Define o tempo de espera do envio da sinalização de ringback, no protocolo R2/MFC, para iniciar o envio de áudio de silêncio. Apenas utilizado quando "r2-strict-behaviour" estiver ajustado para "no";
  • r2-strict-behaviour: Ativa ("yes") ou desativa ("no") o comportamento da sinalização R2/MFC conforme a norma define. O padrão é "no", e pode ser alterado para "yes" caso seja necessário receber/enviar dados precisos da sinalização do protocolo (condição de B, por exemplo); -
  • ringback-delay-co: Define o tempo de delay para ativar a geração de tom de controle de chamada (ringback) pelo Endpoint da Khomp quando há uma indicação de ringback, e não há áudio sendo enviado por quem indicou a situação de controle da chamada; -
  • ringback-delay-pbx: Define o tempo de delay para ativar a geração de controle de chamada (ringback) pelo Endpoint da Khomp quando há uma indicação de ringback, e o áudio de controle enviado não possui nenhum tom (ou seja, está em silêncio);
  • suppression-delay: Ativa ("yes") ou desativa ("no") o delay necessário para supressão DTMF. Se desativado ("no"), também desativa supressão de DTMFs;
  • trace: Define opções de depuração. Não deve ser utilizado em produção a não ser que estritamente necessário;
  • user-transfer-digits: Define uma seqüência de dígitos DTMF para iniciar a transferencia entre o FreeSWITCH® e um outro PABX (utilizando sinalização de usuário, como QSig ou FXO FLASH); -
  • flash-to-digits: Define os dígitos para serem enviados quando o FLASH é detectado na FXS;

  • @@ -117,15 +119,13 @@
    • context;
    • input-volume;
    • output-volume; -
    • accountcode;
    • calleridnum;
    • calleridname; -
    • mailbox;
    • flash-to-digits.

    Cada opção é separada uma da outra por um pipe "|" ou uma barra "/" e definidas após dois pontos ":", exemplo:

    -
     <param name="200" value="language:en|context:master-branch" />
    +
     <param name="200" value="input-volume:1|context:master-branch" />
     

    Para maiores informações sobre a sintaxe e exemplos, favor consultar o arquivo de configuração.


    diff --git a/src/mod/endpoints/mod_khomp/docs/Manual.pdf b/src/mod/endpoints/mod_khomp/docs/Manual.pdf index 935b299dbc821be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*pmj_7okN*8HX$1p;FO(1re3>J_oLql75&#V5vObo{f!t5;eEjjm>c}U;hyCU_&2LiFb~fQx}Gn6;niFK;ENkR zAFusP;eRs71q8o{rsosExn8v6OaQ{1wxt`P0-(Jo2e8%=m8-(Yj zjhFL<4Z_LwKP*81y;69NI^Mr&<>CQwzqEmXFKoP=z`sM5ix{Dc3Qk{2CwLjI3VcwUGP1oRB$e{T4XH-aG` z@c)F^e?=JNS%P1%3L<>Yfq!58JR_i_ayDc>18z<*FOQiSFVAz#nwUc%oIIQmfH@bh sF)zpjV!{m)68QgZp)Vwa=HhDX?CR-kZh;1dfWZ&|8a=(FvJ~3?2l$?2=>Px# diff --git a/src/mod/endpoints/mod_khomp/docs/README.pdf b/src/mod/endpoints/mod_khomp/docs/README.pdf index 2b95cfaad4d41964e1155d28a906699c0227b1a1..13a5f5469a80ec0d20f7c85e60e193622eaee77a 100644 GIT binary patch delta 1303 zcmbQRPNILE#DsQEBLhPqFgG@CoX|Rfv2_Ad>jdW32`pPDuvYyQwlp*{urx6>)-^OV zwKO&`G&i!`F7uD|7&D{E_Q#BDUW_6uuV{L1a&)zJouE}3Y$F!myI|+9?M}>W8jSS@ zmI@GHXIETOl$w~!Rl!&r;+uclfM@UT@DDQ>HzuF#voE`SZHYu%QpRjX>o13Hc`Z9+ z7JE{!>))@ye<$YTNi^M1(46$%HmL3!OUobO30@sS8d>^0PT%IpmtUWE;*dh)+B3}p zSre4_o}`2pyw}a`J7scW`o-3>7efl_dpAxx-Mc9#&~n;G*OJWZ0`4ze?=L-jF-Lky z_o?#}Iuoo5CP$x3cAD^{aDrvm?Dd5l;Vj$lJwIH%?-|SNT0Wze!xJx0R(UkX*;3=s zzNFH-*)6-eAP{dan#PVJCmssC~1a~aQ`4K*FxHYNVmmH+FXn&A6SvCLgH-H7@7n+;E|Ppmll zY;EzyrmPKrU8Z+NulBcLeWI&;Vb8M1lXA~{e_MRH?=wSL&(h~N)@fG0pZ%`(+@93M z|M$!^eo|=_Kc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H{+H-7SC)!=SI2Dj#`qL8oY zeg;uTUkLASCQlAAJzb@GHBW|~Gd!kFX>Gzo~5I^oIIY{6V^tdtnGk8pB zfNJV{gejBOd4xJ&kG|tNRcHMG+HZRLu6v>wc-c@$)!Zapy3BvjS3yzYnwX@ue+b9a zhOsc?>T@TmjvSPbUeblXX0GUSDBK*9zeE>5l&D|$`B80BV;%zrp*nnPTP*-2s`m*# zkC5DIMZ zv!^;JcUK0)I^S79uz0`8`feh9<#T+pcHrqRWwjmEUSw2kA^!vS^pKAwLPO#{bHFom_R5( z|J0pk5kUFbyf=)}DXm!P5R1*CyRXnYN#(blRBtMlY(t$|W%mfAXA=X7r`T1$4j4Fn z@p6=VJ69eJmOrzYQc2(rT|}QQBy{ESadL$5d#5Bk#Fq`I1&qwOzzJz4MAP+s)q;T$ zf4zfwU1E+Y-ne_zP^kSzI(|b&ZS2^&(TK_|{n5}Cu$Pp8B!#$!jV=!7nlCS!1{8xD z-s>dBT*~?e5ZpB1ST|hpFE@FWSAVQBujIXK@Wr!lX154MCW(WB6WpTag zO=RpnSnBbl26ArA;X_tnLC+1vXN^U_9-oH*N-j*xWT9$Ox+D5zWADzUfzsAI)*)clm_MiOi%uu!{zV+0jL&NM zAq;wW+;a?1k{R(JDYe*~vN7?~j=q9d$A`jLgcVBWte)-Jm0UMq>hk6pB6_sO|>J#ch zX*t_wz^U4s+IsJ_K9XEu%?7JFsyiLJeAvrl&m9>T{3K-Oj|_@x-?QRG!rF#xhR2-S>Y}c;8<5Alf^G8qP4D3Hk%lyEDFu=OFpThis step is carried out in a semi-automated way using the khompwizard program, a wizard that configures the basic parameters of the system boards. This wizard initializes the configuration files using information from the user when they are needed, initializing the standard settings to default values.

    Typically, this program runs automatically after installation of the system. However, you may need to run it manually if an update is being performed, or if new cards were added to the system after installing new drivers.


    -If you need to set advanced parameters of the board and/or signaling, the program k3lconfig allows you to access all the available settings for each installed card. For more information about this program, check the
    k3lconfig User's Guide. For solving synchronization issues, check the Troubleshooting section for manual configuration of the boards. +If you need to set advanced parameters of the board and/or signaling, the program k3lconfig allows you to access all the available settings for each installed card. For more information about this program, check the k3lconfig User's Guide. For solving synchronization issues, check the Troubleshooting section for manual configuration of the boards.

    Endpoint Configuration

    @@ -39,16 +39,21 @@ If you need to set advanced parameters of the board and/or signaling, the progra
  • context-gsm-call (or context-gsm): Context of entry for GSM boards (the default is "khomp-CC-DD", where "DD" will be replaced at the time of connection by the device number, "CC" by channel number, and "SSSS" by the device serial number);
  • context-gsm-sms: Context for incoming SMSs (the default is "khomp-sms-CC-DD", where "DD" will be replaced by the number of device, "CC" by channel number and "SSSS" by the device's serial number);
  • context-pr: Context for incoming connections on boards KPR (default is "khomp-CC-DD", where "DD" will be replaced at the time of connection by the device number, "CC "by channel number); +
  • delay-ringback-co: Sets the delay to enable the generation of call control tone (ringback) by the Endpoint Khomp when there is an ringback indication from signaling and there is no audio being sent by the channel which indicated the situation (local option); +
  • delay-ringback-pbx: Sets the delay to enable the generation of call control tone (ringback) by the Endpoint Khomp when there is an ringback indication, and the audio has no tone (silence) (local option);
  • disconnect-delay: Sets the time in milliseconds to perform processing a disconnect event, to ignore situations where other equipment performing the double service to overthrow collect calls (local option); +
  • drop-collect-call: Enables/Disables the action of dropping collect calls. If enabled, all collect calls will be dropped no matter what KDropCollectCall is set to (the default value is "no");
  • echo-canceller (former 'echocanceller): Active ("yes") or disables ("no") echo cancellation automatic Endpoint (local option); +
  • flash-to-digits: Defines the digits to be sent when the FLASH is detected on FXS channels;
  • fxo-send-pre-audio: When enabled ("yes") releases audio channel before the outgoing call connection boards KFXO (the default value is "yes"); +
  • fxs-digit-timeout: Defines the timeout, in seconds, between digits of a FXS board's extension;
  • fxs-global-orig: Start number for sequencial branch numbering in FXS cards that are not listed in the [fxs-branches] section (the numbering follows ascending order from board number and physical channel number) (default is "0");
  • fxs-co-dialtone: Sequences of numbers, separated by commas, which fires a continuous tone (of central office) in FXS branches (eg: "0,99" means that, when you dial "0" or "99", the user will hear a continuous dial tone) (default is empty);
  • fxs-bina: When enabled ("yes"), calls to FXS lines will send digits corresponding to the source phone identification using BINA DTMF signaling (the default value is "no") (local option); +
  • ignore-letter-dtmfs: Defines if the channel should ignore some uncommon DTMF digits detected by the board (A, B, C and D). However, if you need to pass those digits througth the board, you may need to set this option to 'no' (the default value is "yes");
  • input-volume: Sets the volume gain for incoming audio (entering the board), from -10 to +10 (local option);
  • kommuter-activation: Sets whether to activate devices kommuter found in the system will be done automatically ("auto") by the channel, or manually ("manual") by the user through the command "khomp kommuter on/off"
  • kommuter-timeout: Sets the timeout (in seconds) for initializing the kommuter devices. If this timeout is reached without receiving notification of the channel, the devices will switch back to "off" condition. The minimum value is "0", where the links will always remain switched "on", and the maximum is "255"; -
  • language: Set language to Khomp channel calls (local option);
  • log-to-console: Set log messages to be printed on the console;
  • log-to-disk (old "log"): Set log messages to be saved to disk;
  • out-of-band-DTMF (former dtmfsuppression): Activate ("yes") or disables ("no") the removal and DTMF sending these out-of-band (local option); @@ -56,12 +61,9 @@ If you need to set advanced parameters of the board and/or signaling, the progra
  • pulse-forwarding (former 'pulsedetection): Active ("yes") or disables ("no") for the detection of pulses and converting them into DTMF (local option);
  • r2-preconnect-wait (former 'r2preconnectwait): Sets the timeout sending the ringback signaling, protocol R2/MFC to start sending audio silence. Only used when "r2-strict-Behavior" is set to "no" (local option);
  • r2-strict-Behaviour: Enable ("yes") or disables ("no") the behavior of signaling R2/MFC as the standard sets. The default is "no", and can be changed to "yes" if needed to receive / send data precise signaling protocol (condition B, for example) (local option); -
  • ringback-delay-co: Sets the delay to enable the generation of call control tone (ringback) by the Endpoint Khomp when there is an ringback indication from signaling and there is no audio being sent by the channel which indicated the situation (local option); -
  • ringback-delay-pbx: Sets the delay to enable the generation of call control tone (ringback) by the Endpoint Khomp when there is an ringback indication, and the audio has no tone (silence) (local option);
  • suppression-delay (former suppressiondelay): Activate ("yes") or disables ("no") the delay necessary to suppress DTMF. If disabled ("no"), also disables suppression of DTMF (local option);
  • trace: Set debugging options. Should not be used in production unless absolutely necessary; -
  • user-transfer-digits: Defines a sequence of DTMF digits to initiate the transfer between FreeSWITCH® and another PBX (using user signaling, like QSig or FXO FLASH). -
  • flash-to-digits: Defines the digits to be sent when the FLASH is detected on FXS channels.. +
  • user-transfer-digits: Defines a sequence of DTMF digits to initiate the transfer between FreeSWITCH® and another PBX (using user signaling, like QSig or FXO FLASH);

  • @@ -121,15 +123,13 @@ For details, please refer to the configuration file for examples.
    • context;
    • input-volume;
    • output-volume; -
    • accountcode;
    • calleridnum;
    • calleridname; -
    • mailbox;
    • flash-to-digits.

    Each option is separated from each other by a pipe "|" or a slash "/" and defined after the colon ":". Example:

    -
    <param name="200" value="language:en|context:master-branch" />
    +
    <param name="200" value="input-volume:1|context:master-branch" />
     

    For more information on the syntax and examples, please refer to the configuration file.

    For more information visit the configuration file 'khomp.conf.xml'. diff --git a/src/mod/endpoints/mod_khomp/docs/User_Guide.pdf b/src/mod/endpoints/mod_khomp/docs/User_Guide.pdf index 832596bdb255ccbd3bc03c675d3afe7a590008b7..e0c33e1c74e1c6f9588831d2b52013482fd13437 100644 GIT binary patch delta 36916 zcmZ^KbwE^2_b?zVozfv7Aq~59hm@prcXxwIEK&-BGz&;~BS?3MlyrB4l7b>Bd>8O} zAN}6<#~<9eGpFawIp@yImb{_-97Y-S3KhZu2L5gK_92c_KwjBvrSyKcKsKY`5eMo3|= zKLK31?(p|-+B`6UZUE}HfDPUM3P{;=E8q>Q+Tb40G6L*#CkPjo-w%2O8~O+WAwVFo zfzKc^fZR$yh!C6eMtTDaM{_4rTQpv7m`OW`i~z#V#l}m;$)0*$om%{|6R9`5WA#>o4Xqo zAIHtGh{$h2ZeIa3U|inD+)a-Ue2e|>I2a~20D4XYx#?zL<1{lfF}H9uvv6bMv|!}p zgbfdX2*|kp8MJ)n#%k(n;%H|58-P1u5JUpK(cu>PX57iy-NwoB4*yov8>&{WP9Dy8 zeYdmB0A}R7kzADl!pMIsF$2U1%*cN$9nb`N?<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yH z2;U`6;IK<-g7QIryVifL2T(rPCBFa_fB}8{T7UlW0Z=fI-1h<}P(jG01qLbzte+Rl z0n5QfgM&iBmy8e!`&W2@_$&5;!hmirHVB7ba;-4H&0m~OK(qk6I2B=ljxVYSCIDFL zg+73I3W~yg|BpUlVCW^!1p^%T#c2lGM zL9I;ud>3s2F31nND1JELEH2Sd@yA860)~#-xBZtp=;h@T4)~r+gNE~7QXL#{ju#9Q z2n~3DO>LC?{}w+$6u21C0KV)}tOwBeFWL-16S(Mt0UG#XFbdEF{~hG~(mz0iTy!7+ z4cIOGR|)_PesMYp@&a#1To6A% + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/endpoints/mod_khomp/examples/transfer.xml b/src/mod/endpoints/mod_khomp/examples/transfer.xml new file mode 100644 index 0000000000..5c66633574 --- /dev/null +++ b/src/mod/endpoints/mod_khomp/examples/transfer.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/endpoints/mod_khomp/include/applications.h b/src/mod/endpoints/mod_khomp/include/applications.h index 75f55ec5ca..21b66b2b0a 100644 --- a/src/mod/endpoints/mod_khomp/include/applications.h +++ b/src/mod/endpoints/mod_khomp/include/applications.h @@ -268,7 +268,7 @@ struct Transfer if (!(_call->_flags.check(Kflags::XFER_DIALING))) { _call->_flags.set(Kflags::XFER_DIALING); - _idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_transferdigittimeout, &userXferTimer, _pvt, TM_VAL_CALL); + _idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_options._transferdigittimeout(), &userXferTimer, _pvt, TM_VAL_CALL); } else { @@ -280,7 +280,7 @@ struct Transfer } } - catch (K3LAPI::invalid_device & err) + catch (K3LAPITraits::invalid_device & err) { LOG(ERROR, PVT_FMT(_pvt->target(), "Unable to get device: %d!") % err.device); } @@ -506,7 +506,7 @@ struct Transfer if (!(_call->_flags.check(Kflags::XFER_DIALING) || _call->_flags.check(Kflags::XFER_QSIG_DIALING))) { _call->_flags.set(Kflags::XFER_DIALING); - _idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_transferdigittimeout, &userXferTimer, _pvt, TM_VAL_CALL); + _idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_options._transferdigittimeout(), &userXferTimer, _pvt, TM_VAL_CALL); } else { @@ -530,7 +530,7 @@ struct Transfer } } - catch (K3LAPI::invalid_device & err) + catch (K3LAPITraits::invalid_device & err) { LOG(ERROR, PVT_FMT(_pvt->target(), "Unable to get device: %d!") % err.device); } @@ -735,6 +735,9 @@ struct Transfer }; /*************************** SMS **********************************************/ +#define ESL_SMS_RECEIVED "khomp::sms_received" +#define ESL_SMS_SENT "khomp::sms_sent" + struct SMS : public Application { typedef std::list< switch_core_session_t *> OwnersList; @@ -889,6 +892,78 @@ struct SMS : public Application bool _conf; }; + static struct _SMSEvent : public ESL + { + + _SMSEvent() : ESL("khomp::sms") + { + if(_events) + { + _events->push_back(ESL_SMS_RECEIVED); + _events->push_back(ESL_SMS_SENT); + } + } + + ~_SMSEvent() + { + if(_events) + { + //Remove two from vector + _events->pop_back(); + _events->pop_back(); + } + } + + bool operator()(Board::KhompPvt * pvt, ReceiveData & data) + { + switch_event_t *event = create(ESL_SMS_RECEIVED); + + if(!event) + { + LOG(ERROR, "Cannot create SMS ESL"); + return false; + } + + add(event, pvt->target()); + add(event, "Type", data._type); + add(event, "From", data._from); + add(event, "Date", data._date); + add(event, "Size", data._size); + add(event, "Coding", data._coding); + add(event, "Serial", data._serial); + add(event, "Id", data._id); + add(event, "Page", data._page); + add(event, "Pages", data._pages); + add(event, "Sc_date", data._sc_date); + add(event, "Status", data._status); + add(event, "Body", data._body); + + return fire(&event); + } + + bool operator()(Board::KhompPvt * pvt, SendData & data) + { + switch_event_t *event = create(ESL_SMS_SENT); + + if(!event) + { + LOG(ERROR, "Cannot create SMS ESL"); + return false; + } + + add(event, pvt->target()); + add(event, "Dest", data._dest); + add(event, "Body", data._body); + add(event, "Confirmation?", (data._conf ? "Yes" : "No")); + + + return fire(&event); + } + + + + } SMSEvent; + struct Request { /* "empty" constructor */ diff --git a/src/mod/endpoints/mod_khomp/include/cli.h b/src/mod/endpoints/mod_khomp/include/cli.h index 214e2aa2d5..bb251bb16b 100644 --- a/src/mod/endpoints/mod_khomp/include/cli.h +++ b/src/mod/endpoints/mod_khomp/include/cli.h @@ -99,12 +99,52 @@ struct Command std::string usage; /* usage of the command, a help */ }; +struct CommandXMLOutput : public Command +{ + void createRoot(const char *name) + { + root = switch_xml_new(name); + } + + void insertXML(switch_xml_t xml) + { + switch_xml_insert(xml,root,0); + } + + void clearRoot() + { + if(root) + { + switch_xml_free(root); + root = NULL; + } + } + + void printXMLOutput(switch_stream_handle_t *stream) + { + K::Logger::Logg2(C_CLI,stream,switch_xml_toxml(root,SWITCH_FALSE)); + } + + CommandXMLOutput() : root(NULL) {}; + + switch_xml_t root; /* for commands that ouput as xml */ +}; + struct Cli { /* Useful definitions --------------------------------------------------- */ typedef switch_status_t (APIFunc)(const char*, switch_core_session_t*, switch_stream_handle_t*); typedef std::vector Commands; + /* Define the output types form commands */ + typedef enum + { + VERBOSE = 1, + CONCISE, + DETAILED, + XML + } OutputType; + /* register our commands, but you must create the command function */ static void registerCommands(APIFunc func,switch_loadable_module_interface_t **mod_int); @@ -145,27 +185,31 @@ struct Cli /* The Commands --------------------------------------------------------- */ /* khomp summary */ - static struct _KhompSummary : public Command + static struct _KhompSummary : public CommandXMLOutput { _KhompSummary(bool on_cli_term = true): - _on_cli_term(on_cli_term) + CommandXMLOutput(), + _on_cli_term(on_cli_term), + xdevs(NULL) { complete_name = "summary"; options.push_back("verbose"); options.push_back("concise"); + options.push_back("xml"); brief = "Print system info."; usage = \ "Prints detailed info about the system like API version and \n" \ "boards characteristics like DSPs version.\n\n" \ -"Usage: khomp summary [concise]"; +"Usage: khomp summary [concise|verbose|xml]"; _commands.push_back(this); }; bool execute(int argc, char *argv[]); - bool _on_cli_term; /* indicates if message is sent to fs_cli */ + bool _on_cli_term; /* indicates if message is sent to fs_cli */ + switch_xml_t xdevs; /* support xml needed to help the interation */ } KhompSummary; /* khomp show calls */ @@ -239,21 +283,22 @@ struct Cli } KhompChannelsUnblock; /* khomp show statistics */ - static struct _KhompShowStatistics : public Command + static struct _KhompShowStatistics : public CommandXMLOutput { - _KhompShowStatistics() + _KhompShowStatistics() : CommandXMLOutput(), xdevs(NULL) { complete_name = "show statistics"; options.push_back("verbose"); options.push_back("detailed"); + options.push_back("xml"); brief = "Shows statistics of the channels."; usage = \ "Shows statistics of the channels, like number of calls incoming \n" \ "and outgoing, status, status time.\n\n" \ -"Usage: khomp show statistics [{verbose [ []]} | \n" \ +"Usage: khomp show statistics [{{verbose|xml} [ []]} | \n" \ " {detailed }]\n" \ "\tboard -- Number of the board (start from 0).\n" \ "\tchannel -- Number of the channel (start from 0).\n" \ @@ -274,20 +319,22 @@ struct Cli bool execute(int argc, char *argv[]); /* support functions */ - void cliStatistics(unsigned int device); - void cliDetailedStatistics(unsigned int device, unsigned int channel); + void cliStatistics(unsigned int device, OutputType output_type); + void cliDetailedStatistics(unsigned int device, unsigned int channel, OutputType output_type); + switch_xml_t xdevs; /* support xml needed to help the interation */ } KhompShowStatistics; /* khomp show channels */ - static struct _KhompShowChannels: public Command + static struct _KhompShowChannels: public CommandXMLOutput { - _KhompShowChannels() + _KhompShowChannels() : CommandXMLOutput(), xdev(NULL) { complete_name = "show channels"; options.push_back("verbose"); options.push_back("concise"); + options.push_back("xml"); brief = "Show all channels status."; usage = \ @@ -295,34 +342,40 @@ struct Cli "khomp API point of view.\n\n" \ "Usage: \n" \ "khomp show channels [{ []} | \n" \ - "{{concise|verbose} [ []]}]\n" \ + "{{concise|verbose|xml} [ []]}]\n" \ "\tboard -- Number of the board (start from 0).\n" \ "e.g. khomp show channels - List status of all channels of all boards.\n" \ "e.g. khomp show channels concise 0 - List status of all channels of \n" \ -" board 0 in a concise way."; +" board 0 in a concise way.\n" \ +"e.g. khomp show channels xml 0 - List status of all channels of \n" \ +" board 0 in a xml structure."; _commands.push_back(this); }; /* support function for _KhompShowChannels */ - void showChannel(unsigned int device, bool concise, unsigned int channel); - void showChannels(unsigned int device, bool concise); + void showChannel(unsigned int device, unsigned int channel, OutputType output_type = Cli::VERBOSE); + void showChannels(unsigned int device, OutputType output_type = Cli::VERBOSE); bool execute(int argc, char *argv[]); + switch_xml_t xdev; /* support xml needed to help the interation */ + } KhompShowChannels; /* khomp show links */ - static struct _KhompShowLinks: public Command + static struct _KhompShowLinks: public CommandXMLOutput { - _KhompShowLinks() + _KhompShowLinks() : CommandXMLOutput(), xdev(NULL) { complete_name = "show links"; options.push_back("verbose"); options.push_back("concise"); + options.push_back("xml"); options.push_back("errors"); options.push_back("errors verbose"); options.push_back("errors concise"); + options.push_back("errors xml"); brief = "Show E1 link(s) status/errors counters in a concise \n" \ "way or not."; @@ -332,8 +385,9 @@ struct Cli "status/the error counters of each link on the board. It prints in \n" \ "a concise way for parsing facilities.\n\n" \ "Usage: \n" \ -"khomp show links [[errors] [{} | {{concise|verbose} []}]]\n" \ +"khomp show links [[errors] [{} | {{concise|verbose|xml} []}]]\n"\ "e.g. khomp show links - Show all links of all boards.\n" \ +"e.g. khomp show links xml - Show all links of all boards in xml.\n" \ "e.g. khomp show links errors - Show error counters of all links of \n" \ " all boards.\n" \ "e.g. khomp show links errors 0 - Show error counters of all links of \n" \ @@ -343,10 +397,12 @@ struct Cli }; /* support function for _KhompShowLinks */ - void showLinks(unsigned int device, bool concise); - void showErrors(unsigned int device, bool concise); + void showLinks(unsigned int device, OutputType output_type = Cli::VERBOSE); + void showErrors(unsigned int device, OutputType output_type = Cli::VERBOSE); + std::string getLinkStatus(int dev, int obj, Verbose::Presentation fmt); bool execute(int argc, char *argv[]); + switch_xml_t xdev; /* support xml needed to help the interation */ } KhompShowLinks; /* khomp clear links */ @@ -653,24 +709,41 @@ struct Cli { complete_name = "get"; + options.push_back("dialplan"); options.push_back("echo-canceller"); + options.push_back("auto-gain-control"); options.push_back("out-of-band-dtmfs"); + options.push_back("suppression-delay"); options.push_back("auto-fax-adjustment"); + options.push_back("fax-adjustment-timeout"); options.push_back("pulse-forwarding"); options.push_back("r2-strict-behaviour"); options.push_back("r2-preconnect-wait"); - options.push_back("native-bridge"); - options.push_back("suppression-delay"); - options.push_back("context-fxo"); - options.push_back("context-fxo-alt"); - options.push_back("context-fxs"); - options.push_back("context-fxs-alt"); - options.push_back("context-gsm-call"); - options.push_back("context-gsm-call-alt"); - options.push_back("context-gsm-sms"); options.push_back("context-digital"); + options.push_back("context-fxs"); + options.push_back("context-fxo"); + options.push_back("context-gsm-call"); + options.push_back("context-gsm-sms"); + options.push_back("context-pr"); + options.push_back("log-to-console"); + options.push_back("log-to-disk"); + options.push_back("trace"); options.push_back("output-volume"); options.push_back("input-volume"); + options.push_back("fxs-global-orig"); + options.push_back("fxs-co-dialtone"); + options.push_back("fxs-bina"); + options.push_back("disconnect-delay"); + options.push_back("delay-ringback-co"); + options.push_back("delay-ringback-pbx"); + options.push_back("ignore-letter-dtmfs"); + options.push_back("fxo-send-pre-audio"); + options.push_back("fxs-digit-timeout"); + options.push_back("drop-collect-call"); + options.push_back("kommuter-activation"); + options.push_back("kommuter-timeout"); + options.push_back("user-transfer-digits"); + options.push_back("flash-to-digits"); brief = "Get configuration options in the Khomp channel."; @@ -678,36 +751,37 @@ struct Cli "Usage: khomp get