Debian Codegraph @

src/IPList.hpp

raw
1 // For all support, instructions and copyright go to:
2 // http://e2guardian.org/
3 // Released under the GPL v2, with the OpenSSL exception described in the README file.
4
5 #ifndef __HPP_IPLIST
6 #define __HPP_IPLIST
7
8 // INCLUDES
9
10 #include <list>
11 #include <cstdint>
12
13 // DECLARATIONS
14
15 // convenience structs for subnets and IP ranges
16 struct ipl_subnetstruct {
17 uint32_t maskedaddr;
18 uint32_t mask;
19 };
20
21 struct ipl_rangestruct {
22 public:
23 uint32_t startaddr;
24 uint32_t endaddr;
25 int operator<(const ipl_rangestruct &a) const
26 {
27 if (startaddr < a.startaddr)
28 return 1;
29 return 0;
30 }
31 };
32
33 // IP subnet/range/mask & hostname list
34 class IPList
35 {
36 public:
37 void reset();
38 bool inList(const std::string &ipstr, std::string *&host) const;
39 bool ifsreadIPMelangeList(std::ifstream *input, bool checkendstring, const char *endstring);
40 bool readIPMelangeList(const char *filename);
41
42 private:
43 std::vector<uint32_t> iplist;
44 std::vector<String> hostlist;
45 std::vector<ipl_rangestruct> iprangelist;
46 //std::list<ipl_subnetstruct> ipsubnetlist;
47 };
48
49 #endif