Proxy-Authenticate: Digest realm="atlanta.com",domain="sip:ss1.carrier.com", qop="auth",nonce="f84f1cec41e6cbe5aea9c8e8
8d359",opaque="", stale=FALSE, algorithm=MD5
Proxy-Authorization: Digest username="Alice",realm="atlanta.com",nonce="c60f3082ee1212b402a21831
ae",response="245f23415f11432b3434341c
022"
WWW-Authenticate: Digest realm="atlanta.com",domain="sip:boxesbybob.com", qop="auth",nonce="f84f1cec41e6cbe5aea9c8e8
8d359",opaque="", stale=FALSE, algorithm=MD5
SIP response与HTTP/1.1一致,并进行了扩展。其中部分response没有使用,扩展了6xx。
21.1 Provisional 1xx
Provisional response = informational response。如果server需要超过200ms才能产生final response,那么就先发送1xx。
在本文档中的1xx的发送,是非可靠的,client不发送ack
100 Tring
表明request已经被接收,一些特定的action正在进行。
UAC收到后,停止重传request,比如INVITE;
100和其它provisional response不同的是,it is never forwarded upstream by a stateful proxy.
180 Ring
收到request的UA,正在尝试alert the user,触发local ringback
181 Call Is Being Forward
182 Queued
Called party暂时unavailable,server决定排队该call而不是reject。当Callee变为available时,server就会返回适当的final response。
reason字段可能会给出进一步的信息,比如“5 calls queued; expected waiting time is 15 minutes”
Server可能发送多个182更新/通知该call的状态;
183 Session Progress
提供call的信息,未被明确分类到其它response里面的信息;
Reason-Phrase和message body可能会提供进一步的信息
21.2 Successful 2xx
200 OK
21.3 Redirection 3xx
3xx response提供user的最新位置信息,或者可能满足该call的alternative services
300 Multiple Choices
地址解析得到多个选项,每个都有自己特定的location,user可以选择一个preferred communication end point,重定向request到那个location。
如果request中的Accept字段允许,那么message body中可能包含一个资源特性和位置的列表,以便user可以从中选择一个最合适的。
Choices在Contact字段列出;HTTP只允许一个,但SIP允许多个。
301 Moved Permanently
User不再使用Request-URI中的地址了,UAC应该尝试Contact字段给出的新地址。
UAC应该更新本地的目录、地址簿、缓存等。
302 Moved Temporarily
UAC应该重试Contact字段给出的地址,即用作Request-URI。
其时效可以通过Expires字段或者Contact的expires参数给出。UA和proxy都可能会缓存该URI。
如果没有Expires字段或者expires参数,那么这个address只针对这次request,UA和proxy不能缓存。
如果缓存的URI失败了,那么此前的那个URI可能会被再试一次。
这个临时的URI可能提前失效,那么一个新的临时URI会可用。
305 Use Proxy
请求的resource必须通过Contact字段给出的proxy才能访问。UAC应该通过给出的proxy重复此前的请求。
305 response只能由UAS产生。
380 Alternative Service
该call失败了,但有alternative service可用。
Alternative Service在message body中定义,格式没有在该文档中定义。
21.4 Request Failure 4xx
4xx是从particular server返回的definite failure。UAC不应该不做任何修改(比如收到401后,添加适当的authorization)就再次重试。
但是,相同的请求,在不同server那里,可能会成功。
400 Bad Request
Request不能被理解,Reason-Phrase提供进一步的细节。
401 Unauthorized
这个请求需要user authentication。该response由UAS或者registrars发出。Proxy发出407(Proxy Authentication Required)。
402 Payment Required
403 Forbidden
Server理解请求,但拒绝执行。Authorization也没用,UAC不应该在重复该请求。
404 Not Found
Server确认:在Request-URI中给出的domain中不存在这个user。
如果Request-URI和收到该request的任何domain都不匹配,那么这个response也会被返回。
405 Method Not Allowed
Request-Line定义的method能够被理解,但是不允许用于Request-URI给出的address。
该Response必须包含一个Allow字段,给出允许的method
406 Not Acceptable
The resource identified by the request is only capable of generating response entities that have content characteristics not acceptable according to the Accept header field sent in the request.
407 Proxy Authentication Required
408 Request Timeout
Server无法在合适的时间内产生response,比如无法决定Callee的Location。
UAC可以稍后重试。
410 Gone
请求的资源不再可用,且forwarding address未知。这种情况是permanent的。如果server不知道或者无法判断是否permanent,那么404应该被使用。
413 Request Entity Too Large
因为请求中的entity-body(message-body ?)太大,Server不愿意呢或者不能处理。
Server可能关闭connection,阻止UAC继续。
如果是临时的,那么Server在response中携带Retry-After。
414 Request-URI Too Long
415 Unsupported Media Type
Server不支持Message body的格式。Server可能通过Accept,Accept-Encoding,Accept-Language字段返回其支持的format
416 Unsupported URI Scheme
Server不知道Request-URI的scheme
420 Bad Extension
Server不知道Proxy-Require或者Require字段定义的协议扩展。
Server必须在response的Unsupported字段中列出不支持的extensions。
421 Extension Required
Server需要特定的extenstion处理该请求,但没有列在Supported字段中。响应的Require字段必须列出需要的extension。
除非UAS确实无法提供有用的服务,否则不应该使用该response。
如果需要的extension不在Supported字段中,那么server应该使用baseline SIP capability和UAC支持的扩展处理该请求。
423 Interval Too Brief
Resource的refresh interval太短。response中的Min-Expires字段应该被使用。
480 Temporarily Unavailable
被叫的end system被联系到了,但是callee当前unavailable,比如:
- not logged in
- logged in but in a state that precludes communication with the callee
- has activated the "do not disturb" feature
Response中可能携带Retry-After,而该callee也可能在其它location available,但server不知道。
Reason-Phrase可能提供更精确的cause,其值应该是可以设置的。而486可能被用来指示更准确的失败原因。
当redirect/proxy server认识Request-URI标识的user,但不知道其forwarding location时,该response也可能被redirect/proxy server使用。
481 Call/Transaction Does Not Exist
482 Loop Detected
483 Too Many Hops
484 Address Incomplete
指Request-URI不完整。Reason-Phrase提供额外信息。
485 Ambiguous
Request-URI模糊。响应中的Contact可能会列出可能的清晰地址。但这可能会泄露用户的隐私。
因此,是使用404还是列出可能的选项,应该是在server端可配置的。
一些邮件系统提供这个功能,比如outlook。
486 Busy Here
被叫的end system能够被联系到,但callee当前不希望,或者不能在这个end system上面接受额外的call。
Retry-After有可能在响应中;被叫有可能在其它location是available的。
如果Server知道没有任何end system能够接受这个call,那么就使用600(Busy Everywhere)
487 Request Terminated
请求已经被BYE或者Cancel请求终止。这个响应不会用于Cancel。
488 Not Acceptable Here
与606同义,但只用于request-uri的特定resource。该请求在其它地方可能成功。
491 Request Pending
在同一个dialog内,UAS有一个pending request。 ch14.2描述了如何解决这个情况 ?
493 Undecipherable - 不可读的
UAS收到的请求,包含一个加密的MIME body,但UAS却没有合适的界面key。
响应中可能提供一个用于加密MIME body的public key。
21.5 Server Failure 5xx
500 Server Internal Error
Server遇到了未预期的条件使其无法继续处理请求。UAC可以显示error,并在几秒后retry
如果是临时的,那么可以使用Retry-After字段通知UAC。
501 Not Implemented
Server不支持处理请求的功能。当UAS不认识请求的method并且对任何user来说都是如此时,这个response是合适的。注意:
- Proxy转发所有请求,不管method
- 405在server认识请求的method,但该method不允许或者不支持时使用。
502 Bad Gateway
Gateway或者Proxy从其下游server收到了一个invalid response,那么就向UAC回502.
503 Service Unavailable
Server由于过载或者维护等原因,暂时无法处理请求。可以使用Retry-After通知UAC什么时候可以重试。
UAC按照500处理。
收到503的A client(proxy or UAC),应该forward请求到一个alternate server。在Retry-After指示的duration内,不应该向server发送任何其它请求。
----- 》 意思是说,503响应是针对UAC的,而不仅仅是针对这个call ?
Server也有可能拒绝连接,或者丢弃request,来代替503 response。
504 Server Time-out
Server在处理request时,可能需要访问external server,但没有得到及时响应。
如果在Expires字段定义的duration内,没有从upstream server收到响应,那么应该使用408(Request Timeout)。
505 Version Not Supported
Server不能或者不愿意呢使用请求中的SIP version处理这个请求
513 Message Too Large
21.6 Global Failures 6xx
Server有关于特定user的足够信息,比仅仅是Request-URI中给出的。此时可以使用6xx响应。
600 Busy Everywhere
被叫end system能够联系到,但是被叫忙且不愿意接听。这个response有可能提供一个Retry-After。如果callee不想泄露reject reason,那么可以使用603(Decline)。
这个response只用于server知道没有其它的end point(比如语音信箱)会answer the request。否则应该使用486(Busy Here)
603 Decline
Callee's machine被联系到了,但user不想或者不能接听。Retry-After。
使用该response,表明server知道没有任何其它end point会answer the request。
604 Does Not Exist Anywhere
Server有足够信息作出判断,Request-URI指出的user在任何地方都不存在。
606 Not Acceptable
成功联系到了user's agent,但SDP的某些方面,比如request media,bandwidth,addressing style不能被接受。
该response表明,user希望接听call,但不足以支持session discribed。
response可能会在Warning header字段列出一系列原因。
使用该响应时,server知道没有其它的end point会处理该请求
UAS使用401(Unauthorized),而Proxy使用407(Proxy Authentication Required)。
22.1 Framework
由于SIP没有canonical root URL,因此protection spaces在SIP中有不同的解释。
realm用于定义protection domain,而RFC2543中则使用Request-URI和realm定义protection domain。
- realm必须全球唯一,推荐包含hostname或者domain name
- realm应该是能够显示给user的字符串
通常,SIP authentication只对特定的realm有意义,因此对于Digest authentication来说,每一个这样的protection domain都有自己的usernames/passwords集合。
如果Server不要求对特定的request鉴权,那么它可能使用默认的username “anonymous”,其没有密码(“”)。
类似的,代表许多user的UACs,比如PSTN gateways,可能有自己的username/password,而不是代表特定user。
有两个请求的authentication需要特殊处理:Ack,Cancel。
Authentication Scheme包括:basic,digest,他们都依赖于response携带参数。
因此,对于没有response的request的鉴权成了问题,包括Ack -》 如果Server接受了INVITE中的credentials,那么Server也要接受对应Ack中的相同的credentials。UAC在构造Ack时,会原封不动拷贝INVITE消息中的Authorization和Proxy-Authorization header,而Server不能challenge the Ack
虽然Cancel有response,但Cancel request不能被重发,因此Server也不能challenge the Cancel request。
通常来讲,Server应该接受来自其所cancel,如果该cancel来自与其所cancel请求相同的hop。
如果已有的credentials不再有效,Server可能会重复其challenge,或者响应403(Forbidden)。而UAC不能使用刚刚被reject的credentials。
22.2 User-to-User Authentication
UAS从UAC收到request后,可能会在处理前对originator进行鉴权。如果请求中没有包含Authorization header,UAS可以通过401(Unauthorized)拒绝该请求。
WWW-Authenticate必须包含在401里面,该challenge至少指出:
- Authentication scheme
- parameters applicable to the realm
例子:
WWW-Authenticate: Digest
realm="biloxi.com",
qop="auth,auth-int",
nonce="dcd98b7102dd2f0e8b11d0f6
00bfb0c093",
opaque="5ccc069c403ebaf9f0171e95
17f40e41"
UAC收到401后,如果可能的话,应该重新发起该request,包含正确的credentials。UAC可能会请求user的输入。
该credentials应该被cache起来,针对realm和To header的组合,以备后面的请求使用。
UAS则可以使用任意方式cache credentials。
如果UAC找不到任何credentials,它可能会使用username(anonymous)和password("")重试。
例子:
Authorization: Digest username="bob",
realm="biloxi.com",
nonce="dcd98b7102dd2f0e8b11d0f6
00bfb0c093",
uri="sip:bob@biloxi.com",
qop=auth,
nc=00000001,
cnonce="0a4f113b",
response="6629fae49393a05397450978
507c4ef1",
opaque="5ccc069c403ebaf9f0171e95
17f40e41"
当UAC收到401/407后重新发送reuquest时,应该增加CSeq header value,以表明是新的request。
22.3 Proxy-to-User Authentication
在forking的情况下,可能有多个proxy对UAC进行challenge,这时,执行forking的proxy负责把多个challenge组合到一个response中。而UAC在重新发送request时,会针对每个challenge提供Authorization。
当然,这些credentials中的realm参数不一样。但challege中的realm参数却可能一样。
22.4 The Digest Authentication Scheme
SIP不使用 Basic Authentication Scheme
RFC2617要求server检查Request-URI和Authorization中的参数uri,要求二者一致。但SIP中,二者有可能不一致。
如果challenge中携带qop参数,则credentials中必须携带。
credentials中携带cnonce的时候,必须携带qop参数。
23 S/MIME
----------------------------------------------------
SIP message可以携带MIME bodies,MIME标准包含了对MIME contents进行加密和完整性保护的机制。
但这会阻止某些server发生作用,比如firewall。
23.1 S/MIME Certificates
发送者使用接收者的public key进行加密,接收者使用自己的private key进行解密。
23.2 S/MIME Key Exchange
SIP本身可以用来分发public keys。当CMS SignedData message用于S/MIME,它必须包含certificate,包含验证该签名必需的public key。
23.3 Securing MIME bodies
The following is an example of an encrypted S/MIME SDP body
within a SIP message:
INVITE sip:bob@biloxi.com SIP/2.0
Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8
To: Bob
From: Alice ;tag=1928301774
Call-ID: a84b4c76e66710
CSeq: 314159 INVITE
Max-Forwards: 70
Contact:
Content-Type: application/pkcs7-mime; smime-type=enveloped-data;
name=smime.p7m
Content-Disposition: attachment; filename=smime.p7m
handling=required
*******************************************************
* Content-Type: application/sdp
*
*
*
* v=0
*
* o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com *
* s=-
*
* t=0 0
*
* c=IN IP4 pc33.atlanta.com
*
* m=audio 3456 RTP/AVP 0 1 3 99
*
* a=rtpmap:0 PCMU/8000
*
*******************************************************
23.4 SIP Header Privacy and Integrity using S/MIME: Tunneling SIP
作为提供一定程度端到端鉴权、完整性保护、加密的手段之一,S/MIME可以封装整个SIP消息到MIME bodies中,"message/sip"。
如果UAS收到的request中包含tunneled "message/sip" S/MIME body,那么在response中也应该如此。
23.4.1 Integrity and Confidentiality Properties of SIP Headers
24 Flow
----------------------------------------------------
24.1 Registration
例子如下,request-uri指明registar,From和To相同,但To字段的tag没有。
Via指出response的接收处,Expires指明2小时后过期。
--------------------------------------------------------
REGISTER sip:registrar.biloxi.com SIP/2.0
Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7
Max-Forwards: 70
To: Bob
From: Bob ;tag=456248
Call-ID: 843817637684230@998sdasdh09
CSeq: 1826 REGISTER
Contact:
Expires: 7200
Content-Length: 0
response如下。Via的received参数指明在哪个IP上面收到的response。
To字段添加了tag
--------------------------------------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP bobspc.biloxi.com:5060;branch=z9hG4bKnashds7
;received=192.0.2.4
To: Bob ;tag=2493k59kd
From: Bob ;tag=456248
Call-ID: 843817637684230@998sdasdh09
CSeq: 1826 REGISTER
Contact:
Expires: 7200
Content-Length: 0
24.2 Session Setup