diff --git a/pri.c b/pri.c index 3fee6a0..1288f58 100644 --- a/pri.c +++ b/pri.c @@ -1159,9 +1159,18 @@ int pri_redirecting_update(struct pri *ctrl, q931_call *call, const struct pri_p case PRI_SWITCH_EUROISDN_E1: case PRI_SWITCH_EUROISDN_T1: if (PTMP_MODE(ctrl)) { - /* PTMP mode */ - q931_notify_redirection(ctrl, call, PRI_NOTIFY_CALL_DIVERTING, - &call->redirecting.to.number); + if (NT_MODE(ctrl)) { + /* + * NT PTMP mode + * + * We should not send these messages to the network if we are + * the CPE side since phones do not redirect calls within + * themselves. Well... If you consider someone else picking up + * the handset a redirection then how is the network to know? + */ + q931_notify_redirection(ctrl, call, PRI_NOTIFY_CALL_DIVERTING, + &call->redirecting.to.number); + } break; } /* PTP mode - same behaviour as Q.SIG */ diff --git a/q931.c b/q931.c index d144eb7..9e3c4ab 100644 --- a/q931.c +++ b/q931.c @@ -2101,6 +2101,23 @@ static int transmit_redirecting_number(int full_ie, struct pri *ctrl, q931_call if (!call->redirecting.from.number.valid) { return 0; } + if (BRI_TE_PTMP(ctrl)) { + /* + * We should not send this ie to the network if we are the TE + * PTMP side since phones do not redirect calls within + * themselves. Well... If you consider someone else dialing the + * handset a redirection then how is the network to know? + */ + return 0; + } + if (call->redirecting.state != Q931_REDIRECTING_STATE_IDLE) { + /* + * There was a DivertingLegInformation2 in the message so the + * Q931_REDIRECTING_NUMBER ie is redundant. Some networks + * (Deutsche Telekom) complain about it. + */ + return 0; + } datalen = strlen(call->redirecting.from.number.str); ie->data[0] = call->redirecting.from.number.plan;