X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FIPAddressV4.cpp;h=a33386d5aafd8625dc485a6f767a3ba799adf8e1;hb=aa7aebf348c1b60d2ef2e81dd526aacd2f8d8769;hp=a5db28fc50933d52375985b2ba5df1b0a69069de;hpb=07286cf094a743a4db0b7cc68f7daf0337064d37;p=folly.git diff --git a/folly/IPAddressV4.cpp b/folly/IPAddressV4.cpp index a5db28fc..a33386d5 100644 --- a/folly/IPAddressV4.cpp +++ b/folly/IPAddressV4.cpp @@ -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. @@ -28,7 +28,6 @@ using std::string; namespace folly { -static IPAddressV4 loopback_addr("127.0.0.0"); // free functions size_t hash_value(const IPAddressV4& addr) { @@ -145,10 +144,18 @@ bool IPAddressV4::inSubnetWithMask(const IPAddressV4& subnet, return (mask == subMask); } +// public bool IPAddressV4::isLoopback() const { + static IPAddressV4 loopback_addr("127.0.0.0"); return inSubnetWithMask(loopback_addr, fetchMask(8)); } +// public +bool IPAddressV4::isLinkLocal() const { + static IPAddressV4 linklocal_addr("169.254.0.0"); + return inSubnetWithMask(linklocal_addr, fetchMask(16)); +} + // public bool IPAddressV4::isNonroutable() const { auto ip = toLongHBO();