Asterisk shows these modification in logfiles too:
Executing [s@macro-dialout-trunk-predial-hook:1] SIPAddHeader(“PJSIP/374-0000002d”, “P-Preferred-Identity:sip:[email protected]”) in new stack
Executing [s@macro-dialout-trunk-predial-hook:2] MacroExit(“PJSIP/374-0000002d”, “”) in new stack
But when I’m tcpdumping these packets, none of the invites to sipgate do contain the p-preferred-identity:
The other solution is to switch this trunk back to a Chan-SIP connection. Then your SipAddHeader() call will actually work because it is part of the right interface stack.