英文:
PJSIP How to forward all the SIP headers as received in incoming call
问题
我正在运行一个Asterisk 20.03 SIP服务器。我在传入的SIP INVITE中收到了多个X标头,并希望在将此INVITE转发给连接的SIP客户端时发送所有这些SIP标头。
我尝试了以下配置:
; extensions.conf
[default]
exten => 1234,1,Set(X-My-ID = ${PJSIP_HEADER(read,X-My-ID)})
exten => 1234,1,Set(X-My-Loc = ${PJSIP_HEADER(read,X-My-Loc)})
exten => 1234,1,Set(X-My-Add = ${PJSIP_HEADER(read,X-My-Add)})
exten => 1234,1,Dial(PJSIP/1234,10)
但是我看不到SIP标头被添加到发送给SIP客户端的INVITE中。
我想要转发在INVITE中收到的所有这些SIP标头,我应该如何做?
英文:
I am running an Asterisk 20.03 SIP server. I receive multiple X Headers in the incoming SIP INVITE, and I want to send all these SIP headers when I forward this INVITE to the connected SIP client.
I did try below configuration:
; extensions.conf
[default]
exten => 1234,1,Set(X-My-ID = ${PJSIP_HEADER(read,X-My-ID)})
exten => 1234,1,Set(X-My-Loc = ${PJSIP_HEADER(read,X-My-Loc)})
exten => 1234,1,Set(X-My-Add = ${PJSIP_HEADER(read,X-My-Add)})
exten => 1234,1,Dial(PJSIP/1234,10)
But I don't see the SIP headers getting added in the INVITE to SIP client.
I want to forward all these SIP headers received in the INVITE, how can I do that?
答案1
得分: 2
以下是翻译好的内容:
你只是使用这些行来设置变量的值:
exten => 1234,1,Set(X-My-ID = ${PJSIP_HEADER(read,X-My-ID)})
exten => 1234,1,Set(X-My-Loc = ${PJSIP_HEADER(read,X-My-Loc)})
exten => 1234,1,Set(X-My-Add = ${PJSIP_HEADER(read,X-My-Add)})
你还没有增加优先级,所以这些行都不会被执行。
我认为这应该是你要找的内容:
[headers]
exten => add,1,Set(PJSIP_HEADER(add,X-My-ID)=${MyID})
same => n,Set(PJSIP_HEADER(add,X-My-Loc)=${MyLoc})
same => n,Set(PJSIP_HEADER(add,X-My-Add)=${MyAdd})
[default]
exten => 1234,1,Set(_MyID=${PJSIP_HEADER(read,X-My-ID)})
same => n,Set(_MyLoc=${PJSIP_HEADER(read,X-My-Loc)})
same => n,Set(_MyAdd=${PJSIP_HEADER(read,X-My-Add)})
same => n,Dial(PJSIP/${EXTEN},10,b(headers^add^1))
这将使用标头值设置通道变量的值,然后Dial命令调用另一个上下文将这些值添加到标头中。有关更多详细信息,请参阅Server Fault上的类似问题。
英文:
You're just setting the value of a variable with these lines:
exten => 1234,1,Set(X-My-ID = ${PJSIP_HEADER(read,X-My-ID)})
exten => 1234,1,Set(X-My-Loc = ${PJSIP_HEADER(read,X-My-Loc)})
exten => 1234,1,Set(X-My-Add = ${PJSIP_HEADER(read,X-My-Add)})
You're also not incrementing the priority so none of those lines will get executed anyway.
I think this should do what you're looking for:
[headers]
exten => add,1,Set(PJSIP_HEADER(add,X-My-ID)=${MyID})
same => n,Set(PJSIP_HEADER(add,X-My-Loc)=${MyLoc})
same => n,Set(PJSIP_HEADER(add,X-My-Add)=${MyAdd})
[default]
exten => 1234,1,Set(_MyID=${PJSIP_HEADER(read,X-My-ID)})
same => n,Set(_MyLoc=${PJSIP_HEADER(read,X-My-Loc)})
same => n,Set(_MyAdd=${PJSIP_HEADER(read,X-My-Add)})
same => n,Dial(PJSIP/${EXTEN},10,b(headers^add^1))
This sets the value of channel variables with the header values, and then the Dial
command calls another context to add these values in to the headers. See a similar question on Server Fault for more details.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论