B. I have setup a few sip trunks. Now how do i set them up so that if i
dial 01192 that call goes to gateway A and if i dial 1XXX then that call
goes to gateway B
Handle each in a different extension in the dialplan:
<extension name="route1">
<condition field="destination_number" expression="^(01192)$">
<action application="bridge" data="sofia/gateway/gatewaya/$1"/>
</condition>
</extension>
<extension name="route2">
<condition field="destination_number" expression="^(1\d\d\d)$">
<action application="bridge" data="sofia/gateway/gatewayb/$1"/>
</condition>
</extension>
Adjust the expressions to suit the numbers you want to handle better. The contents of the () brackets are placed in variable $1, which is being used in the bridge to dial that number via the gateway. You can add prefixes etc there if you need them. ^ and $ match the start and end of the string, not actual characters. They're called regular expressions if you want to read up on them, and are more flexible than just matching absolute strings because you match patterns instead.
An example of changing a prefix, should your gateway need that (for example converting a local number to an international prefix):
<condition field="destination_number" expression="^0(1192)$">
<action application="bridge" data="sofia/gateway/gatewaya/44$1"/>
</condition>
01192 would be dialed as 441192 through gateway a.
-Steve