Apparantly it should be simple to mangle the From in request: http://kamailio.org/docs/modules/stable/modules_k/uac.html#id2525538
The task at hand is use the prefix 131 to suppress callerid for this call:
if($rU=~"^131[0-9]+$") { strip(3); append_hf("Privacy: id\r\n"); uac_replace_from("anonymous","sip:anonymous@anonymous.invalid:$rp"); uac_replace_to("","sip:$rU@$rd"); }
Just before this replace there is an other uac_replace_from to rewrite an alphanumeric username to the default callerid for that device. If there are 2 uac_replace_from in the path, things go wrong like below. A uac_restore_from() before the second uac_replace_from doesn't change this behavior.
device calls 1310123456789:
U 10.0.34.226:1300 -> 10.0.35.226:5060 INVITE sip:1310123456789@kamailio.local:5060 SIP/2.0. From: sip:anonymous@10.0.3.44:5060;tag=26e5ce5850. To: sip:1310123456789@kamailio.local:5060.
Kamailio forwards request to dispatcher but fails to properly replace the from uri:
U 10.0.35.226:5060 -> 10.0.32.36:5060 INVITE sip:+31123456789@kamailio.local:5060 SIP/2.0. From: "anonymous" sip: +31987654321@10.0.3.44:5060sip:anonymous@anonymous.invalid:5060;tag=26e5ce5850. To: sip:0123456789@kamailio.local.
Even though the debug log suggests it did the proper replacement:
uac [replace.c:265]: value to store is is 'sip:anonymous@10.0.3.44:5060' and len is '30' uac [replace.c:268]: Storing in FROM-AVP (for use in reply): 'sip:anonymous@10.0.3.44:5060' with len '30' uac [replace.c:324]: uri to replace [sip:anonymous@10.0.3.44:5060] uac [replace.c:325]: replacement uri is [sip:anonymous@anonymous.invalid:5060] uac [replace.c:383]: encode is=<AAAAAAAAAAAAAAAAAABQXkFeV15BQUcUXF5AUWxpZDo1MDYw> len=48 uac [replace.c:265]: value to store is is 'sip:1310619024127@kamailio.local:5060' and len is '54' uac [replace.c:271]: Storing in TO-AVP (for use in reply): 'sip:1310123456789@kamailio.local:5060' with len '54' uac [replace.c:324]: uri to replace [sip:1310123456789@kamailio.local:5060] uac [replace.c:325]: replacement uri is [sip:0123456789@kamailio.local] uac [replace.c:383]: encode is=<AAAAAAEFAAkGAw0BAANxQlYuERJDCRxeHAoXWgYRXRdbAxtNHxwNCgdACxgubmw6NTA2MA--> len=72
Kamailio version: kamailio 3.3.2 (x86_64/linux) (the latest stable debian/squeeze package).