Skip to content

Commit 7ff8de0

Browse files
authored
Editorial: define finding the IPv6 address compressed piece index
Also adopt Infra number definitions and redo IPv6 pieces. Fixes #321.
1 parent 302c5af commit 7ff8de0

File tree

1 file changed

+70
-24
lines changed

1 file changed

+70
-24
lines changed

url.bs

Lines changed: 70 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -756,14 +756,14 @@ not equivalent and typically treated as distinct.
756756

757757
<p>An <dfn export>IP address</dfn> is an <a>IPv4 address</a> or an <a>IPv6 address</a>.
758758

759-
<p>An <dfn export id=concept-ipv4>IPv4 address</dfn> is a 32-bit unsigned integer that identifies a
760-
network address.
759+
<p>An <dfn export id=concept-ipv4>IPv4 address</dfn> is a <a for=/>32-bit unsigned integer</a> that
760+
identifies a network address.
761761
[[RFC791]]
762762

763-
<p>An <dfn export id=concept-ipv6>IPv6 address</dfn> is a 128-bit unsigned integer that identifies a
764-
network address. For the purposes of this standard it is represented as a <a for=/>list</a> of eight
765-
16-bit unsigned integers, also known as
766-
<dfn export lt="IPv6 piece" id=concept-ipv6-piece>IPv6 pieces</dfn>.
763+
<p>An <dfn export id=concept-ipv6>IPv6 address</dfn> is a <a for=/>128-bit unsigned integer</a> that
764+
identifies a network address. This integer is composed of a <a for=/>list</a> of 8
765+
<a for=/>16-bit unsigned integers</a>, also known as an <a for=/>IPv6 address</a>'s
766+
<dfn export for="IPv6 address" id=concept-ipv6-piece>pieces</dfn>.
767767
[[RFC4291]]
768768

769769
<p class="note">Support for <code>&lt;zone_id></code> is
@@ -1217,7 +1217,8 @@ these steps. They return failure or a <a for=/>tuple</a> of a number and a boole
12171217
actually doing that with the editors of this document first.
12181218

12191219
<ol>
1220-
<li><p>Let <var>address</var> be a new <a>IPv6 address</a> whose <a>IPv6 pieces</a> are all 0.
1220+
<li><p>Let <var>address</var> be a new <a>IPv6 address</a> whose <a for="IPv6 address">pieces</a>
1221+
are all 0.
12211222

12221223
<li><p>Let <var>pieceIndex</var> be 0.
12231224

@@ -1444,20 +1445,14 @@ actually doing that with the editors of this document first.
14441445
<ol>
14451446
<li><p>Let <var>output</var> be the empty string.
14461447

1447-
<li>
1448-
<p>Let <var>compress</var> be an index to the first <a>IPv6 piece</a> in the first longest
1449-
sequences of <var>address</var>'s <a>IPv6 pieces</a> that are 0.
1450-
1451-
<p class=example id=example-e2b3492e>In <code>0:f:0:0:f:f:0:0</code> it would point to
1452-
the second 0.
1453-
1454-
<li><p>If there is no sequence of <var>address</var>'s <a>IPv6 pieces</a> that are 0 that is
1455-
longer than 1, then set <var>compress</var> to null.
1448+
<li><p>Let <var>compress</var> be the result of
1449+
<a for=/>finding the IPv6 address compressed piece index</a> given <var>address</var>.
14561450

14571451
<li><p>Let <var>ignore0</var> be false.
14581452

14591453
<li>
1460-
<p><a for=set>For each</a> <var>pieceIndex</var> in the range 0 to 7, inclusive:
1454+
<p><a for=set>For each</a> <var>pieceIndex</var> of <var>address</var>'s
1455+
<a for="IPv6 address">pieces</a>'s <a for=list>indices</a>:
14611456

14621457
<ol>
14631458
<li><p>If <var>ignore0</var> is true and <var>address</var>[<var>pieceIndex</var>] is 0, then
@@ -1469,8 +1464,8 @@ actually doing that with the editors of this document first.
14691464
<p>If <var>compress</var> is <var>pieceIndex</var>, then:
14701465

14711466
<ol>
1472-
<li><p>Let <var>separator</var> be "<code>::</code>" if <var>pieceIndex</var> is 0, and
1473-
U+003A (:) otherwise.
1467+
<li><p>Let <var>separator</var> be "<code>::</code>" if <var>pieceIndex</var> is 0; otherwise
1468+
U+003A (:).
14741469

14751470
<li><p>Append <var>separator</var> to <var>output</var>.
14761471

@@ -1491,6 +1486,57 @@ A Recommendation for IPv6 Address Text Representation.
14911486
[[RFC5952]]
14921487
</div>
14931488

1489+
<div algorithm>
1490+
<p>To <dfn>find the IPv6 address compressed piece index</dfn> given an <a for=/>IPv6 address</a>
1491+
<var>address</var>:
1492+
1493+
<ol>
1494+
<li><p>Let <var>longestIndex</var> be null.
1495+
1496+
<li><p>Let <var>longestSize</var> be 1.
1497+
1498+
<li><p>Let <var>foundIndex</var> be null.
1499+
1500+
<li><p>Let <var>foundSize</var> be 0.
1501+
1502+
<li>
1503+
<p><a for=list>For each</a> <var>pieceIndex</var> of <var>address</var>'s
1504+
<a for="IPv6 address">pieces</a>'s <a for=list>indices</a>:
1505+
1506+
<ol>
1507+
<li>
1508+
<p>If <var>address</var>'s <a for="IPv6 address">pieces</a>[<var>pieceIndex</var>] is not 0:
1509+
1510+
<ol>
1511+
<li><p>If <var>foundSize</var> is greater than <var>longestSize</var>, then set
1512+
<var>longestIndex</var> to <var>foundIndex</var> and <var>longestSize</var> to
1513+
<var>foundSize</var>.
1514+
1515+
<li>Set <var>foundIndex</var> to null.
1516+
1517+
<li>Set <var>foundSize</var> to 0.
1518+
</ol>
1519+
1520+
<li>
1521+
<p>Otherwise:
1522+
1523+
<ol>
1524+
<li><p>If <var>foundIndex</var> is null, then set <var>foundIndex</var> to
1525+
<var>pieceIndex</var>.
1526+
1527+
<li><p>Increment <var>foundSize</var> by 1.
1528+
</ol>
1529+
</ol>
1530+
1531+
<li><p>If <var>foundSize</var> is greater than <var>longestSize</var>, then return
1532+
<var>foundIndex</var>.
1533+
1534+
<li><p>Return <var>longestIndex</var>.
1535+
</ol>
1536+
1537+
<p class=example id=example-e2b3492e>In <code>0:f:0:0:f:f:0:0</code> it would point to the second 0.
1538+
</div>
1539+
14941540

14951541
<h3 id=host-equivalence>Host equivalence</h3>
14961542

@@ -1713,8 +1759,8 @@ It is initially the empty string.
17131759
</table>
17141760
</div>
17151761

1716-
<p>A <a for=/>URL</a>'s <dfn export for=url id=concept-url-port>port</dfn> is either
1717-
null or a 16-bit unsigned integer that identifies a networking port. It is initially null.
1762+
<p>A <a for=/>URL</a>'s <dfn export for=url id=concept-url-port>port</dfn> is either null or a
1763+
<a for=/>16-bit unsigned integer</a> that identifies a networking port. It is initially null.
17181764

17191765
<p>A <a for=/>URL</a>'s
17201766
<dfn export for=url id=concept-url-path oldids=non-relative-flag,url-cannot-be-a-base-url-flag>path</dfn>
@@ -1974,8 +2020,8 @@ followed by a <a>path-absolute-URL string</a>.
19742020

19752021
<ul class=brief>
19762022
<li><p>the empty string
1977-
<li><p>one or more <a>ASCII digits</a> representing a decimal number no greater than
1978-
2<sup>16</sup>&nbsp;&minus;&nbsp;1.
2023+
<li><p>one or more <a>ASCII digits</a> representing a decimal number that is a
2024+
<a for=/>16-bit unsigned integer</a>.
19792025
</ul>
19802026

19812027
<p>A <dfn export oldids=syntax-url-scheme-relative>scheme-relative-URL string</dfn> must be
@@ -2577,7 +2623,7 @@ and then runs these steps:
25772623
by <var>buffer</var> in radix-10 using <a>ASCII digits</a> for digits with values
25782624
0 through 9.
25792625

2580-
<li><p>If <var>port</var> is greater than 2<sup>16</sup>&nbsp;&minus;&nbsp;1,
2626+
<li><p>If <var>port</var> is not a <a for=/>16-bit unsigned integer</a>,
25812627
<a>port-out-of-range</a> <a>validation error</a>, return failure.
25822628

25832629
<li><p>Set <var>url</var>'s <a for=url>port</a> to null, if <var>port</var> is

0 commit comments

Comments
 (0)