Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
understanding-SIP.pdf
Скачиваний:
113
Добавлен:
01.03.2016
Размер:
3.99 Mб
Скачать

 

 

 

Appendix

377

 

 

 

Table A.2

 

 

 

 

ABNF Order of Precedence

 

 

 

 

Strings, names formation

 

 

 

 

 

Comment

 

 

 

 

 

Value range

 

 

 

 

 

Repetition

 

 

 

 

 

Grouping, optional

 

 

 

 

 

Concatenation

 

 

 

 

 

Alternative

 

 

 

 

 

Table A.3

 

 

 

 

ABNF Example for Host

 

 

host

= hostname / IPv4address / IPv6ref

 

 

hostname

= *( domainlabel “.” ) toplabel [ “.”

 

 

domainlabel

= alphanum/alphanum *( alphanum / “-” ) alphanum

 

 

toplabel

= ALPHA / ALPHA *( alphanum / “-” ) alphanum

 

 

IPv4address

= 1*3DIGIT “.” 1*3DIGIT “.” 1*3DIGIT “.” 1*3DIGIT

 

 

IPv6ref

= “[” IPv6address “]”

 

 

IPv6address

= hexpart [ “:”IPv4address]

 

 

hexpart

= hexseq / hexseq “::”[ hexseq ] / “::”[ hexseq ]

 

 

hexseq

= hex4 *( „:“ hex4)

 

 

hex4

= 1*4HEXDIG

 

 

alphanum

= ALPHA / DIGIT

 

 

ALPHA

= %x41-5A / %x61-7A ; A-Z / a-z

 

 

DIGIT

= %x30-39 ; 0-9

 

 

HEXDIG

= DIGIT / “A” / “B” / “C” / “D” / “E” / “F”

 

 

 

 

 

 

 

This rule allows a host to be either a domain name or an IPv4 address or IPv6 address. For example, ese.wustl.edu matches this rule but ese..edu does not. Example.com3 matches this rule but example.3com does not (this is due to a rule in DNS that top level domain names may not begin with a digit and enforced by the rule toplabel). For IPv4 addresses, any four sets of three digits separated by a “.” will match the rule IPv4address.

A.2 Introduction to XML

XML [2] is a simplification of the Standardized Generalized Markup Language (SGML). It is very similar to the Hypertext Markup Language (HTML) used to represent documents on the World Wide Web (WWW). While SIP does not use XML encoding, many bodies used with SIP do. XML is standardized by the World Wide Web Consortium (W3C). Elements in XML are known as tags or

378

SIP: Understanding the Session Initiation Protocol

elements and are enclosed in <>. Here is an example tag, which contains a single value:

<tag>value</tag>

For every element opened in XML (<tag> in the above example), the tag must be closed (</tag>). An XML document is said to be well-formed if every opened tag is also closed. The value, which is enclosed by the open and closed tags, is the value associated with that element. In addition to values, elements can also have attributes inside the <>. For example:

<tag attribute=”another value”>value</tag>

is the same as the previous element but with the addition of the information in the attribute. Attribute values can be enclosed in either double quotes (“) or single quotes (‘). Elements can also be opened and closed at the same time:

<tag attribute=’information’ />

This element has no value but does have the single attribute, which is enclosed in single quotes. Elements can also be enclosed in other elements:

<address>

<number>402</number> <street>Wildwood Ave</street>

</address>

In this example, the <number> and <street> elements are subelements inside the <address> element.

XML documents can be validated by another document, which indicates what elements, information, and attributes may be present. Two common methods of defining XML documents are XML schema and a document type definition (DTD). Both schema and DTD are XML documents. A complete XML document begins with an XML declaration, which indicates the current version of XML (1.0) and the encoding (commonly UTF-8):

<?xml version=”1.0” encoding=”UTF-8”>

Table A.4 shows some common entity values in XML. Comments begin with <!-- and end with -->. XML documents usually use the file extension .xml. XML is commonly used for encoding information in SIP message bodies. A key advantage of XML over, for example, ABNF, is that a general purpose XML parser can be used to parse and validate an XML document. XML documents

 

 

Appendix

379

 

 

Table A.4

 

 

 

Entity Values in XML

 

 

Value

Meaning

 

 

&amp

ampersand

 

 

<

less than

 

 

>

greater than

 

 

&apos

apostrophe

 

 

"

quotation mark

 

 

escaped ASCII space

 

can also be used to write IETF Internet Drafts using the XML document format [3] and the XML2RFC tool [4].

Namespaces are an XML extension used to manage XML extensions while avoiding name collisions. For example, it is common for elements to define a namespace using the xmlns attribute. Additional namespace attributes can also be defined. If a particular namespace is not understood, it can be ignored by the XML parser. For example,

<presence xmlns=”urn:ietf:params:xml:ns:pidf” xmlns:dm=”urn:ietf:params:xml:ns:pidf:data-model” xmlns:cipid=”urn:ietf:params:xml:ns:pidf:cipid” xmlns:caps=”urn:ietf:params:xml:ns:pidf:caps”

entity=”pres:someone@example.com”> <tuple id=”34g45sfde”>

<status>

<basic>open</basic>

</status>

<contact>sip:someone@pc29.example.com</contact>

<caps:servcaps>

<caps:audio>true</caps:audio>

<caps:video>true</caps:video>

</caps:servcaps>

</tuple>

</presence>

This presence element has a default namespace, which is the IETF URN for PIDF, and three other namespaces of dm, cipid, and caps. The subelements tuple, status, and contacts are all defined in the default namespace while the elements servcaps, audio, and video are defined in the caps namespace.

Note that the line breaks and indentation tabs often shown with XML are optional, but are a good idea to help with the readability of XML. XML elements and values are case sensitive.

References

[1]Crocker, D., and P. Overell, “Augmented BNF for Syntax Specifications: ABNF,” STD 68, RFC 5234, January 2008.

380

SIP: Understanding the Session Initiation Protocol

[2]World Wide Web Consortium, “Extensible Markup Language (XML) 1.0,” W3C XML, February 1998.

[3]Rose, M., “Writing I-Ds and RFCs Using XML,” RFC 2629, June 1999.

[4]http://xml.resource.org.