[asterisk-bugs] [JIRA] (ASTERISK-18232) Broken REGISTER sent to IPv4 server when bindaddr=[::]

Ale (JIRA) noreply at issues.asterisk.org
Wed Dec 10 18:00:28 CST 2014


    [ https://issues.asterisk.org/jira/browse/ASTERISK-18232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=223981#comment-223981 ] 

Ale commented on ASTERISK-18232:
--------------------------------

Actually, there was a second bug in the same function: IPv6 mapped IPv4 addresses were just taken as IPv6 and were thus never going through the rewriting. This was giving seemingly illogical problems, i.e., correct Via: and Contact: headers for packets sent by Asterisk to a static peer (e.g., registration to a SIP provider was ok), but wrong headers for packets send to a connected dynamic (e.g., response to SIP INVITE). Here is the workaround:

{code:title=channels/chan_sip.c|borderStyle=solid}
// line 3813
//	if (ast_sockaddr_is_ipv6(&theirs)) {
// changed to
	if (ast_sockaddr_is_ipv6(&theirs) && !ast_sockaddr_is_ipv4_mapped(&theirs)) {
{code}


> Broken REGISTER sent to IPv4 server when bindaddr=[::]
> ------------------------------------------------------
>
>                 Key: ASTERISK-18232
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-18232
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Channels/chan_sip/IPv6, Channels/chan_sip/Registration
>            Reporter: Jacek
>
> h3. CONFIGURATION
> h4. DNS:
> {noformat}sip.example.com. IN A 81.82.83.84
> dynamichost.selfip.com. IN A 90.91.92.93
> dynamichost.selfip.com. IN AAAA 2001:db8::{noformat}
> h4. ifconfig
> {noformat}eth0      Link encap:Ethernet  HWaddr 00:01:02:03:04:05
>           inet addr:10.1.1.3  Bcast:10.255.255.255  Mask:255.0.0.0
>           inet6 addr: 2001:db8::/48 Scope:Global{noformat}
> h4. sip.conf
> {noformat}[general]
> bindaddr=[::]:5060
> domain=dynamichost.selfip.com
> fromdomain=dynamichost.selfip.com
> localnet=10.0.0.0/8
> externhost=dynamichost.selfip.com
> externrefresh=60
> nat=no
> useragent=MySIPclient
> sdpsession=MySIPclient
> register => 123456789:passw0rd at sip.example.com/123456789{noformat}
> h4. Notes:
> * 90.91.92.93 is dynamic (dynamichost.selfip.com A record changes respectively)
> * 10.1.1.3 is set to be in Demilitarized Zone of NAT (so "almost" no NAT).
> * Asterisk 1.8.5.0 built from sources.
> ----
> h3. DESCRIPTION
> The registration is not working, because IPv4-only SIP server on sip.example.com is unable to parse Via header with IPv6 address, which Asterisk sends (see Asterisk DEBUG output below). Everything works fine, when I replace bindaddr=[::]:5060 with bindaddr=0.0.0.0:5060
> {noformat}Asterisk Ready.
>    -- Re-registration for  123456789 at sip.example.com                                                                                                               
> Splitting 'sip.example.com' into...
> ...host 'sip.example.com' and port ''.
>        > doing dnsmgr_lookup for 'sip.example.com'
> Splitting 'sip.example.com' into...
> ...host 'sip.example.com' and port ''.
> Allocating new SIP dialog for 45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com - REGISTER (No RTP)
> OBPROXY: Not applying OBproxy to this call
> SIP Registry sip.example.com: refcount now 3
> For destination '81.82.83.84', our source address is '10.1.1.3'.
> Splitting 'dynamichost.selfip.com' into...
> ...host 'dynamichost.selfip.com' and port ''.
> Multiple addresses, using the first one only
> Target address 81.82.83.84:5060 is not local, substituting externaddr
> Setting SIP_TRANSPORT_UDP with address [2001:db8::]:5060
> SIP Registry sip.example.com: refcount now 4
> Scheduled a registration timeout for sip.example.com id  #7 
> Splitting 'sip.example.com' into...
> ...host 'sip.example.com' and port ''.
> Splitting 'sip.example.com' into...
> ...host 'sip.example.com' and port ''.
> Splitting 'sip.example.com' into...
> ...host 'sip.example.com' and port ''.
> Initializing initreq for method REGISTER - callid 45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com
>  Header  0 [ 33]: REGISTER sip:sip.example.com SIP/2.0
>  Header  1 [ 61]: Via: SIP/2.0/UDP [2001:db8::]:5060;branch=z9hG4bK51847aad
>  Header  2 [ 16]: Max-Forwards: 20
>  Header  3 [ 51]: From: <sip:123456789 at sip.example.com>;tag=as40fbbb71
>  Header  4 [ 34]: To: <sip:123456789 at sip.example.com>
>  Header  5 [ 58]: Call-ID: 45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com
>  Header  6 [ 18]: CSeq: 102 REGISTER
>  Header  7 [ 23]: User-Agent: MySIPclient
>  Header  8 [ 12]: Expires: 300
>  Header  9 [ 48]: Contact: <sip:123456789@[2001:db8::]:5060>
> REGISTER 10 headers, 0 lines
> REGISTER attempt 1 to 123456789 at sip.example.com
> Reliably Transmitting (no NAT) to 81.82.83.84:5060:
> REGISTER sip:sip.example.com SIP/2.0
> Via: SIP/2.0/UDP [2001:db8::]:5060;branch=z9hG4bK51847aad
> Max-Forwards: 20
> From: <sip:123456789 at sip.example.com>;tag=as40fbbb71
> To: <sip:123456789 at sip.example.com>
> Call-ID: 45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com
> CSeq: 102 REGISTER
> User-Agent: MySIPclient
> Expires: 300
> Contact: <sip:123456789@[2001:db8::]:5060>
> Content-Length: 0
> ---
> *** SIP TIMER: Initializing retransmit timer on packet: Id  #8
> Trying to put 'REGISTER si' onto UDP socket destined for 81.82.83.84:5060
> SIP Registry sip.example.com: refcount now 3
> <--- SIP read from UDP:81.82.83.84:5060 --->
> SIP/2.0 400 Malformed topmost Via header
> Via: SIP/2.0/UDP [2001:db8::]:-1
> To: <sip:123456789 at sip.example.com>;tag=2753ba73
> From: <sip:123456789 at sip.example.com>;tag=as40fbbb71
> Call-ID: 45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com
> CSeq: 102 REGISTER
> Content-Length: 0
> <------------->
>  Header  0 [ 40]: SIP/2.0 400 Malformed topmost Via header
>  Header  1 [ 36]: Via: SIP/2.0/UDP [2001:db8::]:-1
>  Header  2 [ 47]: To: <sip:123456789 at sip.example.com>;tag=2753ba73
>  Header  3 [ 51]: From: <sip:123456789 at sip.example.com>;tag=as40fbbb71
>  Header  4 [ 58]: Call-ID: 45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com
>  Header  5 [ 18]: CSeq: 102 REGISTER
>  Header  6 [ 17]: Content-Length: 0
> --- (7 headers 0 lines) ---
> = Looking for  Call ID: 45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com (Checking To) --From tag as40fbbb71 --To-tag 2753ba73  
> ** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #8
> Stopping retransmission on '45f67c40284438057bfe2e3c485144e4 at dynamichost.selfip.com' of Request 102: Match Found
>     -- Got SIP response 400 "Malformed topmost Via header" back from 81.82.83.84:5060{noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list