reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
DnsAAAARecord.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
5#include "AresCompat.hxx"
6
7#ifndef __CYGWIN__
8#ifndef RRFIXEDSZ
9#define RRFIXEDSZ 10
10#endif
11#ifndef NS_RRFIXEDSZ
12#define NS_RRFIXEDSZ 10
13#endif
14#endif
15
16#include <stdlib.h>
17
18#include "rutil/Socket.hxx"
19#include "rutil/Data.hxx"
20#include "rutil/DnsUtil.hxx"
25
26using namespace resip;
27
29{
30#ifdef USE_IPV6
31 char* name = 0;
32 long len = 0;
33 if (ARES_SUCCESS != ares_expand_name(overlay.data() - overlay.nameLength() - RRFIXEDSZ, overlay.msg(), overlay.msgLength(), &name, &len))
34 {
35 throw AaaaException("Failed parse of AAAA record", __FILE__, __LINE__);
36 }
37 mName = name;
38 free(name);
39 mTTL = overlay.ttl();
40 if (overlay.dataLength() != (int)sizeof(in6_addr))
41 {
42 throw AaaaException("Failed parse of AAAA record", __FILE__, __LINE__);
43 }
44 memcpy(&mAddr, overlay.data(), sizeof(in6_addr));
45#else
46 resip_assert(0);
47#endif
48}
49
50bool DnsAAAARecord::isSameValue(const Data& value) const
51{
52#ifdef USE_IPV6
53 return DnsUtil::inet_ntop(mAddr) == value;
54#else
55 resip_assert(0);
56 return false;
57#endif
58}
59
61DnsAAAARecord::dump(EncodeStream& strm) const
62{
63#ifdef USE_IPV6
64 strm << mName << " (AAAA) --> " << DnsUtil::inet_ntop(mAddr) << " ttl=" << mTTL;
65 return strm;
66#else
67 resip_assert(0);
68 strm << " (AAAA) --> ? (IPV6 is disabled in this library, what "
69 "happened here?)";
70 return strm;
71#endif
72}
73
74/* ====================================================================
75 * The Vovida Software License, Version 1.0
76 *
77 * Copyright (c) 2000-2005 Vovida Networks, Inc. All rights reserved.
78 *
79 * Redistribution and use in source and binary forms, with or without
80 * modification, are permitted provided that the following conditions
81 * are met:
82 *
83 * 1. Redistributions of source code must retain the above copyright
84 * notice, this list of conditions and the following disclaimer.
85 *
86 * 2. Redistributions in binary form must reproduce the above copyright
87 * notice, this list of conditions and the following disclaimer in
88 * the documentation and/or other materials provided with the
89 * distribution.
90 *
91 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
92 * and "Vovida Open Communication Application Library (VOCAL)" must
93 * not be used to endorse or promote products derived from this
94 * software without prior written permission. For written
95 * permission, please contact vocal@vovida.org.
96 *
97 * 4. Products derived from this software may not be called "VOCAL", nor
98 * may "VOCAL" appear in their name, without prior written
99 * permission of Vovida Networks, Inc.
100 *
101 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
102 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
103 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
104 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
105 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
106 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
107 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
108 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
109 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
110 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
112 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
113 * DAMAGE.
114 *
115 * ====================================================================
116 *
117 * This software consists of voluntary contributions made by Vovida
118 * Networks, Inc. and many individuals on behalf of Vovida Networks,
119 * Inc. For more information on Vovida Networks, Inc., please see
120 * <http://www.vovida.org/>.
121 *
122 */
123
#define resip_assert(x)
This file needs to work for both C and C++ code.
Handles cross-platform sockets compatibility.
#define ARES_SUCCESS
Definition ares.h:79
int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen)
#define RRFIXEDSZ
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
virtual EncodeStream & dump(EncodeStream &strm) const
virtual const Data & name() const
DnsAAAARecord(const RROverlay &overlay)
virtual bool isSameValue(const Data &value) const
static Data inet_ntop(const struct in_addr &addr)
Converts from the network format to presentation format.
Definition DnsUtil.cxx:240
int msgLength() const
Definition RROverlay.hxx:40
int dataLength() const
Definition RROverlay.hxx:41
const unsigned char * msg() const
Definition RROverlay.hxx:39
int nameLength() const
Definition RROverlay.hxx:42
const unsigned char * data() const
Definition RROverlay.hxx:38
int ttl() const
Definition RROverlay.hxx:43
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream