reSIProcate/rutil  9694
testDnsUtil.cxx
Go to the documentation of this file.
00001 #include <iostream>
00002 #include "assert.h"
00003 
00004 #include "rutil/DnsUtil.hxx"
00005 #include "rutil/Logger.hxx"
00006 #include "rutil/Inserter.hxx"
00007 
00008 using namespace resip;
00009 using namespace std;
00010 
00011 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
00012 
00013 int
00014 main(int argc, char* argv[])
00015 {
00016    Log::Level l = Log::Debug;
00017    Log::initialize(Log::Cout, l, argv[0]);
00018    
00019    {
00020       resipCerr << "Network Interfaces: " << endl << Inserter(DnsUtil::getInterfaces()) << endl << endl;
00021    }
00022    
00023    {
00024       Data addr("1:1");
00025       resipCerr << "!! "<< addr << endl;
00026       assert(DnsUtil::isIpV6Address(addr));
00027    }
00028 
00029    {
00030       Data addr("1:1:192.168.2.233");
00031       resipCerr << "!! "<< addr << endl;
00032       assert(DnsUtil::isIpV6Address(addr));
00033    }
00034 
00035    {
00036       Data addr("1:1:::::");
00037       resipCerr << "!! "<< addr << endl;
00038       assert(DnsUtil::isIpV6Address(addr));
00039    }
00040 
00041    {
00042       Data addr("1:1::::::168.192.2.233");
00043       resipCerr << "!! "<< addr << endl;
00044       assert(DnsUtil::isIpV6Address(addr));
00045    }
00046 
00047    {
00048       Data addr("5f1b:df00:ce3e:e200:20:800:2b37:6426");
00049       resipCerr << "!! "<< addr << endl;
00050       assert(DnsUtil::isIpV6Address(addr));
00051    }
00052 
00053    {
00054       Data addr("5f1b:df00:ce3e:e200:20:800:2b37:6426:121.12.131.12");
00055       resipCerr << "!! "<< addr << endl;
00056       assert(DnsUtil::isIpV6Address(addr));
00057    }
00058 
00059    {
00060       Data addr("192.168.2.233");
00061       resipCerr << "!! "<< addr << endl;
00062       assert(!DnsUtil::isIpV6Address(addr));
00063    }
00064 
00065    {
00066       Data addr("u@a.tv:1290");
00067       resipCerr << "!! "<< addr << endl;
00068       assert(!DnsUtil::isIpV6Address(addr));
00069    }
00070 
00071    {
00072       Data addr("::1");
00073       resipCerr << "!! "<< addr << endl;
00074       assert(DnsUtil::isIpV6Address(addr));
00075    }
00076 
00077    {
00078       Data addr("::");
00079       resipCerr << "!! "<< addr << endl;
00080       assert(DnsUtil::isIpV6Address(addr));
00081    }
00082 
00083    {
00084       Data addr("FF01::43");
00085       resipCerr << "!! "<< addr << endl;
00086       assert(DnsUtil::isIpV6Address(addr));
00087    }
00088 
00089    {
00090       Data c("apple:5060");
00091       Data addr(Data::Share, c.c_str(), 5);
00092       resipCerr << "!! " << addr << endl;
00093       assert(!DnsUtil::isIpV6Address(addr));
00094    }
00095    
00096    {
00097       Data addr(":zzz");
00098       if(DnsUtil::isIpV6Address(addr))
00099       {
00100          DnsUtil::canonicalizeIpV6Address(addr);
00101       }
00102    }
00103 
00104    resipCerr << "All OK" << endl;
00105 }
00106 /* ====================================================================
00107  * The Vovida Software License, Version 1.0 
00108  * 
00109  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00110  * 
00111  * Redistribution and use in source and binary forms, with or without
00112  * modification, are permitted provided that the following conditions
00113  * are met:
00114  * 
00115  * 1. Redistributions of source code must retain the above copyright
00116  *    notice, this list of conditions and the following disclaimer.
00117  * 
00118  * 2. Redistributions in binary form must reproduce the above copyright
00119  *    notice, this list of conditions and the following disclaimer in
00120  *    the documentation and/or other materials provided with the
00121  *    distribution.
00122  * 
00123  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00124  *    and "Vovida Open Communication Application Library (VOCAL)" must
00125  *    not be used to endorse or promote products derived from this
00126  *    software without prior written permission. For written
00127  *    permission, please contact vocal@vovida.org.
00128  *
00129  * 4. Products derived from this software may not be called "VOCAL", nor
00130  *    may "VOCAL" appear in their name, without prior written
00131  *    permission of Vovida Networks, Inc.
00132  * 
00133  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00134  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00135  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00136  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00137  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00138  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00139  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00140  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00141  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00142  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00144  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00145  * DAMAGE.
00146  * 
00147  * ====================================================================
00148  * 
00149  * This software consists of voluntary contributions made by Vovida
00150  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00151  * Inc.  For more information on Vovida Networks, Inc., please see
00152  * <http://www.vovida.org/>.
00153  *
00154  */