Extension line: add specific header if RPID privacy=full

I’m new to writing extension lines for asterisk, but in essence I need to check if the Remote-Party-ID header contains privacy=full. If so, then I need to run the following command:

exten => _X.,n,SIPAddHeader(Privacy:id)

Has anyone ever written code for this or come across this? I’d really appreciate some assistance on this.

If I put this in to the appropriate context it adds it perfectly fine, but on every call. I require this header to be added ONLY if the Remote-Party-ID header privacy option = full

I’m running asterisk 1.4

Use sip_header() function to get the specified SIP header and then use ExecIf() to evaluate the result

Found a solution which works perfectly (just adapt to your version of Asterisk for ExecIf)

exten => _X.,n,ExecIF($[${REGEX(“privacy=full” ${SIP_HEADER(Remote-Party-ID)}}] = “1”],SipAddHeader|Privacy:id)

This takes a privacy of a RPID and turns it into a PAID header