### Description
Kamailio cannot parse Via header with full IPv6 address. And generate errors like ``` ERROR: <core> [core/parser/msg_parser.c:340]: parse_headers(): bad header field [Via: SIP/2.0/TCP [2a00:1370:8131:ffdf:4398:8903:f613:58b6];branch=z9hG4bK02cc.edc691e200000000000000] ```
#### SIP Traffic
OPTIONS messages cannot be parsed ``` OPTIONS sip:example.com:5080;transport=tcp SIP/2.0 Via: SIP/2.0/TCP [2a00:1370:8131:ffdf:4398:8903:f613:58b6];branch=z9hG4bK0241.2e5db116000000000000000000000000.0 To: sip:example.com:5080;transport=tcp From: sip:proxy@example.com;tag=ecfe220eb77cee2ab0369a33b85d6b69-54b37dee CSeq: 10 OPTIONS Call-ID: 0d2146aa2a479f0d-2232@192.168.1.6 Max-Forwards: 70 Content-Length: 0 ```
OPTIONS messages parsed successfully. ``` OPTIONS sip:example.com.com:5080;transport=tcp SIP/2.0 Via: SIP/2.0/TCP [2600:1f1c:6d5:aa00::6];branch=z9hG4bK67a6.b0578ab2000000000000000000000000.0 To: sip:example.com:5080;transport=tcp From: sip:proxy@example.com;tag=c9c2897ae0601f24edc14b3f5f65b7e4-02fff025 CSeq: 10 OPTIONS Call-ID: 3555c29958953393-581752@3.101.84.6 Max-Forwards: 70 Content-Length: 0 ```
### Additional Information
compiled commit 1483ddb735c3fa3ea77b6e2d54ec67584e56e15b
* **Operating System**:
lsb_release -a ``` [safarov@safarov-dell config]$ lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: Fedora Description: Fedora release 33 (Thirty Three) Release: 33 Codename: ThirtyThree ```
uname -a ``` [root@safarov-dell kamailio]# uname -a Linux safarov-dell.home 5.14.9-100.fc33.x86_64 #1 SMP Thu Sep 30 12:45:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ```
It works for me with Kamailio master branch injecting the OPTIONS to the network using protoshoot from the same source tree:
``` ./misc/tools/protoshoot/protoshoot -f /tmp/options.sip ```
The debug messages are:
``` 1(10089) DEBUG: <core> [core/udp_server.c:494]: udp_rcv_loop(): received on udp socket: (103/100/377) [[OPTIONS sip:example.com:5080;transport=tcp SIP/2.0 0A Via: SIP/2.0/TCP [2a00:1370:8131:ffdf:4398:8903:f]] 1(10089) DEBUG: <core> [core/parser/parse_fline.c:250]: parse_first_line(): first line type 1 (request) flags 1 1(10089) DEBUG: <core> [core/parser/msg_parser.c:677]: parse_msg(): SIP Request: 1(10089) DEBUG: <core> [core/parser/msg_parser.c:679]: parse_msg(): method: <OPTIONS> 1(10089) DEBUG: <core> [core/parser/msg_parser.c:681]: parse_msg(): uri: sip:example.com:5080;transport=tcp 1(10089) DEBUG: <core> [core/parser/msg_parser.c:683]: parse_msg(): version: <SIP/2.0> 1(10089) DEBUG: <core> [core/parser/parse_hname2.c:302]: parse_sip_header_name(): parsed header name [Via] type 1 1(10089) DEBUG: <core> [core/parser/parse_via.c:1303]: parse_via_param(): Found param type 232, <branch> = <z9hG4bK0241.2e5db116000000000000000000000000.0>; state=15 1(10089) DEBUG: <core> [core/parser/parse_via.c:2639]: parse_via(): end of header reached, state=5 1(10089) DEBUG: <core> [core/parser/msg_parser.c:555]: parse_headers(): Via found, flags=2 1(10089) DEBUG: <core> [core/parser/msg_parser.c:557]: parse_headers(): this is the first via 1(10089) DEBUG: <core> [core/parser/parse_hname2.c:302]: parse_sip_header_name(): parsed header name [To] type 3 1(10089) DEBUG: <core> [core/parser/parse_addr_spec.c:884]: parse_addr_spec(): end of header reached, state=10 1(10089) DEBUG: <core> [core/parser/msg_parser.c:173]: get_hdr_field(): <To> [37]; uri=[sip:example.com:5080;transport=tcp] 1(10089) DEBUG: <core> [core/parser/msg_parser.c:176]: get_hdr_field(): to body (37)[sip:example.com:5080;transport=tcp ], to tag (0)[] 1(10089) DEBUG: <core> [core/parser/parse_hname2.c:302]: parse_sip_header_name(): parsed header name [From] type 4 1(10089) DEBUG: <core> [core/parser/parse_hname2.c:302]: parse_sip_header_name(): parsed header name [CSeq] type 5 1(10089) DEBUG: <core> [core/parser/msg_parser.c:154]: get_hdr_field(): cseq <CSeq>: <10> <OPTIONS> 1(10089) DEBUG: <core> [core/parser/parse_hname2.c:302]: parse_sip_header_name(): parsed header name [Call-ID] type 6 1(10089) DEBUG: <core> [core/receive.c:392]: receive_msg(): --- received sip message - request - call-id: [0d2146aa2a479f0d-2232@192.168.1.6] - cseq: [10 OPTIONS] 1(10089) DEBUG: <core> [core/parser/parse_hname2.c:302]: parse_sip_header_name(): parsed header name [Max-Forwards] type 8 1(10089) DEBUG: <core> [core/parser/parse_hname2.c:302]: parse_sip_header_name(): parsed header name [Content-Length] type 12 1(10089) DEBUG: <core> [core/parser/msg_parser.c:187]: get_hdr_field(): content_length=0 1(10089) DEBUG: <core> [core/parser/msg_parser.c:91]: get_hdr_field(): found end of header ```
Maybe it is something else in your config or another (custom) version.
Closing, it couldn't be reproduced.
Closed #2898.
Thanks, Daniel @miconda I will collect more debug logs and provide them here later.