|
reSIProcate/rutil
9694
|
00001 #if !defined(RESIP_LOCAL_DNS_HXX) 00002 #define RESIP_LOCAL_DNS_HXX 00003 00004 #include <map> 00005 #include "rutil/Data.hxx" 00006 #include "rutil/dns/ExternalDns.hxx" 00007 00008 extern "C" 00009 { 00010 struct ares_channeldata; 00011 } 00012 00013 00014 namespace resip 00015 { 00016 class LocalDns : public ExternalDns 00017 { 00018 public: 00019 LocalDns(); 00020 virtual ~LocalDns(); 00021 00022 virtual int init(); 00023 virtual unsigned int getTimeTillNextProcessMS(); 00024 virtual void buildFdSet(fd_set& read, fd_set& write, int& size); 00025 virtual void process(fd_set& read, fd_set& write); 00026 00027 virtual void freeResult(ExternalDnsRawResult /* res */) {} 00028 virtual void freeResult(ExternalDnsHostResult /* res */) {} 00029 00030 void lookup(const char* target, unsigned short type, ExternalDnsHandler* handler, void* userData); 00031 00032 virtual void lookupARecords(const char* target, ExternalDnsHandler* handler, void* userData) {} 00033 virtual void lookupAAAARecords(const char* target, ExternalDnsHandler* handler, void* userData) {} 00034 virtual void lookupNAPTR(const char* target, ExternalDnsHandler* handler, void* userData) {} 00035 virtual void lookupSRV(const char* target, ExternalDnsHandler* handler, void* userData) {} 00036 virtual char* errorMessage(long errorCode) 00037 { 00038 const char* msg = "Local Dns"; 00039 00040 int len = (int)strlen(msg); 00041 char* errorString = new char[len+1]; 00042 00043 strncpy(errorString, msg, len); 00044 errorString[len] = '\0'; 00045 return errorString; 00046 } 00047 00048 private: 00049 00050 struct ares_channeldata* mChannel; 00051 00052 typedef std::pair<ExternalDnsHandler*, void*> Payload; 00053 static ExternalDnsRawResult makeRawResult(void *arg, int status, unsigned char *abuf, int alen); 00054 static ExternalDnsHandler* getHandler(void* arg); 00055 00056 static void localCallback(void *arg, int status, unsigned char* abuf, int alen); 00057 00058 static void message(const char* file, unsigned char* buf, int& len); 00059 static std::map<Data, Data> files; 00060 static Data mTarget; 00061 }; 00062 00063 } 00064 00065 #endif 00066 00067 /* ==================================================================== 00068 * The Vovida Software License, Version 1.0 00069 * 00070 * Copyright (c) 2000-2005 Vovida Networks, Inc. All rights reserved. 00071 * 00072 * Redistribution and use in source and binary forms, with or without 00073 * modification, are permitted provided that the following conditions 00074 * are met: 00075 * 00076 * 1. Redistributions of source code must retain the above copyright 00077 * notice, this list of conditions and the following disclaimer. 00078 * 00079 * 2. Redistributions in binary form must reproduce the above copyright 00080 * notice, this list of conditions and the following disclaimer in 00081 * the documentation and/or other materials provided with the 00082 * distribution. 00083 * 00084 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00085 * and "Vovida Open Communication Application Library (VOCAL)" must 00086 * not be used to endorse or promote products derived from this 00087 * software without prior written permission. For written 00088 * permission, please contact vocal@vovida.org. 00089 * 00090 * 4. Products derived from this software may not be called "VOCAL", nor 00091 * may "VOCAL" appear in their name, without prior written 00092 * permission of Vovida Networks, Inc. 00093 * 00094 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00095 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00096 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00097 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00098 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00099 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00100 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00101 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00102 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00103 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00104 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00105 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00106 * DAMAGE. 00107 * 00108 * ==================================================================== 00109 * 00110 * This software consists of voluntary contributions made by Vovida 00111 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00112 * Inc. For more information on Vovida Networks, Inc., please see 00113 * <http://www.vovida.org/>. 00114 * 00115 */
1.7.5.1