Asterisk fails to pick up SIP RPID and resend it as CallerID

We use OpenSER (1.2.2 )primarily as our SIP server. Meaning every user originates on OpenSER. We use Asterisk (1.4.11) as a PSTN-GW connected via zaptel (wcte11xp) to our phone network.

When routing SIP messages through Asterisk the users phone number gets misplaced. It seems asterisk is guessing the ${CALLERID(num)} is the username part of the SIP uri contact… which in our case it is not. Instead we are relying on adding Remote-Party-ID and/or P-Asserted-Identity… this works fine with other commercial PSTN-GW’s we’ve been testing!

However, I can’t seem to make Asterisk pick it up. Running sip debug on the console shows that the RPID does arrive at asterisk. But it isn’t used for anything… Manually overriding the outgoing id with Set(CALLERID(54321)) works - so I know asterisk can send it across the pri/zap interface to the network - but that is not a solution.

Any ideas?! I’ve tried the trust_rpid, send_rpid options in sip.conf, but it’s my understanding those are only valid for outbound sip connections FROM asterisk?!

An example of our invite and what happens in the simple dialling scheme we have in extensions.conf grabbed from the console;

INVITE sip:12345@asterisk:5062 SIP/2.0 Record-Route: <;lr;ftag=65k7wbrrxe> Via: SIP/2.0/UDP;branch=z9hG4bK0aea.2ca4bdb3.0 Via: SIP/2.0/UDP;branch=z9hG4bK-nmbzi2tbal3d;rport=5060 From: "Full Name" <>;tag=65k7wbrrxe To: <> Call-ID: 3c27c524cd14-rj2115v4lwyu@snom360-00041323858B CSeq: 2 INVITE Max-Forwards: 69 Contact: <;line=k6kb9uu9>;flow-id=1 P-Key-Flags: resolution="31x13", keys="4" User-Agent: snom360/6.5.10 Accept: application/sdp Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO Allow-Events: talk, hold, refer Supported: timer, 100rel, replaces, callerid Session-Expires: 3600;refresher=uas Min-SE: 90 Content-Type: application/sdp Content-Length: 477 Remote-Party-ID: <>

-- Executing [12345@from_openser:1] NoOp("SIP/", "num: username") in new stack -- Executing [12345@from_openser:2] NoOp("SIP/", "name: Full Name") in new stack -- Executing [12345@from_openser:3] NoOp("SIP/", "ani: username") in new stack -- Executing [12345@from_openser:4] NoOp("SIP/", "dnid: 12345") in new stack -- Executing [12345@from_openser:5] NoOp("SIP/", "rdnis:") in new stack -- Executing [12345@from_openser:6] Dial("SIP/", "Zap/g1/12345||r") in new stack -- Requested transfer capability: 0x00 - SPEECH -- Called g1/12345