aboutsummaryrefslogtreecommitdiff
path: root/misc/rfc4122-uuid.txt
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-02-18 17:41:24 +0000
committerMike Buland <eichlan@xagasoft.com>2011-02-18 17:41:24 +0000
commit26bb069c535e3fd5b0e0fb28fb54a2a540b60a84 (patch)
tree9eab7637e5fa1d881c775a6f0611b74e385196f1 /misc/rfc4122-uuid.txt
parent80c8dd155a164c186fd11e3e3f66e8f3cfdf19fe (diff)
downloadlibbu++-26bb069c535e3fd5b0e0fb28fb54a2a540b60a84.tar.gz
libbu++-26bb069c535e3fd5b0e0fb28fb54a2a540b60a84.tar.bz2
libbu++-26bb069c535e3fd5b0e0fb28fb54a2a540b60a84.tar.xz
libbu++-26bb069c535e3fd5b0e0fb28fb54a2a540b60a84.zip
Some Uuid tweaks, not much, just figuring out the format. MyriadFs is coming
along quite nicely. It looks like it works great for normal programs, but there need to be some tweaks made to a few things before it's working 100% via fuse. Also, the fuse module won't let you specify a file, a little odd.
Diffstat (limited to '')
-rw-r--r--misc/rfc4122-uuid.txt (renamed from misc/rfc4122)693
1 files changed, 280 insertions, 413 deletions
diff --git a/misc/rfc4122 b/misc/rfc4122-uuid.txt
index 5c5a8a5..31ceaab 100644
--- a/misc/rfc4122
+++ b/misc/rfc4122-uuid.txt
@@ -1,136 +1,9 @@
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 1
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 3
4<head> 4
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5
6 <meta name="robots" content="index,follow" /> 6
7 <meta name="creator" content="rfcmarkup version 1.73" />
8 <link rel="icon" href="/images/rfc.png" type="image/png" />
9 <link rel="shortcut icon" href="/images/rfc.png" type="image/png" />
10 <title>RFC 4122 - A Universally Unique IDentifier (UUID) URN Namespace</title>
11
12 <style type="text/css">
13 body {
14 margin: 0px 8px;
15 font-size: 1em;
16 }
17 h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
18 font-weight: bold;
19 line-height: 0pt;
20 display: inline;
21 white-space: pre;
22 font-family: monospace;
23 font-size: 1em;
24 font-weight: bold;
25 }
26 pre {
27 font-size: 1em;
28 margin-top: 0px;
29 margin-bottom: 0px;
30 }
31 .pre {
32 white-space: pre;
33 font-family: monospace;
34 }
35 .header{
36 font-weight: bold;
37 }
38 .newpage {
39 page-break-before: always;
40 }
41 .invisible {
42 text-decoration: none;
43 color: white;
44 }
45 @media print {
46 body {
47 font-size: 10.5pt;
48 }
49 h1, h2, h3, h4, h5, h6 {
50 font-size: 10.5pt;
51 }
52
53 a:link, a:visited {
54 color: inherit;
55 text-decoration: none;
56 }
57 .noprint {
58 display: none;
59 }
60 }
61 @media screen {
62 .grey, .grey a:link, .grey a:visited {
63 color: #777;
64 }
65 .docinfo {
66 background-color: #EEE;
67 }
68 .top {
69 border-top: 7px solid #EEE;
70 }
71 .bgwhite { background-color: white; }
72 .bgred { background-color: #F44; }
73 .bggrey { background-color: #666; }
74 .bgbrown { background-color: #840; }
75 .bgorange { background-color: #FA0; }
76 .bgyellow { background-color: #EE0; }
77 .bgmagenta{ background-color: #F4F; }
78 .bgblue { background-color: #66F; }
79 .bgcyan { background-color: #4DD; }
80 .bggreen { background-color: #4F4; }
81
82 .legend { font-size: 90%; }
83 .cplate { font-size: 70%; border: solid grey 1px; }
84 }
85 </style>
86
87 <script type="text/javascript"><!--
88 function addHeaderTags() {
89 var spans = document.getElementsByTagName("span");
90 for (var i=0; i < spans.length; i++) {
91 var elem = spans[i];
92 if (elem) {
93 var level = elem.getAttribute("class");
94 if (level == "h1" || level == "h2" || level == "h3" || level == "h4" || level == "h5" || level == "h6") {
95 elem.innerHTML = "<"+level+">"+elem.innerHTML+"</"+level+">";
96 }
97 }
98 }
99 }
100 var legend_html = "Colour legend:<br /> <table> <tr><td>Unknown:</td> <td><span class='cplate bgwhite'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Draft:</td> <td><span class='cplate bgred'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Informational:</td> <td><span class='cplate bgorange'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Experimental:</td> <td><span class='cplate bgyellow'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Best Common Practice:</td><td><span class='cplate bgmagenta'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Proposed Standard:</td><td><span class='cplate bgblue'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Draft Standard:</td> <td><span class='cplate bgcyan'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Standard:</td> <td><span class='cplate bggreen'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Historic:</td> <td><span class='cplate bggrey'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td>Obsolete:</td> <td><span class='cplate bgbrown'>&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> </table>";
101 function showElem(id) {
102 var elem = document.getElementById(id);
103 elem.innerHTML = eval(id+"_html");
104 elem.style.visibility='visible';
105 }
106 function hideElem(id) {
107 var elem = document.getElementById(id);
108 elem.style.visibility='hidden';
109 elem.innerHTML = "";
110 }
111 // -->
112 </script>
113</head>
114<body onload="addHeaderTags()">
115 <div style="height: 13px;">
116 <div onmouseover="this.style.cursor='pointer';"
117 onclick="showElem('legend');"
118 onmouseout="hideElem('legend')"
119 style="height: 6px; position: absolute;"
120 class="pre noprint docinfo bgblue"
121 title="Click for colour legend." > </div>
122 <div id="legend"
123 class="docinfo noprint pre legend"
124 style="position:absolute; top: 4px; left: 4ex; visibility:hidden; background-color: white; padding: 4px 9px 5px 7px; border: solid #345 1px; "
125 onmouseover="showElem('legend');"
126 onmouseout="hideElem('legend');">
127 </div>
128 </div>
129<span class="pre noprint docinfo top">[<a href="../html/" title="Document search and retrieval page">RFCs/IDs</a>] [<a href="/rfc/rfc4122.txt" title="Plaintext version of this document">Plain Text</a>] [From <a href="draft-mealling-uuid-urn">draft-mealling-uuid-urn</a>] </span><br />
130<span class="pre noprint docinfo"> </span><br />
131<span class="pre noprint docinfo"> PROPOSED STANDARD</span><br />
132<span class="pre noprint docinfo"> <a href="http://www.rfc-editor.org/errata_search.php?rfc=4122">Errata</a></span><br />
133<pre>
134Network Working Group P. Leach 7Network Working Group P. Leach
135Request for Comments: 4122 Microsoft 8Request for Comments: 4122 Microsoft
136Category: Standards Track M. Mealling 9Category: Standards Track M. Mealling
@@ -140,7 +13,7 @@ Category: Standards Track M. Mealling
140 July 2005 13 July 2005
141 14
142 15
143 <span class="h1">A Universally Unique IDentifier (UUID) URN Namespace</span> 16 A Universally Unique IDentifier (UUID) URN Namespace
144 17
145Status of This Memo 18Status of This Memo
146 19
@@ -182,41 +55,41 @@ Abstract
182 55
183 56
184 57
185<span class="grey">Leach, et al. Standards Track [Page 1]</span> 58Leach, et al. Standards Track [Page 1]
186</pre><pre class='newpage'><a name="page-2" id="page-2" href="#page-2" class="invisible"> </a> 59
187<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 60RFC 4122 A UUID URN Namespace July 2005
188 61
189 62
190Table of Contents 63Table of Contents
191 64
192 <a href="#section-1">1</a>. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-2">2</a> 65 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
193 <a href="#section-2">2</a>. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a> 66 2. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . 3
194 <a href="#section-3">3</a>. Namespace Registration Template . . . . . . . . . . . . . . . <a href="#page-3">3</a> 67 3. Namespace Registration Template . . . . . . . . . . . . . . . 3
195 <a href="#section-4">4</a>. Specification . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a> 68 4. Specification . . . . . . . . . . . . . . . . . . . . . . . . 5
196 <a href="#section-4.1">4.1</a>. Format. . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a> 69 4.1. Format. . . . . . . . . . . . . . . . . . . . . . . . . . 5
197 <a href="#section-4.1.1">4.1.1</a>. Variant. . . . . . . . . . . . . . . . . . . . . . <a href="#page-6">6</a> 70 4.1.1. Variant. . . . . . . . . . . . . . . . . . . . . . 6
198 <a href="#section-4.1.2">4.1.2</a>. Layout and Byte Order. . . . . . . . . . . . . . . <a href="#page-6">6</a> 71 4.1.2. Layout and Byte Order. . . . . . . . . . . . . . . 6
199 <a href="#section-4.1.3">4.1.3</a>. Version. . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a> 72 4.1.3. Version. . . . . . . . . . . . . . . . . . . . . . 7
200 <a href="#section-4.1.4">4.1.4</a>. Timestamp. . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a> 73 4.1.4. Timestamp. . . . . . . . . . . . . . . . . . . . . 8
201 <a href="#section-4.1.5">4.1.5</a>. Clock Sequence . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a> 74 4.1.5. Clock Sequence . . . . . . . . . . . . . . . . . . 8
202 <a href="#section-4.1.6">4.1.6</a>. Node . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a> 75 4.1.6. Node . . . . . . . . . . . . . . . . . . . . . . . 9
203 <a href="#section-4.1.7">4.1.7</a>. Nil UUID . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a> 76 4.1.7. Nil UUID . . . . . . . . . . . . . . . . . . . . . 9
204 <a href="#section-4.2">4.2</a>. Algorithms for Creating a Time-Based UUID . . . . . . . . <a href="#page-9">9</a> 77 4.2. Algorithms for Creating a Time-Based UUID . . . . . . . . 9
205 <a href="#section-4.2.1">4.2.1</a>. Basic Algorithm. . . . . . . . . . . . . . . . . . <a href="#page-10">10</a> 78 4.2.1. Basic Algorithm. . . . . . . . . . . . . . . . . . 10
206 <a href="#section-4.2.2">4.2.2</a>. Generation Details . . . . . . . . . . . . . . . . <a href="#page-12">12</a> 79 4.2.2. Generation Details . . . . . . . . . . . . . . . . 12
207 <a href="#section-4.3">4.3</a>. Algorithm for Creating a Name-Based UUID. . . . . . . . . <a href="#page-13">13</a> 80 4.3. Algorithm for Creating a Name-Based UUID. . . . . . . . . 13
208 4.4. Algorithms for Creating a UUID from Truly Random or 81 4.4. Algorithms for Creating a UUID from Truly Random or
209 Pseudo-Random Numbers . . . . . . . . . . . . . . . . . . <a href="#page-14">14</a> 82 Pseudo-Random Numbers . . . . . . . . . . . . . . . . . . 14
210 <a href="#section-4.5">4.5</a>. Node IDs that Do Not Identify the Host. . . . . . . . . . <a href="#page-15">15</a> 83 4.5. Node IDs that Do Not Identify the Host. . . . . . . . . . 15
211 <a href="#section-5">5</a>. Community Considerations . . . . . . . . . . . . . . . . . . . <a href="#page-15">15</a> 84 5. Community Considerations . . . . . . . . . . . . . . . . . . . 15
212 <a href="#section-6">6</a>. Security Considerations . . . . . . . . . . . . . . . . . . . <a href="#page-16">16</a> 85 6. Security Considerations . . . . . . . . . . . . . . . . . . . 16
213 <a href="#section-7">7</a>. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-16">16</a> 86 7. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 16
214 <a href="#section-8">8</a>. Normative References . . . . . . . . . . . . . . . . . . . . . <a href="#page-16">16</a> 87 8. Normative References . . . . . . . . . . . . . . . . . . . . . 16
215 <a href="#appendix-A">A</a>. <a href="#appendix-A">Appendix A</a> - Sample Implementation . . . . . . . . . . . . . . <a href="#page-18">18</a> 88 A. Appendix A - Sample Implementation . . . . . . . . . . . . . . 18
216 <a href="#appendix-B">B</a>. <a href="#appendix-B">Appendix B</a> - Sample Output of utest . . . . . . . . . . . . . <a href="#page-29">29</a> 89 B. Appendix B - Sample Output of utest . . . . . . . . . . . . . 29
217 <a href="#appendix-C">C</a>. <a href="#appendix-C">Appendix C</a> - Some Name Space IDs . . . . . . . . . . . . . . . <a href="#page-30">30</a> 90 C. Appendix C - Some Name Space IDs . . . . . . . . . . . . . . . 30
218 91
219<span class="h2"><a name="section-1">1</a>. Introduction</span> 921. Introduction
220 93
221 This specification defines a Uniform Resource Name namespace for 94 This specification defines a Uniform Resource Name namespace for
222 UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally 95 UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally
@@ -227,23 +100,23 @@ Table of Contents
227 to implement services using UUIDs as URNs. Nothing in this document 100 to implement services using UUIDs as URNs. Nothing in this document
228 should be construed to override the DCE standards that defined UUIDs. 101 should be construed to override the DCE standards that defined UUIDs.
229 102
230 There is an ITU-T Recommendation and ISO/IEC Standard [<a href="#ref-3" title='"Procedures for the operation of OSI Registration Authorities: Generation and registration of Universally Unique Identifiers (UUIDs) and their use as ASN.1 Object Identifier components"'>3</a>] that are 103 There is an ITU-T Recommendation and ISO/IEC Standard [3] that are
231 derived from earlier versions of this document. Both sets of 104 derived from earlier versions of this document. Both sets of
232 specifications have been aligned, and are fully technically 105 specifications have been aligned, and are fully technically
233 compatible. In addition, a global registration function is being 106 compatible. In addition, a global registration function is being
234 provided by the Telecommunications Standardisation Bureau of ITU-T; 107 provided by the Telecommunications Standardisation Bureau of ITU-T;
235 for details see &lt;<a href="http://www.itu.int/ITU-T/asn1/uuid.html">http://www.itu.int/ITU-T/asn1/uuid.html</a>&gt;. 108 for details see <http://www.itu.int/ITU-T/asn1/uuid.html>.
236 109
237 110
238 111
239 112
240 113
241<span class="grey">Leach, et al. Standards Track [Page 2]</span> 114Leach, et al. Standards Track [Page 2]
242</pre><pre class='newpage'><a name="page-3" id="page-3" href="#page-3" class="invisible"> </a> 115
243<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 116RFC 4122 A UUID URN Namespace July 2005
244 117
245 118
246<span class="h2"><a name="section-2">2</a>. Motivation</span> 1192. Motivation
247 120
248 One of the main reasons for using UUIDs is that no centralized 121 One of the main reasons for using UUIDs is that no centralized
249 authority is required to administer them (although one format uses 122 authority is required to administer them (although one format uses
@@ -263,7 +136,7 @@ Table of Contents
263 registration process allows for UUIDs to be one of the URNs with the 136 registration process allows for UUIDs to be one of the URNs with the
264 lowest minting cost. 137 lowest minting cost.
265 138
266<span class="h2"><a name="section-3">3</a>. Namespace Registration Template</span> 1393. Namespace Registration Template
267 140
268 Namespace ID: UUID 141 Namespace ID: UUID
269 Registration Information: 142 Registration Information:
@@ -282,7 +155,7 @@ Table of Contents
282 very persistent objects across a network. 155 very persistent objects across a network.
283 156
284 The internal representation of a UUID is a specific sequence of 157 The internal representation of a UUID is a specific sequence of
285 bits in memory, as described in <a href="#section-4">Section 4</a>. To accurately 158 bits in memory, as described in Section 4. To accurately
286 represent a UUID as a URN, it is necessary to convert the bit 159 represent a UUID as a URN, it is necessary to convert the bit
287 sequence to a string representation. 160 sequence to a string representation.
288 161
@@ -294,13 +167,13 @@ Table of Contents
294 167
295 168
296 169
297<span class="grey">Leach, et al. Standards Track [Page 3]</span> 170Leach, et al. Standards Track [Page 3]
298</pre><pre class='newpage'><a name="page-4" id="page-4" href="#page-4" class="invisible"> </a> 171
299<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 172RFC 4122 A UUID URN Namespace July 2005
300 173
301 174
302 The formal definition of the UUID string representation is 175 The formal definition of the UUID string representation is
303 provided by the following ABNF [<a href="#ref-7" title='"Augmented BNF for Syntax Specifications: ABNF"'>7</a>]: 176 provided by the following ABNF [7]:
304 177
305 UUID = time-low "-" time-mid "-" 178 UUID = time-low "-" time-mid "-"
306 time-high-and-version "-" 179 time-high-and-version "-"
@@ -324,7 +197,7 @@ Table of Contents
324 urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6 197 urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6
325 198
326 Relevant ancillary documentation: 199 Relevant ancillary documentation:
327 [<a href="#ref-1" title='"Network Computing Architecture"'>1</a>][2] 200 [1][2]
328 Identifier uniqueness considerations: 201 Identifier uniqueness considerations:
329 This document specifies three algorithms to generate UUIDs: the 202 This document specifies three algorithms to generate UUIDs: the
330 first leverages the unique values of 802 MAC addresses to 203 first leverages the unique values of 802 MAC addresses to
@@ -350,12 +223,12 @@ Table of Contents
350 223
351 224
352 225
353<span class="grey">Leach, et al. Standards Track [Page 4]</span> 226Leach, et al. Standards Track [Page 4]
354</pre><pre class='newpage'><a name="page-5" id="page-5" href="#page-5" class="invisible"> </a> 227
355<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 228RFC 4122 A UUID URN Namespace July 2005
356 229
357 230
358 or privacy concerns make its use undesirable, <a href="#section-4.5">Section 4.5</a> 231 or privacy concerns make its use undesirable, Section 4.5
359 specifies two alternatives. Another approach is to use version 3 232 specifies two alternatives. Another approach is to use version 3
360 or version 4 UUIDs as defined below. 233 or version 4 UUIDs as defined below.
361 234
@@ -364,7 +237,7 @@ Table of Contents
364 237
365 Rules for Lexical Equivalence: 238 Rules for Lexical Equivalence:
366 Consider each field of the UUID to be an unsigned integer as shown 239 Consider each field of the UUID to be an unsigned integer as shown
367 in the table in section <a href="#section-4.1.2">Section 4.1.2</a>. Then, to compare a pair of 240 in the table in section Section 4.1.2. Then, to compare a pair of
368 UUIDs, arithmetically compare the corresponding fields from each 241 UUIDs, arithmetically compare the corresponding fields from each
369 UUID in order of significance and according to their data type. 242 UUID in order of significance and according to their data type.
370 Two UUIDs are equal if and only if all the corresponding fields 243 Two UUIDs are equal if and only if all the corresponding fields
@@ -396,9 +269,9 @@ Table of Contents
396 Scope: 269 Scope:
397 UUIDs are global in scope. 270 UUIDs are global in scope.
398 271
399<span class="h2"><a name="section-4">4</a>. Specification</span> 2724. Specification
400 273
401<span class="h3"><a name="section-4.1">4.1</a>. Format</span> 2744.1. Format
402 275
403 The UUID format is 16 octets; some bits of the eight octet variant 276 The UUID format is 16 octets; some bits of the eight octet variant
404 field specified below determine finer structure. 277 field specified below determine finer structure.
@@ -406,12 +279,12 @@ Table of Contents
406 279
407 280
408 281
409<span class="grey">Leach, et al. Standards Track [Page 5]</span> 282Leach, et al. Standards Track [Page 5]
410</pre><pre class='newpage'><a name="page-6" id="page-6" href="#page-6" class="invisible"> </a> 283
411<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 284RFC 4122 A UUID URN Namespace July 2005
412 285
413 286
414<span class="h4"><a name="section-4.1.1">4.1.1</a>. Variant</span> 2874.1.1. Variant
415 288
416 The variant field determines the layout of the UUID. That is, the 289 The variant field determines the layout of the UUID. That is, the
417 interpretation of all other bits in the UUID depends on the setting 290 interpretation of all other bits in the UUID depends on the setting
@@ -438,7 +311,7 @@ Table of Contents
438 defined here is not guaranteed, and is not likely to be an issue in 311 defined here is not guaranteed, and is not likely to be an issue in
439 practice. 312 practice.
440 313
441<span class="h4"><a name="section-4.1.2">4.1.2</a>. Layout and Byte Order</span> 3144.1.2. Layout and Byte Order
442 315
443 To minimize confusion about bit assignments within octets, the UUID 316 To minimize confusion about bit assignments within octets, the UUID
444 record definition is defined only in terms of fields that are 317 record definition is defined only in terms of fields that are
@@ -462,9 +335,9 @@ Table of Contents
462 335
463 336
464 337
465<span class="grey">Leach, et al. Standards Track [Page 6]</span> 338Leach, et al. Standards Track [Page 6]
466</pre><pre class='newpage'><a name="page-7" id="page-7" href="#page-7" class="invisible"> </a> 339
467<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 340RFC 4122 A UUID URN Namespace July 2005
468 341
469 342
470 clock_seq_hi_and_rese unsigned 8 8 The high field of the 343 clock_seq_hi_and_rese unsigned 8 8 The high field of the
@@ -500,7 +373,7 @@ Table of Contents
500 | node (2-5) | 373 | node (2-5) |
501 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 374 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
502 375
503<span class="h4"><a name="section-4.1.3">4.1.3</a>. Version</span> 3764.1.3. Version
504 377
505 The version number is in the most significant 4 bits of the time 378 The version number is in the most significant 4 bits of the time
506 stamp (bits 4 through 7 of the time_hi_and_version field). 379 stamp (bits 4 through 7 of the time_hi_and_version field).
@@ -518,9 +391,9 @@ Table of Contents
518 391
519 392
520 393
521<span class="grey">Leach, et al. Standards Track [Page 7]</span> 394Leach, et al. Standards Track [Page 7]
522</pre><pre class='newpage'><a name="page-8" id="page-8" href="#page-8" class="invisible"> </a> 395
523<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 396RFC 4122 A UUID URN Namespace July 2005
524 397
525 398
526 0 0 1 1 3 The name-based version 399 0 0 1 1 3 The name-based version
@@ -538,7 +411,7 @@ Table of Contents
538 The version is more accurately a sub-type; again, we retain the term 411 The version is more accurately a sub-type; again, we retain the term
539 for compatibility. 412 for compatibility.
540 413
541<span class="h4"><a name="section-4.1.4">4.1.4</a>. Timestamp</span> 4144.1.4. Timestamp
542 415
543 The timestamp is a 60-bit value. For UUID version 1, this is 416 The timestamp is a 60-bit value. For UUID version 1, this is
544 represented by Coordinated Universal Time (UTC) as a count of 100- 417 represented by Coordinated Universal Time (UTC) as a count of 100-
@@ -552,12 +425,12 @@ Table of Contents
552 offset. 425 offset.
553 426
554 For UUID version 3 or 5, the timestamp is a 60-bit value constructed 427 For UUID version 3 or 5, the timestamp is a 60-bit value constructed
555 from a name as described in <a href="#section-4.3">Section 4.3</a>. 428 from a name as described in Section 4.3.
556 429
557 For UUID version 4, the timestamp is a randomly or pseudo-randomly 430 For UUID version 4, the timestamp is a randomly or pseudo-randomly
558 generated 60-bit value, as described in <a href="#section-4.4">Section 4.4</a>. 431 generated 60-bit value, as described in Section 4.4.
559 432
560<span class="h4"><a name="section-4.1.5">4.1.5</a>. Clock Sequence</span> 4334.1.5. Clock Sequence
561 434
562 For UUID version 1, the clock sequence is used to help avoid 435 For UUID version 1, the clock sequence is used to help avoid
563 duplicates that could arise when the clock is set backwards in time 436 duplicates that could arise when the clock is set backwards in time
@@ -574,9 +447,9 @@ Table of Contents
574 447
575 448
576 449
577<span class="grey">Leach, et al. Standards Track [Page 8]</span> 450Leach, et al. Standards Track [Page 8]
578</pre><pre class='newpage'><a name="page-9" id="page-9" href="#page-9" class="invisible"> </a> 451
579<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 452RFC 4122 A UUID URN Namespace July 2005
580 453
581 454
582 Similarly, if the node ID changes (e.g., because a network card has 455 Similarly, if the node ID changes (e.g., because a network card has
@@ -593,12 +466,12 @@ Table of Contents
593 The initial value MUST NOT be correlated to the node identifier. 466 The initial value MUST NOT be correlated to the node identifier.
594 467
595 For UUID version 3 or 5, the clock sequence is a 14-bit value 468 For UUID version 3 or 5, the clock sequence is a 14-bit value
596 constructed from a name as described in <a href="#section-4.3">Section 4.3</a>. 469 constructed from a name as described in Section 4.3.
597 470
598 For UUID version 4, clock sequence is a randomly or pseudo-randomly 471 For UUID version 4, clock sequence is a randomly or pseudo-randomly
599 generated 14-bit value as described in <a href="#section-4.4">Section 4.4</a>. 472 generated 14-bit value as described in Section 4.4.
600 473
601<span class="h4"><a name="section-4.1.6">4.1.6</a>. Node</span> 4744.1.6. Node
602 475
603 For UUID version 1, the node field consists of an IEEE 802 MAC 476 For UUID version 1, the node field consists of an IEEE 802 MAC
604 address, usually the host address. For systems with multiple IEEE 477 address, usually the host address. For systems with multiple IEEE
@@ -608,34 +481,34 @@ Table of Contents
608 transmitted on an 802.3 LAN. 481 transmitted on an 802.3 LAN.
609 482
610 For systems with no IEEE address, a randomly or pseudo-randomly 483 For systems with no IEEE address, a randomly or pseudo-randomly
611 generated value may be used; see <a href="#section-4.5">Section 4.5</a>. The multicast bit must 484 generated value may be used; see Section 4.5. The multicast bit must
612 be set in such addresses, in order that they will never conflict with 485 be set in such addresses, in order that they will never conflict with
613 addresses obtained from network cards. 486 addresses obtained from network cards.
614 487
615 For UUID version 3 or 5, the node field is a 48-bit value constructed 488 For UUID version 3 or 5, the node field is a 48-bit value constructed
616 from a name as described in <a href="#section-4.3">Section 4.3</a>. 489 from a name as described in Section 4.3.
617 490
618 For UUID version 4, the node field is a randomly or pseudo-randomly 491 For UUID version 4, the node field is a randomly or pseudo-randomly
619 generated 48-bit value as described in <a href="#section-4.4">Section 4.4</a>. 492 generated 48-bit value as described in Section 4.4.
620 493
621<span class="h4"><a name="section-4.1.7">4.1.7</a>. Nil UUID</span> 4944.1.7. Nil UUID
622 495
623 The nil UUID is special form of UUID that is specified to have all 496 The nil UUID is special form of UUID that is specified to have all
624 128 bits set to zero. 497 128 bits set to zero.
625 498
626<span class="h3"><a name="section-4.2">4.2</a>. Algorithms for Creating a Time-Based UUID</span> 4994.2. Algorithms for Creating a Time-Based UUID
627 500
628 Various aspects of the algorithm for creating a version 1 UUID are 501 Various aspects of the algorithm for creating a version 1 UUID are
629 discussed in the following sections. 502 discussed in the following sections.
630 503
631 504
632 505
633<span class="grey">Leach, et al. Standards Track [Page 9]</span> 506Leach, et al. Standards Track [Page 9]
634</pre><pre class='newpage'><a name="page-10" id="page-10" href="#page-10" class="invisible"> </a> 507
635<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 508RFC 4122 A UUID URN Namespace July 2005
636 509
637 510
638<span class="h4"><a name="section-4.2.1">4.2.1</a>. Basic Algorithm</span> 5114.2.1. Basic Algorithm
639 512
640 The following algorithm is simple, correct, and inefficient: 513 The following algorithm is simple, correct, and inefficient:
641 514
@@ -663,7 +536,7 @@ Table of Contents
663 o Release the global lock. 536 o Release the global lock.
664 537
665 o Format a UUID from the current timestamp, clock sequence, and node 538 o Format a UUID from the current timestamp, clock sequence, and node
666 ID values according to the steps in <a href="#section-4.2.2">Section 4.2.2</a>. 539 ID values according to the steps in Section 4.2.2.
667 540
668 If UUIDs do not need to be frequently generated, the above algorithm 541 If UUIDs do not need to be frequently generated, the above algorithm
669 may be perfectly adequate. For higher performance requirements, 542 may be perfectly adequate. For higher performance requirements,
@@ -686,12 +559,12 @@ Table of Contents
686 559
687 560
688 561
689<span class="grey">Leach, et al. Standards Track [Page 10]</span> 562Leach, et al. Standards Track [Page 10]
690</pre><pre class='newpage'><a name="page-11" id="page-11" href="#page-11" class="invisible"> </a> 563
691<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 564RFC 4122 A UUID URN Namespace July 2005
692 565
693 566
694<span class="h5"><a name="section-4.2.1.1">4.2.1.1</a>. Reading Stable Storage</span> 5674.2.1.1. Reading Stable Storage
695 568
696 The state only needs to be read from stable storage once at boot 569 The state only needs to be read from stable storage once at boot
697 time, if it is read into a system-wide shared volatile store (and 570 time, if it is read into a system-wide shared volatile store (and
@@ -708,7 +581,7 @@ Table of Contents
708 sequence to a random value, then instead of keeping it in stable 581 sequence to a random value, then instead of keeping it in stable
709 store, the current node ID may be returned. 582 store, the current node ID may be returned.
710 583
711<span class="h5"><a name="section-4.2.1.2">4.2.1.2</a>. System Clock Resolution</span> 5844.2.1.2. System Clock Resolution
712 585
713 The timestamp is generated from the system time, whose resolution may 586 The timestamp is generated from the system time, whose resolution may
714 be less than the resolution of the UUID timestamp. 587 be less than the resolution of the UUID timestamp.
@@ -733,7 +606,7 @@ Table of Contents
733 will permit higher speed allocation by making multiple UUIDs 606 will permit higher speed allocation by making multiple UUIDs
734 potentially available for each time stamp value. 607 potentially available for each time stamp value.
735 608
736<span class="h5"><a name="section-4.2.1.3">4.2.1.3</a>. Writing Stable Storage</span> 6094.2.1.3. Writing Stable Storage
737 610
738 The state does not always need to be written to stable store every 611 The state does not always need to be written to stable store every
739 time a UUID is generated. The timestamp in the stable store can be 612 time a UUID is generated. The timestamp in the stable store can be
@@ -742,9 +615,9 @@ Table of Contents
742 615
743 616
744 617
745<span class="grey">Leach, et al. Standards Track [Page 11]</span> 618Leach, et al. Standards Track [Page 11]
746</pre><pre class='newpage'><a name="page-12" id="page-12" href="#page-12" class="invisible"> </a> 619
747<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 620RFC 4122 A UUID URN Namespace July 2005
748 621
749 622
750 the clock sequence and node ID remain unchanged, only the shared 623 the clock sequence and node ID remain unchanged, only the shared
@@ -753,19 +626,19 @@ Table of Contents
753 typical time it takes the system to reboot, a crash will not cause a 626 typical time it takes the system to reboot, a crash will not cause a
754 reinitialization of the clock sequence. 627 reinitialization of the clock sequence.
755 628
756<span class="h5"><a name="section-4.2.1.4">4.2.1.4</a>. Sharing State Across Processes</span> 6294.2.1.4. Sharing State Across Processes
757 630
758 If it is too expensive to access shared state each time a UUID is 631 If it is too expensive to access shared state each time a UUID is
759 generated, then the system-wide generator can be implemented to 632 generated, then the system-wide generator can be implemented to
760 allocate a block of time stamps each time it is called; a per- 633 allocate a block of time stamps each time it is called; a per-
761 process generator can allocate from that block until it is exhausted. 634 process generator can allocate from that block until it is exhausted.
762 635
763<span class="h4"><a name="section-4.2.2">4.2.2</a>. Generation Details</span> 6364.2.2. Generation Details
764 637
765 Version 1 UUIDs are generated according to the following algorithm: 638 Version 1 UUIDs are generated according to the following algorithm:
766 639
767 o Determine the values for the UTC-based timestamp and clock 640 o Determine the values for the UTC-based timestamp and clock
768 sequence to be used in the UUID, as described in <a href="#section-4.2.1">Section 4.2.1</a>. 641 sequence to be used in the UUID, as described in Section 4.2.1.
769 642
770 o For the purposes of this algorithm, consider the timestamp to be a 643 o For the purposes of this algorithm, consider the timestamp to be a
771 60-bit unsigned integer and the clock sequence to be a 14-bit 644 60-bit unsigned integer and the clock sequence to be a 14-bit
@@ -798,9 +671,9 @@ Table of Contents
798 671
799 672
800 673
801<span class="grey">Leach, et al. Standards Track [Page 12]</span> 674Leach, et al. Standards Track [Page 12]
802</pre><pre class='newpage'><a name="page-13" id="page-13" href="#page-13" class="invisible"> </a> 675
803<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 676RFC 4122 A UUID URN Namespace July 2005
804 677
805 678
806 o Set the 6 least significant bits (bits zero through 5) of the 679 o Set the 6 least significant bits (bits zero through 5) of the
@@ -814,7 +687,7 @@ Table of Contents
814 o Set the node field to the 48-bit IEEE address in the same order of 687 o Set the node field to the 48-bit IEEE address in the same order of
815 significance as the address. 688 significance as the address.
816 689
817<span class="h3"><a name="section-4.3">4.3</a>. Algorithm for Creating a Name-Based UUID</span> 6904.3. Algorithm for Creating a Name-Based UUID
818 691
819 The version 3 or 5 UUID is meant for generating UUIDs from "names" 692 The version 3 or 5 UUID is meant for generating UUIDs from "names"
820 that are drawn from, and unique within, some "name space". The 693 that are drawn from, and unique within, some "name space". The
@@ -845,18 +718,18 @@ Table of Contents
845 as follows: 718 as follows:
846 719
847 o Allocate a UUID to use as a "name space ID" for all UUIDs 720 o Allocate a UUID to use as a "name space ID" for all UUIDs
848 generated from names in that name space; see <a href="#appendix-C">Appendix C</a> for some 721 generated from names in that name space; see Appendix C for some
849 pre-defined values. 722 pre-defined values.
850 723
851 o Choose either MD5 [<a href="#ref-4" title='"The MD5 Message-Digest Algorithm "'>4</a>] or SHA-1 [<a href="#ref-8" title='"Secure Hash Standard"'>8</a>] as the hash algorithm; If 724 o Choose either MD5 [4] or SHA-1 [8] as the hash algorithm; If
852 backward compatibility is not an issue, SHA-1 is preferred. 725 backward compatibility is not an issue, SHA-1 is preferred.
853 726
854 727
855 728
856 729
857<span class="grey">Leach, et al. Standards Track [Page 13]</span> 730Leach, et al. Standards Track [Page 13]
858</pre><pre class='newpage'><a name="page-14" id="page-14" href="#page-14" class="invisible"> </a> 731
859<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 732RFC 4122 A UUID URN Namespace July 2005
860 733
861 734
862 o Convert the name to a canonical sequence of octets (as defined by 735 o Convert the name to a canonical sequence of octets (as defined by
@@ -876,7 +749,7 @@ Table of Contents
876 749
877 o Set the four most significant bits (bits 12 through 15) of the 750 o Set the four most significant bits (bits 12 through 15) of the
878 time_hi_and_version field to the appropriate 4-bit version number 751 time_hi_and_version field to the appropriate 4-bit version number
879 from <a href="#section-4.1.3">Section 4.1.3</a>. 752 from Section 4.1.3.
880 753
881 o Set the clock_seq_hi_and_reserved field to octet 8 of the hash. 754 o Set the clock_seq_hi_and_reserved field to octet 8 of the hash.
882 755
@@ -890,7 +763,7 @@ Table of Contents
890 763
891 o Convert the resulting UUID to local byte order. 764 o Convert the resulting UUID to local byte order.
892 765
893<span class="h3"><a name="section-4.4">4.4</a>. Algorithms for Creating a UUID from Truly Random or</span> 7664.4. Algorithms for Creating a UUID from Truly Random or
894 Pseudo-Random Numbers 767 Pseudo-Random Numbers
895 768
896 The version 4 UUID is meant for generating UUIDs from truly-random or 769 The version 4 UUID is meant for generating UUIDs from truly-random or
@@ -903,28 +776,28 @@ Table of Contents
903 776
904 o Set the four most significant bits (bits 12 through 15) of the 777 o Set the four most significant bits (bits 12 through 15) of the
905 time_hi_and_version field to the 4-bit version number from 778 time_hi_and_version field to the 4-bit version number from
906 <a href="#section-4.1.3">Section 4.1.3</a>. 779 Section 4.1.3.
907 780
908 o Set all the other bits to randomly (or pseudo-randomly) chosen 781 o Set all the other bits to randomly (or pseudo-randomly) chosen
909 values. 782 values.
910 783
911 784
912 785
913<span class="grey">Leach, et al. Standards Track [Page 14]</span> 786Leach, et al. Standards Track [Page 14]
914</pre><pre class='newpage'><a name="page-15" id="page-15" href="#page-15" class="invisible"> </a> 787
915<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 788RFC 4122 A UUID URN Namespace July 2005
916 789
917 790
918 See <a href="#section-4.5">Section 4.5</a> for a discussion on random numbers. 791 See Section 4.5 for a discussion on random numbers.
919 792
920<span class="h3"><a name="section-4.5">4.5</a>. Node IDs that Do Not Identify the Host</span> 7934.5. Node IDs that Do Not Identify the Host
921 794
922 This section describes how to generate a version 1 UUID if an IEEE 795 This section describes how to generate a version 1 UUID if an IEEE
923 802 address is not available, or its use is not desired. 796 802 address is not available, or its use is not desired.
924 797
925 One approach is to contact the IEEE and get a separate block of 798 One approach is to contact the IEEE and get a separate block of
926 addresses. At the time of writing, the application could be found at 799 addresses. At the time of writing, the application could be found at
927 &lt;<a href="http://standards.ieee.org/regauth/oui/pilot-ind.html">http://standards.ieee.org/regauth/oui/pilot-ind.html</a>&gt;, and the cost 800 <http://standards.ieee.org/regauth/oui/pilot-ind.html>, and the cost
928 was US$550. 801 was US$550.
929 802
930 A better solution is to obtain a 47-bit cryptographic quality random 803 A better solution is to obtain a 47-bit cryptographic quality random
@@ -942,7 +815,7 @@ Table of Contents
942 correct local/global bit. 815 correct local/global bit.
943 816
944 Advice on generating cryptographic-quality random numbers can be 817 Advice on generating cryptographic-quality random numbers can be
945 found in <a href="./rfc1750">RFC1750</a> [<a href="#ref-5" title='"Randomness Requirements for Security"'>5</a>]. 818 found in RFC1750 [5].
946 819
947 In addition, items such as the computer's name and the name of the 820 In addition, items such as the computer's name and the name of the
948 operating system, while not strictly speaking random, will help 821 operating system, while not strictly speaking random, will help
@@ -952,11 +825,11 @@ Table of Contents
952 specific, because both the data available and the functions to obtain 825 specific, because both the data available and the functions to obtain
953 them are often very system specific. A generic approach, however, is 826 them are often very system specific. A generic approach, however, is
954 to accumulate as many sources as possible into a buffer, use a 827 to accumulate as many sources as possible into a buffer, use a
955 message digest such as MD5 [<a href="#ref-4" title='"The MD5 Message-Digest Algorithm "'>4</a>] or SHA-1 [<a href="#ref-8" title='"Secure Hash Standard"'>8</a>], take an arbitrary 6 828 message digest such as MD5 [4] or SHA-1 [8], take an arbitrary 6
956 bytes from the hash value, and set the multicast bit as described 829 bytes from the hash value, and set the multicast bit as described
957 above. 830 above.
958 831
959<span class="h2"><a name="section-5">5</a>. Community Considerations</span> 8325. Community Considerations
960 833
961 The use of UUIDs is extremely pervasive in computing. They comprise 834 The use of UUIDs is extremely pervasive in computing. They comprise
962 the core identifier infrastructure for many operating systems 835 the core identifier infrastructure for many operating systems
@@ -966,15 +839,15 @@ Table of Contents
966 839
967 840
968 841
969<span class="grey">Leach, et al. Standards Track [Page 15]</span> 842Leach, et al. Standards Track [Page 15]
970</pre><pre class='newpage'><a name="page-16" id="page-16" href="#page-16" class="invisible"> </a> 843
971<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 844RFC 4122 A UUID URN Namespace July 2005
972 845
973 846
974 This specification attempts to standardize that practice as openly as 847 This specification attempts to standardize that practice as openly as
975 possible and in a way that attempts to benefit the entire Internet. 848 possible and in a way that attempts to benefit the entire Internet.
976 849
977<span class="h2"><a name="section-6">6</a>. Security Considerations</span> 8506. Security Considerations
978 851
979 Do not assume that UUIDs are hard to guess; they should not be used 852 Do not assume that UUIDs are hard to guess; they should not be used
980 as security capabilities (identifiers whose mere possession grants 853 as security capabilities (identifiers whose mere possession grants
@@ -990,7 +863,7 @@ Table of Contents
990 be willing to rely on the random number source at all hosts. If this 863 be willing to rely on the random number source at all hosts. If this
991 is not feasible, the namespace variant should be used. 864 is not feasible, the namespace variant should be used.
992 865
993<span class="h2"><a name="section-7">7</a>. Acknowledgments</span> 8667. Acknowledgments
994 867
995 This document draws heavily on the OSF DCE specification for UUIDs. 868 This document draws heavily on the OSF DCE specification for UUIDs.
996 Ted Ts'o provided helpful comments, especially on the byte ordering 869 Ted Ts'o provided helpful comments, especially on the byte ordering
@@ -1002,42 +875,42 @@ Table of Contents
1002 S. Engelschall, John Larmouth, and Paul Thorpe. Professor Larmouth 875 S. Engelschall, John Larmouth, and Paul Thorpe. Professor Larmouth
1003 was also invaluable in achieving coordination with ISO/IEC. 876 was also invaluable in achieving coordination with ISO/IEC.
1004 877
1005<span class="h2"><a name="section-8">8</a>. Normative References</span> 8788. Normative References
1006 879
1007 [<a name="ref-1" id="ref-1">1</a>] Zahn, L., Dineen, T., and P. Leach, "Network Computing 880 [1] Zahn, L., Dineen, T., and P. Leach, "Network Computing
1008 Architecture", ISBN 0-13-611674-4, January 1990. 881 Architecture", ISBN 0-13-611674-4, January 1990.
1009 882
1010 [<a name="ref-2" id="ref-2">2</a>] "DCE: Remote Procedure Call", Open Group CAE Specification C309, 883 [2] "DCE: Remote Procedure Call", Open Group CAE Specification C309,
1011 ISBN 1-85912-041-5, August 1994. 884 ISBN 1-85912-041-5, August 1994.
1012 885
1013 [<a name="ref-3" id="ref-3">3</a>] ISO/IEC 9834-8:2004 Information Technology, "Procedures for the 886 [3] ISO/IEC 9834-8:2004 Information Technology, "Procedures for the
1014 operation of OSI Registration Authorities: Generation and 887 operation of OSI Registration Authorities: Generation and
1015 registration of Universally Unique Identifiers (UUIDs) and their 888 registration of Universally Unique Identifiers (UUIDs) and their
1016 use as ASN.1 Object Identifier components" ITU-T Rec. X.667, 889 use as ASN.1 Object Identifier components" ITU-T Rec. X.667,
1017 2004. 890 2004.
1018 891
1019 [<a name="ref-4" id="ref-4">4</a>] Rivest, R., "The MD5 Message-Digest Algorithm ", <a href="./rfc1321">RFC 1321</a>, April 892 [4] Rivest, R., "The MD5 Message-Digest Algorithm ", RFC 1321, April
1020 1992. 893 1992.
1021 894
1022 895
1023 896
1024 897
1025<span class="grey">Leach, et al. Standards Track [Page 16]</span> 898Leach, et al. Standards Track [Page 16]
1026</pre><pre class='newpage'><a name="page-17" id="page-17" href="#page-17" class="invisible"> </a> 899
1027<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 900RFC 4122 A UUID URN Namespace July 2005
1028 901
1029 902
1030 [<a name="ref-5" id="ref-5">5</a>] Eastlake, D., 3rd, Schiller, J., and S. Crocker, "Randomness 903 [5] Eastlake, D., 3rd, Schiller, J., and S. Crocker, "Randomness
1031 Requirements for Security", <a href="./bcp106">BCP 106</a>, <a href="./rfc4086">RFC 4086</a>, June 2005. 904 Requirements for Security", BCP 106, RFC 4086, June 2005.
1032 905
1033 [<a name="ref-6" id="ref-6">6</a>] Moats, R., "URN Syntax", <a href="./rfc2141">RFC 2141</a>, May 1997. 906 [6] Moats, R., "URN Syntax", RFC 2141, May 1997.
1034 907
1035 [<a name="ref-7" id="ref-7">7</a>] Crocker, D. and P. Overell, "Augmented BNF for Syntax 908 [7] Crocker, D. and P. Overell, "Augmented BNF for Syntax
1036 Specifications: ABNF", <a href="./rfc2234">RFC 2234</a>, November 1997. 909 Specifications: ABNF", RFC 2234, November 1997.
1037 910
1038 [<a name="ref-8" id="ref-8">8</a>] National Institute of Standards and Technology, "Secure Hash 911 [8] National Institute of Standards and Technology, "Secure Hash
1039 Standard", FIPS PUB 180-1, April 1995, 912 Standard", FIPS PUB 180-1, April 1995,
1040 &lt;<a href="http://www.itl.nist.gov/fipspubs/fip180-1.htm">http://www.itl.nist.gov/fipspubs/fip180-1.htm</a>&gt;. 913 <http://www.itl.nist.gov/fipspubs/fip180-1.htm>.
1041 914
1042 915
1043 916
@@ -1078,12 +951,12 @@ Table of Contents
1078 951
1079 952
1080 953
1081<span class="grey">Leach, et al. Standards Track [Page 17]</span> 954Leach, et al. Standards Track [Page 17]
1082</pre><pre class='newpage'><a name="page-18" id="page-18" href="#page-18" class="invisible"> </a> 955
1083<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 956RFC 4122 A UUID URN Namespace July 2005
1084 957
1085 958
1086<span class="h2"><a name="appendix-A">Appendix A</a>. <a href="#appendix-A">Appendix A</a> - Sample Implementation</span> 959Appendix A. Appendix A - Sample Implementation
1087 960
1088 This implementation consists of 5 files: uuid.h, uuid.c, sysdep.h, 961 This implementation consists of 5 files: uuid.h, uuid.c, sysdep.h,
1089 sysdep.c and utest.c. The uuid.* files are the system independent 962 sysdep.c and utest.c. The uuid.* files are the system independent
@@ -1100,7 +973,7 @@ copyrt.h
1100 973
1101/* 974/*
1102** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. 975** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
1103** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &amp; 976** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
1104** Digital Equipment Corporation, Maynard, Mass. 977** Digital Equipment Corporation, Maynard, Mass.
1105** Copyright (c) 1998 Microsoft. 978** Copyright (c) 1998 Microsoft.
1106** To anyone who acknowledges that this file is provided "AS IS" 979** To anyone who acknowledges that this file is provided "AS IS"
@@ -1134,9 +1007,9 @@ typedef struct {
1134 1007
1135 1008
1136 1009
1137<span class="grey">Leach, et al. Standards Track [Page 18]</span> 1010Leach, et al. Standards Track [Page 18]
1138</pre><pre class='newpage'><a name="page-19" id="page-19" href="#page-19" class="invisible"> </a> 1011
1139<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1012RFC 4122 A UUID URN Namespace July 2005
1140 1013
1141 1014
1142/* uuid_create -- generate a UUID */ 1015/* uuid_create -- generate a UUID */
@@ -1173,10 +1046,10 @@ int uuid_compare(uuid_t *u1, uuid_t *u2);
1173uuid.c 1046uuid.c
1174 1047
1175#include "copyrt.h" 1048#include "copyrt.h"
1176#include &lt;string.h&gt; 1049#include <string.h>
1177#include &lt;stdio.h&gt; 1050#include <stdio.h>
1178#include &lt;stdlib.h&gt; 1051#include <stdlib.h>
1179#include &lt;time.h&gt; 1052#include <time.h>
1180#include "sysdep.h" 1053#include "sysdep.h"
1181#include "uuid.h" 1054#include "uuid.h"
1182 1055
@@ -1190,9 +1063,9 @@ static void format_uuid_v1(uuid_t *uuid, unsigned16 clockseq,
1190 1063
1191 1064
1192 1065
1193<span class="grey">Leach, et al. Standards Track [Page 19]</span> 1066Leach, et al. Standards Track [Page 19]
1194</pre><pre class='newpage'><a name="page-20" id="page-20" href="#page-20" class="invisible"> </a> 1067
1195<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1068RFC 4122 A UUID URN Namespace July 2005
1196 1069
1197 1070
1198static void format_uuid_v3or5(uuid_t *uuid, unsigned char hash[16], 1071static void format_uuid_v3or5(uuid_t *uuid, unsigned char hash[16],
@@ -1212,15 +1085,15 @@ int uuid_create(uuid_t *uuid)
1212 /* acquire system-wide lock so we're alone */ 1085 /* acquire system-wide lock so we're alone */
1213 LOCK; 1086 LOCK;
1214 /* get time, node ID, saved state from non-volatile storage */ 1087 /* get time, node ID, saved state from non-volatile storage */
1215 get_current_time(&amp;timestamp); 1088 get_current_time(&timestamp);
1216 get_ieee_node_identifier(&amp;node); 1089 get_ieee_node_identifier(&node);
1217 f = read_state(&amp;clockseq, &amp;last_time, &amp;last_node); 1090 f = read_state(&clockseq, &last_time, &last_node);
1218 1091
1219 /* if no NV state, or if clock went backwards, or node ID 1092 /* if no NV state, or if clock went backwards, or node ID
1220 changed (e.g., new network card) change clockseq */ 1093 changed (e.g., new network card) change clockseq */
1221 if (!f || memcmp(&amp;node, &amp;last_node, sizeof node)) 1094 if (!f || memcmp(&node, &last_node, sizeof node))
1222 clockseq = true_random(); 1095 clockseq = true_random();
1223 else if (timestamp &lt; last_time) 1096 else if (timestamp < last_time)
1224 clockseq++; 1097 clockseq++;
1225 1098
1226 /* save the state for next time */ 1099 /* save the state for next time */
@@ -1240,23 +1113,23 @@ void format_uuid_v1(uuid_t* uuid, unsigned16 clock_seq,
1240{ 1113{
1241 /* Construct a version 1 uuid with the information we've gathered 1114 /* Construct a version 1 uuid with the information we've gathered
1242 plus a few constants. */ 1115 plus a few constants. */
1243 uuid-&gt;time_low = (unsigned long)(timestamp &amp; 0xFFFFFFFF); 1116 uuid->time_low = (unsigned long)(timestamp & 0xFFFFFFFF);
1244 uuid-&gt;time_mid = (unsigned short)((timestamp &gt;&gt; 32) &amp; 0xFFFF); 1117 uuid->time_mid = (unsigned short)((timestamp >> 32) & 0xFFFF);
1245 uuid-&gt;time_hi_and_version = 1118 uuid->time_hi_and_version =
1246 1119
1247 1120
1248 1121
1249<span class="grey">Leach, et al. Standards Track [Page 20]</span> 1122Leach, et al. Standards Track [Page 20]
1250</pre><pre class='newpage'><a name="page-21" id="page-21" href="#page-21" class="invisible"> </a> 1123
1251<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1124RFC 4122 A UUID URN Namespace July 2005
1252 1125
1253 1126
1254 (unsigned short)((timestamp &gt;&gt; 48) &amp; 0x0FFF); 1127 (unsigned short)((timestamp >> 48) & 0x0FFF);
1255 uuid-&gt;time_hi_and_version |= (1 &lt;&lt; 12); 1128 uuid->time_hi_and_version |= (1 << 12);
1256 uuid-&gt;clock_seq_low = clock_seq &amp; 0xFF; 1129 uuid->clock_seq_low = clock_seq & 0xFF;
1257 uuid-&gt;clock_seq_hi_and_reserved = (clock_seq &amp; 0x3F00) &gt;&gt; 8; 1130 uuid->clock_seq_hi_and_reserved = (clock_seq & 0x3F00) >> 8;
1258 uuid-&gt;clock_seq_hi_and_reserved |= 0x80; 1131 uuid->clock_seq_hi_and_reserved |= 0x80;
1259 memcpy(&amp;uuid-&gt;node, &amp;node, sizeof uuid-&gt;node); 1132 memcpy(&uuid->node, &node, sizeof uuid->node);
1260} 1133}
1261 1134
1262/* data type for UUID generator persistent state */ 1135/* data type for UUID generator persistent state */
@@ -1280,7 +1153,7 @@ int read_state(unsigned16 *clockseq, uuid_time_t *timestamp,
1280 fp = fopen("state", "rb"); 1153 fp = fopen("state", "rb");
1281 if (fp == NULL) 1154 if (fp == NULL)
1282 return 0; 1155 return 0;
1283 fread(&amp;st, sizeof st, 1, fp); 1156 fread(&st, sizeof st, 1, fp);
1284 fclose(fp); 1157 fclose(fp);
1285 inited = 1; 1158 inited = 1;
1286 } 1159 }
@@ -1302,9 +1175,9 @@ void write_state(unsigned16 clockseq, uuid_time_t timestamp,
1302 1175
1303 1176
1304 1177
1305<span class="grey">Leach, et al. Standards Track [Page 21]</span> 1178Leach, et al. Standards Track [Page 21]
1306</pre><pre class='newpage'><a name="page-22" id="page-22" href="#page-22" class="invisible"> </a> 1179
1307<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1180RFC 4122 A UUID URN Namespace July 2005
1308 1181
1309 1182
1310 if (!inited) { 1183 if (!inited) {
@@ -1316,9 +1189,9 @@ void write_state(unsigned16 clockseq, uuid_time_t timestamp,
1316 st.cs = clockseq; 1189 st.cs = clockseq;
1317 st.ts = timestamp; 1190 st.ts = timestamp;
1318 st.node = node; 1191 st.node = node;
1319 if (timestamp &gt;= next_save) { 1192 if (timestamp >= next_save) {
1320 fp = fopen("state", "wb"); 1193 fp = fopen("state", "wb");
1321 fwrite(&amp;st, sizeof st, 1, fp); 1194 fwrite(&st, sizeof st, 1, fp);
1322 fclose(fp); 1195 fclose(fp);
1323 /* schedule next save for 10 seconds from now */ 1196 /* schedule next save for 10 seconds from now */
1324 next_save = timestamp + (10 * 10 * 1000 * 1000); 1197 next_save = timestamp + (10 * 10 * 1000 * 1000);
@@ -1336,13 +1209,13 @@ void get_current_time(uuid_time_t *timestamp)
1336 uuid_time_t time_now; 1209 uuid_time_t time_now;
1337 1210
1338 if (!inited) { 1211 if (!inited) {
1339 get_system_time(&amp;time_now); 1212 get_system_time(&time_now);
1340 uuids_this_tick = UUIDS_PER_TICK; 1213 uuids_this_tick = UUIDS_PER_TICK;
1341 inited = 1; 1214 inited = 1;
1342 } 1215 }
1343 1216
1344 for ( ; ; ) { 1217 for ( ; ; ) {
1345 get_system_time(&amp;time_now); 1218 get_system_time(&time_now);
1346 1219
1347 /* if clock reading changed since last UUID generated, */ 1220 /* if clock reading changed since last UUID generated, */
1348 if (time_last != time_now) { 1221 if (time_last != time_now) {
@@ -1351,16 +1224,16 @@ void get_current_time(uuid_time_t *timestamp)
1351 time_last = time_now; 1224 time_last = time_now;
1352 break; 1225 break;
1353 } 1226 }
1354 if (uuids_this_tick &lt; UUIDS_PER_TICK) { 1227 if (uuids_this_tick < UUIDS_PER_TICK) {
1355 uuids_this_tick++; 1228 uuids_this_tick++;
1356 break; 1229 break;
1357 } 1230 }
1358 1231
1359 1232
1360 1233
1361<span class="grey">Leach, et al. Standards Track [Page 22]</span> 1234Leach, et al. Standards Track [Page 22]
1362</pre><pre class='newpage'><a name="page-23" id="page-23" href="#page-23" class="invisible"> </a> 1235
1363<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1236RFC 4122 A UUID URN Namespace July 2005
1364 1237
1365 1238
1366 /* going too fast for our clock; spin */ 1239 /* going too fast for our clock; spin */
@@ -1377,10 +1250,10 @@ static unsigned16 true_random(void)
1377 uuid_time_t time_now; 1250 uuid_time_t time_now;
1378 1251
1379 if (!inited) { 1252 if (!inited) {
1380 get_system_time(&amp;time_now); 1253 get_system_time(&time_now);
1381 time_now = time_now / UUIDS_PER_TICK; 1254 time_now = time_now / UUIDS_PER_TICK;
1382 srand((unsigned int) 1255 srand((unsigned int)
1383 (((time_now &gt;&gt; 32) ^ time_now) &amp; 0xffffffff)); 1256 (((time_now >> 32) ^ time_now) & 0xffffffff));
1384 inited = 1; 1257 inited = 1;
1385 } 1258 }
1386 1259
@@ -1403,10 +1276,10 @@ void uuid_create_md5_from_name(uuid_t *uuid, uuid_t nsid, void *name,
1403 net_nsid.time_mid = htons(net_nsid.time_mid); 1276 net_nsid.time_mid = htons(net_nsid.time_mid);
1404 net_nsid.time_hi_and_version = htons(net_nsid.time_hi_and_version); 1277 net_nsid.time_hi_and_version = htons(net_nsid.time_hi_and_version);
1405 1278
1406 MD5Init(&amp;c); 1279 MD5Init(&c);
1407 MD5Update(&amp;c, &amp;net_nsid, sizeof net_nsid); 1280 MD5Update(&c, &net_nsid, sizeof net_nsid);
1408 MD5Update(&amp;c, name, namelen); 1281 MD5Update(&c, name, namelen);
1409 MD5Final(hash, &amp;c); 1282 MD5Final(hash, &c);
1410 1283
1411 /* the hash is in network byte order at this point */ 1284 /* the hash is in network byte order at this point */
1412 format_uuid_v3or5(uuid, hash, 3); 1285 format_uuid_v3or5(uuid, hash, 3);
@@ -1414,9 +1287,9 @@ void uuid_create_md5_from_name(uuid_t *uuid, uuid_t nsid, void *name,
1414 1287
1415 1288
1416 1289
1417<span class="grey">Leach, et al. Standards Track [Page 23]</span> 1290Leach, et al. Standards Track [Page 23]
1418</pre><pre class='newpage'><a name="page-24" id="page-24" href="#page-24" class="invisible"> </a> 1291
1419<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1292RFC 4122 A UUID URN Namespace July 2005
1420 1293
1421 1294
1422void uuid_create_sha1_from_name(uuid_t *uuid, uuid_t nsid, void *name, 1295void uuid_create_sha1_from_name(uuid_t *uuid, uuid_t nsid, void *name,
@@ -1433,10 +1306,10 @@ void uuid_create_sha1_from_name(uuid_t *uuid, uuid_t nsid, void *name,
1433 net_nsid.time_mid = htons(net_nsid.time_mid); 1306 net_nsid.time_mid = htons(net_nsid.time_mid);
1434 net_nsid.time_hi_and_version = htons(net_nsid.time_hi_and_version); 1307 net_nsid.time_hi_and_version = htons(net_nsid.time_hi_and_version);
1435 1308
1436 SHA1_Init(&amp;c); 1309 SHA1_Init(&c);
1437 SHA1_Update(&amp;c, &amp;net_nsid, sizeof net_nsid); 1310 SHA1_Update(&c, &net_nsid, sizeof net_nsid);
1438 SHA1_Update(&amp;c, name, namelen); 1311 SHA1_Update(&c, name, namelen);
1439 SHA1_Final(hash, &amp;c); 1312 SHA1_Final(hash, &c);
1440 1313
1441 /* the hash is in network byte order at this point */ 1314 /* the hash is in network byte order at this point */
1442 format_uuid_v3or5(uuid, hash, 5); 1315 format_uuid_v3or5(uuid, hash, 5);
@@ -1448,40 +1321,40 @@ void format_uuid_v3or5(uuid_t *uuid, unsigned char hash[16], int v)
1448{ 1321{
1449 /* convert UUID to local byte order */ 1322 /* convert UUID to local byte order */
1450 memcpy(uuid, hash, sizeof *uuid); 1323 memcpy(uuid, hash, sizeof *uuid);
1451 uuid-&gt;time_low = ntohl(uuid-&gt;time_low); 1324 uuid->time_low = ntohl(uuid->time_low);
1452 uuid-&gt;time_mid = ntohs(uuid-&gt;time_mid); 1325 uuid->time_mid = ntohs(uuid->time_mid);
1453 uuid-&gt;time_hi_and_version = ntohs(uuid-&gt;time_hi_and_version); 1326 uuid->time_hi_and_version = ntohs(uuid->time_hi_and_version);
1454 1327
1455 /* put in the variant and version bits */ 1328 /* put in the variant and version bits */
1456 uuid-&gt;time_hi_and_version &amp;= 0x0FFF; 1329 uuid->time_hi_and_version &= 0x0FFF;
1457 uuid-&gt;time_hi_and_version |= (v &lt;&lt; 12); 1330 uuid->time_hi_and_version |= (v << 12);
1458 uuid-&gt;clock_seq_hi_and_reserved &amp;= 0x3F; 1331 uuid->clock_seq_hi_and_reserved &= 0x3F;
1459 uuid-&gt;clock_seq_hi_and_reserved |= 0x80; 1332 uuid->clock_seq_hi_and_reserved |= 0x80;
1460} 1333}
1461 1334
1462/* uuid_compare -- Compare two UUID's "lexically" and return */ 1335/* uuid_compare -- Compare two UUID's "lexically" and return */
1463#define CHECK(f1, f2) if (f1 != f2) return f1 &lt; f2 ? -1 : 1; 1336#define CHECK(f1, f2) if (f1 != f2) return f1 < f2 ? -1 : 1;
1464int uuid_compare(uuid_t *u1, uuid_t *u2) 1337int uuid_compare(uuid_t *u1, uuid_t *u2)
1465{ 1338{
1466 int i; 1339 int i;
1467 1340
1468 CHECK(u1-&gt;time_low, u2-&gt;time_low); 1341 CHECK(u1->time_low, u2->time_low);
1469 CHECK(u1-&gt;time_mid, u2-&gt;time_mid); 1342 CHECK(u1->time_mid, u2->time_mid);
1470 1343
1471 1344
1472 1345
1473<span class="grey">Leach, et al. Standards Track [Page 24]</span> 1346Leach, et al. Standards Track [Page 24]
1474</pre><pre class='newpage'><a name="page-25" id="page-25" href="#page-25" class="invisible"> </a> 1347
1475<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1348RFC 4122 A UUID URN Namespace July 2005
1476 1349
1477 1350
1478 CHECK(u1-&gt;time_hi_and_version, u2-&gt;time_hi_and_version); 1351 CHECK(u1->time_hi_and_version, u2->time_hi_and_version);
1479 CHECK(u1-&gt;clock_seq_hi_and_reserved, u2-&gt;clock_seq_hi_and_reserved); 1352 CHECK(u1->clock_seq_hi_and_reserved, u2->clock_seq_hi_and_reserved);
1480 CHECK(u1-&gt;clock_seq_low, u2-&gt;clock_seq_low) 1353 CHECK(u1->clock_seq_low, u2->clock_seq_low)
1481 for (i = 0; i &lt; 6; i++) { 1354 for (i = 0; i < 6; i++) {
1482 if (u1-&gt;node[i] &lt; u2-&gt;node[i]) 1355 if (u1->node[i] < u2->node[i])
1483 return -1; 1356 return -1;
1484 if (u1-&gt;node[i] &gt; u2-&gt;node[i]) 1357 if (u1->node[i] > u2->node[i])
1485 return 1; 1358 return 1;
1486 } 1359 }
1487 return 0; 1360 return 0;
@@ -1496,15 +1369,15 @@ sysdep.h
1496#define WININC 0 1369#define WININC 0
1497 1370
1498#ifdef WININC 1371#ifdef WININC
1499#include &lt;windows.h&gt; 1372#include <windows.h>
1500#else 1373#else
1501#include &lt;sys/types.h&gt; 1374#include <sys/types.h>
1502#include &lt;sys/time.h&gt; 1375#include <sys/time.h>
1503#include &lt;sys/sysinfo.h&gt; 1376#include <sys/sysinfo.h>
1504#endif 1377#endif
1505 1378
1506#include "global.h" 1379#include "global.h"
1507/* change to point to where MD5 .h's live; <a href="./rfc1321">RFC 1321</a> has sample 1380/* change to point to where MD5 .h's live; RFC 1321 has sample
1508 implementation */ 1381 implementation */
1509#include "md5.h" 1382#include "md5.h"
1510 1383
@@ -1526,9 +1399,9 @@ typedef unsigned char byte;
1526 1399
1527 1400
1528 1401
1529<span class="grey">Leach, et al. Standards Track [Page 25]</span> 1402Leach, et al. Standards Track [Page 25]
1530</pre><pre class='newpage'><a name="page-26" id="page-26" href="#page-26" class="invisible"> </a> 1403
1531<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1404RFC 4122 A UUID URN Namespace July 2005
1532 1405
1533 1406
1534#define unsigned64_t unsigned __int64 1407#define unsigned64_t unsigned __int64
@@ -1551,7 +1424,7 @@ void get_random_info(char seed[16]);
1551sysdep.c 1424sysdep.c
1552 1425
1553#include "copyrt.h" 1426#include "copyrt.h"
1554#include &lt;stdio.h&gt; 1427#include <stdio.h>
1555#include "sysdep.h" 1428#include "sysdep.h"
1556 1429
1557/* system dependent call to get IEEE node ID. 1430/* system dependent call to get IEEE node ID.
@@ -1566,25 +1439,25 @@ void get_ieee_node_identifier(uuid_node_t *node)
1566 if (!inited) { 1439 if (!inited) {
1567 fp = fopen("nodeid", "rb"); 1440 fp = fopen("nodeid", "rb");
1568 if (fp) { 1441 if (fp) {
1569 fread(&amp;saved_node, sizeof saved_node, 1, fp); 1442 fread(&saved_node, sizeof saved_node, 1, fp);
1570 fclose(fp); 1443 fclose(fp);
1571 } 1444 }
1572 else { 1445 else {
1573 get_random_info(seed); 1446 get_random_info(seed);
1574 seed[0] |= 0x01; 1447 seed[0] |= 0x01;
1575 memcpy(&amp;saved_node, seed, sizeof saved_node); 1448 memcpy(&saved_node, seed, sizeof saved_node);
1576 fp = fopen("nodeid", "wb"); 1449 fp = fopen("nodeid", "wb");
1577 if (fp) { 1450 if (fp) {
1578 fwrite(&amp;saved_node, sizeof saved_node, 1, fp); 1451 fwrite(&saved_node, sizeof saved_node, 1, fp);
1579 fclose(fp); 1452 fclose(fp);
1580 } 1453 }
1581 } 1454 }
1582 1455
1583 1456
1584 1457
1585<span class="grey">Leach, et al. Standards Track [Page 26]</span> 1458Leach, et al. Standards Track [Page 26]
1586</pre><pre class='newpage'><a name="page-27" id="page-27" href="#page-27" class="invisible"> </a> 1459
1587<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1460RFC 4122 A UUID URN Namespace July 2005
1588 1461
1589 1462
1590 inited = 1; 1463 inited = 1;
@@ -1606,7 +1479,7 @@ void get_system_time(uuid_time_t *uuid_time)
1606 Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582. 1479 Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
1607 The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec) 1480 The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
1608 + 18 years and 5 leap days. */ 1481 + 18 years and 5 leap days. */
1609 GetSystemTimeAsFileTime((FILETIME *)&amp;time); 1482 GetSystemTimeAsFileTime((FILETIME *)&time);
1610 time.QuadPart += 1483 time.QuadPart +=
1611 1484
1612 (unsigned __int64) (1000*1000*10) // seconds 1485 (unsigned __int64) (1000*1000*10) // seconds
@@ -1615,7 +1488,7 @@ void get_system_time(uuid_time_t *uuid_time)
1615 *uuid_time = time.QuadPart; 1488 *uuid_time = time.QuadPart;
1616} 1489}
1617 1490
1618/* Sample code, not for use in production; see <a href="./rfc1750">RFC 1750</a> */ 1491/* Sample code, not for use in production; see RFC 1750 */
1619void get_random_info(char seed[16]) 1492void get_random_info(char seed[16])
1620{ 1493{
1621 MD5_CTX c; 1494 MD5_CTX c;
@@ -1629,24 +1502,24 @@ void get_random_info(char seed[16])
1629 char hostname[MAX_COMPUTERNAME_LENGTH + 1]; 1502 char hostname[MAX_COMPUTERNAME_LENGTH + 1];
1630 } r; 1503 } r;
1631 1504
1632 MD5Init(&amp;c); 1505 MD5Init(&c);
1633 GlobalMemoryStatus(&amp;r.m); 1506 GlobalMemoryStatus(&r.m);
1634 GetSystemInfo(&amp;r.s); 1507 GetSystemInfo(&r.s);
1635 GetSystemTimeAsFileTime(&amp;r.t); 1508 GetSystemTimeAsFileTime(&r.t);
1636 QueryPerformanceCounter(&amp;r.pc); 1509 QueryPerformanceCounter(&r.pc);
1637 r.tc = GetTickCount(); 1510 r.tc = GetTickCount();
1638 1511
1639 1512
1640 1513
1641<span class="grey">Leach, et al. Standards Track [Page 27]</span> 1514Leach, et al. Standards Track [Page 27]
1642</pre><pre class='newpage'><a name="page-28" id="page-28" href="#page-28" class="invisible"> </a> 1515
1643<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1516RFC 4122 A UUID URN Namespace July 2005
1644 1517
1645 1518
1646 r.l = MAX_COMPUTERNAME_LENGTH + 1; 1519 r.l = MAX_COMPUTERNAME_LENGTH + 1;
1647 GetComputerName(r.hostname, &amp;r.l); 1520 GetComputerName(r.hostname, &r.l);
1648 MD5Update(&amp;c, &amp;r, sizeof r); 1521 MD5Update(&c, &r, sizeof r);
1649 MD5Final(seed, &amp;c); 1522 MD5Final(seed, &c);
1650} 1523}
1651 1524
1652#else 1525#else
@@ -1655,7 +1528,7 @@ void get_system_time(uuid_time_t *uuid_time)
1655{ 1528{
1656 struct timeval tp; 1529 struct timeval tp;
1657 1530
1658 gettimeofday(&amp;tp, (struct timezone *)0); 1531 gettimeofday(&tp, (struct timezone *)0);
1659 1532
1660 /* Offset between UUID formatted times and Unix formatted times. 1533 /* Offset between UUID formatted times and Unix formatted times.
1661 UUID UTC base time is October 15, 1582. 1534 UUID UTC base time is October 15, 1582.
@@ -1665,7 +1538,7 @@ void get_system_time(uuid_time_t *uuid_time)
1665 + I64(0x01B21DD213814000); 1538 + I64(0x01B21DD213814000);
1666} 1539}
1667 1540
1668/* Sample code, not for use in production; see <a href="./rfc1750">RFC 1750</a> */ 1541/* Sample code, not for use in production; see RFC 1750 */
1669void get_random_info(char seed[16]) 1542void get_random_info(char seed[16])
1670{ 1543{
1671 MD5_CTX c; 1544 MD5_CTX c;
@@ -1675,12 +1548,12 @@ void get_random_info(char seed[16])
1675 char hostname[257]; 1548 char hostname[257];
1676 } r; 1549 } r;
1677 1550
1678 MD5Init(&amp;c); 1551 MD5Init(&c);
1679 sysinfo(&amp;r.s); 1552 sysinfo(&r.s);
1680 gettimeofday(&amp;r.t, (struct timezone *)0); 1553 gettimeofday(&r.t, (struct timezone *)0);
1681 gethostname(r.hostname, 256); 1554 gethostname(r.hostname, 256);
1682 MD5Update(&amp;c, &amp;r, sizeof r); 1555 MD5Update(&c, &r, sizeof r);
1683 MD5Final(seed, &amp;c); 1556 MD5Final(seed, &c);
1684} 1557}
1685 1558
1686#endif 1559#endif
@@ -1689,14 +1562,14 @@ utest.c
1689 1562
1690#include "copyrt.h" 1563#include "copyrt.h"
1691#include "sysdep.h" 1564#include "sysdep.h"
1692#include &lt;stdio.h&gt; 1565#include <stdio.h>
1693#include "uuid.h" 1566#include "uuid.h"
1694 1567
1695 1568
1696 1569
1697<span class="grey">Leach, et al. Standards Track [Page 28]</span> 1570Leach, et al. Standards Track [Page 28]
1698</pre><pre class='newpage'><a name="page-29" id="page-29" href="#page-29" class="invisible"> </a> 1571
1699<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1572RFC 4122 A UUID URN Namespace July 2005
1700 1573
1701 1574
1702uuid_t NameSpace_DNS = { /* 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */ 1575uuid_t NameSpace_DNS = { /* 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */
@@ -1714,7 +1587,7 @@ void puid(uuid_t u)
1714 printf("%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", u.time_low, u.time_mid, 1587 printf("%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", u.time_low, u.time_mid,
1715 u.time_hi_and_version, u.clock_seq_hi_and_reserved, 1588 u.time_hi_and_version, u.clock_seq_hi_and_reserved,
1716 u.clock_seq_low); 1589 u.clock_seq_low);
1717 for (i = 0; i &lt; 6; i++) 1590 for (i = 0; i < 6; i++)
1718 printf("%2.2x", u.node[i]); 1591 printf("%2.2x", u.node[i]);
1719 printf("\n"); 1592 printf("\n");
1720} 1593}
@@ -1725,20 +1598,20 @@ void main(int argc, char **argv)
1725 uuid_t u; 1598 uuid_t u;
1726 int f; 1599 int f;
1727 1600
1728 uuid_create(&amp;u); 1601 uuid_create(&u);
1729 printf("uuid_create(): "); puid(u); 1602 printf("uuid_create(): "); puid(u);
1730 1603
1731 f = uuid_compare(&amp;u, &amp;u); 1604 f = uuid_compare(&u, &u);
1732 printf("uuid_compare(u,u): %d\n", f); /* should be 0 */ 1605 printf("uuid_compare(u,u): %d\n", f); /* should be 0 */
1733 f = uuid_compare(&amp;u, &amp;NameSpace_DNS); 1606 f = uuid_compare(&u, &NameSpace_DNS);
1734 printf("uuid_compare(u, NameSpace_DNS): %d\n", f); /* s.b. 1 */ 1607 printf("uuid_compare(u, NameSpace_DNS): %d\n", f); /* s.b. 1 */
1735 f = uuid_compare(&amp;NameSpace_DNS, &amp;u); 1608 f = uuid_compare(&NameSpace_DNS, &u);
1736 printf("uuid_compare(NameSpace_DNS, u): %d\n", f); /* s.b. -1 */ 1609 printf("uuid_compare(NameSpace_DNS, u): %d\n", f); /* s.b. -1 */
1737 uuid_create_md5_from_name(&amp;u, NameSpace_DNS, "www.widgets.com", 15); 1610 uuid_create_md5_from_name(&u, NameSpace_DNS, "www.widgets.com", 15);
1738 printf("uuid_create_md5_from_name(): "); puid(u); 1611 printf("uuid_create_md5_from_name(): "); puid(u);
1739} 1612}
1740 1613
1741<span class="h2"><a name="appendix-B">Appendix B</a>. <a href="#appendix-B">Appendix B</a> - Sample Output of utest</span> 1614Appendix B. Appendix B - Sample Output of utest
1742 1615
1743 uuid_create(): 7d444840-9dc0-11d1-b245-5ffdce74fad2 1616 uuid_create(): 7d444840-9dc0-11d1-b245-5ffdce74fad2
1744 uuid_compare(u,u): 0 1617 uuid_compare(u,u): 0
@@ -1750,12 +1623,12 @@ void main(int argc, char **argv)
1750 1623
1751 1624
1752 1625
1753<span class="grey">Leach, et al. Standards Track [Page 29]</span> 1626Leach, et al. Standards Track [Page 29]
1754</pre><pre class='newpage'><a name="page-30" id="page-30" href="#page-30" class="invisible"> </a> 1627
1755<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1628RFC 4122 A UUID URN Namespace July 2005
1756 1629
1757 1630
1758<span class="h2"><a name="appendix-C">Appendix C</a>. <a href="#appendix-C">Appendix C</a> - Some Name Space IDs</span> 1631Appendix C. Appendix C - Some Name Space IDs
1759 1632
1760 This appendix lists the name space IDs for some potentially 1633 This appendix lists the name space IDs for some potentially
1761 interesting name spaces, as initialized C structures and in the 1634 interesting name spaces, as initialized C structures and in the
@@ -1806,9 +1679,9 @@ void main(int argc, char **argv)
1806 1679
1807 1680
1808 1681
1809<span class="grey">Leach, et al. Standards Track [Page 30]</span> 1682Leach, et al. Standards Track [Page 30]
1810</pre><pre class='newpage'><a name="page-31" id="page-31" href="#page-31" class="invisible"> </a> 1683
1811<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1684RFC 4122 A UUID URN Namespace July 2005
1812 1685
1813 1686
1814Authors' Addresses 1687Authors' Addresses
@@ -1832,7 +1705,7 @@ Authors' Addresses
1832 1705
1833 Phone: +1-678-581-9656 1706 Phone: +1-678-581-9656
1834 EMail: michael@refactored-networks.com 1707 EMail: michael@refactored-networks.com
1835 URI: <a href="http://www.refactored-networks.com">http://www.refactored-networks.com</a> 1708 URI: http://www.refactored-networks.com
1836 1709
1837 1710
1838 Rich Salz 1711 Rich Salz
@@ -1843,7 +1716,7 @@ Authors' Addresses
1843 1716
1844 Phone: +1 617-864-0455 1717 Phone: +1 617-864-0455
1845 EMail: rsalz@datapower.com 1718 EMail: rsalz@datapower.com
1846 URI: <a href="http://www.datapower.com">http://www.datapower.com</a> 1719 URI: http://www.datapower.com
1847 1720
1848 1721
1849 1722
@@ -1862,9 +1735,9 @@ Authors' Addresses
1862 1735
1863 1736
1864 1737
1865<span class="grey">Leach, et al. Standards Track [Page 31]</span> 1738Leach, et al. Standards Track [Page 31]
1866</pre><pre class='newpage'><a name="page-32" id="page-32" href="#page-32" class="invisible"> </a> 1739
1867<span class="grey"><a href="./rfc4122">RFC 4122</a> A UUID URN Namespace July 2005</span> 1740RFC 4122 A UUID URN Namespace July 2005
1868 1741
1869 1742
1870Full Copyright Statement 1743Full Copyright Statement
@@ -1872,7 +1745,7 @@ Full Copyright Statement
1872 Copyright (C) The Internet Society (2005). 1745 Copyright (C) The Internet Society (2005).
1873 1746
1874 This document is subject to the rights, licenses and restrictions 1747 This document is subject to the rights, licenses and restrictions
1875 contained in <a href="./bcp78">BCP 78</a>, and except as set forth therein, the authors 1748 contained in BCP 78, and except as set forth therein, the authors
1876 retain all their rights. 1749 retain all their rights.
1877 1750
1878 This document and the information contained herein are provided on an 1751 This document and the information contained herein are provided on an
@@ -1892,14 +1765,14 @@ Intellectual Property
1892 might or might not be available; nor does it represent that it has 1765 might or might not be available; nor does it represent that it has
1893 made any independent effort to identify any such rights. Information 1766 made any independent effort to identify any such rights. Information
1894 on the procedures with respect to rights in RFC documents can be 1767 on the procedures with respect to rights in RFC documents can be
1895 found in <a href="./bcp78">BCP 78</a> and <a href="./bcp79">BCP 79</a>. 1768 found in BCP 78 and BCP 79.
1896 1769
1897 Copies of IPR disclosures made to the IETF Secretariat and any 1770 Copies of IPR disclosures made to the IETF Secretariat and any
1898 assurances of licenses to be made available, or the result of an 1771 assurances of licenses to be made available, or the result of an
1899 attempt made to obtain a general license or permission for the use of 1772 attempt made to obtain a general license or permission for the use of
1900 such proprietary rights by implementers or users of this 1773 such proprietary rights by implementers or users of this
1901 specification can be obtained from the IETF on-line IPR repository at 1774 specification can be obtained from the IETF on-line IPR repository at
1902 <a href="http://www.ietf.org/ipr">http://www.ietf.org/ipr</a>. 1775 http://www.ietf.org/ipr.
1903 1776
1904 The IETF invites any interested party to bring to its attention any 1777 The IETF invites any interested party to bring to its attention any
1905 copyrights, patents or patent applications, or other proprietary 1778 copyrights, patents or patent applications, or other proprietary
@@ -1919,10 +1792,4 @@ Acknowledgement
1919 1792
1920 1793
1921Leach, et al. Standards Track [Page 32] 1794Leach, et al. Standards Track [Page 32]
1922</pre><pre class='newpage'> 1795
1923
1924</pre><br />
1925<span class="noprint"><small><small>Html markup produced by rfcmarkup 1.73, available from
1926<a href="http://tools.ietf.org/tools/rfcmarkup/">http://tools.ietf.org/tools/rfcmarkup/</a>
1927</small></small></span>
1928</body></html>