How to add new headers to INVITE packet with APIs? e.g. my packet is this: INVITE sip:1000@192.168.2.73 SIP/2.0 Via: SIP/2.0/UDP 192.168.2.77:5080;rport;branch=z9hG4bKUFpyDr890F1pB Max-Forwards: 70 From: "Outbound Call" <sip:TCAPI_User@192.168.2.73>;tag=UZ6gtcDZvQy8e To: <sip:1000@192.168.2.73> .... i want to add new attribute to these headers named 'Token', something like this: INVITE sip:1000@192.168.2.73 SIP/2.0 Via: SIP/2.0/UDP 192.168.2.77:5080;rport;branch=z9hG4bKUFpyDr890F1pB Max-Forwards: 70 From: "Outbound Call" <sip:TCAPI_User@192.168.2.73>;tag=UZ6gtcDZvQy8e To: <sip:1000@192.168.2.73> Token: gasd^@@SGHT W454v$ERYWEVGR%^#V$CSDGASF .... .... How can i do this?!
Hi Sayyed, First of all, it is best-practical for custom SIP headers to have names that start with X- (e.g. X-Token), which will ensure that the header will be treated by all upstream implementations as a custom header and not interpreted or filtered out before relay. That said, to create a new header on the B leg, you can just set a channel variable with the name: sip_h_X-Token. In the XML dial plan, this would look like: <action application="set" data="sip_h_X-Token=abc123"/> There's no reason you can't also do this in an API call, which provides the ability to set channel variables, and also access to the dialplan application that does so. For instance, I use ESL Outbound in Javascript and do something like this: conn.execute('set', 'sip_h_X-Token=abc123'); Your actual implementation will vary depending on the nature of the API you're using (ESL inbound, ESL outbound, mod_curl_xml (if that can be called an API)), and, of course, the language environment and any libraries employed. -- Alex -- Alex Balashov - Principal Evariste Systems LLC 235 E Ponce de Leon Ave Suite 106 Decatur, GA 30030 United States Tel: +1-678-954-0670 Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
participants (2)
-
Alex Balashov
-
Sayyed Mohammad Emami Razavi