/*
- * 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.
#include <boost/operators.hpp>
+#include <folly/Conv.h>
#include <folly/Format.h>
#include <folly/Range.h>
#include <folly/IPAddressException.h>
* @return string representing the netblock
*/
static std::string networkToString(const CIDRNetwork& network) {
- return network.first.str() + "/" + std::to_string(network.second);
+ return network.first.str() + "/" + folly::to<std::string>(network.second);
}
/**
sockaddr_in6 *sin = reinterpret_cast<sockaddr_in6*>(dest);
sin->sin6_addr = asV6().toAddr();
sin->sin6_port = port;
+ sin->sin6_scope_id = asV6().getScopeId();
return sizeof(*sin);
} else {
throw InvalidAddressFamilyException(family());
: asV6().isLoopback();
}
+ // Return true if the address qualifies as link local
+ bool isLinkLocal() const {
+ return isV4() ? asV4().isLinkLocal()
+ : asV6().isLinkLocal();
+ }
+
// Return true if the address qualifies as broadcast.
bool isLinkLocalBroadcast() const {
return isV4() ? asV4().isLinkLocalBroadcast()
* @return IPAddress instance with bits set to 0
*/
IPAddress mask(uint8_t numBits) const {
- return isV4() ? IPAddress(std::move(asV4().mask(numBits)))
- : IPAddress(std::move(asV6().mask(numBits)));
+ return isV4() ? IPAddress(asV4().mask(numBits))
+ : IPAddress(asV6().mask(numBits));
}
/**