2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
23 $Date: 2009/02/24 08:13:03 $
42 #error "You need either stdint.h or inttypes.h to compile this!"
49 //-----------------------------------------------------------------------------
53 uint32_t mask; // Netmask
54 uint16_t port1; // Port 1
55 uint16_t port2; // Port 2
56 int proto; // Protocol
59 //-----------------------------------------------------------------------------
60 typedef std::list<RULE> RULES;
61 //-----------------------------------------------------------------------------
67 RULES_PARSER(const std::string & fileName);
71 void SetFile(const std::string & fileName);
73 const RULES & GetRules() const { return rules; };
74 bool IsError() const { return error; };
75 const std::string ErrorMsg() const { return errorStream.str(); };
80 mutable std::stringstream errorStream;
81 std::map<std::string, int> protocols;
84 bool ParseLine(std::string line);
85 bool ParseAddress(const std::string & address, RULE * rule) const;
86 bool ParseMask(const std::string & mask, RULE * rule) const;
87 bool ParsePorts(const std::string & port1,
88 const std::string & port2,