some of the headers changed from when this was released, I wrote a 2600hz magazine guide on this a long time ago, but that kinda dates me. The method above I think Kevin Mitnik was demoing and someone recorded it, not 100% sure though.
You can do a tcp dump, and look for the new headers (to see how your provider is sending them)while the blocked call comes in - just call your DID from a blocked cell phone, and search from your cell phone number, you'll spot the proper header easy this way! Start this dump just before the call comes in, and control c it right after, look for your cell phone number that comes in blocked (if your provider unblocks it, it will be there in the header! then find which part of the header they are sending it under, and cut it out (see how I did it below).
tcpdump -i eth0 -n -s 0 port 5060 -vvv -w /tmp/`date +%F_%T`.cap
some voip providers provide the PAI on local DIDs, as well as Toll Free.
Some providers just unmask all toll free DIDs, so you don't even have to do this.
So get a cheap one for $1, and use it only to fwd calls back to your cell phone which has the original blocked call.
It gets a little compicated if you use your main incoming DID to also fwd to your cell, if you fwd your cell to the DID, in that case you need to pull out the diversion header, check to see if its your cell phone doing the diversion, and if so, to just fwd it back to the cell phone (instead of gong through the IVR for instance).
So the flow would be, blocked call to cell, cell to your asterisk DID (with a provider who provides good headers), divert on busy (such as *67*number# on gsm) to your asterisk did, incoming route check for diversion header of your cell phone, fwd back to cell phone if its a diversion, else send it to your ivd (or whatever).
Here is mine, which by the way, looks for the two types of headers, one from toll free incoming calls, and one from local incoming calls, in the headers (in my case its P-Asserted-Identity and Contact respectfully), it will show the incoming phone number. I also have a notification routine, which will put [PRIVATE] as the callerid name, and show the number, and sends that as a ams text and email (so I know an incoming call is on its way) - I also put in the email and sms the diversion reason (busy, call fwd always, etc) so if I get someone calling me, and it is in fact a forwarded number in itself (nothing to do with above) I can see the original number as well as the number which is diverting it to my number
(sorry for my mess below, I know it's a mess, but it works FOR NOW!)
[from-voipprovider]
include => app-blacklist-check-custom
exten => _X!,1,Set(privheader=${SIP_HEADER(Privacy)})
exten => _X!,n,Set(paidcheck=${CUT(CUT(CUT(SIP_HEADER(P-Asserted-Identity),+,2),@,1),:,1)})
exten => _X!,n,Set(fromcheck=${CUT(CUT(CUT(SIP_HEADER(From),+,2),@,1),:,1)})
exten => _X!,n,Set(contactcheck=${CUT(CUT(CUT(SIP_HEADER(Contact),+,2),@,1),:,1)})
exten => _X!,n,Set(fwdfromnum=${CUT(CUT(CUT(SIP_HEADER(Diversion),+,2),@,1),:,1)})
exten => _X!,n,Set(divreason=${CUT(CUT(CUT(SIP_HEADER(Diversion),\;,2),\;,1),=,2)})
exten => _X!,n,Set(diversion=${SIP_HEADER(Diversion)})
exten => _X!,n,Set(CALLERID(name)=${fromcheck})
exten => _X!,n,GotoIf($[${LEN(${privheader})} > 1]?unblocktf)
exten => _X!,n,GotoIf($["${CUT(CUT(CUT(SIP_HEADER(From),:,2),@,1),:,1)}" = "Anonymous"]?unblocklocal)
exten => _X!,n(notblocked),NoOp
exten => _X!,n,Set(CALLERID(num)=${CUT(CUT(CUT(SIP_HEADER(P-Asserted-Identity),+,2),@,1),:,1)})
exten => _X!,n,Set(CALLERID(ani)=${CUT(CUT(CUT(SIP_HEADER(P-Asserted-Identity),+,2),@,1),:,1)})
exten => _X!,n,Set(CURLOPT(conntimeout)=1)
exten => _X!,n,Set(CURLOPT(httptimeout)=2)
exten => _X!,n,Set(CALLERID(name)=${CURL(
https://[email protected]/v2/phone/${CALLERID(num):1}?format=pbx)})
exten => _X!,n,Set(cidname99=${CALLERID(name)})
exten => _X!,n,Set(cidnum99=${CALLERID(num)})
exten => _X!,n,Set(ani299=${CALLINGANI2})
exten => _X!,n,Set(rdnis99=${CALLERID(rdnis)})
exten => _X!,n,Set(ani99=${CALLERID(ani)})
exten => _X!,n,GotoIf($[${LEN(${fwdfromnum})} = 0]?nofwd)
exten => _X!,n,Set(CALLERID(name)=[FWD] ${CALLERID(name)})
exten => _X!,n,Set(cidname99=${CALLERID(name)})
exten => _X!,n(nofwd),NoOp
exten => _X!,n,GotoIf($["${fwdfromnum}" = "1MYCELL"]?fwdfromcell1)
exten => _X!,n,GotoIf($["${fwdfromnum}" = "1MYCELL2"]?fwdfromcell2)
exten => _X!,n,Gosub(callnotify,${EXTEN},1)
exten => _X!,n,Goto(from-trunk,${EXTEN},1)
exten => _X!,n(unblocktf),NoOp
exten => _X!,n,Set(CALLERID(num)=${CUT(CUT(CUT(SIP_HEADER(P-Asserted-Identity),+,2),@,1),:,1)})
exten => _X!,n,Set(CALLERID(ani)=${CUT(CUT(CUT(SIP_HEADER(P-Asserted-Identity),+,2),@,1),:,1)})
exten => _X!,n,Set(CURLOPT(conntimeout)=1)
exten => _X!,n,Set(CURLOPT(httptimeout)=2)
exten => _X!,n,Set(CALLERID(name)=${CURL(
https://[email protected]/v2/phone/${CALLERID(num):1}?format=pbx)})
exten => _X!,n,Set(CALLERID(name)=[PRIVATE] ${CALLERID(name)})
exten => _X!,n,Set(cidname99=${CALLERID(name)})
exten => _X!,n,Set(cidnum99=${CALLERID(num)})
exten => _X!,n,Set(ani299=${CALLINGANI2})
exten => _X!,n,Set(rdnis99=${CALLERID(rdnis)})
exten => _X!,n,Set(ani99=${CALLERID(ani)})
exten => _X!,n,GotoIf($[${LEN(${fwdfromnum})} = 0]?nofwd2)
exten => _X!,n,Set(CALLERID(name)=[FWD] ${CALLERID(name)})
exten => _X!,n,Set(cidname99=${CALLERID(name)})
exten => _X!,n(nofwd2),NoOp
exten => _X!,n,GotoIf($["${fwdfromnum}" = "MYCELL"]?fwdfromcell1)
exten => _X!,n,GotoIf($["${fwdfromnum}" = "MYCELL2"]?fwdfromcell2)
exten => _X!,n,Gosub(callnotify,${EXTEN},1)
exten => _X!,n,Goto(from-trunk,${EXTEN},1)
exten => _X!,n(unblocklocal),NoOp
exten => _X!,n,Set(CALLERID(num)=${CUT(CUT(CUT(SIP_HEADER(Contact),+,2),@,1),:,1)})
exten => _X!,n,Set(CALLERID(ani)=${CUT(CUT(CUT(SIP_HEADER(Contact),+,2),@,1),:,1)})
exten => _X!,n,Set(CURLOPT(conntimeout)=1)
exten => _X!,n,Set(CURLOPT(httptimeout)=2)
;exten => _X!,n,Set(CALLERID(name)=${CURL(
https://[email protected]/v2/phone/${CALLERID(num):1}?format=pbx)})
exten => _X!,n,Set(CALLERID(name)=[PRIVATE] ${CALLERID(name)})
exten => _X!,n,Set(cidname99=${CALLERID(name)})
exten => _X!,n,Set(cidnum99=${CALLERID(num)})
exten => _X!,n,Set(ani299=${CALLINGANI2})
exten => _X!,n,Set(rdnis99=${CALLERID(rdnis)})
exten => _X!,n,Set(ani99=${CALLERID(ani)})
exten => _X!,n,GotoIf($[${LEN(${fwdfromnum})} = 0]?nofwd3)
exten => _X!,n,Set(CALLERID(name)=[FWD] ${CALLERID(name)})
exten => _X!,n,Set(cidname99=${CALLERID(name)})
exten => _X!,n(nofwd3),NoOp
exten => _X!,n,GotoIf($["${fwdfromnum}" = "1MYCELL"]?fwdfromcell1)
exten => _X!,n,GotoIf($["${fwdfromnum}" = "1MYCELL2"]?fwdfromcell2)
exten => _X!,n,Gosub(callnotify,${EXTEN},1)
exten => _X!,n,Goto(from-trunk,${EXTEN},1)
exten => _X!,n(returntotrunk),NoOp
exten => _X!,n,Goto(from-trunk,${EXTEN},1)
exten => _X!,n(fwdfromcell1),NoOp
exten => _X!,n,Dial(SIP/MYPROVIDER/1MYCELL,45,)
exten => _X!,n,Congestion
exten => _X!,n(fwdfromcell2),NoOp
exten => _X!,n,Dial(SIP/MYPROVIDER/1MYCELL2,45,)
exten => _X!,n,Congestion
[callnotify]
exten => 1MYDID1,1,System(echo "To:
[email protected]" > /tmp/asterisk/${EXTEN}email)
exten => 1MYDID1,n,System(echo "To:
[email protected]" > /tmp/asterisk/${EXTEN}page)
exten => 1MYDID1,n,System(echo "${cidnum99}" > /tmp/asterisk/INCOMINGcid)
exten => 1MYDID1,n,System(echo "Subject: [PBX] ${cidname99} @ ${cidnum99}" >> /tmp/asterisk/${EXTEN}email)
exten => 1MYDID,n,System(echo "${cidname99}" > /tmp/asterisk/INCOMINGcnam)
exten => 1MYDID,n,System(echo "" >> /tmp/asterisk/${EXTEN}email)
exten => 1MYDID,n,System(echo "" >> /tmp/asterisk/${EXTEN}page)
exten => 1MYDID,n,System(echo "\r\n NAME: ${cidname99}\r\n\r\n CID: ${cidnum99}\r\n\r\n DID: ${EXTEN} \r\n\r\n FWD: ${fwdfromnum} [${divreason}] \r\n\r\n\r\n -Asterisk" >> /tmp/asterisk/${EXTEN}email)
exten => 1MYDID,n,System(echo "${cidname99} @ ${cidnum99} | DIALED:${EXTEN} | FWDFRM:${fwdfromnum}" >> /tmp/asterisk/${EXTEN}page)
exten => 1MYDID,n,System(sendmail -t -f
[email protected]< /tmp/asterisk/${EXTEN}email)
exten => 1MYDID,n,System(sendmail -t -f
[email protected]< /tmp/asterisk/${EXTEN}page)
exten => 1MYDID,n,Return