849c6d63be6fe57eda3922dbd9ce2c6dd977aadc
[folly.git] / folly / IPAddressV6.cpp
1 /*
2  * Copyright 2014 Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "IPAddressV6.h"
18
19 #include <ostream>
20 #include <string>
21
22 #include <folly/Format.h>
23 #include <folly/IPAddress.h>
24 #include <folly/IPAddressV4.h>
25 #include <folly/MacAddress.h>
26
27 using std::ostream;
28 using std::string;
29
30 namespace folly {
31
32 // public static const
33 const uint32_t IPAddressV6::PREFIX_TEREDO = 0x20010000;
34 const uint32_t IPAddressV6::PREFIX_6TO4 = 0x2002;
35
36 // free functions
37 size_t hash_value(const IPAddressV6& addr) {
38   return addr.hash();
39 }
40 ostream& operator<<(ostream& os, const IPAddressV6& addr) {
41   os << addr.str();
42   return os;
43 }
44 void toAppend(IPAddressV6 addr, string* result) {
45   result->append(addr.str());
46 }
47 void toAppend(IPAddressV6 addr, fbstring* result) {
48   result->append(addr.str());
49 }
50
51 // public default constructor
52 IPAddressV6::IPAddressV6() {
53 }
54
55 // public string constructor
56 IPAddressV6::IPAddressV6(StringPiece addr) {
57   auto ip = addr.str();
58
59   // Allow addresses surrounded in brackets
60   if (ip.size() < 2) {
61     throw IPAddressFormatException("Invalid IPv6 address '", ip,
62                                    "': address too short");
63   }
64   if (ip.front() == '[' && ip.back() == ']') {
65     ip = ip.substr(1, ip.size() - 2);
66   }
67
68   struct addrinfo* result;
69   struct addrinfo hints;
70   memset(&hints, 0, sizeof(hints));
71   hints.ai_family = AF_INET6;
72   hints.ai_socktype = SOCK_STREAM;
73   hints.ai_flags = AI_NUMERICHOST;
74   if (!getaddrinfo(ip.c_str(), nullptr, &hints, &result)) {
75     struct sockaddr_in6* ipAddr = (struct sockaddr_in6*)result->ai_addr;
76     addr_.in6Addr_ = ipAddr->sin6_addr;
77     scope_ = ipAddr->sin6_scope_id;
78     freeaddrinfo(result);
79   } else {
80     throw IPAddressFormatException("Invalid IPv6 address '", ip, "'");
81   }
82 }
83
84 // in6_addr constructor
85 IPAddressV6::IPAddressV6(const in6_addr& src)
86   : addr_(src)
87 {
88 }
89
90 // sockaddr_in6 constructor
91 IPAddressV6::IPAddressV6(const sockaddr_in6& src)
92   : addr_(src.sin6_addr)
93   , scope_(src.sin6_scope_id)
94 {
95 }
96
97 // ByteArray16 constructor
98 IPAddressV6::IPAddressV6(const ByteArray16& src)
99   : addr_(src)
100 {
101 }
102
103 // link-local constructor
104 IPAddressV6::IPAddressV6(LinkLocalTag, MacAddress mac)
105   : addr_(mac) {
106 }
107
108 IPAddressV6::AddressStorage::AddressStorage(MacAddress mac) {
109   // The link-local address uses modified EUI-64 format,
110   // See RFC 4291 sections 2.5.1, 2.5.6, and Appendix A
111   const auto* macBytes = mac.bytes();
112   memcpy(&bytes_.front(), "\xfe\x80\x00\x00\x00\x00\x00\x00", 8);
113   bytes_[8] = macBytes[0] ^ 0x02;
114   bytes_[9] = macBytes[1];
115   bytes_[10] = macBytes[2];
116   bytes_[11] = 0xff;
117   bytes_[12] = 0xfe;
118   bytes_[13] = macBytes[3];
119   bytes_[14] = macBytes[4];
120   bytes_[15] = macBytes[5];
121 }
122
123 void IPAddressV6::setFromBinary(ByteRange bytes) {
124   if (bytes.size() != 16) {
125     throw IPAddressFormatException("Invalid IPv6 binary data: length must "
126                                    "be 16 bytes, got ", bytes.size());
127   }
128   memcpy(&addr_.in6Addr_.s6_addr, bytes.data(), sizeof(in6_addr));
129   scope_ = 0;
130 }
131
132 // public
133 IPAddressV4 IPAddressV6::createIPv4() const {
134   if (!isIPv4Mapped()) {
135     throw IPAddressFormatException("addr is not v4-to-v6-mapped");
136   }
137   const unsigned char* by = bytes();
138   return IPAddressV4(detail::Bytes::mkAddress4(&by[12]));
139 }
140
141 // convert two uint8_t bytes into a uint16_t as hibyte.lobyte
142 static inline uint16_t unpack(uint8_t lobyte, uint8_t hibyte) {
143   return ((uint16_t)hibyte << 8) | (uint16_t)lobyte;
144 }
145
146 // given a src string, unpack count*2 bytes into dest
147 // dest must have as much storage as count
148 static inline void unpackInto(const unsigned char* src,
149                               uint16_t* dest,
150                               size_t count) {
151   for (int i = 0, hi = 1, lo = 0; i < count; i++) {
152     dest[i] = unpack(src[hi], src[lo]);
153     hi += 2;
154     lo += 2;
155   }
156 }
157
158 // public
159 IPAddressV4 IPAddressV6::getIPv4For6To4() const {
160   if (!is6To4()) {
161     throw IPAddressV6::TypeError(format(
162             "Invalid IP '{}': not a 6to4 address", str()).str());
163   }
164   // convert 16x8 bytes into first 4x16 bytes
165   uint16_t ints[4] = {0,0,0,0};
166   unpackInto(bytes(), ints, 4);
167   // repack into 4x8
168   union {
169     unsigned char bytes[4];
170     in_addr addr;
171   } ipv4;
172   ipv4.bytes[0] = (uint8_t)((ints[1] & 0xFF00) >> 8);
173   ipv4.bytes[1] = (uint8_t)(ints[1] & 0x00FF);
174   ipv4.bytes[2] = (uint8_t)((ints[2] & 0xFF00) >> 8);
175   ipv4.bytes[3] = (uint8_t)(ints[2] & 0x00FF);
176   return IPAddressV4(ipv4.addr);
177 }
178
179 // public
180 bool IPAddressV6::isIPv4Mapped() const {
181   // v4 mapped addresses have their first 10 bytes set to 0, the next 2 bytes
182   // set to 255 (0xff);
183   const unsigned char* by = bytes();
184
185   // check if first 10 bytes are 0
186   for (int i = 0; i < 10; i++) {
187     if (by[i] != 0x00) {
188       return false;
189     }
190   }
191   // check if bytes 11 and 12 are 255
192   if (by[10] == 0xff && by[11] == 0xff) {
193     return true;
194   }
195   return false;
196 }
197
198 // public
199 IPAddressV6::Type IPAddressV6::type() const {
200   // convert 16x8 bytes into first 2x16 bytes
201   uint16_t ints[2] = {0,0};
202   unpackInto(bytes(), ints, 2);
203
204   if ((((uint32_t)ints[0] << 16) | ints[1]) == IPAddressV6::PREFIX_TEREDO) {
205     return Type::TEREDO;
206   }
207
208   if ((uint32_t)ints[0] == IPAddressV6::PREFIX_6TO4) {
209     return Type::T6TO4;
210   }
211
212   return Type::NORMAL;
213 }
214
215 // public
216 string IPAddressV6::toJson() const {
217   return format(
218       "{{family:'AF_INET6', addr:'{}', hash:{}}}", str(), hash()).str();
219 }
220
221 // public
222 size_t IPAddressV6::hash() const {
223   if (isIPv4Mapped()) {
224     /* An IPAddress containing this object would be equal (i.e. operator==)
225        to an IPAddress containing the corresponding IPv4.
226        So we must make sure that the hash values are the same as well */
227     return IPAddress::createIPv4(*this).hash();
228   }
229
230   static const uint64_t seed = AF_INET6;
231   uint64_t hash1 = 0, hash2 = 0;
232   hash::SpookyHashV2::Hash128(&addr_, 16, &hash1, &hash2);
233   return hash::hash_combine(seed, hash1, hash2);
234 }
235
236 // public
237 bool IPAddressV6::inSubnet(StringPiece cidrNetwork) const {
238   auto subnetInfo = IPAddress::createNetwork(cidrNetwork);
239   auto addr = subnetInfo.first;
240   if (!addr.isV6()) {
241     throw IPAddressFormatException("Address '", addr.toJson(), "' ",
242                                    "is not a V6 address");
243   }
244   return inSubnetWithMask(addr.asV6(), fetchMask(subnetInfo.second));
245 }
246
247 // public
248 bool IPAddressV6::inSubnetWithMask(const IPAddressV6& subnet,
249                                    const ByteArray16& cidrMask) const {
250   const ByteArray16 mask = detail::Bytes::mask(toByteArray(), cidrMask);
251   const ByteArray16 subMask = detail::Bytes::mask(subnet.toByteArray(),
252                                                   cidrMask);
253   return (mask == subMask);
254 }
255
256 // public
257 bool IPAddressV6::isLoopback() const {
258   const unsigned char* by = bytes();
259   for (int i = 0; i < 15; i++) {
260     if (by[i] != 0x00) {
261       return false;
262     }
263   }
264   return (by[15] == 0x01);
265 }
266
267 bool IPAddressV6::isRoutable() const {
268   return
269     // 2000::/3 is the only assigned global unicast block
270     inBinarySubnet({{0x20, 0x00}}, 3) ||
271     // ffxe::/16 are global scope multicast addresses,
272     // which are eligible to be routed over the internet
273     (isMulticast() && getMulticastScope() == 0xe);
274 }
275
276 bool IPAddressV6::isLinkLocalBroadcast() const {
277   static const IPAddressV6 kLinkLocalBroadcast("ff02::1");
278   return *this == kLinkLocalBroadcast;
279 }
280
281 // public
282 bool IPAddressV6::isPrivate() const {
283   return isLoopback() || inBinarySubnet({{0xfc, 0x00}}, 7);
284 }
285
286 bool IPAddressV6::isLinkLocal() const {
287   return inBinarySubnet({{0xfe, 0x80}}, 10);
288 }
289
290 bool IPAddressV6::isMulticast() const {
291   return addr_.bytes_[0] == 0xff;
292 }
293
294 uint8_t IPAddressV6::getMulticastFlags() const {
295   DCHECK(isMulticast());
296   return ((addr_.bytes_[1] >> 4) & 0xf);
297 }
298
299 uint8_t IPAddressV6::getMulticastScope() const {
300   DCHECK(isMulticast());
301   return (addr_.bytes_[1] & 0xf);
302 }
303
304 IPAddressV6 IPAddressV6::getSolicitedNodeAddress() const {
305   // Solicted node addresses must be constructed from unicast (or anycast)
306   // addresses
307   DCHECK(!isMulticast());
308
309   uint8_t bytes[16] = { 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310                         0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00 };
311   bytes[13] = addr_.bytes_[13];
312   bytes[14] = addr_.bytes_[14];
313   bytes[15] = addr_.bytes_[15];
314   return IPAddressV6::fromBinary(ByteRange(bytes, 16));
315 }
316
317 // public
318 IPAddressV6 IPAddressV6::mask(size_t numBits) const {
319   static const auto bits = bitCount();
320   if (numBits > bits) {
321     throw IPAddressFormatException("numBits(", numBits, ") > bitCount(",
322                                    bits, ")");
323   }
324   ByteArray16 ba = detail::Bytes::mask(fetchMask(numBits), addr_.bytes_);
325   return IPAddressV6(ba);
326 }
327
328 // public
329 string IPAddressV6::str() const {
330   char buffer[INET6_ADDRSTRLEN] = {0};
331   sockaddr_in6 sock = toSockAddr();
332   if (!getnameinfo(
333         (sockaddr*)&sock, sizeof(sock),
334         buffer, INET6_ADDRSTRLEN,
335         nullptr, 0, NI_NUMERICHOST)) {
336     string ip(buffer);
337     return std::move(ip);
338   } else {
339     throw IPAddressFormatException("Invalid address with hex ",
340                                    "'", detail::Bytes::toHex(bytes(), 16), "'");
341   }
342 }
343
344 // public
345 string IPAddressV6::toFullyQualified() const {
346   return detail::fastIpv6ToString(addr_.in6Addr_);
347 }
348
349 // public
350 uint8_t IPAddressV6::getNthMSByte(size_t byteIndex) const {
351   const auto highestIndex = byteCount() - 1;
352   if (byteIndex > highestIndex) {
353     throw std::invalid_argument(to<string>("Byte index must be <= ",
354         to<string>(highestIndex), " for addresses of type :",
355         detail::familyNameStr(AF_INET6)));
356   }
357   return bytes()[byteIndex];
358 }
359
360 // protected
361 const ByteArray16 IPAddressV6::fetchMask(size_t numBits) {
362   static const uint8_t bits = bitCount();
363   if (numBits > bits) {
364     throw IPAddressFormatException("IPv6 addresses are 128 bits.");
365   }
366   // masks_ is backed by an array so is zero indexed
367   return masks_[numBits];
368 }
369
370 // protected
371 bool IPAddressV6::inBinarySubnet(const std::array<uint8_t, 2> addr,
372                                  size_t numBits) const {
373   const unsigned char* subbytes = mask(numBits).bytes();
374   return (std::memcmp(addr.data(), subbytes, 2) == 0);
375 }
376
377 // static private
378 const std::array<ByteArray16, 129> IPAddressV6::masks_ = {{
379 /* /0   */ {{ 0x00,0x00,0x00,0x00,
380              0x00,0x00,0x00,0x00,
381              0x00,0x00,0x00,0x00,
382              0x00,0x00,0x00,0x00 }},
383 /* /1   */ {{ 0x80,0x00,0x00,0x00,
384              0x00,0x00,0x00,0x00,
385              0x00,0x00,0x00,0x00,
386              0x00,0x00,0x00,0x00 }},
387 /* /2   */ {{ 0xc0,0x00,0x00,0x00,
388              0x00,0x00,0x00,0x00,
389              0x00,0x00,0x00,0x00,
390              0x00,0x00,0x00,0x00 }},
391 /* /3   */ {{ 0xe0,0x00,0x00,0x00,
392              0x00,0x00,0x00,0x00,
393              0x00,0x00,0x00,0x00,
394              0x00,0x00,0x00,0x00 }},
395 /* /4   */ {{ 0xf0,0x00,0x00,0x00,
396              0x00,0x00,0x00,0x00,
397              0x00,0x00,0x00,0x00,
398              0x00,0x00,0x00,0x00 }},
399 /* /5   */ {{ 0xf8,0x00,0x00,0x00,
400              0x00,0x00,0x00,0x00,
401              0x00,0x00,0x00,0x00,
402              0x00,0x00,0x00,0x00 }},
403 /* /6   */ {{ 0xfc,0x00,0x00,0x00,
404              0x00,0x00,0x00,0x00,
405              0x00,0x00,0x00,0x00,
406              0x00,0x00,0x00,0x00 }},
407 /* /7   */ {{ 0xfe,0x00,0x00,0x00,
408              0x00,0x00,0x00,0x00,
409              0x00,0x00,0x00,0x00,
410              0x00,0x00,0x00,0x00 }},
411 /* /8   */ {{ 0xff,0x00,0x00,0x00,
412              0x00,0x00,0x00,0x00,
413              0x00,0x00,0x00,0x00,
414              0x00,0x00,0x00,0x00 }},
415 /* /9   */ {{ 0xff,0x80,0x00,0x00,
416              0x00,0x00,0x00,0x00,
417              0x00,0x00,0x00,0x00,
418              0x00,0x00,0x00,0x00 }},
419 /* /10  */ {{ 0xff,0xc0,0x00,0x00,
420              0x00,0x00,0x00,0x00,
421              0x00,0x00,0x00,0x00,
422              0x00,0x00,0x00,0x00 }},
423 /* /11  */ {{ 0xff,0xe0,0x00,0x00,
424              0x00,0x00,0x00,0x00,
425              0x00,0x00,0x00,0x00,
426              0x00,0x00,0x00,0x00 }},
427 /* /12  */ {{ 0xff,0xf0,0x00,0x00,
428              0x00,0x00,0x00,0x00,
429              0x00,0x00,0x00,0x00,
430              0x00,0x00,0x00,0x00 }},
431 /* /13  */ {{ 0xff,0xf8,0x00,0x00,
432              0x00,0x00,0x00,0x00,
433              0x00,0x00,0x00,0x00,
434              0x00,0x00,0x00,0x00 }},
435 /* /14  */ {{ 0xff,0xfc,0x00,0x00,
436              0x00,0x00,0x00,0x00,
437              0x00,0x00,0x00,0x00,
438              0x00,0x00,0x00,0x00 }},
439 /* /15  */ {{ 0xff,0xfe,0x00,0x00,
440              0x00,0x00,0x00,0x00,
441              0x00,0x00,0x00,0x00,
442              0x00,0x00,0x00,0x00 }},
443 /* /16  */ {{ 0xff,0xff,0x00,0x00,
444              0x00,0x00,0x00,0x00,
445              0x00,0x00,0x00,0x00,
446              0x00,0x00,0x00,0x00 }},
447 /* /17  */ {{ 0xff,0xff,0x80,0x00,
448              0x00,0x00,0x00,0x00,
449              0x00,0x00,0x00,0x00,
450              0x00,0x00,0x00,0x00 }},
451 /* /18  */ {{ 0xff,0xff,0xc0,0x00,
452              0x00,0x00,0x00,0x00,
453              0x00,0x00,0x00,0x00,
454              0x00,0x00,0x00,0x00 }},
455 /* /19  */ {{ 0xff,0xff,0xe0,0x00,
456              0x00,0x00,0x00,0x00,
457              0x00,0x00,0x00,0x00,
458              0x00,0x00,0x00,0x00 }},
459 /* /20  */ {{ 0xff,0xff,0xf0,0x00,
460              0x00,0x00,0x00,0x00,
461              0x00,0x00,0x00,0x00,
462              0x00,0x00,0x00,0x00 }},
463 /* /21  */ {{ 0xff,0xff,0xf8,0x00,
464              0x00,0x00,0x00,0x00,
465              0x00,0x00,0x00,0x00,
466              0x00,0x00,0x00,0x00 }},
467 /* /22  */ {{ 0xff,0xff,0xfc,0x00,
468              0x00,0x00,0x00,0x00,
469              0x00,0x00,0x00,0x00,
470              0x00,0x00,0x00,0x00 }},
471 /* /23  */ {{ 0xff,0xff,0xfe,0x00,
472              0x00,0x00,0x00,0x00,
473              0x00,0x00,0x00,0x00,
474              0x00,0x00,0x00,0x00 }},
475 /* /24  */ {{ 0xff,0xff,0xff,0x00,
476              0x00,0x00,0x00,0x00,
477              0x00,0x00,0x00,0x00,
478              0x00,0x00,0x00,0x00 }},
479 /* /25  */ {{ 0xff,0xff,0xff,0x80,
480              0x00,0x00,0x00,0x00,
481              0x00,0x00,0x00,0x00,
482              0x00,0x00,0x00,0x00 }},
483 /* /26  */ {{ 0xff,0xff,0xff,0xc0,
484              0x00,0x00,0x00,0x00,
485              0x00,0x00,0x00,0x00,
486              0x00,0x00,0x00,0x00 }},
487 /* /27  */ {{ 0xff,0xff,0xff,0xe0,
488              0x00,0x00,0x00,0x00,
489              0x00,0x00,0x00,0x00,
490              0x00,0x00,0x00,0x00 }},
491 /* /28  */ {{ 0xff,0xff,0xff,0xf0,
492              0x00,0x00,0x00,0x00,
493              0x00,0x00,0x00,0x00,
494              0x00,0x00,0x00,0x00 }},
495 /* /29  */ {{ 0xff,0xff,0xff,0xf8,
496              0x00,0x00,0x00,0x00,
497              0x00,0x00,0x00,0x00,
498              0x00,0x00,0x00,0x00 }},
499 /* /30  */ {{ 0xff,0xff,0xff,0xfc,
500              0x00,0x00,0x00,0x00,
501              0x00,0x00,0x00,0x00,
502              0x00,0x00,0x00,0x00 }},
503 /* /31  */ {{ 0xff,0xff,0xff,0xfe,
504              0x00,0x00,0x00,0x00,
505              0x00,0x00,0x00,0x00,
506              0x00,0x00,0x00,0x00 }},
507 /* /32  */ {{ 0xff,0xff,0xff,0xff,
508              0x00,0x00,0x00,0x00,
509              0x00,0x00,0x00,0x00,
510              0x00,0x00,0x00,0x00 }},
511 /* /33  */ {{ 0xff,0xff,0xff,0xff,
512              0x80,0x00,0x00,0x00,
513              0x00,0x00,0x00,0x00,
514              0x00,0x00,0x00,0x00 }},
515 /* /34  */ {{ 0xff,0xff,0xff,0xff,
516              0xc0,0x00,0x00,0x00,
517              0x00,0x00,0x00,0x00,
518              0x00,0x00,0x00,0x00 }},
519 /* /35  */ {{ 0xff,0xff,0xff,0xff,
520              0xe0,0x00,0x00,0x00,
521              0x00,0x00,0x00,0x00,
522              0x00,0x00,0x00,0x00 }},
523 /* /36  */ {{ 0xff,0xff,0xff,0xff,
524              0xf0,0x00,0x00,0x00,
525              0x00,0x00,0x00,0x00,
526              0x00,0x00,0x00,0x00 }},
527 /* /37  */ {{ 0xff,0xff,0xff,0xff,
528              0xf8,0x00,0x00,0x00,
529              0x00,0x00,0x00,0x00,
530              0x00,0x00,0x00,0x00 }},
531 /* /38  */ {{ 0xff,0xff,0xff,0xff,
532              0xfc,0x00,0x00,0x00,
533              0x00,0x00,0x00,0x00,
534              0x00,0x00,0x00,0x00 }},
535 /* /39  */ {{ 0xff,0xff,0xff,0xff,
536              0xfe,0x00,0x00,0x00,
537              0x00,0x00,0x00,0x00,
538              0x00,0x00,0x00,0x00 }},
539 /* /40  */ {{ 0xff,0xff,0xff,0xff,
540              0xff,0x00,0x00,0x00,
541              0x00,0x00,0x00,0x00,
542              0x00,0x00,0x00,0x00 }},
543 /* /41  */ {{ 0xff,0xff,0xff,0xff,
544              0xff,0x80,0x00,0x00,
545              0x00,0x00,0x00,0x00,
546              0x00,0x00,0x00,0x00 }},
547 /* /42  */ {{ 0xff,0xff,0xff,0xff,
548              0xff,0xc0,0x00,0x00,
549              0x00,0x00,0x00,0x00,
550              0x00,0x00,0x00,0x00 }},
551 /* /43  */ {{ 0xff,0xff,0xff,0xff,
552              0xff,0xe0,0x00,0x00,
553              0x00,0x00,0x00,0x00,
554              0x00,0x00,0x00,0x00 }},
555 /* /44  */ {{ 0xff,0xff,0xff,0xff,
556              0xff,0xf0,0x00,0x00,
557              0x00,0x00,0x00,0x00,
558              0x00,0x00,0x00,0x00 }},
559 /* /45  */ {{ 0xff,0xff,0xff,0xff,
560              0xff,0xf8,0x00,0x00,
561              0x00,0x00,0x00,0x00,
562              0x00,0x00,0x00,0x00 }},
563 /* /46  */ {{ 0xff,0xff,0xff,0xff,
564              0xff,0xfc,0x00,0x00,
565              0x00,0x00,0x00,0x00,
566              0x00,0x00,0x00,0x00 }},
567 /* /47  */ {{ 0xff,0xff,0xff,0xff,
568              0xff,0xfe,0x00,0x00,
569              0x00,0x00,0x00,0x00,
570              0x00,0x00,0x00,0x00 }},
571 /* /48  */ {{ 0xff,0xff,0xff,0xff,
572              0xff,0xff,0x00,0x00,
573              0x00,0x00,0x00,0x00,
574              0x00,0x00,0x00,0x00 }},
575 /* /49  */ {{ 0xff,0xff,0xff,0xff,
576              0xff,0xff,0x80,0x00,
577              0x00,0x00,0x00,0x00,
578              0x00,0x00,0x00,0x00 }},
579 /* /50  */ {{ 0xff,0xff,0xff,0xff,
580              0xff,0xff,0xc0,0x00,
581              0x00,0x00,0x00,0x00,
582              0x00,0x00,0x00,0x00 }},
583 /* /51  */ {{ 0xff,0xff,0xff,0xff,
584              0xff,0xff,0xe0,0x00,
585              0x00,0x00,0x00,0x00,
586              0x00,0x00,0x00,0x00 }},
587 /* /52  */ {{ 0xff,0xff,0xff,0xff,
588              0xff,0xff,0xf0,0x00,
589              0x00,0x00,0x00,0x00,
590              0x00,0x00,0x00,0x00 }},
591 /* /53  */ {{ 0xff,0xff,0xff,0xff,
592              0xff,0xff,0xf8,0x00,
593              0x00,0x00,0x00,0x00,
594              0x00,0x00,0x00,0x00 }},
595 /* /54  */ {{ 0xff,0xff,0xff,0xff,
596              0xff,0xff,0xfc,0x00,
597              0x00,0x00,0x00,0x00,
598              0x00,0x00,0x00,0x00 }},
599 /* /55  */ {{ 0xff,0xff,0xff,0xff,
600              0xff,0xff,0xfe,0x00,
601              0x00,0x00,0x00,0x00,
602              0x00,0x00,0x00,0x00 }},
603 /* /56  */ {{ 0xff,0xff,0xff,0xff,
604              0xff,0xff,0xff,0x00,
605              0x00,0x00,0x00,0x00,
606              0x00,0x00,0x00,0x00 }},
607 /* /57  */ {{ 0xff,0xff,0xff,0xff,
608              0xff,0xff,0xff,0x80,
609              0x00,0x00,0x00,0x00,
610              0x00,0x00,0x00,0x00 }},
611 /* /58  */ {{ 0xff,0xff,0xff,0xff,
612              0xff,0xff,0xff,0xc0,
613              0x00,0x00,0x00,0x00,
614              0x00,0x00,0x00,0x00 }},
615 /* /59  */ {{ 0xff,0xff,0xff,0xff,
616              0xff,0xff,0xff,0xe0,
617              0x00,0x00,0x00,0x00,
618              0x00,0x00,0x00,0x00 }},
619 /* /60  */ {{ 0xff,0xff,0xff,0xff,
620              0xff,0xff,0xff,0xf0,
621              0x00,0x00,0x00,0x00,
622              0x00,0x00,0x00,0x00 }},
623 /* /61  */ {{ 0xff,0xff,0xff,0xff,
624              0xff,0xff,0xff,0xf8,
625              0x00,0x00,0x00,0x00,
626              0x00,0x00,0x00,0x00 }},
627 /* /62  */ {{ 0xff,0xff,0xff,0xff,
628              0xff,0xff,0xff,0xfc,
629              0x00,0x00,0x00,0x00,
630              0x00,0x00,0x00,0x00 }},
631 /* /63  */ {{ 0xff,0xff,0xff,0xff,
632              0xff,0xff,0xff,0xfe,
633              0x00,0x00,0x00,0x00,
634              0x00,0x00,0x00,0x00 }},
635 /* /64  */ {{ 0xff,0xff,0xff,0xff,
636              0xff,0xff,0xff,0xff,
637              0x00,0x00,0x00,0x00,
638              0x00,0x00,0x00,0x00 }},
639 /* /65  */ {{ 0xff,0xff,0xff,0xff,
640              0xff,0xff,0xff,0xff,
641              0x80,0x00,0x00,0x00,
642              0x00,0x00,0x00,0x00 }},
643 /* /66  */ {{ 0xff,0xff,0xff,0xff,
644              0xff,0xff,0xff,0xff,
645              0xc0,0x00,0x00,0x00,
646              0x00,0x00,0x00,0x00 }},
647 /* /67  */ {{ 0xff,0xff,0xff,0xff,
648              0xff,0xff,0xff,0xff,
649              0xe0,0x00,0x00,0x00,
650              0x00,0x00,0x00,0x00 }},
651 /* /68  */ {{ 0xff,0xff,0xff,0xff,
652              0xff,0xff,0xff,0xff,
653              0xf0,0x00,0x00,0x00,
654              0x00,0x00,0x00,0x00 }},
655 /* /69  */ {{ 0xff,0xff,0xff,0xff,
656              0xff,0xff,0xff,0xff,
657              0xf8,0x00,0x00,0x00,
658              0x00,0x00,0x00,0x00 }},
659 /* /70  */ {{ 0xff,0xff,0xff,0xff,
660              0xff,0xff,0xff,0xff,
661              0xfc,0x00,0x00,0x00,
662              0x00,0x00,0x00,0x00 }},
663 /* /71  */ {{ 0xff,0xff,0xff,0xff,
664              0xff,0xff,0xff,0xff,
665              0xfe,0x00,0x00,0x00,
666              0x00,0x00,0x00,0x00 }},
667 /* /72  */ {{ 0xff,0xff,0xff,0xff,
668              0xff,0xff,0xff,0xff,
669              0xff,0x00,0x00,0x00,
670              0x00,0x00,0x00,0x00 }},
671 /* /73  */ {{ 0xff,0xff,0xff,0xff,
672              0xff,0xff,0xff,0xff,
673              0xff,0x80,0x00,0x00,
674              0x00,0x00,0x00,0x00 }},
675 /* /74  */ {{ 0xff,0xff,0xff,0xff,
676              0xff,0xff,0xff,0xff,
677              0xff,0xc0,0x00,0x00,
678              0x00,0x00,0x00,0x00 }},
679 /* /75  */ {{ 0xff,0xff,0xff,0xff,
680              0xff,0xff,0xff,0xff,
681              0xff,0xe0,0x00,0x00,
682              0x00,0x00,0x00,0x00 }},
683 /* /76  */ {{ 0xff,0xff,0xff,0xff,
684              0xff,0xff,0xff,0xff,
685              0xff,0xf0,0x00,0x00,
686              0x00,0x00,0x00,0x00 }},
687 /* /77  */ {{ 0xff,0xff,0xff,0xff,
688              0xff,0xff,0xff,0xff,
689              0xff,0xf8,0x00,0x00,
690              0x00,0x00,0x00,0x00 }},
691 /* /78  */ {{ 0xff,0xff,0xff,0xff,
692              0xff,0xff,0xff,0xff,
693              0xff,0xfc,0x00,0x00,
694              0x00,0x00,0x00,0x00 }},
695 /* /79  */ {{ 0xff,0xff,0xff,0xff,
696              0xff,0xff,0xff,0xff,
697              0xff,0xfe,0x00,0x00,
698              0x00,0x00,0x00,0x00 }},
699 /* /80  */ {{ 0xff,0xff,0xff,0xff,
700              0xff,0xff,0xff,0xff,
701              0xff,0xff,0x00,0x00,
702              0x00,0x00,0x00,0x00 }},
703 /* /81  */ {{ 0xff,0xff,0xff,0xff,
704              0xff,0xff,0xff,0xff,
705              0xff,0xff,0x80,0x00,
706              0x00,0x00,0x00,0x00 }},
707 /* /82  */ {{ 0xff,0xff,0xff,0xff,
708              0xff,0xff,0xff,0xff,
709              0xff,0xff,0xc0,0x00,
710              0x00,0x00,0x00,0x00 }},
711 /* /83  */ {{ 0xff,0xff,0xff,0xff,
712              0xff,0xff,0xff,0xff,
713              0xff,0xff,0xe0,0x00,
714              0x00,0x00,0x00,0x00 }},
715 /* /84  */ {{ 0xff,0xff,0xff,0xff,
716              0xff,0xff,0xff,0xff,
717              0xff,0xff,0xf0,0x00,
718              0x00,0x00,0x00,0x00 }},
719 /* /85  */ {{ 0xff,0xff,0xff,0xff,
720              0xff,0xff,0xff,0xff,
721              0xff,0xff,0xf8,0x00,
722              0x00,0x00,0x00,0x00 }},
723 /* /86  */ {{ 0xff,0xff,0xff,0xff,
724              0xff,0xff,0xff,0xff,
725              0xff,0xff,0xfc,0x00,
726              0x00,0x00,0x00,0x00 }},
727 /* /87  */ {{ 0xff,0xff,0xff,0xff,
728              0xff,0xff,0xff,0xff,
729              0xff,0xff,0xfe,0x00,
730              0x00,0x00,0x00,0x00 }},
731 /* /88  */ {{ 0xff,0xff,0xff,0xff,
732              0xff,0xff,0xff,0xff,
733              0xff,0xff,0xff,0x00,
734              0x00,0x00,0x00,0x00 }},
735 /* /89  */ {{ 0xff,0xff,0xff,0xff,
736              0xff,0xff,0xff,0xff,
737              0xff,0xff,0xff,0x80,
738              0x00,0x00,0x00,0x00 }},
739 /* /90  */ {{ 0xff,0xff,0xff,0xff,
740              0xff,0xff,0xff,0xff,
741              0xff,0xff,0xff,0xc0,
742              0x00,0x00,0x00,0x00 }},
743 /* /91  */ {{ 0xff,0xff,0xff,0xff,
744              0xff,0xff,0xff,0xff,
745              0xff,0xff,0xff,0xe0,
746              0x00,0x00,0x00,0x00 }},
747 /* /92  */ {{ 0xff,0xff,0xff,0xff,
748              0xff,0xff,0xff,0xff,
749              0xff,0xff,0xff,0xf0,
750              0x00,0x00,0x00,0x00 }},
751 /* /93  */ {{ 0xff,0xff,0xff,0xff,
752              0xff,0xff,0xff,0xff,
753              0xff,0xff,0xff,0xf8,
754              0x00,0x00,0x00,0x00 }},
755 /* /94  */ {{ 0xff,0xff,0xff,0xff,
756              0xff,0xff,0xff,0xff,
757              0xff,0xff,0xff,0xfc,
758              0x00,0x00,0x00,0x00 }},
759 /* /95  */ {{ 0xff,0xff,0xff,0xff,
760              0xff,0xff,0xff,0xff,
761              0xff,0xff,0xff,0xfe,
762              0x00,0x00,0x00,0x00 }},
763 /* /96  */ {{ 0xff,0xff,0xff,0xff,
764              0xff,0xff,0xff,0xff,
765              0xff,0xff,0xff,0xff,
766              0x00,0x00,0x00,0x00 }},
767 /* /97  */ {{ 0xff,0xff,0xff,0xff,
768              0xff,0xff,0xff,0xff,
769              0xff,0xff,0xff,0xff,
770              0x80,0x00,0x00,0x00 }},
771 /* /98  */ {{ 0xff,0xff,0xff,0xff,
772              0xff,0xff,0xff,0xff,
773              0xff,0xff,0xff,0xff,
774              0xc0,0x00,0x00,0x00 }},
775 /* /99  */ {{ 0xff,0xff,0xff,0xff,
776              0xff,0xff,0xff,0xff,
777              0xff,0xff,0xff,0xff,
778              0xe0,0x00,0x00,0x00 }},
779 /* /100 */ {{ 0xff,0xff,0xff,0xff,
780              0xff,0xff,0xff,0xff,
781              0xff,0xff,0xff,0xff,
782              0xf0,0x00,0x00,0x00 }},
783 /* /101 */ {{ 0xff,0xff,0xff,0xff,
784              0xff,0xff,0xff,0xff,
785              0xff,0xff,0xff,0xff,
786              0xf8,0x00,0x00,0x00 }},
787 /* /102 */ {{ 0xff,0xff,0xff,0xff,
788              0xff,0xff,0xff,0xff,
789              0xff,0xff,0xff,0xff,
790              0xfc,0x00,0x00,0x00 }},
791 /* /103 */ {{ 0xff,0xff,0xff,0xff,
792              0xff,0xff,0xff,0xff,
793              0xff,0xff,0xff,0xff,
794              0xfe,0x00,0x00,0x00 }},
795 /* /104 */ {{ 0xff,0xff,0xff,0xff,
796              0xff,0xff,0xff,0xff,
797              0xff,0xff,0xff,0xff,
798              0xff,0x00,0x00,0x00 }},
799 /* /105 */ {{ 0xff,0xff,0xff,0xff,
800              0xff,0xff,0xff,0xff,
801              0xff,0xff,0xff,0xff,
802              0xff,0x80,0x00,0x00 }},
803 /* /106 */ {{ 0xff,0xff,0xff,0xff,
804              0xff,0xff,0xff,0xff,
805              0xff,0xff,0xff,0xff,
806              0xff,0xc0,0x00,0x00 }},
807 /* /107 */ {{ 0xff,0xff,0xff,0xff,
808              0xff,0xff,0xff,0xff,
809              0xff,0xff,0xff,0xff,
810              0xff,0xe0,0x00,0x00 }},
811 /* /108 */ {{ 0xff,0xff,0xff,0xff,
812              0xff,0xff,0xff,0xff,
813              0xff,0xff,0xff,0xff,
814              0xff,0xf0,0x00,0x00 }},
815 /* /109 */ {{ 0xff,0xff,0xff,0xff,
816              0xff,0xff,0xff,0xff,
817              0xff,0xff,0xff,0xff,
818              0xff,0xf8,0x00,0x00 }},
819 /* /110 */ {{ 0xff,0xff,0xff,0xff,
820              0xff,0xff,0xff,0xff,
821              0xff,0xff,0xff,0xff,
822              0xff,0xfc,0x00,0x00 }},
823 /* /111 */ {{ 0xff,0xff,0xff,0xff,
824              0xff,0xff,0xff,0xff,
825              0xff,0xff,0xff,0xff,
826              0xff,0xfe,0x00,0x00 }},
827 /* /112 */ {{ 0xff,0xff,0xff,0xff,
828              0xff,0xff,0xff,0xff,
829              0xff,0xff,0xff,0xff,
830              0xff,0xff,0x00,0x00 }},
831 /* /113 */ {{ 0xff,0xff,0xff,0xff,
832              0xff,0xff,0xff,0xff,
833              0xff,0xff,0xff,0xff,
834              0xff,0xff,0x80,0x00 }},
835 /* /114 */ {{ 0xff,0xff,0xff,0xff,
836              0xff,0xff,0xff,0xff,
837              0xff,0xff,0xff,0xff,
838              0xff,0xff,0xc0,0x00 }},
839 /* /115 */ {{ 0xff,0xff,0xff,0xff,
840              0xff,0xff,0xff,0xff,
841              0xff,0xff,0xff,0xff,
842              0xff,0xff,0xe0,0x00 }},
843 /* /116 */ {{ 0xff,0xff,0xff,0xff,
844              0xff,0xff,0xff,0xff,
845              0xff,0xff,0xff,0xff,
846              0xff,0xff,0xf0,0x00 }},
847 /* /117 */ {{ 0xff,0xff,0xff,0xff,
848              0xff,0xff,0xff,0xff,
849              0xff,0xff,0xff,0xff,
850              0xff,0xff,0xf8,0x00 }},
851 /* /118 */ {{ 0xff,0xff,0xff,0xff,
852              0xff,0xff,0xff,0xff,
853              0xff,0xff,0xff,0xff,
854              0xff,0xff,0xfc,0x00 }},
855 /* /119 */ {{ 0xff,0xff,0xff,0xff,
856              0xff,0xff,0xff,0xff,
857              0xff,0xff,0xff,0xff,
858              0xff,0xff,0xfe,0x00 }},
859 /* /120 */ {{ 0xff,0xff,0xff,0xff,
860              0xff,0xff,0xff,0xff,
861              0xff,0xff,0xff,0xff,
862              0xff,0xff,0xff,0x00 }},
863 /* /121 */ {{ 0xff,0xff,0xff,0xff,
864              0xff,0xff,0xff,0xff,
865              0xff,0xff,0xff,0xff,
866              0xff,0xff,0xff,0x80 }},
867 /* /122 */ {{ 0xff,0xff,0xff,0xff,
868              0xff,0xff,0xff,0xff,
869              0xff,0xff,0xff,0xff,
870              0xff,0xff,0xff,0xc0 }},
871 /* /123 */ {{ 0xff,0xff,0xff,0xff,
872              0xff,0xff,0xff,0xff,
873              0xff,0xff,0xff,0xff,
874              0xff,0xff,0xff,0xe0 }},
875 /* /124 */ {{ 0xff,0xff,0xff,0xff,
876              0xff,0xff,0xff,0xff,
877              0xff,0xff,0xff,0xff,
878              0xff,0xff,0xff,0xf0 }},
879 /* /125 */ {{ 0xff,0xff,0xff,0xff,
880              0xff,0xff,0xff,0xff,
881              0xff,0xff,0xff,0xff,
882              0xff,0xff,0xff,0xf8 }},
883 /* /126 */ {{ 0xff,0xff,0xff,0xff,
884              0xff,0xff,0xff,0xff,
885              0xff,0xff,0xff,0xff,
886              0xff,0xff,0xff,0xfc }},
887 /* /127 */ {{ 0xff,0xff,0xff,0xff,
888              0xff,0xff,0xff,0xff,
889              0xff,0xff,0xff,0xff,
890              0xff,0xff,0xff,0xfe }},
891 /* /128 */ {{ 0xff,0xff,0xff,0xff,
892              0xff,0xff,0xff,0xff,
893              0xff,0xff,0xff,0xff,
894              0xff,0xff,0xff,0xff }},
895 }};
896
897 } // folly