With SIP, the signaling is done via SIP and the digitized audio is sent via a different protocol, RTP. The SIP and RTP can and often are sent to different IP addresses. Thats normally not a problem, as long as the IP addresses are all reachable..
Whats happening in your situation, is something like this:
PBX2 sends a SIP INVITE to PBX1. Included in that INVITE is information about where to send the audio. PBX2 specifies its own IP address. Since its IP address is reachable from PBX1, calls between the two work.
Now, when the callee is an outside line, PBX1 sends its own INVITE to your provider, and passes on in that INVITE the information about where to send the audio (ie, the IP address of PBX2) If both PBXs were on public IPs, this would be fine. Since they are not both reachable from the outside, you need to modify the behavior of PBX1
On PBX1, in your sip.conf
file, there should be a peer configuration for PBX2. In that peer configuration, you need to add the following line:
canreinvite=no
(On more recent versions of asterisk, you would use directmedia=no
instead.)
This will cause PBX1 to stay in the media path whenever it is involved with a call with PBX2. In otherwords, when you call the outside world, PBX1 will give your provider its own IP address for where to send the audio, it will then proxy that audio, and send it on to PBX2.
Hope this helps!
when you transfer the calls, asterisk will search for the extension in your current context so if someone calls using "sales" he will be able to transfer only to extensions 41XX, if you want to let him transfer to extensions 40XX then you should add 40XX
to sales context, example:
[sales]
include => out-trunksip
exten => _41XX,1,Answer
exten => _41XX,n,Set(calltime=${STRFTIME(${EPOCH},,%C%y%m%d.%H.%M.%S)})
exten => _41XX,n,Set(CALLEDNUMBER=${EXTEN})
exten => _41XX,n,MixMonitor(/tmp/Para_${CALLEDNUMBER}-${calltime}-De_${CALLERID(num)}.wav)
exten => _41XX,n,Dial(SIP/${EXTEN},40,TtRr)
exten => _41XX,n,Hangup
exten => _40XX,1,Dial(SIP/${EXTEN},40,TtRr)
(you can also include supervisor context in your sales context)
If you want to prevent sales users from calling supervisor users and viceversa but still allow them to transfer calls to each other then you can solve it this way:
create a new context designated only for call transfers where you provide extensions which should be reachale when transfering a call, example:
[call-transfer]
exten => _40XX,1,Dial(SIP/${EXTEN},40,TtRr)
exten => _41XX,1,Dial(SIP/${EXTEN},40,TtRr)
Then set __TRANSFER_CONTEXT=call-transfer:
[supervisor]
include => from-internal
exten => _40XX,1,Answer
exten => _40XX,n,Set(__TRANSFER_CONTEXT=call-transfer)
exten => _40XX,n,Set(calltime=${STRFTIME(${EPOCH},,%C%y%m%d.%H.%M.%S)})
exten => _40XX,n,Set(CALLEDNUMBER=${EXTEN})
exten => _40XX,n,MixMonitor(/tmp/Para_${CALLEDNUMBER}-${calltime}-De_${CALLERID(num)}.wav)
exten => _40XX,n,Dial(SIP/${EXTEN},40,TtRr)
exten => _40XX,n,Hangup
[sales]
include => out-trunksip
exten => _41XX,1,Answer
exten => _40XX,n,Set(__TRANSFER_CONTEXT=call-transfer)
exten => _41XX,n,Set(calltime=${STRFTIME(${EPOCH},,%C%y%m%d.%H.%M.%S)})
exten => _41XX,n,Set(CALLEDNUMBER=${EXTEN})
exten => _41XX,n,MixMonitor(/tmp/Para_${CALLEDNUMBER}-${calltime}-De_${CALLERID(num)}.wav)
exten => _41XX,n,Dial(SIP/${EXTEN},40,TtRr)
exten => _41XX,n,Hangup
I'm just not sure if __TRANSFER_CONTEXT is still present in new asterisk versions :)
Best Answer
I saw that you tagged Cisco in our question, so I am guessing you are using Cisco phones, I have only used Cisco phones with Asterisk, so that is all I will be able to cover in my answer.
The first thing you will need to do is add a directory entry to your SIPDefault.cnf file (inside the TFTP directory your phone points to. Here is the line you need to add:
The url must be a web server that is accessible to the phone, not the server. That line can go anywhere in the SIPDefault.cnf file
The file on the server should follow this format:
Unfortunately I am not all that experienced with exchange or gmail. What I gan tell you is that you will need to create a cron job that will run a program every x amount of time that will generate this XML file and put it on the server. Every time the phone accesses the directory it will download the XML file.
EDIT: Here is a link that provides a lot of useful information, including a section on creating the XML file with PHP: http://www.voip-info.org/wiki/view/Asterisk+Cisco+79XX+XML+Services
Hope that helps some!