From 97eb39500850230003e05862578e50fc55365d3c Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 22 Oct 2009 14:55:15 +0000 Subject: [PATCH] use SWITCH_MESSAGE_INDICATE_UUID_CHANGE to change tokens in openzap when a uuid of FS changes OPENZAP-88 git-svn-id: http://svn.openzap.org/svn/openzap/trunk@846 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/mod_openzap/mod_openzap.c | 5 +++++ libs/freetdm/src/include/openzap.h | 1 + libs/freetdm/src/zap_io.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/libs/freetdm/mod_openzap/mod_openzap.c b/libs/freetdm/mod_openzap/mod_openzap.c index 5477a9a478..301fefcb84 100644 --- a/libs/freetdm/mod_openzap/mod_openzap.c +++ b/libs/freetdm/mod_openzap/mod_openzap.c @@ -965,6 +965,11 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s } } break; + case SWITCH_MESSAGE_INDICATE_UUID_CHANGE: + { + zap_channel_replace_token(tech_pvt->zchan, msg->string_array_arg[0], msg->string_array_arg[1]); + } + break; default: break; } diff --git a/libs/freetdm/src/include/openzap.h b/libs/freetdm/src/include/openzap.h index 084b2afe21..2c7d132b3b 100644 --- a/libs/freetdm/src/include/openzap.h +++ b/libs/freetdm/src/include/openzap.h @@ -635,6 +635,7 @@ OZ_DECLARE(void) zap_channel_clear_needed_tones(zap_channel_t *zchan); OZ_DECLARE(zap_status_t) zap_channel_get_alarms(zap_channel_t *zchan); OZ_DECLARE(zap_status_t) zap_channel_send_fsk_data(zap_channel_t *zchan, zap_fsk_data_state_t *fsk_data, float db_level); OZ_DECLARE(zap_status_t) zap_channel_clear_token(zap_channel_t *zchan, const char *token); +OZ_DECLARE(void) zap_channel_replace_token(zap_channel_t *zchan, const char *old_token, const char *new_token); OZ_DECLARE(zap_status_t) zap_channel_add_token(zap_channel_t *zchan, char *token, int end); OZ_DECLARE(zap_status_t) zap_channel_set_state(zap_channel_t *zchan, zap_channel_state_t state, int lock); OZ_DECLARE(zap_status_t) zap_span_load_tones(zap_span_t *span, const char *mapname); diff --git a/libs/freetdm/src/zap_io.c b/libs/freetdm/src/zap_io.c index 2670c37ea7..e73f8bdd45 100644 --- a/libs/freetdm/src/zap_io.c +++ b/libs/freetdm/src/zap_io.c @@ -703,6 +703,20 @@ OZ_DECLARE(void) zap_channel_rotate_tokens(zap_channel_t *zchan) } } +OZ_DECLARE(void) zap_channel_replace_token(zap_channel_t *zchan, const char *old_token, const char *new_token) +{ + int i; + + if (zchan->token_count) { + for(i = 0; i < zchan->token_count; i++) { + if (!strcmp(zchan->tokens[i], old_token)) { + zap_copy_string(zchan->tokens[i], new_token, ZAP_TOKEN_STRLEN); + break; + } + } + } +} + OZ_DECLARE(zap_status_t) zap_channel_add_token(zap_channel_t *zchan, char *token, int end) { zap_status_t status = ZAP_FAIL;