Solution: Reverse engineer the way call manager sends mailbox requests to cisco unity. Then apply this method to kamailio.
I ran the built in packet capture tool on the call manager box using these instructions: http://www.netcraftsmen.net/resources/blogs/networktraces-cisco-uc.html
What I found out is that when CUCM sends a forwarded call to a unity mailbox, it uses the diversion header in SIP to accomplish this.

In the capture above, you can see that ext 36939 called 36909. The ext 36909 didnt answer and the call was forwarded to Unity at ext 36930 (pilot number for unity). Since its against rfc3261 to mangle the To: header, cucm inserts a diversion header to tell unity which mailbox greeting it should play. Thanks Cisco, for not breaking the rules!
So now I just need kamailio to insert a diversion header into the failure route when a user doesnt answer their softphone. Kamailio will use LDAP to find out a users mailbox id and insert that 5 digit extension into the diversion header.
So, the failure route will look like this:
failure_route[1] {
if (t_check_status("408") || t_check_status("480"))
{
avp_subst("$avp(s:telephone)", "/.{6}/\1/g");
append_hf("Diversion: <sip:$avp(s:telephone)@ccm.example.com>;reason=unconditional;privacy=off;screen=yes\r\n");
rewritehost("ccm.example.com");
xlog("Forwarding to <$rU> on CCM via failure route");
t_relay();
exit;
};
Now kamailio will include the callee's 5 digit mailbox id in the diversion header. This will force unity to play the callee's mailbox greeting and you can leave a message.
The last step is to check the inbound diversion check box on the inbound sip trunk from kamailio to CUCM.

Recent Comments