reSIProcate/rutil  9694
DnsAAAARecord.cxx
Go to the documentation of this file.
00001 #if defined(HAVE_CONFIG_H)
00002 #include "config.h"
00003 #endif
00004 
00005 #include "AresCompat.hxx"
00006 
00007 #ifndef __CYGWIN__
00008 #ifndef RRFIXEDSZ
00009 #define RRFIXEDSZ 10
00010 #endif
00011 #ifndef NS_RRFIXEDSZ
00012 #define NS_RRFIXEDSZ 10
00013 #endif
00014 #endif
00015 
00016 #include <stdlib.h>
00017 
00018 #include "rutil/Socket.hxx"
00019 #include "rutil/Data.hxx"
00020 #include "rutil/DnsUtil.hxx"
00021 #include "rutil/BaseException.hxx"
00022 #include "rutil/dns/RROverlay.hxx"
00023 #include "rutil/dns/DnsResourceRecord.hxx"
00024 #include "rutil/dns/DnsAAAARecord.hxx"
00025 
00026 using namespace resip;
00027 
00028 DnsAAAARecord::DnsAAAARecord(const RROverlay& overlay)
00029 {
00030 #ifdef USE_IPV6
00031    char* name = 0;
00032    long len = 0;
00033    ares_expand_name(overlay.data()-overlay.nameLength()-RRFIXEDSZ, overlay.msg(), overlay.msgLength(), &name, &len);
00034    mName = name;
00035    free(name);
00036    memcpy(&mAddr, overlay.data(), sizeof(in6_addr));
00037 #else
00038    assert(0);
00039 #endif
00040 }
00041 
00042 bool DnsAAAARecord::isSameValue(const Data& value) const
00043 {
00044 #ifdef USE_IPV6
00045    return DnsUtil::inet_ntop(mAddr) == value;
00046 #else
00047    assert(0);
00048    return false;
00049 #endif
00050 }
00051 
00052 EncodeStream&
00053 DnsAAAARecord::dump(EncodeStream& strm) const
00054 {
00055 #ifdef USE_IPV6
00056    strm << mName << " (AAAA) --> " << DnsUtil::inet_ntop(mAddr);
00057    return strm;
00058 #else
00059    assert(0);
00060    strm <<  " (AAAA) --> ? (IPV6 is disabled in this library, what "
00061                                     "happened here?)";
00062    return strm;
00063 #endif
00064 }
00065 
00066 /* ====================================================================
00067  * The Vovida Software License, Version 1.0 
00068  * 
00069  * Copyright (c) 2000-2005 Vovida Networks, Inc.  All rights reserved.
00070  * 
00071  * Redistribution and use in source and binary forms, with or without
00072  * modification, are permitted provided that the following conditions
00073  * are met:
00074  * 
00075  * 1. Redistributions of source code must retain the above copyright
00076  *    notice, this list of conditions and the following disclaimer.
00077  * 
00078  * 2. Redistributions in binary form must reproduce the above copyright
00079  *    notice, this list of conditions and the following disclaimer in
00080  *    the documentation and/or other materials provided with the
00081  *    distribution.
00082  * 
00083  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00084  *    and "Vovida Open Communication Application Library (VOCAL)" must
00085  *    not be used to endorse or promote products derived from this
00086  *    software without prior written permission. For written
00087  *    permission, please contact vocal@vovida.org.
00088  *
00089  * 4. Products derived from this software may not be called "VOCAL", nor
00090  *    may "VOCAL" appear in their name, without prior written
00091  *    permission of Vovida Networks, Inc.
00092  * 
00093  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00094  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00095  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00096  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00097  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00098  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00099  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00100  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00101  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00102  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00103  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00104  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00105  * DAMAGE.
00106  * 
00107  * ====================================================================
00108  * 
00109  * This software consists of voluntary contributions made by Vovida
00110  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00111  * Inc.  For more information on Vovida Networks, Inc., please see
00112  * <http://www.vovida.org/>.
00113  *
00114  */
00115