|
reSIProcate/rutil
9694
|
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 <cstdlib> 00017 #include <vector> 00018 #include "rutil/Data.hxx" 00019 #include "rutil/BaseException.hxx" 00020 #include "RROverlay.hxx" 00021 00022 using namespace resip; 00023 using namespace std; 00024 00025 #define RESIPROCATE_SUBSYSTEM Subsystem::DNS 00026 00027 // aptr - points to the begining of the resource record. 00028 // abuf - points to the begining of the message. 00029 // alen - length of abuf. 00030 RROverlay::RROverlay(const unsigned char *aptr, 00031 const unsigned char *abuf, 00032 int alen) : 00033 mData(0), 00034 mMsg(0), 00035 mMsgLen(0), 00036 mDataLen(0), 00037 mNameLen(0), 00038 mTTL(0), 00039 mType(-1) 00040 { 00041 char *name; 00042 long len = 0; 00043 00044 // Parse the RR name. 00045 int status = ares_expand_name(aptr, abuf, alen, &name, &len); 00046 if (status != ARES_SUCCESS) 00047 { 00048 throw OverlayException("Failed parse of RR", __FILE__, __LINE__); 00049 } 00050 mDomain = name; 00051 aptr += len; 00052 mNameLen = len; 00053 free(name); 00054 00055 // Make sure there is enough data after the RR name for the fixed 00056 // part of the RR. 00057 if (aptr + RRFIXEDSZ > abuf + alen) 00058 { 00059 throw OverlayException("Failed parse of RR", __FILE__, __LINE__); 00060 } 00061 00062 // Parse the fixed part of the RR, and advance to the RR data field. 00063 // 00064 mType = DNS_RR_TYPE(aptr); 00065 mDataLen = DNS_RR_LEN(aptr); 00066 mTTL = DNS_RR_TTL(aptr); 00067 00068 aptr += RRFIXEDSZ; 00069 if (aptr + mDataLen > abuf + alen) 00070 { 00071 throw OverlayException("Failed parse of RR", __FILE__, __LINE__); 00072 } 00073 00074 mData = aptr; 00075 mMsgLen = alen; 00076 mMsg = abuf; 00077 aptr += mDataLen; 00078 } 00079 00080 /* ==================================================================== 00081 * The Vovida Software License, Version 1.0 00082 * 00083 * Copyright (c) 2000-2005 Vovida Networks, Inc. All rights reserved. 00084 * 00085 * Redistribution and use in source and binary forms, with or without 00086 * modification, are permitted provided that the following conditions 00087 * are met: 00088 * 00089 * 1. Redistributions of source code must retain the above copyright 00090 * notice, this list of conditions and the following disclaimer. 00091 * 00092 * 2. Redistributions in binary form must reproduce the above copyright 00093 * notice, this list of conditions and the following disclaimer in 00094 * the documentation and/or other materials provided with the 00095 * distribution. 00096 * 00097 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00098 * and "Vovida Open Communication Application Library (VOCAL)" must 00099 * not be used to endorse or promote products derived from this 00100 * software without prior written permission. For written 00101 * permission, please contact vocal@vovida.org. 00102 * 00103 * 4. Products derived from this software may not be called "VOCAL", nor 00104 * may "VOCAL" appear in their name, without prior written 00105 * permission of Vovida Networks, Inc. 00106 * 00107 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00108 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00109 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00110 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00111 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00112 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00113 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00114 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00115 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00116 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00117 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00118 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00119 * DAMAGE. 00120 * 00121 * ==================================================================== 00122 * 00123 * This software consists of voluntary contributions made by Vovida 00124 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00125 * Inc. For more information on Vovida Networks, Inc., please see 00126 * <http://www.vovida.org/>. 00127 * 00128 */ 00129
1.7.5.1