IPvXAddress.cc

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2005 Andras Varga
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this program; if not, see <http://www.gnu.org/licenses/>.
00016 //
00017 
00018 #include <iostream>
00019 #include "IPvXAddress.h"
00020 
00021 bool IPvXAddress::tryParse(const char *addr)
00022 {
00023     // try as IPv4
00024     if (IPAddress::isWellFormed(addr))
00025     {
00026         set(IPAddress(addr));
00027         return true;
00028     }
00029 
00030     // try as IPv6
00031     IPv6Address ipv6;
00032     if (ipv6.tryParse(addr))
00033     {
00034         set(ipv6);
00035         return true;
00036     }
00037 
00038     // no luck
00039     return false;
00040 }
00041 
00042