<?xml version="1.0" encoding="US-ASCII"?>

<!-- This is built from a template for a generic Internet Draft. Suggestions for
     improvement welcome - write to Brian Carpenter, brian.e.carpenter @ gmail.com -->

<!-- This can be converted using the Web service at http://xml.resource.org/experimental.html
     (which supports the latest, sometimes undocumented and under-tested, features.) -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [

<!-- You need one entry like the following for each RFC referenced -->

<!ENTITY RFC2119 PUBLIC ''
  'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
<!ENTITY RFC3986 PUBLIC ''
  'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml'>
<!ENTITY RFC4007 PUBLIC ''
  'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4007.xml'>
<!ENTITY RFC5952 PUBLIC ''
  'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5952.xml'>
<!ENTITY RFC5234 PUBLIC ''
  'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5234.xml'>
<!ENTITY RFC3493 PUBLIC ''
  'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3493.xml'>
<!ENTITY RFC4001 PUBLIC ''
  'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4001.xml'>




<!-- You need one entry like the following for each I-D referenced -->


]>

<?rfc rfcedstyle="yes"?>
<?rfc subcompact="no"?>
<?rfc toc="yes"?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes" ?>

<rfc number="6874" category="std" ipr="trust200902" updates="3986">

<?rfc iprnotified="no" ?>    <!-- Change to "yes" if someone has disclosed IPR for the draft -->
<?rfc compact="yes"?>


<front>
<title abbrev="IPv6 Zone IDs in URIs">Representing IPv6 Zone Identifiers in Address Literals and Uniform Resource Identifiers</title>


<author initials="B." surname="Carpenter" fullname="Brian Carpenter">
    <organization abbrev="Univ. of Auckland"></organization>
    <address>
      <postal>
        <street>Department of Computer Science</street>
        <street>University of Auckland</street>
        <street>PB 92019</street>
        <city>Auckland</city>
        <region></region>
        <code>1142</code>
        <country>New Zealand</country>
      </postal>
      
      <email>brian.e.carpenter@gmail.com</email>
    </address>
</author>

<author initials="S." surname="Cheshire"
            fullname="Stuart Cheshire">
    <organization abbrev="Apple Inc.">
        Apple Inc.
    </organization>
  <address>
    <postal>
        <street>1 Infinite Loop</street>
        <city>Cupertino</city> <region>CA</region>
        <code>95014</code>
        <country>United States</country>
    </postal>

    <email>cheshire@apple.com</email>
  </address>
</author>

<author initials="R." surname="Hinden"
            fullname="Robert M. Hinden">
    <organization abbrev="Check Point">
        Check Point Software Technologies, Inc.
    </organization>
  <address>
    <postal>
        <street>800 Bridge Parkway</street>
        <city>Redwood City</city> <region>CA</region>
        <code>94065</code>
        <country>United States</country>
    </postal>

    <email>bob.hinden@gmail.com</email>
  </address>
</author>


<date month="February" year="2013" />

<area>Internet</area>
<workgroup>6MAN</workgroup>

<!-- [rfced] Please insert any keywords (beyond those that appear in
the title) for use on http://www.rfc-editor.org/rfcsearch.html. 

<keyword>example</keyword>
-->

<abstract>

<t>This document describes how the zone identifier of an IPv6 scoped address, defined
as &lt;zone_id&gt; in the IPv6 Scoped Address Architecture (RFC 4007), can be represented in a literal IPv6 address and in a Uniform Resource Identifier 
that includes such a literal address. It updates the URI Generic Syntax
specification (RFC 3986) accordingly.

</t>
    
</abstract>
</front>

<middle>
<section anchor="intro" title="Introduction">

<t>The Uniform Resource Identifier (URI) syntax specification <xref target="RFC3986"/> defined how a
literal IPv6 address can be represented in the "host" part of a URI.
Two months later, the IPv6 Scoped Address Architecture specification <xref target="RFC4007"/> extended
the text representation of limited-scope IPv6 addresses such that a zone identifier may be concatenated
to a literal address, for purposes described in that specification. Zone identifiers are especially
useful in contexts in which literal addresses are typically used, for example, during fault diagnosis,
when it may be essential to specify which interface is used for sending to a link-local address. 
It should be noted that zone identifiers have purely local meaning within the
node in which
they are defined, often being the same as IPv6 interface names. They are completely meaningless
for any other node. Today, they are meaningful only when attached to addresses with less
than global scope, but it is possible that other uses might be defined in the future. </t>

<t>The IPv6 Scoped Address Architecture specification <xref target="RFC4007" /> does not specify how zone identifiers are to be represented
in URIs. Practical experience has shown that this feature is useful, in particular when using a
web browser for debugging with link-local addresses, but because it is undefined,
it is not implemented consistently in URI parsers or in browsers. </t>

<t>Some versions of some browsers directly accept the IPv6 Scoped Address
syntax <xref target="RFC4007" />
for scoped IPv6 addresses embedded in URIs, i.e., they have been coded to
interpret a "%" sign following the literal address as introducing a zone
identifier <xref target="RFC4007" />, instead of introducing two hexadecimal
characters representing some percent-encoded octet <xref target="RFC3986" />. Clearly, 
interpreting the "%" sign as introducing a zone identifier is very convenient
for users, although it formally breaches
the established URI syntax <xref target="RFC3986" />. This document defines an alternative
approach that respects and extends the rules of URI syntax, and IPv6 literals in general, to be consistent.
</t>

<t>Thus, this document updates the URI syntax specification <xref target="RFC3986"/> by adding syntax to allow a zone identifier
to be included in a literal IPv6 address within a URI. </t>

<!-- It also updates <xref target="RFC4007"/>,
in particular by adding a second allowed delimiter for zone identifiers. -->

<t>It should be noted that in contexts other than a user interface, a zone identifier is mapped into
a numeric zone index or interface number. The MIB textual convention InetZoneIndex <xref target="RFC4001"/> and the
socket interface <xref target="RFC3493"/> define this as a 32-bit unsigned integer. The mapping
between the human-readable zone identifier string and the numeric value is a host-specific
function that varies between operating systems. The present document is concerned only
with the human-readable string. </t>

<t>Several alternative solutions were considered while this document was developed. Appendix
A briefly describes the various options and their advantages and disadvantages. </t>

<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
   document are to be interpreted as described in "Key words for use in
   RFCs to Indicate Requirement Levels" <xref target="RFC2119"/>.</t>


</section> <!-- intro -->

<section anchor="spec" title="Specification">
<t>According to IPv6 Scoped Address syntax <xref target="RFC4007" />, a zone identifier is attached to the textual representation of an IPv6
address by concatenating "%" followed by &lt;zone_id>, where &lt;zone_id> is a string identifying the zone of the address.
However, the IPv6 Scoped Address Architecture specification gives no precise definition of the character set allowed in &lt;zone_id>.
There are no rules or de facto standards for this. For example, the first Ethernet interface in a host
might be called %0, %1, %en1, %eth0, or whatever the implementer happened to choose.</t>

<t>In a URI, a literal IPv6 address is always embedded between "[" and "]". 
This document specifies how a &lt;zone_id> can be appended to the address.
According to URI syntax <xref target="RFC3986" />, "%" is always treated as an
escape character in a URI, so, according to the established URI syntax
<xref target="RFC3986" /> any occurrences of literal "%" symbols in a URI MUST
be percent-encoded and represented in the form "%25". 
Thus, the scoped address fe80::a%en1 would appear in a URI as http://[fe80::a%25en1].
</t>


<t>A &lt;zone_id> SHOULD contain only ASCII characters classified 
as "unreserved" for use in URIs <xref target="RFC3986" />. This excludes characters such as  "]" or even "%" that would complicate parsing. 
However, the syntax described below does allow such characters to be percent-encoded, for
compatibility with existing devices that use them. </t>

<t>If an operating system uses any other characters in zone or interface identifiers that are not in the
"unreserved" character set, they MUST be represented using percent encoding
<xref target="RFC3986" />.</t>

<t>We now present the necessary formal syntax. </t>

<t>
The URI syntax specification <xref target="RFC3986" /> formally defined the
IPv6 literal format in ABNF <xref target="RFC5234"/> by the following rule:
<figure><artwork>
   IP-literal = "[" ( IPv6address / IPvFuture  ) "]"
</artwork></figure>
</t>

<t>To provide support for a zone identifier, 
the existing syntax of IPv6address is retained, and a zone identifier may be
added optionally to any literal address. This syntax allows flexibility for unknown future
uses. The rule quoted above from the previous URI syntax specification
<xref target="RFC3986" /> is replaced by three rules:

<figure><artwork>
   IP-literal = "[" ( IPv6address / IPv6addrz / IPvFuture  ) "]"

   ZoneID = 1*( unreserved / pct-encoded )
   
   IPv6addrz = IPv6address "%25" ZoneID
</artwork></figure></t>

<t>This syntax fills the gap that is described at the end of Section 11.7 of
the IPv6 Scoped Address Architecture specification <xref target="RFC4007" />. </t>

<t>The established rules for textual representation of IPv6 addresses <xref target="RFC5952"/> SHOULD be applied in producing URIs. </t>

<t>The URI syntax specification <xref target="RFC3986" /> states that URIs have a global scope, but that in some cases their
interpretation depends on the end-user's context. URIs including a ZoneID are
to be interpreted only in the context of the host at which they originate, since
the ZoneID is of local significance only. </t>

<t>The IPv6 Scoped Address Architecture specification <xref target="RFC4007" /> offers guidance on how the ZoneID affects interface/address selection
inside the IPv6 stack. Note that the behaviour of an IPv6 stack, if it is passed a non-null
zone index for an address other than link-local, is undefined. </t>


</section> <!-- spec  -->

<section anchor="browsers" title="Web Browsers">

<t>This section discusses how web browsers might handle this syntax extension.
Unfortunately, there is no formal distinction between the syntax allowed
in a browser's input dialogue box and the syntax allowed in URIs. For this
reason, no normative statements are made in this section. </t>

<t>Due to the lack of defined syntax, web browsers have been
inconsistent in providing for ZoneIDs. Many have no support, but there
are examples of ad hoc support. For example, some versions of Firefox allowed the
use of a ZoneID preceded by a bare "%" character, but 
this feature was removed for consistency with established syntax <xref
target="RFC3986" />. As another example, some
versions of Internet Explorer allow use of a ZoneID preceded by a "%"
character encoded as "%25", still beyond the syntax allowed by the established
rules <xref target="RFC3986" />. This
syntax extension is in fact used internally in the Windows operating system and some
of its APIs. </t> 

<t>It is desirable for all browsers to recognise a ZoneID preceded by a percent-encoded "%".
In the spirit of "be liberal with what you accept", we also suggest that URI parsers accept bare
"%" signs when possible (i.e., a "%" not followed by two valid and meaningful hexadecimal characters).
This would make it possible for a user to copy and paste a string such as 
"fe80::a%en1" from the output of a "ping" command and have it work. 
On the other hand, "%ee1" would need to be manually rewritten to "fe80::a%25ee1"
to avoid any risk of misinterpretation. </t>

<t>Such bare "%" signs are for user interface convenience, and need to be
turned into properly encoded characters (where "%25" encodes "%")
before the URI is used in any protocol or HTML document. However, URIs including
a ZoneID have no meaning outside the originating node. It would therefore
be highly desirable for a browser to remove the ZoneID from a URI before including
that URI in an HTTP request.
</t>

<t>The normal diagnostic usage for the ZoneID syntax will cause it to be entered in the browser's
input dialogue box. Thus, URIs including a ZoneID are unlikely to be encountered in
HTML documents. However, if they do (for example, in a diagnostic script coded in HTML),
it would be appropriate to treat them exactly as above. </t>

</section> <!-- browsers -->

<section anchor="security" title="Security Considerations">

<t>The security considerations from the URI syntax specification <xref
target="RFC3986"/> and the IPv6 Scoped Address Architecture specification <xref target="RFC4007"/> apply. 
In particular, this URI format creates a specific pathway by which a deceitful zone
index might be communicated, as mentioned in the final security consideration
of the Scoped Address Architecture specification.
It is emphasised that the format is intended only for debugging purposes, but of course
this intention does not prevent misuse. </t>

<t>To limit this risk, implementations MUST NOT allow use of this format except for
well-defined usages, such as sending to link-local addresses under prefix fe80::/10.
At the time of writing, this is the only well-defined usage known. </t>

<t>An HTTP client, proxy, or other intermediary MUST remove any ZoneID attached
to an outgoing URI, as it has only
local significance at the sending host. </t>

</section> <!-- security -->



<section anchor="ack" title="Acknowledgements">

<t>
The lack of this format was first pointed out by Margaret Wasserman some years ago,
and more recently by Kerry Lynn. A previous draft document by Martin Duerst and Bill
Fenner <xref target="LITERAL-ZONE" /> discussed this topic but was not finalised. </t>

<t>Valuable comments and contributions were made by
Karl Auer,
Carsten Bormann,
Benoit Claise,
Stephen Farrell,
Brian Haberman,
Ted Hardie,
Tatuya Jinmei,
Yves Lafon,
Barry Leiba,
Radia Perlman,
Tom Petch,
Tomoyuki Sahara,
Juergen Schoenwaelder,
Dave Thaler,
Martin Thomson,
and
Ole Troan.
 </t>

<t>Brian Carpenter was a visitor at the Computer Laboratory, Cambridge University during part of this work. </t>

</section> <!-- ack -->


</middle>

<back>

<references title="Normative References">

&RFC3986;
&RFC4007;
&RFC5952;
&RFC2119;

<!-- &RFC5234; -->
<reference anchor='RFC5234'>

<front>
<title>Augmented BNF for Syntax Specifications: ABNF</title>
<author initials='D.' surname='Crocker' fullname='D. Crocker' role="editor">
<organization /></author>
<author initials='P.' surname='Overell' fullname='P. Overell'>
<organization /></author>
<date year='2008' month='January' />
<abstract>
<t>Internet technical specifications often need to define a formal syntax.  Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications.  The current specification documents ABNF.  It balances compactness and simplicity with reasonable representational power.  The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order-independence, and value ranges.  This specification also supplies additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications. [STANDARDS-TRACK]</t></abstract></front>

<seriesInfo name='STD' value='68' />
<seriesInfo name='RFC' value='5234' />
<format type='TXT' octets='26359' target='http://www.rfc-editor.org/rfc/rfc5234.txt' />
</reference>



</references>

<references title="Informative References">

&RFC3493;
&RFC4001;

<!-- &DRAFT-fenner;  expired -->
   <reference anchor="LITERAL-ZONE">

     <front>
       <title>Formats for IPv6 Scope Zone Identifiers in Literal Address Formats</title>

       <author initials="B." surname="Fenner" fullname="B. Fenner">
         <organization></organization>
       </author>
       <author initials="M." surname="Duerst" fullname="M. Duerst">
         <organization></organization>
       </author>

       <date month ="October" year="2005" />
     </front>
     <seriesInfo name="Work in" value="Progress" />
   </reference>


</references>

<section anchor="AppendixA" title="Options Considered">

<t>The syntax defined above allows a ZoneID to be added to any
IPv6 address. The 6man WG discussed and rejected an alternative in which
the existing syntax of IPv6address would be extended by an option
to add the ZoneID only for the case of link-local addresses. It
was felt that the solution presented in this document offers more flexibility for
future uses and is more straightforward to implement.
</t>

<t>The various syntax options considered are now briefly described.</t>

<t><list style="numbers">
<t>Leave the problem unsolved.
<vspace blankLines="1" />
This would mean that per-interface diagnostics would still have to be performed using ping or ping6:
<vspace blankLines="1" />
   ping fe80::a%en1
<vspace blankLines="1" /> 
Advantage: works today.
<vspace blankLines="1" /> 
Disadvantage: less convenient than using a browser.
<vspace blankLines="1" />
</t> 
 
<t>Simply use the percent character:
<vspace blankLines="1" /> 
   http://[fe80::a%en1]
<vspace blankLines="1" />
Advantage: allows use of browser; allows cut and paste.
<vspace blankLines="1" />
Disadvantage: invalid syntax under RFC 3986; not acceptable to URI community.
<vspace blankLines="1" />
</t>


<t>Simply use an alternative separator:
<vspace blankLines="1" /> 
    http://[fe80::a-en1]
<vspace blankLines="1" />
Advantage: allows use of browser; simple syntax.
<vspace blankLines="1" /> 
Disadvantage: Requires all IPv6 address literal parsers and
generators to be updated in order to allow simple cut and paste; inconsistent
with existing tools and practice.
<vspace blankLines="1" /> 
Note: The initial proposal for this choice was to use an underscore
as the separator, but it was noted that this becomes effectively invisible when
a user interface automatically underlines URLs.
<vspace blankLines="1" />
</t>


<t>Simply use the "IPvFuture" syntax left open in RFC 3986:
<vspace blankLines="1" />
    http://[v6.fe80::a_en1]
<vspace blankLines="1" />
Advantage: allows use of browser.
<vspace blankLines="1" />
Disadvantage: ugly and redundant; doesn't allow simple cut and paste.
<vspace blankLines="1" />
</t> 

<t>Retain the percent character already specified for introducing
       zone identifiers for IPv6 Scoped Addresses [RFC4007], and then
       percent-encode it when it appears in a URI, according to the
       already-established URI syntax rules [RFC 3986]:
<vspace blankLines="1" />
   http://[fe80::a%25en1]
<vspace blankLines="1" />
Advantage: allows use of browser; consistent with general URI
       syntax.
<vspace blankLines="1" />
Disadvantage: somewhat ugly and confusing; doesn't allow simple
       cut and paste.
<vspace blankLines="1" />
This is the option chosen for standardisation.
</t>
</list></t>
</section>


</back>
</rfc>

