Convert a Null-terminated Unicode string to IPv6 address and prefix length. This function outputs a value of type IPv6_ADDRESS and may output a value of type UINT8 by interpreting the contents of the Unicode string specified by String. The format of the input Unicode string String is as follows: X:X:X:X:X:X:X:X[/P] X contains one to four hexadecimal digit chara
| 1142 | |
| 1143 | **/ |
| 1144 | RETURN_STATUS |
| 1145 | EFIAPI |
| 1146 | StrToIpv6Address ( |
| 1147 | IN CONST CHAR16 *String, |
| 1148 | OUT CHAR16 **EndPointer, OPTIONAL |
| 1149 | OUT IPv6_ADDRESS *Address, |
| 1150 | OUT UINT8 *PrefixLength OPTIONAL |
| 1151 | ) |
| 1152 | { |
| 1153 | RETURN_STATUS Status; |
| 1154 | UINTN AddressIndex; |
| 1155 | UINTN Uintn; |
| 1156 | IPv6_ADDRESS LocalAddress; |
| 1157 | UINT8 LocalPrefixLength; |
| 1158 | CONST CHAR16 *Pointer; |
| 1159 | CHAR16 *End; |
| 1160 | UINTN CompressStart; |
| 1161 | BOOLEAN ExpectPrefix; |
| 1162 | |
| 1163 | LocalPrefixLength = MAX_UINT8; |
| 1164 | CompressStart = ARRAY_SIZE (Address->Addr); |
| 1165 | ExpectPrefix = FALSE; |
| 1166 | |
| 1167 | ASSERT (((UINTN) String & BIT0) == 0); |
| 1168 | |
| 1169 | // |
| 1170 | // 1. None of String or Guid shall be a null pointer. |
| 1171 | // |
| 1172 | SAFE_STRING_CONSTRAINT_CHECK ((String != NULL), RETURN_INVALID_PARAMETER); |
| 1173 | SAFE_STRING_CONSTRAINT_CHECK ((Address != NULL), RETURN_INVALID_PARAMETER); |
| 1174 | |
| 1175 | for (Pointer = String, AddressIndex = 0; AddressIndex < ARRAY_SIZE (Address->Addr) + 1;) { |
| 1176 | if (!InternalIsHexaDecimalDigitCharacter (*Pointer)) { |
| 1177 | if (*Pointer != L':') { |
| 1178 | // |
| 1179 | // ":" or "/" should be followed by digit characters. |
| 1180 | // |
| 1181 | return RETURN_UNSUPPORTED; |
| 1182 | } |
| 1183 | |
| 1184 | // |
| 1185 | // Meet second ":" after previous ":" or "/" |
| 1186 | // or meet first ":" in the beginning of String. |
| 1187 | // |
| 1188 | if (ExpectPrefix) { |
| 1189 | // |
| 1190 | // ":" shall not be after "/" |
| 1191 | // |
| 1192 | return RETURN_UNSUPPORTED; |
| 1193 | } |
| 1194 | |
| 1195 | if (CompressStart != ARRAY_SIZE (Address->Addr) || AddressIndex == ARRAY_SIZE (Address->Addr)) { |
| 1196 | // |
| 1197 | // "::" can only appear once. |
| 1198 | // "::" can only appear when address is not full length. |
| 1199 | // |
| 1200 | return RETURN_UNSUPPORTED; |
| 1201 | } else { |
no test coverage detected