Realtime registration in Asterisk

Hi all,
Here is my situation. I have to register some user agents with asterisk. Then I want asterisk to register with a sip provider for these clients using multiple accounts. For example, User1 and User2 can register with Asterisk. But they cannot register with the sip provider directly. When Asterisk receives REGISTER from them, it should send REGISTER to the provider using the respective account credentials for the Users.

Like If we receive register from User1 with username: User1 secret: passwd, we execute
register =>

similarly for User2, with username: User2 secret: passwd, we execute
register =>

So that the context of section [1001] and [1002] can be tweaked and we can route the call to the respective user in dialplan.
Is it possible ? When I google, the closest I could get is the use of Asterisk Realtime. But I am not sure, if it will help my case. Thank you in advance for the help.

Short answer: it’s not possible.

Long answer: it is possible, but you will need do a lot of analysis and C coding. That’s only possible because it is open source; it will not be easy.

Also note that having multiple accounts with the same provider can result in Asterisk having trouble matching incoming calls to sip.conf sections.

Thank you for the quick reply !
So do you mean it is not typical behaviour of Asterisk waiting for an event and send a REGISTER ? understood.
Couldn’t it be accomplished with Asterisk Realtime and with AGI C scripting, Without getting my hands into the source code ?

Asterisk would need to know the credentials from the users in advance. There is no provision to take wild card credentials and then make the actual values used available to scripting.

At the moment, this feels like a SIP proxy application. I suspect it is a case where you have take the design too far and are asking for a solution to sub-problem, when you really need a solution to a higher level requirement.

You’re right ! But the real application would be too complex to describe. So I thought I’d simplify. If I find something
I would post here, how I solved this case. Thank you for helping…