/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// public
IPAddressV6 IPAddressV4::createIPv6() const {
- ByteArray16 ba{{0}};
+ ByteArray16 ba{};
ba[10] = 0xff;
ba[11] = 0xff;
std::memcpy(&ba[12], bytes(), 4);
return IPAddressV6(ba);
}
+// public
+IPAddressV6 IPAddressV4::getIPv6For6To4() const {
+ ByteArray16 ba{};
+ ba[0] = (uint8_t)((IPAddressV6::PREFIX_6TO4 & 0xFF00) >> 8);
+ ba[1] = (uint8_t)(IPAddressV6::PREFIX_6TO4 & 0x00FF);
+ std::memcpy(&ba[2], bytes(), 4);
+ return IPAddressV6(ba);
+}
+
// public
string IPAddressV4::toJson() const {
return format(