Hello,
I’m looking for a possibility to prevent an infinite loop of call forwardings.
Setup
I have two users Alice and Bob. Alice has set up call forwarding to Bob. Bob has set up call forwarding to Alice. When someone calls either person then I have an infinite loop.
I would rather like to drop the call after a certain number of redirections.
Scenario 1 - Alice and Bob are both on the same Asterisk instance.
My current solution is to increment REDIRECTING(count) on each forward.
Set(REDIRECTING(count,i)=$[${REDIRECTING(count)} + 1])
If a certain limit is exceeded I drop the call.
Scenario 2 - Alice and Bob are on two separate Asterisk instances. Both Asterisk instances are connected via IAX2.
For this case my solution with REDIRECTING(count) doesn’t work.
- Each time a call arrives in one Asterisk instance, REDIRECTING(count) is zero.
- The number I store in REDIRECTING(from-num) on Asterisk instance A is accessible on Asterisk instance B at CALLERID(rdnis). But unfortunately I didn’t find a way to get the value of the redirecting counter.
Questions
- How can I prevent infinite loops?
- Am I doing it right in scenario 1?
- What about scenario 2?
I tried to search on the internet on how to prevent infinite loops but unfortunately without success.
One idea/workaround/hack would be to introduce a waiting time (e.g. half a second) before processing each call. This would slow down the infinite loop considerably.
Best regards,
Sebastian