Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

poslib/resolver.h

Go to the documentation of this file.

  
00001 /* 00002 Posadis - A DNS Server 00003 Dns Resolver API 00004 Copyright (C) 2002 Meilof Veeningen <> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #ifndef __POSLIB_RESOLVER_H 00022 #define __POSLIB_RESOLVER_H 00023 00024 #include "sysstl.h" 00025 00026 #include "socket.h" 00027 #include "dnsmessage.h" 00028 00045 #define Q_DFL 0 00046 00055 #define Q_NOTCP 1 00056 00057 class WaitAnswerData { 00058 public: 00059 WaitAnswerData(u_int16 _r_id, _addr& _from); 00060 u_int16 r_id; 00061 _addr from; 00062 }; 00063 00085 class pos_resolver { 00086 public: 00093 pos_resolver(); 00094 00100 virtual ~pos_resolver(); 00101 00110 int n_udp_tries; 00111 00120 int *udp_tries; 00121 00132 int tcp_timeout; 00133 00156 virtual void query(DnsMessage *q, DnsMessage*& a, _addr *server, int flags = Q_DFL); 00157 00171 virtual void query(DnsMessage *q, DnsMessage*& a, stl_slist(_addr) &servers, int flags = Q_DFL); 00172 00181 virtual void sendmessage(DnsMessage *msg, _addr *res, int sockid = -1); 00182 00199 virtual bool waitanswer(DnsMessage*& ans, stl_slist(WaitAnswerData)& wait, int timeout, stl_slist(WaitAnswerData)::iterator& it, int sockid = -1); 00200 00209 virtual int tcpconnect(_addr *res); 00210 00218 virtual void tcpdisconnect(int sockid); 00219 00233 virtual void tcpquery(DnsMessage *q, DnsMessage*& a, int sockid); 00234 00242 virtual void tcpsendmessage(DnsMessage *msg, int sockid); 00243 00254 virtual void tcpwaitanswer(DnsMessage*& ans, int sockid); 00255 }; 00256 00270 class pos_cliresolver : public pos_resolver { 00271 public: 00277 pos_cliresolver(); 00278 00284 virtual ~pos_cliresolver(); 00285 00286 void query(DnsMessage *q, DnsMessage*& a, _addr *server, int flags = Q_DFL); 00287 void query(DnsMessage *q, DnsMessage*& a, stl_slist(_addr) &servers, int flags = Q_DFL); 00296 void sendmessage(DnsMessage *msg, _addr *res, int sockid = -1); 00313 bool waitanswer(DnsMessage*& ans, stl_slist(WaitAnswerData)& wait, int timeout, stl_slist(WaitAnswerData)::iterator& it, int sockid = -1); 00314 00324 void stop(); 00325 private: 00326 void clrstop(); 00327 int sockid; 00328 bool quit_flag; 00329 bool is_tcp; 00330 #ifndef _WIN32 00331 int clipipes[2]; 00332 #endif 00333 }; 00334 00335 #endif /* __POSLIB_RESOLVER_H */

  
Generated on Fri Dec 24 19:55:14 2004 for Poslib by doxygen 1.3.7