以ABNF描述的SIP语法如下:
SIP-URL = "sip:" [userinfo hostport url-parameters [headers];有两种类型,Address of Record (AOR)用来标识用户,需要 DNS SRV 支持,另外一种 Fully Qualified Domain Name (FQDN),用来标识特定设备。
userinfo = [user I telephone-subscriber]password]; 用户信息
user = *( unreserved I escaped「&” I IH+"「$” IM," I ”;” I n?n I *7n )
telephone-subscriber = v定义在[RFC2806]>
password = *( unreserved I escaped I "&" I "=" II "$" I );密码
hostport = host「:n port];端口号
host = hostname I IPv4address I IPv6reference ;主机名 或地址
hostname = *( domainlabel n.n) toplabel [v."];主机名
domainlabel = alphanum I alphanum *( alphanum I) alphanum
toplabel = alpha I alpha *( alphanum In-") alphanum
IPv4address = 1*3DIGIT H.H 1*3DIGIT P3DIGIT T 1*3DIGIT ;地址
IPv6reference = ”「IPv6address ”]”
IPv6address = hexpart IPv4address]
hexpart = hexseq I hexseq [hexseq] I"::" [hexseq]
hexseq = hex4 *(hex4 )
hex4 = l*4HEX
port=l*DIGIT ;端口
url-parameters = *( ”;” url-parameter)
url-parameter = transport-param I user-param I method-param I ttbparam I maddr-param I other-param
transport-param = "transport=" ("udpH I "tcp" I "sctp" I "tls" I other-transport);传输参数 other-transport = token ttl-param = ttl ;最大生存时间参数
ttl = 1*3DIGIT ;0to 255
maddr-param = "maddr=" host
user-param = "user=" ("phone" I "ip" I other-user)
other^user = token
method-param = "method=n Method
tag-param = "tag=M UUID
UUID = l*(HEXr,-n)
other-param = pname ["=" pvalue]
pname = l*paramchar
pvalue = l*paramchar
paramchar = param-reserved I unreserved I escaped
param-reserved = T I"]" I 7" I I H&n I '*+" I
headers = "?" header *( ” & "header)
header = hname "=" hvalue
hname = 1*( hnv-unreserved I unreserved I escaped)
hvalue = *( hnv-unreserved I unreserved I escaped) hnv-unreserved = T II Vn 丨 ”?” I1"@" I ,'+u I H$n.
absoluteURI = v定义在[RFC2068]>
SlP-message = Request I Response ;消息
generic-message = start-line *message-header CRLF [message-body] start-line = Request-Line I Status-Line
message-header = ( general-header I request-header I response-header I entity-header); 消息头 message-body = <定义在[RFC2068]> ;消息体
Request = Request-Line*( general-header I request-header I entity-header ) CRLF [message-body];请求
Request-Line = Method SP Request-URI SP SIP-version CRLF ;请求行
Request-URI = SIP-URL I absoluteURI
general-header = Accept I Accept-Encoding I Accept-Languagel Call-IDI Contactl CSeql Date
I Encryption! Froml Organization! Record-Routel Requirel Supportedl Timestampl To I User-AgentI Via
entity-header = Allowl Content-Disposition! Content-Encodingl Content-Languagel Content-Lengthi Content-iypel Expires
request-header = Authorization! Hidel In-Reply-Ibl Max-Forwardsl Priorityl Proxy-AuthorizationI Proxy-Requirel Routel Response-Keyl Subject
response-header = Proxy-Authenticatel Retry-Afterl Server I Unsupported I Warningl WWW-Authenticate
Method="D4VTTEn I "ACK" I "OPTIONS" I "BYE" I “CANCEL” I "REGISTER" I extension-method extension-method = token option-tag = token
Response = Status-Line*( general-header I response-header I entity-header) CRLF [message-body]
Status-Line = SIP-version SP Status-Code SP Reason-Phrase CRLF
SIP-version = "SIP/2.1";版本
Status-Code = Informational I Successl Redirection! Client-Errorl Server-Errorl Global-Failure
I extension-code
extension-code = 3DIGIT
Reason-Phrase = *<TEXT-UTF8, excluding CR, LF>
Informational = " 100" ;Trying
丨 ”180” ;Ringing
1n181n ;Call Is Being Forwarded
1 ”182” ;Queued
1“183” ;Session Progress
Success = "200" ; OK ;表示成功
Redirection 二 H300n ;Multiple Choices ;重定向
1”301” ;Moved Permanently
1"302" ;Moved Temporarily
「305“ ;Use Proxy
「380” ;Alternative Service
Client-Error 二 ”400" ;Bad Request
1”401” ;Unauthorized
1”402” ;Payment Required
1"403" ;Forbidden
1”404” ;Not Found
「405” ;Method Not Allowed
1"406" ;Not Acceptable
丨 ”407” ;Proxy Authentication Required
1"408" ;Request Timeout
1”409“ ;Conflict
1M410u ;Gone
1”411” ;Length Required
1“413” ;Request Entity Too Large
1"414" ;Request-URI Too Large
丨 ”415” ;Unsupported Media Type
1“420” ;Bad Extension
「480“ ;Temporarily not available
「481” ;Call Leg/Transaction Does Not Exist
1"482" ;Loop Detected
丨 ”483” ;Too Many Hops
1"484" ;Address Incomplete
1"485" ;Ambiguous
1”486” ;Busy Here
I”487” ;Request Cancelled
「488” ;Not Acceptable Here
Server-Error = "500" ;Internal Server Error
1n501" ;Not Implemented
1"502" ;Bad Gateway
「503“ ;Service Unavailable
1“504” ;Gateway Time-out
1"505n ;SIP Version not supported
Global-Failure = ”600” ;Busy Everywhere
1”603” ;Decline
1"604" ;Does not exist anywhere
1 ;Not Acceptable
message-header = field-name [field-value] CRLF
field-name = token
field-value = *( field-content ILWS )
field-content = < the OCTETS making up the field-value and consisting of either *TEXT-UTF8 or combinations of token, separators, and quoted-string>
Accept = v 定义在[RFC2068]>
Accept-Encoding = v定义在[RFC2068]>
Accept-Language = v定义在[RFC2068]>
Alert-Info = "Alert-Info" ”:” #( ”<” URI n>H *( H;H generic-param))
Allow = "Allow'1 ":H l#Method
callid = token「token]
Call-ID = ("Call-ID" I "i") ',:'1 calHd
Call-Info = "Call-Info1' #( n<H URI H>n"purpose" (niconn I ninfoH I "card" I token )] generic-param))
Contact = ( Tontact" I ''m")匕” (I ( 1#( ( name-addr I addr-spec ) *( n;n contact-params))))
name-addr = [display-name] "<" addr-spec ">M
addr-spec = SIP-URL I URI
display-name = *token I quoted-string ; 显示名称
contact-params = ”q" "=" qvalue I "action'1 "=" "proxy" I r'redirectM I "expires" delta-seconds I DQUOTE SIP-date DQUOTE I contact-extension
qvalue = <定义在[RFC2068J>
contact-extension = generic-param
Content-Disposition = "Content-Disposition"disposition-type *(disposition-parm) disposition-type = "render" I "session" I extension-token
disposition-parm = handling-parm I parameter
parameter = <定义在[RFC2068]>
handling-parm = "handling" "=" ( "optional" I "required" I other-handling )
other-handling = token
Content-Encoding = (''Content-Encoding" I "e")":";内容编码
Content-Language = <定义在[RFC2068]> ;语言
Content-Length = (''Content-Length'11 1*DIGIT ;长度
Content-Type = ("Content-Type1' I "cn)H:'' media-type :类型 media-type = <定义在[RFC206®>
CSeq = nCSeq" ”:” 1*DIGIT Method
;日期
SIP-date = rfcll23-date
rfcll23-date = <定义在[RFC2068]>
Encryption = "Encryption" ”:” encryption-scheme 1*SP #encryption-params encryption-scheme = token ;加密模式
encryption-params = generic-param
generic-param = token ["=" (token I quoted-string )]
Expires = "Expires"( SIP-date I delta-seconds )
From = ("From" I "f')(name-addr I addr-spec) tag-param] *( ”;” addr-extension) tag-param = ntag=" token addr-extension = generic-param
Hide = “Hide”":" ('Youte" I "hop" I other-hide)
other-hide = token
In-Reply-To = nIn-Reply-To" ”:” l#callid
Max-Forwards - "Max-Forwards"1*DIGIT
Organization = "Organization" ”:" TEXT-UTF8-TRIM
Priority 二"Priority"priority-value
priority-value = Emergency" I "urgent1* I "normaF* I "non-urgent'* I other-priority other-priority = token
Proxy-Authenticate = v定义在[RFC2068]>
Proxy-Authorization = v定义在[RFC2068]>
Record-Route = "Record-Route"l#name-addr [rr-extension]
rr-extension = token ["=" (token I quoted-string )]
Require = ''Require"]#op曲mtag
■冲『RespO那e-Key=?Response-Key” ":H key-scheme l*SP#key-param
key-scheme = token
key-param = generic-param
Retry-After = "Retry-After" ( SIP-date I delta-seconds ) [comment] "duration" "=n delta-SGoonds]; i: ; ;
Route = "Route"l#name-addr [route-extension]
route-extension = generic-param
Server = v定义在[RFC2068]>
Subject = ("Subjects "s") n:H TEXT-UTF8-TRIM
Supported = ("Supported" I nk")":" l#option-tag
Timestamp = ”Timestamp” DIGIT )*( DIGIT )] [delay];时间戳
delay = *( DIGIT)*( DIGIT)];延迟
To = (nTo" I nt") ":n (name-addr I addr-spec) tag-param] *(addr-extension) Unsupported = "Unsupported"l#option-tag ;不支持
User-Agent = v定义在[RFC2068]>
Via = ( "Via" I "v")1#( sent-protocol sent-by *( via-params ) [comment]) via-params = via-hidden I via-ttl I via-maddr I via-received I via-branch I via-extension via-hidden = "hidden" via-ttl = ''ttl" H=" ttl
via-maddr = "nj3ddr''? "=" maddr :
via-received = "received" host port]
via-branch = "branch" "=" token
via-extension = token ["=" ( token I quoted-string )]
sent-protocol = protocol-name '7n protocol-version transport prpt^colrnanie ?= "SIP" I token ;协议名称 protocol-version = token ;协议版本 transport = "UDP" I "TCP" I token ;传送 sent-by = (host「port]) I ( concealed-host) concealed-host = token
也=1*3DIGIT ;最大生存时间,为0到255
Warning = "Warning"l#waming-value
warning-value = wam-code SP wam-agent SP wam-text
wam-code = 3DIGIT
wam-agent = (host [":" port] ) I pseudonym
adding pseudonym = v定义在[RFC2068]> wam-text = quoted-string
URI = SIP-URL ; URL 地址
digest-uri-value = Request-URI
WWW-Authenticate = "WWW-Authenticate" "pgp" pgp-challenge pgp-challenge = #pgp-params
pgp-params = realm I pgp-version I pgp-micalgorithm I pgp-pubalgorithm I nonce realm - "realm" "=" realm-value
realm-value = quoted-string
pgp-version = "version" "=" DQUOTE DIGIT *(…DIGIT ) ^letter DQUOTE pgp-micalgorithm = "algorithm" "=" ( "md5n I "shal" I token I "ripemdl60" I nMD2n I ”TIGER192" I nHAVAL-5-160n)
pgp-pubalgorithm = "pubkey" "=" ("rsa" I "rsa-encrypt" I "rsa-sign" I "elgamal" I Kdsa" I token)
nonce = "nonce" nonce-value
nonce-value = quoted-string
Authorization = nAuthorization" ”:” "pgp" #pgp-response pgp-response = realm I pgp-version I pgp-signature I signed-by I nonce pgp-signature = "signature" "=" quoted-string signed-by = "signed-by'' ”才 DQUOTE URI DQUOTE Encryption = "Encryption" ”:” "pgp" pgp-eparams pgp-eparams = 1#( pgp-version I pgp-encoding ) pgp-encoding = "encoding" n=" "ascii" I token
Response-Key = "Response-Key" "pgp" pgp-eparams pgp-eparams = 1#( pgp-version I pgp-encoding I pgp-key ) pgp-key = "key" n=H quoted-string
double-return = ( CR CR) I (LF LF ) I ( CR LF CR LF ) OCTET = %xOO-FF ; any 8-bit sequence of data CHAR = %x00-7F ; any US-ASCII character (octets 0 - 127) upalpha = nAn I "B" I "C" I "D" I "E" I HF" I nG" I "H" I HIn I nJn I "K" I "Ln I "M" I "N" I "O" I "P"
I ”Q” | ”R” | | ”T" | "U" | ”V" | ”W" | "X” |nY'1 | ”Z”
lowalpha = "a" I "b" I "c" I "d" I "e" I "f' I "g" I "h" I "i" I "j" I "k" I "1" I "m" I "n" I "o" "s" I "t" I "u" I "v" I "w" I "x" I "y" I "z"
alpha = lowalpha I upalpha
DIGIT = "0" I "1" I "2" I "3" I "4" I "5" I "6" I "7" I "8" I "9"
alphanum = alpha I DIGIT
CTL = %x00-lF I %x7F ; (octets 0 - 31) and DEL (127)
CR = %dl3 ;回车
LF = %dl0 ;换行
SP = %d32 ;空白键
HT = %dG9 ;水平键
CRLF = CRLF ;回车加换行
unreserved = alphanum I mark
mark = I I I "!" I I I | "(" I ")" escaped = "%" HEX HEX
LWS = [CRLF] 1*( SPIHT)
TEXT-UTF8 = *( TEXT^UTF8char I LWS )
TEXT-UTF8-TRIM = *TEXT-UTF8char *( *LWS TEXT-UTF8char)
TEXT-UTF8char = %x21-7E I UTF&NONASCU
UTF8-NONASCII = %xC0-DF 1UTF8-CONT I %xE0-EF 2UTF8-CONT I %xF0-F7 3UTF8-CONT I %xF8-FB 4UTF8-CONTI %xFC-FD 5UTF8-CONT
UTF8-CONT = %x80-BF
HEX = HAn I !,BM I nCH I "D" I "E" I "F'11 "a" I "b" I "cH I ”d” I I "f' I DIGIT
token = 1*( alphanum IIH." IH!" I u%u I II ”+” I I )
separators = "C" I")" I I I 罗 I II H\" I DQUOTEI 7" I n[n I ,,]H IUT I n=n I
I”}” I SPIHT
comment = ”(” *( ctext I quoted-pair I comment) ”)“
ctext = <any TEXT-UTF8 excluding f and ”)”> quoted-string = (DQUOTE *( qdtext I quoted-pair) DQUOTE ) qdtext = LWS I %x211 %x23-5B I %x5D-7E I UTF8-NONASCII quoted-pair = " \" CHAR
DQUOTE = v 定义在[RFC2234]> delta-seconds = v定义在[RFC2068]〉