summaryrefslogtreecommitdiffstats
path: root/lanbrowsing/lisa/addressvalidator.h
blob: c2c332ab381b1b4c22e9f167be4ef8d1111e547a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*    addressvalidator.h
 *
 *    Copyright (c) 2000, Alexander Neundorf
 *    [email protected]
 *
 *    You may distribute under the terms of the GNU General Public
 *    License as specified in the COPYING file.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 */

#ifndef ADDRESSVALIDATOR_H
#define ADDRESSVALIDATOR_H

#include "lisadefines.h"
#include "mystring.h"
#include "configfile.h"

#define NO_SPEC 0
#define NETMASK_SPEC 1
#define EXACTADDR_SPEC 2
#define RANGE_SPEC 3
#define MULTIRANGE_SPEC 4

struct AddressSpec
{
   int address;
   int tqmask;
   int typeOfSpec;
};

class AddressValidator
{
   public:
      AddressValidator(const MyString& addressSpecs);
      AddressValidator();
      ~AddressValidator();
      void configure(Config& config);
      void setValidAddresses(MyString addressSpecs);
      void clearSpecs();
      int isValid(int addressNBO);
      MyString validAddresses() {return allowedHosts;};
   private:
      int localhostNet;
      int localhostMask;
      MyString allowedHosts;
      void addSpec(int type, int address, int tqmask=0);
      AddressSpec specs[MAX_SPECS];
};

#endif