Fix line reversal on connect in case of incoming calls; fix subscriber busy indication if line active despite no active call #5

Merged
jolly merged 2 commits from nt2mku/osmo-cc-pstn-endpoint:nt2mku/work into jolly/work 2024-01-30 17:34:34 +00:00
1 changed files with 17 additions and 2 deletions

View File

@ -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];
@ -1276,7 +1282,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 +1414,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 +1569,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)