Exemplo n.º 1
0
/* ****************************************************************************
*
* isIPv6 -
*/
bool isIPv6(std::string in)
{
   // An IP v6 have between two and seven character ":"
   //  ::
   //  2001:0db8:85a3:08d3:1319:8a2e:0370:7334

   size_t pos;
   std::string partip;
   std::string resu;
   std::string staux = in;
   int cont = 0;

   pos = staux.find(":");
   while (pos != std::string::npos)
   {
      cont++;
      partip = staux.substr(0, pos+1);
      resu += partip;

      if (checkGroupIPv6(partip)== false)
         return false;

      partip = staux.substr(pos+1);
      staux = partip;

      pos = staux.find(":");
   }

   return ((cont > 1) && (cont < 8));
}
Exemplo n.º 2
0
/* ****************************************************************************
*
* isIPv6 -
*
* An IP v6 has between two and seven character ":"
*   o ::
*   o 2001:0db8:85a3:08d3:1319:8a2e:0370:7334
*
*/
bool isIPv6(const std::string& in)
{
  size_t      pos;
  std::string partip;
  std::string staux = in;
  int         cont  = 0;

  pos = staux.find(":");
  while (pos != std::string::npos)
  {
    cont++;
    partip = staux.substr(0, pos+1);

    if (checkGroupIPv6(partip) == false)
    {
      return false;
    }

    partip = staux.substr(pos+1);
    staux  = partip;
    pos    = staux.find(":");
  }

  return ((cont > 1) && (cont < 8));
}