From 9e51fac28533cbf19df20d9f0f22e95bdf064732 Mon Sep 17 00:00:00 2001 From: Dennis Grunert Date: Mon, 29 Jan 2024 22:43:02 +0100 Subject: [PATCH 1/2] Fix line reversal on connect in case of incoming calls In addition to line reversal supervision signals of outgoing (originating) calls, option lr-on-connect now indicates connect and disconnect of incoming (terminating) calls, too. Line is only reversed on answer of incoming calls if option loop-disconnect is not enabled for that endpoint. --- src/pstn/pstn.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pstn/pstn.c b/src/pstn/pstn.c index 441c4ff..42747e6 100644 --- a/src/pstn/pstn.c +++ b/src/pstn/pstn.c @@ -1276,7 +1276,7 @@ void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg) osmo_timer_schedule(&pstn_call->metering_timer, pstn_call->metering_unit_period.tv_sec, pstn_call->metering_unit_period.tv_usec); } } - if(pstn->lr_on_connect && !pstn->lr_metering) { + if(pstn->lr_on_connect && !pstn->lr_metering && !pstn->reversed) { /* reverse loop polarity, supported by UK pstn dialect */ if(pstn->pstn_dialect == PSTN_DIALECT_UK) { LOGP(DTEL, LOGL_INFO, "Switching line polarity to reversed on connect.\n"); @@ -1408,7 +1408,7 @@ void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg) else pstn->audio_path = 0; /* disconnect supervision signals */ - if(pstn->lr_on_connect && !pstn->lr_metering) { + if(pstn->lr_on_connect && !pstn->lr_metering && pstn->reversed) { /* normal line polarity, supported by UK pstn dialect */ if(pstn->pstn_dialect == PSTN_DIALECT_UK) { LOGP(DTEL, LOGL_DEBUG, "Switching line polarity to normal on disconnect.\n"); @@ -1563,6 +1563,15 @@ static void setup_cnf(pstn_t *pstn, int hold) } /* send message to osmo-cc */ osmo_cc_ll_msg(&pstn->cc_ep, pstn_call->cc_callref, new_msg); + /* reverse loop polarity on connect */ + if(pstn->lr_on_connect && !pstn->lr_metering && !pstn->loop_disconnect && !pstn->reversed) { + if(pstn->pstn_dialect == PSTN_DIALECT_UK) { + LOGP(DTEL, LOGL_INFO, "Switching line polarity to reversed on answer.\n"); + pstn->reversed = 1; + uint8_t ie_lr[3] = { PSTN_V5_IE_STEADY_SIGNAL, 1, 0x80 | PSTN_V5_STEADY_SIGNAL_REVERSED }; + v5_sig_req(pstn, ie_lr, sizeof(ie_lr)); + } + } } static void swap_active_hold(pstn_t *pstn) -- 2.40.1 From 5f4e1c2dee90c41376a75d5123438515fa26d548 Mon Sep 17 00:00:00 2001 From: Dennis Grunert Date: Tue, 30 Jan 2024 00:01:16 +0100 Subject: [PATCH 2/2] Fix subscriber busy indication if line active despite no active call If the called subscriber has no active call, but stays off-hook (e.g. after a previously disconnected call), busy must be indicated to incoming call attempts. --- src/pstn/pstn.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pstn/pstn.c b/src/pstn/pstn.c index 42747e6..cf3ab6b 100644 --- a/src/pstn/pstn.c +++ b/src/pstn/pstn.c @@ -1037,6 +1037,12 @@ void cc_message(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg) reject_ind(pstn, callref, OSMO_CC_ISDN_CAUSE_USER_BUSY); goto done; } + /* reject if line is still active, despite no active call */ + if (pstn->call[PSTN_CALL_ACTIVE]->state == CALL_STATE_NULL && pstn->state == PSTN_STATE_ACTIVE) { + LOGP(DTEL, LOGL_INFO, "Call is NULL state, but PSTN line is active. Rejecting call.\n"); + reject_ind(pstn, callref, OSMO_CC_ISDN_CAUSE_USER_BUSY); + goto done; + } /* select call and link with cc */ if (!pstn->call[PSTN_CALL_ACTIVE]->cc_callref) { pstn_call = pstn->call[PSTN_CALL_ACTIVE]; -- 2.40.1