2020年12月19日 星期六

SIP NOTIFY

SIP Method NOTIFY 讓遠端有事件時提供 notification 。

RFC6665 向前相容並 obsolete RFC3265,並稍微更新 RFC4660

能夠 request asynchronous notification of events 提供用處 in many types of SIP services for which cooperation between end-nodes is required. Note, however, that event packages based on this framework may define arbitrarily elaborate rules that govern the subscription and notification for the events or classes of events they describe. "event packages" in Section 5.

應用

  • automatic callback services (based on terminal state events)
  • buddy lists (based on user presence events)
  • 留言通知 (MWI,message waiting indications)
  • PSTN and Internet Internetworking (PINT) [RFC2848] status (based on call state events).
  • 搭配 REFER
  • 告知特業設定,例如註冊後告知是否有設勿干擾或轉接

典型流程是先透過 SIP SUBSCRIBE 訂閱 Event 後建立 dialog,Event 包括 resource or call state for various resources or calls。之後收到 SIP NOTIFY 並更新 dialog 狀態。

   Subscriber          Notifier
       |-----SUBSCRIBE---->|     Request state subscription
       |<-------200--------|     Acknowledge subscription
       |<------NOTIFY----- |     Return current state information
       |--------200------->|
       |<------NOTIFY----- |     Return current state information
       |--------200------->|

訂閱有逾時,由後續 SUBSCRIBE 請求續訂。

...

3.1.2. Identification of Subscribed Events and Event Classes

Event 由 Request URI、Event Type、和 (optionally) 信體識別。The Request URI of a SUBSCRIBE request contains enough information to route the request to the appropriate entity per the request routing procedures outlined in [RFC3261]. It also contains enough information to identify the resource for which event notification is desired, but not necessarily enough information to uniquely identify the nature of the event (e.g., "sip:adam@example.com" would be an appropriate URI to subscribe to for my presence state; it would also be an appropriate URI to subscribe to the state of my voice mailbox).

SUBSCRIBE 必須含有單一 Event,表示要訂閱哪個 event 或 class of events。The "Event" header field will contain a token that indicates the type of state for which a subscription is being requested. This token will be registered with the IANA and will correspond to an event package that further describes the semantics of the event or event class. If the event package to which the event token corresponds defines behavior associated with the body of its SUBSCRIBE requests, those semantics apply. Event packages may also define parameters for the "Event" header field; if they do so, they must define the semantics for such parameters.

3.1.3. Additional SUBSCRIBE Header Field Values

Because SUBSCRIBE 建立 dialog,可包含 Accept 表示後續 NOTIFY 允許的信體格式。Event packages MUST define the behavior for SUBSCRIBE requests without "Accept" header fields; usually, this will connote a single, default body type.

3.2. NOTIFY

NOTIFY 通知 subscribers 有訂閱的狀態改變。訂閱透過 SUBSCRIBE 建立,過去也透過 REFER [RFC3515] 或其它方式建立。NOTIFY 是 target refresh request。

3.2.1. Identification of Reported Events, Event Classes, and Current State

Identification of events being reported in a notification is very similar to that described for subscription to events (see Section 3.1.2). NOTIFY request "Event" MUST 包含單一 event package name for which a notification is being generated. The package name in the "Event" header field MUST match the "Event" header field in the corresponding SUBSCRIBE request. Event packages may define semantics associated with the body of their NOTIFY requests; if they do so, those semantics apply. NOTIFY request bodies are expected to provide additional details about the nature of the event that has occurred and the resultant resource state. When present, the body of the NOTIFY request MUST be formatted into one of the body formats specified in the "Accept" header field of the corresponding SUBSCRIBE request (or the default type according to the event package description, if no "Accept" header field was specified). This body will contain either the state of the subscribed resource or a pointer to such state in the form of a URI (see Section 5.4.13).

4. Node Behavior

...

8.4. Augmented BNF Definitions

   SUBSCRIBEm        = %x53.55.42.53.43.52.49.42.45 ; SUBSCRIBE in caps
   NOTIFYm           = %x4E.4F.54.49.46.59 ; NOTIFY in caps
   extension-method  = SUBSCRIBEm / NOTIFYm / token

   Event             =  ( "Event" / "o" ) HCOLON event-type
                        *( SEMI event-param )
   event-type        =  event-package *( "." event-template )
   event-package     =  token-nodot
   event-template    =  token-nodot
   token-nodot       =  1*( alphanum / "-"  / "!" / "%" / "*"
                            / "_" / "+" / "`" / "'" / "~" )

   ; The use of the "id" parameter is deprecated; it is included
   ; for backwards-compatibility purposes only.

   event-param       =  generic-param / ( "id" EQUAL token )

   Allow-Events      =  ( "Allow-Events" / "u" ) HCOLON event-type
                        *(COMMA event-type)

   Subscription-State   = "Subscription-State" HCOLON substate-value
                          *( SEMI subexp-params )
   substate-value       = "active" / "pending" / "terminated"
                          / extension-substate
   extension-substate   = token
   subexp-params        =   ("reason" EQUAL event-reason-value)
                          / ("expires" EQUAL delta-seconds)
                          / ("retry-after" EQUAL delta-seconds)
                          / generic-param
   event-reason-value   =   "deactivated"
                          / "probation"
                          / "rejected"
                          / "timeout"
                          / "giveup"
                          / "noresource"
                          / "invariant"
                          / event-reason-extension
   event-reason-extension = token

參考

沒有留言:

張貼留言

SIP header Via

所有 SIP 訊息 都要有 Via,縮寫 v。一開始的 UAC 和後續途經的每個 proxy 都會疊加一個 Via 放傳送的位址,依序作為回應的路徑。 格式 sent-protocol sent-by [ ;branch= branch ][ ; 參數 ...] s...