reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RROverlay.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 <cstdlib>
17#include <vector>
18#include "rutil/Data.hxx"
20#include "RROverlay.hxx"
21
22using namespace resip;
23using namespace std;
24
25#define RESIPROCATE_SUBSYSTEM Subsystem::DNS
26
27// aptr - points to the begining of the resource record.
28// abuf - points to the begining of the message.
29// alen - length of abuf.
30RROverlay::RROverlay(const unsigned char *aptr,
31 const unsigned char *abuf,
32 int alen) :
33 mData(0),
34 mMsg(0),
35 mMsgLen(0),
36 mDataLen(0),
37 mNameLen(0),
38 mTTL(0),
39 mType(-1)
40{
41 char *name;
42 long len = 0;
43
44 // Parse the RR name.
45 int status = ares_expand_name(aptr, abuf, alen, &name, &len);
46 if (status != ARES_SUCCESS)
47 {
48 throw OverlayException("Failed parse of RR", __FILE__, __LINE__);
49 }
50 mDomain = name;
51 aptr += len;
52 mNameLen = len;
53 free(name);
54
55 // Make sure there is enough data after the RR name for the fixed
56 // part of the RR.
57 if (aptr + RRFIXEDSZ > abuf + alen)
58 {
59 throw OverlayException("Failed parse of RR", __FILE__, __LINE__);
60 }
61
62 // Parse the fixed part of the RR, and advance to the RR data field.
63 //
64 mType = DNS_RR_TYPE(aptr);
65 mDataLen = DNS_RR_LEN(aptr);
66 mTTL = DNS_RR_TTL(aptr);
67
68 aptr += RRFIXEDSZ;
69 if (aptr + mDataLen > abuf + alen)
70 {
71 throw OverlayException("Failed parse of RR", __FILE__, __LINE__);
72 }
73
74 mData = aptr;
75 mMsgLen = alen;
76 mMsg = abuf;
77 aptr += mDataLen;
78}
79
80/* ====================================================================
81 * The Vovida Software License, Version 1.0
82 *
83 * Copyright (c) 2000-2005 Vovida Networks, Inc. All rights reserved.
84 *
85 * Redistribution and use in source and binary forms, with or without
86 * modification, are permitted provided that the following conditions
87 * are met:
88 *
89 * 1. Redistributions of source code must retain the above copyright
90 * notice, this list of conditions and the following disclaimer.
91 *
92 * 2. Redistributions in binary form must reproduce the above copyright
93 * notice, this list of conditions and the following disclaimer in
94 * the documentation and/or other materials provided with the
95 * distribution.
96 *
97 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
98 * and "Vovida Open Communication Application Library (VOCAL)" must
99 * not be used to endorse or promote products derived from this
100 * software without prior written permission. For written
101 * permission, please contact vocal@vovida.org.
102 *
103 * 4. Products derived from this software may not be called "VOCAL", nor
104 * may "VOCAL" appear in their name, without prior written
105 * permission of Vovida Networks, Inc.
106 *
107 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
108 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
109 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
110 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
111 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
112 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
113 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
114 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
115 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
116 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
118 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
119 * DAMAGE.
120 *
121 * ====================================================================
122 *
123 * This software consists of voluntary contributions made by Vovida
124 * Networks, Inc. and many individuals on behalf of Vovida Networks,
125 * Inc. For more information on Vovida Networks, Inc., please see
126 * <http://www.vovida.org/>.
127 *
128 */
129
#define ARES_SUCCESS
Definition ares.h:79
#define DNS_RR_LEN(r)
Definition ares.h:53
#define DNS_RR_TTL(r)
Definition ares.h:54
int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen)
#define DNS_RR_TYPE(r)
Definition ares.h:52
#define RRFIXEDSZ
RROverlay(const unsigned char *aptr, const unsigned char *abuf, int alen)
Definition RROverlay.cxx:30
dcm! – add UnusedChecking(_enum) below;