transaction: ACK the 401 Unauthorized message before we change
So this code acks the 401 Unauthorized message. It is possible that this message is lost on the way we will not be able to respond to the 401 again. The right thing would be to "fork" off the transaction to deal with re-transmissions.
This commit is contained in:
parent
df79f4c469
commit
1e43d02ed3
29
TODO
29
TODO
|
@ -83,3 +83,32 @@ CSeq: 1084794278 ACK
|
|||
Max-Forwards: 70
|
||||
Contact: <sip:abc@24.134.59.157:3107;transport=udp;line=i4p4q6>;reg-id=1;+sip.instance="<urn:uuid:572d1aa1-bfd5-4b8a-ab1e-f9095df386e5>"
|
||||
Content-Length: 0
|
||||
|
||||
|
||||
|
||||
Reply with ACK to 401 authorized..
|
||||
|
||||
SIP/2.0 401 Unauthorized
|
||||
Via: SIP/2.0/UDP 192.168.0.106:5060;branch=z9hG4bK4000ebad-1c1f-e411-87f8-844bf52a8297;rport=1029;received=91.66.224.184
|
||||
From: <sip:5100310@8.8.8.8>;tag=e698dead-1c1f-e411-87f8-844bf52a8297
|
||||
To: <sip:00123@8.8.8.8>
|
||||
Call-ID: 4eaedead-1c1f-e411-87f8-844bf52a8297@xiaoyu
|
||||
CSeq: 1 INVITE
|
||||
WWW-Authenticate: Digest realm="Yate", nonce="cc615df915f40a7d8ae80ef28c8efba4.1407689697", stale=FALSE, algorithm=MD5
|
||||
Server: YATE/5.4.0
|
||||
Contact: <sip:00123@8.8.8.8:5060>
|
||||
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
|
||||
Content-Length: 0
|
||||
|
||||
|
||||
|
||||
ACK sip:00123@8.8.8.8 SIP/2.0
|
||||
CSeq: 1 ACK
|
||||
Via: SIP/2.0/UDP 192.168.0.106:5060;branch=z9hG4bK4000ebad-1c1f-e411-87f8-844bf52a8297;rport
|
||||
From: <sip:5100310@8.8.8.8>;tag=e698dead-1c1f-e411-87f8-844bf52a8297
|
||||
Call-ID: 4eaedead-1c1f-e411-87f8-844bf52a8297@xiaoyu
|
||||
To: <sip:00123@8.8.8.8>
|
||||
Content-Length: 0
|
||||
Max-Forwards: 70
|
||||
|
||||
|
||||
|
|
|
@ -194,8 +194,12 @@ TestCase subclass: SIPCallAgentTest [
|
|||
transport inject: (self authorizationRequired: branch callId: callId tag: fromTag tag).
|
||||
|
||||
"Verify that a second message has been sent and it contains an auth result"
|
||||
self assert: sent size equals: 2.
|
||||
self assert: sent size equals: 3.
|
||||
msg := SIPParser parse: sent second data.
|
||||
self assert: msg class verb equals: 'ACK'.
|
||||
|
||||
msg := SIPParser parse: sent third data.
|
||||
self assert: msg class verb equals: 'INVITE'.
|
||||
secondBranch := (msg parameter: 'Via' ifAbsent: [nil]) branch.
|
||||
self deny: branch = secondBranch.
|
||||
self assert: (msg parameter: 'CSeq' ifAbsent: [-1]) number equals: 2.
|
||||
|
@ -233,8 +237,12 @@ TestCase subclass: SIPCallAgentTest [
|
|||
transport inject: (self authorizationRequired: branch callId: callId tag: fromTag tag).
|
||||
|
||||
"Verify that a second message has been sent and it contains an auth result"
|
||||
self assert: sent size equals: 2.
|
||||
self assert: sent size equals: 3.
|
||||
msg := SIPParser parse: sent second data.
|
||||
self assert: msg class verb equals: 'ACK'.
|
||||
|
||||
msg := SIPParser parse: sent third data.
|
||||
self assert: msg class verb equals: 'INVITE'.
|
||||
branch := (msg parameter: 'Via' ifAbsent: [nil]) branch.
|
||||
self assert: (msg parameter: 'CSeq' ifAbsent: [-1]) number equals: 2.
|
||||
self assert: call state equals: SIPCall stateInvite.
|
||||
|
@ -272,8 +280,12 @@ TestCase subclass: SIPCallAgentTest [
|
|||
transport inject: (self proxyAuthRequired: branch callId: callId tag: fromTag tag cseq: 1).
|
||||
|
||||
"Verify that a second message has been sent and it contains an auth result"
|
||||
self assert: sent size equals: 2.
|
||||
self assert: sent size equals: 3.
|
||||
msg := SIPParser parse: sent second data.
|
||||
self assert: msg class verb equals: 'ACK'.
|
||||
|
||||
msg := SIPParser parse: sent third data.
|
||||
self assert: msg class verb equals: 'INVITE'.
|
||||
secondBranch := (msg parameter: 'Via' ifAbsent: [nil]) branch.
|
||||
self deny: branch = secondBranch.
|
||||
self assert: (msg parameter: 'CSeq' ifAbsent: [-1]) number equals: 2.
|
||||
|
@ -296,8 +308,8 @@ TestCase subclass: SIPCallAgentTest [
|
|||
|
||||
"Inject a 200 and check the ACK"
|
||||
transport inject: (self ok: secondBranch callId: callId tag: fromTag tag cseq: 2).
|
||||
self assert: sent size equals: 3.
|
||||
msg := SIPParser parse: sent third data.
|
||||
self assert: sent size equals: 4.
|
||||
msg := SIPParser parse: (sent at: 4) data.
|
||||
self assert: (msg parameter: 'CSeq' ifAbsent: [-1]) number equals: 2.
|
||||
self assert: call state equals: SIPCall stateSession.
|
||||
auth := msg parameter: 'Proxy-Authorization' ifAbsent: [nil].
|
||||
|
|
|
@ -82,8 +82,12 @@ TestCase subclass: SIPRegisterTransactionTest [
|
|||
callId := (msg parameter: 'Call-ID' ifAbsent: [-1]).
|
||||
fromTag := (msg parameter: 'From' ifAbsent: [nil]).
|
||||
transport inject: (self createSimple401: branch callId: callId tag: fromTag tag cseq: 1).
|
||||
self assert: sent size equals: 2.
|
||||
self assert: sent size equals: 3.
|
||||
msg := SIPParser parse: sent second data.
|
||||
self assert: msg class verb equals: 'ACK'.
|
||||
|
||||
msg := SIPParser parse: sent third data.
|
||||
self assert: msg class verb equals: 'REGISTER'.
|
||||
self assert: (msg parameter: 'CSeq' ifAbsent: [-1]) number equals: 2.
|
||||
branch := (msg parameter: 'Via' ifAbsent: [nil]) branch.
|
||||
transport inject: (self createSimple200: branch callId: callId tag: fromTag tag cseq: 2).
|
||||
|
|
|
@ -179,6 +179,10 @@ Object subclass: SIPTransaction [
|
|||
((auth at: 'algorithm' ifAbsent: ['MD5']) = 'MD5')
|
||||
ifFalse: [^self wrongAuth: aResp dialog: aDialog].
|
||||
|
||||
"Respond with an ACK"
|
||||
self queueData: (self createAck: branch dialog: aDialog) asDatagram
|
||||
dialog: aDialog.
|
||||
|
||||
authorization := SIPAuthorization new
|
||||
username: initial_dialog identity username;
|
||||
realm: (auth at: 'realm');
|
||||
|
@ -220,6 +224,10 @@ Object subclass: SIPTransaction [
|
|||
((auth at: 'qop' ifAbsent: ['auth']) = 'auth')
|
||||
ifFalse: [^self wrongAuth: aResp dialog: aDialog].
|
||||
|
||||
"Respond with an ACK"
|
||||
self queueData: (self createAck: branch dialog: aDialog) asDatagram
|
||||
dialog: aDialog.
|
||||
|
||||
proxy_authorization := SIPProxyAuthorization new
|
||||
username: initial_dialog identity proxyUsername;
|
||||
realm: (auth at: 'realm');
|
||||
|
|
Reference in New Issue