Exemplo n.º 1
0
   bool
   LocalIPAddresses::IsWithinLoopbackRange(const IPAddress &address)
   {
      if (address.GetType() == IPAddress::IPV4)
      {
         unsigned __int64 longAddress = address.GetAddress1();
      
         // 127.0.0.1 - 127.255.255.255
         if (longAddress >= 2130706433 && longAddress <= 2147483647)
            return true;
         else
            return false;
      }
      else if (address.GetType() == IPAddress::IPV6)
      {
         if (address.GetAddress1() == 0 && address.GetAddress2() == 1)
            return true;
         else
            return false;
      }

      return true;
      

      /*

         */
   }
Exemplo n.º 2
0
bool
IPAddress::operator<(const IPAddress &other)
{
    bool inputIsGreater =
        other.GetAddress1() > GetAddress1() ||
        (other.GetAddress1() == GetAddress1() && other.GetAddress2() > GetAddress2());

    return inputIsGreater;
}
Exemplo n.º 3
0
   AnsiString 
   IPAddressSQLHelper::GetAddress1Equals(const IPAddress &address) const
   {
      String s;
      s.Format(_T("= %I64d"), address.GetAddress1());

      return s;
   }
Exemplo n.º 4
0
   void 
   IPAddressSQLHelper::AppendStatement(SQLStatement &statement, const IPAddress &address, const AnsiString &address1Column, const AnsiString &address2Column) const
   {
      statement.AddColumnInt64(address1Column, address.GetAddress1());
      
      if (address.GetType() == IPAddress::IPV6)
         statement.AddColumnInt64(address2Column, address.GetAddress2());
      else
         statement.AddColumnNULL(address2Column);

   }
Exemplo n.º 5
0
bool
IPAddress::WithinRange(const IPAddress &lower, const IPAddress &upper) const
{
#ifdef _DEBUG
    String lower1 = lower.ToString();
    String lower2 = upper.ToString();
    String thisIP = ToString();
#endif

    if (GetAddress1() < lower.GetAddress1() || GetAddress1() > upper.GetAddress1())
        return false;

    // If it's an IPv4 address, we don't need to compare the second part.
    if (_address.is_v4())
        return true;

    if (GetAddress2() < lower.GetAddress2() || GetAddress2() > upper.GetAddress2())
        return false;

    return true;
}