Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
domainfn.h
Go to the documentation of this file.
1 /*
2  Posadis - A DNS Server
3  Domain functions
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_DOMAINFN_H
22 #define __POSLIB_DOMAINFN_H
23 
24 class domainname;
25 
26 #include "sysstl.h"
27 #include "dnsmessage.h"
28 
47 #define DOM_LEN 255
48 
55 #define DOMLABEL_LEN 63
56 
64 class domainname {
65  public:
71  domainname();
72 
82  domainname(const char *text, const domainname& origin);
83 
96  domainname(const char *text, _cdomain origin = (unsigned char*)"");
97 
107  domainname(message_buff &buff, int ix);
108 
119  domainname(bool is_binary, const unsigned char* dom);
120 
127  domainname(const domainname& nam);
128 
137  bool operator==(const domainname& nam) const;
138 
147  bool operator!=(const domainname& nam) const;
148 
156  domainname& operator=(const domainname& nam);
157 
166  domainname& operator=(const char *buff);
167 
179  domainname& operator+=(const domainname& dom);
188  domainname& operator+(const domainname& dom);
189 
199  bool operator>=(const domainname& dom) const;
200 
210  bool operator>(const domainname& dom) const;
211 
217  ~domainname();
218 
226  _domain c_str() const;
227 
236  int len() const;
237 
246  stl_string tostring() const;
247 
256 #define tocstr() tostring().c_str()
257 
266  int nlabels() const;
267 
277  stl_string label(int ix) const;
278 
287  domainname from(int ix) const;
288 
298  domainname to(int labels) const;
299 
311  stl_string torelstring(const domainname &root) const;
312 
321  stl_string canonical () const;
322 
333  int ncommon(const domainname &dom) const;
334 
335  private:
336  unsigned char *domain;
337 };
338 
344 typedef unsigned char _sdomain[DOM_LEN];
345 
355 void *memdup(const void *src, int len);
356 
366 int dom_comprlen(message_buff &buff, int ix);
367 
377 _domain dom_uncompress(message_buff &buff, int ix);
378 
385  public:
386  dom_compr_info(_cdomain _dom, int _ix, int _nl, int _nul);
388  int ix;
389  int nl;
390  int nul;
391 };
392 
402 void dom_write(stl_string &ret, _cdomain dom, stl_slist(dom_compr_info)* compr);
403 
404 /* traditional domain-name functions */
405 
414 _domain domfrom(_cdomain dom, int ix);
415 
425 bool domisparent(_cdomain parent, _cdomain child);
426 
435 int domlen(_cdomain dom);
436 
445 _domain domdup(_cdomain dom);
446 
455 bool domlcmp(_cdomain dom1, _cdomain dom2);
456 
465 bool domcmp(_cdomain dom1, _cdomain dom2);
466 
475 void domcat(_domain target, _cdomain src);
476 
486 void domcpy(_domain res, _cdomain src);
487 
498 void domfromlabel(_domain dom, const char *label, int len = -1);
499 
509 
518 int dom_nlabels(_cdomain dom);
519 
529 stl_string dom_label(_cdomain dom, int label);
530 
540 _domain dom_plabel(_cdomain dom, int label);
541 
553 int domncommon(_cdomain dom1, _cdomain dom2);
554 
570 int domccmp(_cdomain dom1, _cdomain dom2);
571 
583 void domto(_domain ret, _cdomain src, int labels);
584 
585 #endif /* __POSLIB_DOMAINFN_H */
586