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