Asterisk IPV6: PJSIP syntax error exception when parsing 'Via' header

As a followup to my previous post about Asterisk and IPv6, I have another problem. I use Asterisk 16.3.0 on OpenWrt 19.07.1.

When trying to register, I get the following error:

[2020-02-23 11:58:32] ERROR[2268] pjproject:    sip_transport. Error processing 658 bytes packet from UDP 2001:4090:4008::173:5060 : PJSIP syntax error exception when parsing 'Via' header on line 2 col 137:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP [xxxx:xxx:xxxx:xxxx:4e09:d4ff:fe29:519d]:5060;rport=5060;branch=z9hG4bKPj94e73f11-1bb3-431e-ac7c-e9194d32eedf;received=[xxxx:xxx:xxxx:xxxx:4e09:d4ff:fe29:519d]
From: <sip:<mynumber>@sip.easybell.de>;tag=c1a92b9e-1c05-487d-b035-e5adeadfc925
To: <sip:<mynumber>@sip.easybell.de>;tag=95c37a12bff1a2c36d72bf8333176544.7855
Call-ID: c386c746-6955-4810-acd3-7b41c1e69371
CSeq: 34992 REGISTER
P-NGCP-Auth-IP: 192.168.251.44
P-NGCP-Auth-UA: Asterisk PBX 16.3.0
WWW-Authenticate: Digest realm="sip.easybell.de", nonce="XlJqBV5SaNn3vR1ObujCXmPDwu5xynvu"
Server: Sipwise NGCP Proxy 7.X
Content-Length: 0


-- end of packet.

Apart from the syntax error, there are two things that irritate me about this:

  1. 401 Unauthorized: I can register successfully with the same username/password when using IPv4
  2. P-NGCP-Auth-IP: 192.168.251.44: where is that address coming from?

Does anyone have an idea what might be the problem here?

my pjsip.conf:

[global]
type = global
endpoint_identifier_order = username,ip

[acl]
type = acl
deny = 0.0.0.0/0.0.0.0
permit = [2001:4090:4008::173] ; sip.easybell.de

[transport_udp]
type=transport
protocol=udp
bind = ::

[reg_easybell]
type = registration
transport = transport_udp
contact_user = <mynumber>
client_uri = sip:<mynumber>@sip.easybell.de
server_uri = sip:sip.easybell.de
outbound_auth = auth_easybell
line = yes
endpoint = in_easybell

[auth_easybell]
type = auth
auth_type = userpass
realm = sip.easybell.de
username = <mynumber>
password = <password>

[aor_easybell]
type = aor
contact = sip:sip.easybell.de

[id_easybell]
type = identify
match = sip.easybell.de
endpoint = in_easybell

[in_easybell]
type = endpoint
transport = transport_udp
context = lantiq1_inbound
disallow = all
allow = alaw,ulaw,g722

[out_easybell]
type = endpoint
transport = transport_udp
context = out_easybell
disallow = all
allow = alaw,ulaw,g722
callerid = <mynumber>
from_user = <mynumber>
from_domain = sip.easybell.de
outbound_auth = auth_easybell
aors = aor_easybell

[out_id_easybell]
type = identify
match = localhost
endpoint = out_easybell

The via received parameter isn't supposed to have "" around the IPv6 address. Which can be seen in the BNF in RFC 3261, where IPv6address is used instead of IPv6reference.

via-received = "received" EQUAL (IPv4address / IPv6address) IPv6reference = "[" IPv6address "]"

But a SIP implementation which applies the robustness principle "Be conservative in what you send, be liberal in what you accept" may allow it anyway, but obviously shouldn't send that parameter value.

Thanks for your reply.
I found the upstream issue: https://issues.asterisk.org/jira/browse/ASTERISK-26955

There is a patch that allows brackets in via parameters, that got cherry-picked for the v13 and v16 branches as well, so the next Asterisk point releases should be able to handle this.

Since Asterisk in OpenWrt doesn't use the bundled PJSIP, but builds PJSIP from upstream, one has to apply the patch there. Upstream PJSIP patch: https://github.com/pjsip/pjproject/commit/601d6e6824a7bea35322da15caf18ae05c3917b5.patch

I built pjproject 2.9 from the openwrt-19.07 branch with the patch applied and the syntax error is gone.

The commit was already merged for pjproject v2.10

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.