Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
resolver.h
Go to the documentation of this file.
1 /*
2  Posadis - A DNS Server
3  Dns Resolver API
4  Copyright (C) 2002 Meilof Veeningen <meilof@users.sourceforge.net>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 
21 #ifndef __POSLIB_RESOLVER_H
22 #define __POSLIB_RESOLVER_H
23 
24 #include "sysstl.h"
25 
26 #include "socket.h"
27 #include "dnsmessage.h"
28 
45 #define Q_DFL 0
46 
55 #define Q_NOTCP 1
56 
58  public:
59  WaitAnswerData(u_int16 _r_id, _addr& _from);
62 };
63 
85 class pos_resolver {
86  public:
93  pos_resolver();
94 
100  virtual ~pos_resolver();
101 
111 
120  int *udp_tries;
121 
133 
156  virtual void query(DnsMessage *q, DnsMessage*& a, _addr *server, int flags = Q_DFL) = 0;
157 
177  virtual _addr query(DnsMessage *q, DnsMessage*& a, stl_slist(_addr) &servers, int flags = Q_DFL) = 0;
178 
187  virtual void sendmessage(DnsMessage *msg, _addr *res, int sockid = -1) = 0;
188 
207  virtual bool waitanswer(DnsMessage*& ans, stl_slist(WaitAnswerData)& wait, int timeout, stl_slist(WaitAnswerData)::iterator& it, int sockid = -1) = 0;
208 
217  virtual int tcpconnect(_addr *res);
218 
226  virtual void tcpdisconnect(int sockid);
227 
241  virtual void tcpquery(DnsMessage *q, DnsMessage*& a, int sockid);
242 
250  virtual void tcpsendmessage(DnsMessage *msg, int sockid);
251 
265  virtual void tcpwaitanswer(DnsMessage*& ans, int sockid);
266 };
267 
282  public:
288  pos_cliresolver();
289 
295  virtual ~pos_cliresolver();
296 
297  void query(DnsMessage *q, DnsMessage*& a, _addr *server, int flags = Q_DFL);
298 
299  _addr query(DnsMessage *q, DnsMessage*& a, stl_slist(_addr) &servers, int flags = Q_DFL);
300 
309  void sendmessage(DnsMessage *msg, _addr *res, int sockid = -1);
328  bool waitanswer(DnsMessage*& ans, stl_slist(WaitAnswerData)& wait, int timeout, stl_slist(WaitAnswerData)::iterator& it, int sockid = -1);
329 
339  void stop();
340  private:
341  void clrstop();
342  int sockid;
343  bool quit_flag;
344  bool is_tcp;
345 #ifndef _WIN32
346  int clipipes[2];
347 #endif
348 };
349 
350 #endif /* __POSLIB_RESOLVER_H */
351