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