[Home]

Summary:ASTERISK-00127: Asterisk doesn't respond to 407 for BYE
Reporter:linxu01 (linxu01)Labels:
Date Opened:2003-08-19 16:05:17Date Closed:2011-06-07 14:05:12
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:When an incoming call from a sip proxy to an extension on *, if * hangs up first and * will send BYE to the proxy. The proxy will reply with a 407 for BYE, but * doesn't know how to handle it. Here is the register entry in  sip.conf:

register=9988:123456@sip.mydomain.net/1207

Here is the sip debug message:
(1204 on the sip proxy calling 9988, which routed to 1207 on the *. When 1207 hangs up first, * closes the sip session between * and 1207 first, then sending a BYE to proxy. proxy return a 407, causing * not handling. Finally 1204 hangs up.)

INVITE sip:1207@10.1.3.17 SIP/2.0
Via: SIP/2.0/UDP 10.1.2.15:5060;branch=1_gZ2M2HjLZ7L5HjfdWDl10Q99
Via: SIP/2.0/UDP 10.1.1.1:5060
From: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
To: sip:9988@sip.mydomain.net
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
Date:Tue, 19 Aug 2003 20:14:34 GMT
User-Agent:Cisco-SIP-IP-Phone/2
CSeq: 102 INVITE
Expires: 1500
Contact:sip:1204@10.1.1.1:5060
Content-Type:application/sdp
Content-Length: 169
Record-Route: <sip:9988@sip.mydomain.net:5060;maddr=10.1.2.15>

v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 4482 20697 IN IP4 10.1.1.1
s=SIP Call
c=IN IP4 10.1.1.1
t=0 0
m=audio 23660 RTP/AVP 0 8 18
a=rtpmap:0 pcmu/8000

14 headers, 7 lines
Using latest request as basis request
Sending to 10.1.2.15 : 5060 (non-NAT)
Found audio format UNKN
Found audio format ALAW
Found audio format UNKN
Found description format pcmu
Capabilities: us - 524300, them - 268/0, combined - 12
Non-codec capabilities: us - 1, them - 0, combined - 0
DEBUG[147466]: File chan_sip.c, Line 4628 (handle_request): Check for res
DEBUG[147466]: File chan_sip.c, Line 906 (find_user):  is not a local user
Looking for 1207 in sip-incoming
DEBUG[147466]: File chan_sip.c, Line 3131 (build_route): build_route: Record-Route hop: <sip:9988@sip.mydomain.net:5060;maddr=10.1.2.15>
DEBUG[147466]: File chan_sip.c, Line 3156 (build_route): build_route: Contact hop: sip:1204@10.1.1.1:5060
list_route: hop: <sip:9988@sip.mydomain.net:5060;maddr=10.1.2.15>
list_route: hop: <sip:1204@10.1.1.1:5060>
Transmitting (no NAT):
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.1.2.15:5060;branch=1_gZ2M2HjLZ7L5HjfdWDl10Q99
Via: SIP/2.0/UDP 10.1.1.1:5060
From: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
To: sip:9988@sip.mydomain.net;tag=as4c6fc279
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:1207@10.1.3.17>
Content-Length: 0


to 10.1.2.15:5060
   -- Executing Dial("SIP/-081135f0", "SIP/1207|10") in new stack
DEBUG[311314]: File chan_sip.c, Line 622 (create_addr): Setting NAT on RTP to -1
We're at 10.1.3.17 port 19358
Answering with preferred capability 4
Answering with capability 8
Answering with non-codec capability 1
11 headers, 10 lines
Reliably Transmitting:
INVITE sip:1207@172.17.252.27 SIP/2.0
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK1310c593
From: "1204" <sip:1204@10.1.3.17>;tag=as0c7a9c14
To: <sip:1207@172.17.252.27>
Contact: <sip:1204@10.1.3.17>
Call-ID: 38028e7d6d49f8d75a12940a76aeec04@10.1.3.17
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Content-Type: application/sdp
Content-Length: 211

v=0
o=root 2368 2368 IN IP4 10.1.3.17
s=session
c=IN IP4 10.1.3.17
t=0 0
m=audio 19358 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
(NAT) to 172.17.252.27:5060
   -- Called 1207
Sip read:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK1310c593
From: "1204" <sip:1204@10.1.3.17>;tag=as0c7a9c14
To: <sip:1207@172.17.252.27>;tag=468530005584d5594c7654-272b913f
Call-ID: 38028e7d6d49f8d75a12940a76aeec04@10.1.3.17
Server: Cisco-SIP-IP-Phone/2
Date: Tue, 19 Aug 2003 20:14:34 GMT
CSeq: 102 INVITE
Content-Length: 0


9 headers, 0 lines
DEBUG[147466]: File chan_sip.c, Line 515 (__sip_ack): Acked pending invite 102
DEBUG[147466]: File chan_sip.c, Line 533 (__sip_ack): Stopping retransmission on '38028e7d6d49f8d75a12940a76aeec04@10.1.3.17' of Request 102: Found
Sip read:
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK1310c593
From: "1204" <sip:1204@10.1.3.17>;tag=as0c7a9c14
To: <sip:1207@172.17.252.27>;tag=468530005584d5594c7654-272b913f
Call-ID: 38028e7d6d49f8d75a12940a76aeec04@10.1.3.17
Server: Cisco-SIP-IP-Phone/2
Date: Tue, 19 Aug 2003 20:14:34 GMT
CSeq: 102 INVITE
Content-Length: 0


9 headers, 0 lines
DEBUG[147466]: File chan_sip.c, Line 533 (__sip_ack): Stopping retransmission on '38028e7d6d49f8d75a12940a76aeec04@10.1.3.17' of Request 102: Not Found
   -- SIP/1207-1ca8 is ringing
Transmitting (no NAT):
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 10.1.2.15:5060;branch=1_gZ2M2HjLZ7L5HjfdWDl10Q99
Via: SIP/2.0/UDP 10.1.1.1:5060
From: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
To: sip:9988@sip.mydomain.net;tag=as4c6fc279
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:1207@10.1.3.17>
Content-Length: 0


to 10.1.2.15:5060
Sip read:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK1310c593
From: "1204" <sip:1204@10.1.3.17>;tag=as0c7a9c14
To: <sip:1207@172.17.252.27>;tag=468530005584d5594c7654-272b913f
Call-ID: 38028e7d6d49f8d75a12940a76aeec04@10.1.3.17
Server: Cisco-SIP-IP-Phone/2
Contact: sip:1207@172.17.252.27:5060
Date: Tue, 19 Aug 2003 20:14:36 GMT
CSeq: 102 INVITE
Content-Type: application/sdp
Content-Length: 219

v=0
o=CiscoSystemsSIP-IPPhone-UserAgent 7907 8427 IN IP4 172.17.252.27
s=SIP Call
c=IN IP4 172.17.252.27
t=0 0
m=audio 28606 RTP/AVP 0 101
a=rtpmap:0 pcmu/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11

11 headers, 9 lines
DEBUG[147466]: File chan_sip.c, Line 533 (__sip_ack): Stopping retransmission on '38028e7d6d49f8d75a12940a76aeec04@10.1.3.17' of Request 102: Not Found
Found audio format UNKN
Found audio format UNKN
Found description format pcmu
Found description format telephone-event
Capabilities: us - 524300, them - 4/0, combined - 4
Non-codec capabilities: us - 1, them - 1, combined - 1
DEBUG[147466]: File chan_sip.c, Line 3156 (build_route): build_route: Contact hop: sip:1207@172.17.252.27:5060
list_route: hop: <sip:1207@172.17.252.27:5060>
set_destination: Parsing <sip:1207@172.17.252.27:5060> for address/port to send to
set_destination: set destination to 172.17.252.27, port 5060
Transmitting:
ACK sip:1207@172.17.252.27 SIP/2.0
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK1310c593
From: "1204" <sip:1204@10.1.3.17>;tag=as0c7a9c14
To: <sip:1207@172.17.252.27>;tag=468530005584d5594c7654-272b913f
Contact: <sip:1204@10.1.3.17>
Call-ID: 38028e7d6d49f8d75a12940a76aeec04@10.1.3.17
CSeq: 102 ACK
User-Agent: Asterisk PBX
Content-Length: 0

(NAT) to 172.17.252.27:5060
   -- SIP/1207-1ca8 answered SIP/-081135f0
We're at 10.1.3.17 port 19770
Answering with preferred capability 4
Answering with capability 8
Reliably Transmitting (no NAT):
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.1.2.15:5060;branch=1_gZ2M2HjLZ7L5HjfdWDl10Q99
Via: SIP/2.0/UDP 10.1.1.1:5060
Record-Route: <sip:9988@sip.mydomain.net:5060;maddr=10.1.2.15>
From: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
To: sip:9988@sip.mydomain.net;tag=as4c6fc279
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:1207@10.1.3.17>
Content-Type: application/sdp
Content-Length: 155

v=0
o=root 2368 2368 IN IP4 10.1.3.17
s=session
c=IN IP4 10.1.3.17
t=0 0
m=audio 19770 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000

to 10.1.2.15:5060
   -- Attempting native bridge of SIP/-081135f0 and SIP/1207-1ca8
Sip read:
ACK sip:1207@10.1.3.17:5060 SIP/2.0
Via: SIP/2.0/UDP 10.1.2.15:5060;branch=1_gZ2M2HjLZ7L5HjfdWDl10Q99
Via: SIP/2.0/UDP 10.1.1.1:5060
From: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
To: sip:9988@sip.mydomain.net;tag=as4c6fc279
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
Date:Tue, 19 Aug 2003 20:14:35 GMT
CSeq: 102 ACK
Content-Length: 0


9 headers, 0 lines
DEBUG[147466]: File chan_sip.c, Line 533 (__sip_ack): Stopping retransmission on '00075052-80d62845-28b3aed2-71155263@10.1.1.1' of Response 102: Found
DEBUG[311314]: File rtp.c, Line 1007 (ast_rtp_write): Ooh, format changed from UNKN to ULAW
DEBUG[311314]: File rtp.c, Line 1007 (ast_rtp_write): Ooh, format changed from UNKN to ULAW
Sip read:
BYE sip:1204@10.1.3.17:5060 SIP/2.0
Via: SIP/2.0/UDP 172.17.252.27:5060
From: <sip:1207@172.17.252.27>;tag=468530005584d5594c7654-272b913f
To: "1204" <sip:1204@10.1.3.17>;tag=as0c7a9c14
Call-ID: 38028e7d6d49f8d75a12940a76aeec04@10.1.3.17
Date: Tue, 19 Aug 2003 20:14:39 GMT
User-Agent: Cisco-SIP-IP-Phone/2
CSeq: 101 BYE
Content-Length: 0


9 headers, 0 lines
Sending to 172.17.252.27 : 5060 (NAT)
Transmitting (NAT):
SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.17.252.27:5060;received=172.17.252.27
From: <sip:1207@172.17.252.27>;tag=468530005584d5594c7654-272b913f
To: "1204" <sip:1204@10.1.3.17>;tag=as0c7a9c14
Call-ID: 38028e7d6d49f8d75a12940a76aeec04@10.1.3.17
CSeq: 101 BYE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: <sip:1204@10.1.3.17>
Content-Length: 0


to 172.17.252.27:5060
DEBUG[311314]: File channel.c, Line 2176 (ast_channel_bridge): Didn't get a frame from channel: SIP/1207-1ca8
DEBUG[311314]: File channel.c, Line 2244 (ast_channel_bridge): Bridge stops bridging channels SIP/-081135f0 and SIP/1207-1ca8
DEBUG[311314]: File chan_sip.c, Line 953 (sip_hangup): find_user(1207)
 == Spawn extension (sip-incoming, 1207, 1) exited non-zero on 'SIP/-081135f0'
DEBUG[311314]: File chan_sip.c, Line 953 (sip_hangup): find_user()
DEBUG[311314]: File chan_sip.c, Line 906 (find_user):  is not a local user
set_destination: Parsing <sip:9988@sip.mydomain.net:5060;maddr=10.1.2.15> for address/port to send to
set_destination: set destination to 10.1.2.15, port 5060
Reliably Transmitting:
BYE sip:1204@sip.mydomain.net SIP/2.0
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK65f4060b
Route: <sip:1204@10.1.1.1:5060>
From: sip:9988@sip.mydomain.net;tag=as4c6fc279
To: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
Contact: <sip:1207@10.1.3.17>
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
CSeq: 102 BYE
User-Agent: Asterisk PBX
Content-Length: 0

(no NAT) to 10.1.2.15:5060
Sip read:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK65f4060b
From: sip:9988@sip.mydomain.net;tag=as4c6fc279
To: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
CSeq: 102 BYE
Content-Length: 0


7 headers, 0 lines
DEBUG[147466]: File chan_sip.c, Line 533 (__sip_ack): Stopping retransmission on '00075052-80d62845-28b3aed2-71155263@10.1.1.1' of Request 102: Found
Message is BYE
DEBUG[147466]: File chan_sip.c, Line 835 (__sip_destroy): Destorying call '38028e7d6d49f8d75a12940a76aeec04@10.1.3.17'
DEBUG[147466]: File chan_sip.c, Line 835 (__sip_destroy): Destorying call '00075052-80d62845-28b3aed2-71155263@10.1.1.1'
Sip read:
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.1.3.17:5060;branch=z9hG4bK65f4060b
From: sip:9988@sip.mydomain.net;tag=as4c6fc279
To: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
CSeq: 102 BYE
Content-Length: 0
Proxy-Authenticate:  Digest realm="mydomain.net",domain="sip:1204@sip.mydomain.net",nonce="qPcMY3W+jHMdEkzj/LXmyg==",algorithm=MD5


8 headers, 0 lines
DEBUG[147466]: File chan_sip.c, Line 4550 (handle_request): That's odd...  Got a response on a call we dont know about.
DEBUG[147466]: File chan_sip.c, Line 835 (__sip_destroy): Destorying call '00075052-80d62845-28b3aed2-71155263@10.1.1.1'
Sip read:
BYE sip:1207@10.1.3.17:5060 SIP/2.0
Via: SIP/2.0/UDP 10.1.2.15:5060;branch=1_ffS0vy16062B1IuupR8p5w99
Via: SIP/2.0/UDP 10.1.1.1:5060
From: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
To: sip:9988@sip.mydomain.net;tag=as4c6fc279
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
Date:Tue, 19 Aug 2003 20:14:42 GMT
User-Agent:Cisco-SIP-IP-Phone/2
CSeq: 103 BYE
Content-Length: 0


10 headers, 0 lines
Sending to 10.1.2.15 : 5060 (non-NAT)
Transmitting (no NAT):
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.1.2.15:5060;branch=1_ffS0vy16062B1IuupR8p5w99
Via: SIP/2.0/UDP 10.1.1.1:5060
From: "1204" <sip:1204@sip.mydomain.net>;tag=5250070017d68010a86c32-6fe0d44d
To: sip:9988@sip.mydomain.net;tag=as4c6fc279
Call-ID: 00075052-80d62845-28b3aed2-71155263@10.1.1.1
CSeq: 103 BYE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact:
Content-Length: 0


to 10.1.2.15:5060
Comments:By: Mark Spencer (markster) 2003-08-20 00:50:00

I've committed a "first pass" attempt at implementing this.  Since I don't have the proxy, I have no way of testing if this really works or not.  Please let me know.

By: linxu01 (linxu01) 2003-08-20 09:09:45

The fix doesn't work, since this is an incoming call for Asterisk (p->outgoing is false on line 4269), so the additional check for 407 for BYE is not called. I suspect additional case statement for 407 needed for the switch on line 4446.

By: Mark Spencer (markster) 2003-08-20 09:22:00

Probably needs to be in both places, yah.  Try this latest patch.

By: linxu01 (linxu01) 2003-08-20 10:15:15

Still doesn't work. I missed the following debug output:
DEBUG[147466]: File chan_sip.c, Line 4561 (handle_request): That's odd...  Got a response on a call we dont know about.
handle_request returns after the above statement, never calling to handle_respones. If you want, you can send me the fix and I can test it and make sure it works before commiting to CVS.

By: linxu01 (linxu01) 2003-08-20 14:20:37

This seems more complicated. May need a separate function to handle sending BYE with Authorization header.

By: Mark Spencer (markster) 2003-08-20 15:16:12

Please post me the debug here with DEBUG and verbose together.

By: linxu01 (linxu01) 2003-08-20 15:47:46

I was runng * with debug on (in logger.conf) and vvvv. Also sip debug is on. The traces were in the original post. With the latest patches, the trace is the same. Are there any other options I should turn on?

By: Mark Spencer (markster) 2003-08-20 17:48:36

Those cisco jerks added a "100 Trying"...  How extremely annoying.  Time to put some more thought into this...

By: Mark Spencer (markster) 2003-08-20 17:58:17

Okay, i've submitted a new fix.  Please confirm this one *really* fixes it.  Thanks!

By: linxu01 (linxu01) 2003-08-21 10:17:09

Sorry this fix still doesn't work. There are two problems:
(1) * is sending INVITE instead of BYE. This is easy to fix. So I changed code in the do_proxy_auth to send BYE (w/o SDP);
(2) In BYE message, * doesn't have the correct From and To, and it doesn't have the correct uri for Digest. I'm checking why is this.

Here is the SIP debug showing the first problem:

SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 10.1.1.2.17:5060;branch=z9hG4bK600f0067
From: sip:9988@sip.mydomain.net;tag=as0489b84d
To: "1204" <sip:1204@sip.mydomain.net>;tag=525007002cd680400dde5d-6df0b6ef
Call-ID: 00075052-80d65057-1d87ffac-42e7155e@10.1.1.30
CSeq: 102 BYE
Content-Length: 0
Proxy-Authenticate:  Digest realm="mydomain.net",domain="sip:1204@sip.mydomain.net",nonce="BMMwxrW+M/VabDBwac5OeQ==",algorithm=MD5


8 headers, 0 lines
DEBUG[147466]: File chan_sip.c, Line 542 (__sip_ack): Stopping retransmission on '00075052-80d65057-1d87ffac-42e7155e@10.1.1.30' of Request 102: Found
Message is BYE
We're at 10.1.1.2.17 port 12472
Answering with preferred capability 4
Answering with capability 8
Reliably Transmitting:
INVITE sip: SIP/2.0
Via: SIP/2.0/UDP 10.1.1.2.17:5060;branch=z9hG4bK600f0067
From: "asterisk" <sip:asterisk@10.1.1.2.17>;tag=as0489b84d
To: <sip:>
Contact: <sip:asterisk@10.1.1.2.17>
Call-ID: 00075052-80d65057-1d87ffac-42e7155e@10.1.1.30
CSeq: 103 INVITE
User-Agent: Asterisk PBX
Proxy-Authorization: Digest username="", realm="mydomain.net", algorithm="MD5", uri="sip:@172.16.2.15", nonce="BMMwxrW+M/VabDBwac5OeQ==", response="97c9cf50ba16085c9f01c07b2e508eba"
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Content-Type: application/sdp
Content-Length: 157

v=0
o=root 24694 24694 IN IP4 10.1.1.2.17
s=session
c=IN IP4 10.1.1.2.17
t=0 0
m=audio 12472 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
(no NAT) to 172.16.2.15:5060
Sip read:
SIP/2.0 400 Bad Request
Via: SIP/2.0/UDP 10.1.1.2.17:5060;branch=z9hG4bK600f0067
From: "asterisk" <sip:asterisk@10.1.1.2.17>;tag=as0489b84d
To: <sip:>
Call-ID: 00075052-80d65057-1d87ffac-42e7155e@10.1.1.30
CSeq: 103 INVITE
Content-Length: 0


7 headers, 0 lines
DEBUG[147466]: File chan_sip.c, Line 524 (__sip_ack): Acked pending invite 103
DEBUG[147466]: File chan_sip.c, Line 542 (__sip_ack): Stopping retransmission on '00075052-80d65057-1d87ffac-42e7155e@10.1.1.30' of Request 103: Found
Message is INVITE
DEBUG[147466]: File chan_sip.c, Line 864 (__sip_destroy): Destorying call '00075052-80d65057-1d87ffac-42e7155e@10.1.1.30'
Sip read:
SIP/2.0 400 Bad Request
Via: SIP/2.0/UDP 10.1.1.2.17:5060;branch=z9hG4bK600f0067
From: "asterisk" <sip:asterisk@10.1.1.2.17>;tag=as0489b84d
To: <sip:>
Call-ID: 00075052-80d65057-1d87ffac-42e7155e@10.1.1.30
CSeq: 103 INVITE
Content-Length: 0

Here is my fix in do_proxy_auth:

@@ -4070,13 +4071,17 @@

static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req, char *msg) {
       char digest[256];
+       int sdp = 1;
       p->authtries++;
       memset(digest,0,sizeof(digest));
       if (reply_digest(p,req, "Proxy-Authenticate", msg, digest, sizeof(digest) )) {
               /* No way to authenticate */
               return -1;
       }
-       return transmit_invite(p,"INVITE",1,digest, NULL,NULL);
+
+       if (!strcasecmp(msg, "BYE"))
+               sdp = 0;
+       return transmit_invite(p,msg,sdp,digest, NULL,NULL);
}

static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, char *orig_header, char *digest, int digest_len) {

Here is the SIP debug showing the second problem (actually already in the above trace):

BYE sip: SIP/2.0
Via: SIP/2.0/UDP 10.1.1.2.17:5060;branch=z9hG4bK12e0109e
From: "asterisk" <sip:asterisk@10.1.1.2.17>;tag=as7c144094
To: <sip:>
Contact: <sip:asterisk@10.1.1.2.17>
Call-ID: 00075052-80d650ac-0121906a-65e0ff1a@10.1.1.30
CSeq: 103 BYE
User-Agent: Asterisk PBX
Proxy-Authorization: Digest username="", realm="mydomain.net", algorithm="MD5", uri="sip:@172.16.2.15", nonce="EklfWnBvLiLvGCXUbqYl5Q==", response="3bd364823c208b29a0ca3d9c316d5583"
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Content-Length: 0

(no NAT) to 172.16.2.15:5060
Sip read:
SIP/2.0 400 Bad Request
Via: SIP/2.0/UDP 10.1.1.2.17:5060;branch=z9hG4bK12e0109e
From: "asterisk" <sip:asterisk@10.1.1.2.17>;tag=as7c144094
To: <sip:>
Call-ID: 00075052-80d650ac-0121906a-65e0ff1a@10.1.1.30
CSeq: 103 BYE
Content-Length: 0

I don't understand why From/To info. lost but callid is kept the same.

By: Mark Spencer (markster) 2003-08-21 13:23:50

I think it might be easiest if I just ssh in and take a look.  Can you find me on IRC?  (irc.freenode.net in #asterisk, kram)

By: Mark Spencer (markster) 2003-08-26 11:50:30

Did the recent changes make a difference?  I did some work over the weekend that may improve it.

By: linxu01 (linxu01) 2003-09-05 12:10:50

It's fixed. Thanks,

By: John Todd (jtodd) 2003-09-08 15:06:23

I'm going to mark as "resolved" since linxu01 says it's fixed - unless anyone objects, this bug will be closed in a few days.

By: Digium Subversion (svnbot) 2008-01-15 14:32:35.000-0600

Repository: asterisk
Revision: 1382

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r1382 | markster | 2008-01-15 14:32:34 -0600 (Tue, 15 Jan 2008) | 2 lines

First attempt at fixing bug ASTERISK-127 (authenticate BYE)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=1382