I have registered my Asterisk server to a sip provider and can reach my soft phone from the public telephone network by calling numbers that I have bought. I would now need to get the DNIS number (B-number) from the call to my soft phone so I know how I should answer the call (I have several incoming numbers and they should be answered differently). If I turn on "sip debug" in Asterisk I can see the DNIS in the "To:"-field in the sip header when the call comes in (<sip:"dnis-number"@"sip-provider-ip">). A few "sip conversations" later the "To:"-field changes to my soft phones local number (<sip:email@example.com:5060>).
Can I somehow get the original DNIS into a variable or is there some other way to change the sip header?