2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright (c) 2017, Joyent, Inc.
15 .Dt SCSI_WWNSTR_TO_WWN 9F
18 .Nm scsi_wwnstr_to_wwn ,
19 .Nm scsi_wwn_to_wwnstr ,
21 .Nd SCSI World Wide Name string conversion functions
25 .Fo scsi_wwnstr_to_wwn
26 .Fa "const char *wwwnstr"
30 .Fo scsi_wwn_to_wwnstr
41 This interface is still evolving in illumos.
42 API and ABI stability is not guaranteed.
46 A 64-bit world wide number.
48 A string representation of a world wide number.
50 A pointer to a 64-bit value that will store a world wide number.
52 An integer indicating whether or not the unit address form should be
57 .Fn scsi_wwnstr_to_wwn
59 .Fn scsi_wwn_to_wwnstr
60 functions convert an 8-byte world wide number to and from a string
63 World wide numbers are unique identifiers that are used in storage
64 technologies, particularly ATA, SAS, and FC.
65 The format of a WWN is defined by the IEEE and generally come in 8 and
67 These interfaces only operate on the 8 byte forms.
69 When the WWN is represented as a string, it is represented as a 16
70 character hexadecimal string.
71 This character string may either use uppercase or lowercase hexadecimal
73 The character string may be preceded by a
76 When this is present, this is called the
77 .Em unit-address form .
78 If the string is not 16 ASCII character long or 17, when using the
79 unit-address form, the string is considered invalid.
80 The following macros are provided to help deal with these lengths:
82 .It Dv SCSI_WWN_STRLEN
83 The number of bytes, excluding a terminating nul character, for a world
84 wide number to be represented when not in the unit-address form.
85 .It Dv SCSI_WWN_UA_STRLEN
86 The number of bytes, excluding a terminating nul character, for a world
87 wide number to be represented in the unit-address form.
88 .It Dv SCSI_WWN_BUFLEN
89 A number of bytes that is guaranteed to be sufficient to hold any form
90 of a world wide number and a nul terminator.
94 .Fn scsi_wwnstr_to_wwn
95 function parses the string form of the WWN
97 and converts it to a 64-bit representation.
98 The string form may either be in unit-address form or not.
99 The string must have a nul terminator.
100 If the string is successfully parsed, the world wide number is stored in
104 .Fn scsi_wwn_to_wwnstr
105 converts the world wide number in
107 into a human-readable string as described above.
110 is non-zero then the unit-address form is used and a leading
116 argument is supplied by the user, then it must be large enough to
117 contain both the string form of the world wide number and a nul
121 macro is recommended.
122 It will always ensure that a buffer is large
123 enough to hold any supported string representation of a world wide
130 then a character string of sufficient size will be allocated by the
132 Note, this allocation will block until memory is available.
133 If memory is allocated in this way, then the caller should free this
139 .Fn scsi_wwnstr_to_wwn ,
140 .Fn scsi_wwn_to_wwnstr ,
143 functions may be used in
150 Upon successful completion, the
151 .Fn scsi_wwnstr_to_wwn
159 is returned, indicating an invalid argument or a malformed string in
162 Upon successful completion, the
163 .Fn scsi_wwn_to_wwnstr
164 function returns a pointer to the start of the world wide number.
167 is returned to indicate that the conversion failed.
169 .Xr scsi_hba_iport_unit_address 9F