Update symlinks
[folly.git] / folly / IPAddressV4.h
index ac63ef8f98f36e45d83979c26a1255a887f1e97d..1feac577148e01d140ded5c831cc58f2f97ecc0a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -68,6 +68,13 @@ class IPAddressV4 : boost::totally_ordered<IPAddressV4> {
     return addr;
   }
 
+  /**
+   * Returns the address as a Range.
+   */
+  ByteRange toBinary() const {
+    return ByteRange((const unsigned char *) &addr_.inAddr_.s_addr, 4);
+  }
+
   /**
    * Convert a IPv4 address string to a long in network byte order.
    * @param [in] ip the address to convert
@@ -98,6 +105,11 @@ class IPAddressV4 : boost::totally_ordered<IPAddressV4> {
   // Return the V6 mapped representation of the address.
   IPAddressV6 createIPv6() const;
 
+  /**
+   * Return a V6 address in the format of an 6To4 address.
+   */
+  IPAddressV6 getIPv6For6To4() const;
+
   // Return the long (network byte order) representation of the address.
   uint32_t toLong() const {
     return toAddr().s_addr;
@@ -139,6 +151,9 @@ class IPAddressV4 : boost::totally_ordered<IPAddressV4> {
   // @see IPAddress#isLoopback
   bool isLoopback() const;
 
+  // @see IPAddress#isLinkLocal
+  bool isLinkLocal() const;
+
   // @see IPAddress#isNonroutable
   bool isNonroutable() const;
 
@@ -177,7 +192,7 @@ class IPAddressV4 : boost::totally_ordered<IPAddressV4> {
   ByteArray4 toByteArray() const {
     ByteArray4 ba{{0}};
     std::memcpy(ba.data(), bytes(), 4);
-    return std::move(ba);
+    return ba;
   }
 
   // @see IPAddress#toFullyQualified
@@ -226,6 +241,8 @@ class IPAddressV4 : boost::totally_ordered<IPAddressV4> {
 
  private:
   union AddressStorage {
+    static_assert(sizeof(in_addr) == sizeof(ByteArray4),
+                  "size of in_addr and ByteArray4 are different");
     in_addr inAddr_;
     ByteArray4 bytes_;
     AddressStorage() {