1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-06-24 18:09:40 +02:00

See #2394 grammar can parse most of the sample pf.conf files, including important ones

This commit is contained in:
Vadim Kurland
2011-05-25 18:57:38 -07:00
parent 439f8240ba
commit ea9c28fda1
16 changed files with 3276 additions and 1717 deletions

View File

@@ -7,7 +7,7 @@ FWB_MICRO_VERSION=0
# build number is like "nano" version number. I am incrementing build
# number during development cycle
#
BUILD_NUM="3544"
BUILD_NUM="3546"
VERSION="$FWB_MAJOR_VERSION.$FWB_MINOR_VERSION.$FWB_MICRO_VERSION.$BUILD_NUM"

View File

@@ -1,2 +1,2 @@
#define VERSION "4.3.0.3544"
#define VERSION "4.3.0.3546"
#define GENERATION "4.3"

View File

@@ -3,7 +3,7 @@
%define name fwbuilder
%define version 4.3.0.3544
%define version 4.3.0.3546
%define release 1
%if "%_vendor" == "MandrakeSoft"

View File

@@ -4,6 +4,6 @@ Replaces: fwbuilder (<=4.1.1-1), fwbuilder-common, fwbuilder-bsd, fwbuilder-linu
Priority: extra
Section: checkinstall
Maintainer: vadim@fwbuilder.org
Version: 4.3.0.3544-1
Version: 4.3.0.3546-1
Depends: libqt4-gui (>= 4.3.0), libxml2, libxslt1.1, libsnmp | libsnmp15
Description: Firewall Builder GUI and policy compilers

View File

@@ -1,6 +1,6 @@
%define name fwbuilder
%define version 4.3.0.3544
%define version 4.3.0.3546
%define release 1
%if "%_vendor" == "MandrakeSoft"

View File

@@ -43,8 +43,6 @@
#include <QMap>
typedef std::pair<std::string,std::string> str_tuple;
class IPTImporter : public Importer
{

View File

@@ -43,6 +43,9 @@
#include <QString>
typedef std::pair<std::string,std::string> str_tuple;
typedef std::vector<std::string> str_vector;
class Importer;

View File

@@ -86,9 +86,9 @@ void PFImporter::clear()
quick = false;
direction = "";
iface = "";
address_family = "";
iface_group.clear();
proto_list.clear();
src_group.clear();
dst_group.clear();
@@ -98,12 +98,23 @@ void PFImporter::clear()
tmp_neg = false;
tmp_port_def = "";
tmp_port_op = "";
src_port_group.clear();
dst_port_group.clear();
tmp_port_group.clear();
icmp_type_code_group.clear();
queue = "";
state_op = "";
logopts = "";
flags_check = "";
flags_mask = "";
tag = "";
tagged = "";
route_type = UNKNOWN;
route_group.clear();
Importer::clear();
}
@@ -240,6 +251,16 @@ void PFImporter::pushPolicyRule()
assert(current_rule!=NULL);
// populate all elements of the rule
// Note that standard function
// setInterfaceAndDirectionForRuleSet() assumes there is only one
// interface, but here we can have a group. Information about
// interfaces (even if there is only one) is stored in the list
// iface_group
//
// importer->setInterfaceAndDirectionForRuleSet(
// "", importer->iface, importer->direction);
addMessageToLog(
QString("filtering rule: action %1")
.arg(action.c_str()));

View File

@@ -41,34 +41,151 @@
#include <QString>
class InterfaceSpec
{
public:
bool neg;
std::string name;
InterfaceSpec()
{ neg = false; name = ""; }
InterfaceSpec(const InterfaceSpec &other)
{
neg = other.neg;
name = other.name;
}
InterfaceSpec(bool _neg, const std::string _name)
{ neg = _neg; name = _name; }
};
class AddressSpec
{
public:
typedef enum {
UNKNOWN,
ANY,
HOST_ADDRESS,
NETWORK_ADDRESS,
SPECIAL_ADDRESS,
INTERFACE_NAME,
TABLE } address_type;
address_type at;
std::string address;
std::string netmask;
AddressSpec()
{ at = UNKNOWN; address = ""; netmask = ""; }
AddressSpec(const AddressSpec &other)
{
at = other.at;
address = other.address;
netmask = other.netmask;
}
AddressSpec(address_type _at, const std::string _addr, const std::string _nm)
{ at = _at; address = _addr; netmask = _nm; }
};
class PortSpec
{
public:
std::string port1;
std::string port2;
std::string port_op;
PortSpec()
{ port1 = ""; port2 = ""; port_op = ""; }
PortSpec(const PortSpec &other)
{
port1 = other.port1;
port2 = other.port2;
port_op = other.port_op;
}
PortSpec(const std::string s1, const std::string s2, const std::string s3)
{ port1 = s1; port2 = s2; port_op = s3; }
};
class RouteSpec
{
public:
std::string iface;
std::string address;
std::string netmask;
RouteSpec()
{ iface = ""; address = ""; netmask = ""; }
RouteSpec(const RouteSpec &other)
{
iface = other.iface;
address = other.address;
netmask = other.netmask;
}
RouteSpec(const std::string _iface,
const std::string _addr, const std::string _nm)
{ iface = _iface; address = _addr; netmask = _nm; }
};
class PFImporter : public Importer
{
public:
typedef enum {
UNKNOWN,
ROUTE_TO,
REPLY_TO,
DUP_TO} route_op_type;
std::string direction;
std::string iface;
std::string address_family;
bool quick;
bool src_neg;
bool dst_neg;
bool tmp_neg;
std::list<InterfaceSpec> iface_group;
std::list<std::string> proto_list;
std::list<std::pair<std::string, std::string> > src_group;
std::list<std::pair<std::string, std::string> > dst_group;
std::list<std::pair<std::string, std::string> > tmp_group;
std::list< AddressSpec > src_group;
std::list< AddressSpec > dst_group;
std::list< AddressSpec > tmp_group;
// each item in the list is a vector of 2 or 3 strings
// Unary operations are represented by 2 strings, binary operations
// use 3 strings
std::string tmp_port_op;
std::string tmp_port_def;
std::list< std::vector<std::string> > src_port_group;
std::list< std::vector<std::string> > dst_port_group;
std::list< std::vector<std::string> > tmp_port_group;
std::list< PortSpec > src_port_group;
std::list< PortSpec > dst_port_group;
std::list< PortSpec > tmp_port_group;
std::list<str_tuple> icmp_type_code_group;
route_op_type route_type;
std::list<RouteSpec> route_group;
std::string queue;
std::string state_op;
std::string logopts;
std::string flags_check;
std::string flags_mask;
std::string tag;
std::string tagged;
libfwbuilder::NATRule::NATRuleTypes rule_type;

View File

@@ -44,80 +44,90 @@ PFCfgLexer::PFCfgLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& st
void PFCfgLexer::initLiterals()
{
literals["vrrp"] = 44;
literals["critical"] = 89;
literals["ospf"] = 42;
literals["rdp"] = 36;
literals["disable"] = 96;
literals["vrrp"] = 50;
literals["critical"] = 96;
literals["ospf"] = 48;
literals["rdp"] = 42;
literals["disable"] = 103;
literals["scrub"] = 12;
literals["ipsec"] = 79;
literals["inet"] = 28;
literals["pcp"] = 81;
literals["emergencies"] = 91;
literals["debugging"] = 90;
literals["snp"] = 85;
literals["timeout"] = 16;
literals["to"] = 25;
literals["isis"] = 46;
literals["pptp"] = 83;
literals["pass"] = 17;
literals["no"] = 57;
literals["from"] = 50;
literals["igrp"] = 78;
literals["pim"] = 82;
literals["rsvp"] = 37;
literals["nos"] = 80;
literals["quit"] = 75;
literals["->"] = 98;
literals["exit"] = 74;
literals["modulate"] = 59;
literals["nat"] = 13;
literals["range"] = 87;
literals["out"] = 20;
literals["ipsec"] = 86;
literals["inet"] = 34;
literals["pcp"] = 88;
literals["emergencies"] = 98;
literals["debugging"] = 97;
literals["snp"] = 92;
literals["timeout"] = 17;
literals["to"] = 28;
literals["flags"] = 66;
literals["isis"] = 52;
literals["icmp6-type"] = 69;
literals["pptp"] = 90;
literals["pass"] = 18;
literals["no"] = 72;
literals["from"] = 54;
literals["igrp"] = 85;
literals["pim"] = 89;
literals["tagged"] = 70;
literals["rsvp"] = 43;
literals["route-to"] = 64;
literals["nos"] = 87;
literals["quit"] = 82;
literals["->"] = 105;
literals["icmp-type"] = 67;
literals["exit"] = 81;
literals["modulate"] = 74;
literals["nat"] = 14;
literals["range"] = 94;
literals["urpf-failed"] = 55;
literals["out"] = 21;
literals["queue"] = 10;
literals["gre"] = 38;
literals["gre"] = 44;
literals["set"] = 11;
literals["warnings"] = 95;
literals["ah"] = 40;
literals["host"] = 86;
literals["interface"] = 76;
literals["rip"] = 84;
literals["icmp6"] = 77;
literals["notifications"] = 94;
literals["synproxy"] = 60;
literals["!="] = 65;
literals["warnings"] = 102;
literals["ah"] = 46;
literals["host"] = 93;
literals["interface"] = 83;
literals["rip"] = 91;
literals["icmp6"] = 84;
literals["notifications"] = 101;
literals["synproxy"] = 75;
literals["altq"] = 9;
literals["any"] = 51;
literals["esp"] = 39;
literals["alerts"] = 88;
literals["inet6"] = 29;
literals["inactive"] = 97;
literals["udp"] = 35;
literals["<>"] = 70;
literals["port"] = 64;
literals["ip"] = 31;
literals[">="] = 69;
literals["eigrp"] = 41;
literals["<="] = 67;
literals["errors"] = 92;
literals["ipip"] = 43;
literals["any"] = 56;
literals["esp"] = 45;
literals["alerts"] = 95;
literals["all"] = 26;
literals["inet6"] = 35;
literals["inactive"] = 104;
literals["label"] = 77;
literals["udp"] = 41;
literals["no-route"] = 58;
literals["reply-to"] = 65;
literals["tag"] = 71;
literals["port"] = 79;
literals["code"] = 68;
literals["ip"] = 37;
literals["table"] = 13;
literals["eigrp"] = 47;
literals["errors"] = 99;
literals["ipip"] = 49;
literals["antispoof"] = 8;
literals["binat"] = 14;
literals["igmp"] = 33;
literals["><"] = 71;
literals["on"] = 27;
literals["state"] = 61;
literals["proto"] = 30;
literals["log"] = 21;
literals["rdr"] = 15;
literals["informational"] = 93;
literals["in"] = 19;
literals["keep"] = 58;
literals["block"] = 18;
literals["l2tp"] = 45;
literals["quick"] = 26;
literals["icmp"] = 32;
literals["tcp"] = 34;
literals["binat"] = 15;
literals["igmp"] = 39;
literals["on"] = 30;
literals["state"] = 76;
literals["proto"] = 36;
literals["log"] = 22;
literals["rdr"] = 16;
literals["informational"] = 100;
literals["in"] = 20;
literals["self"] = 57;
literals["keep"] = 73;
literals["block"] = 19;
literals["l2tp"] = 51;
literals["quick"] = 29;
literals["user"] = 27;
literals["icmp"] = 38;
literals["tcp"] = 40;
}
ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
@@ -204,12 +214,6 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x22 /* '\"' */ :
{
mSTRING(true);
theRetToken=_returnToken;
break;
}
case 0x7c /* '|' */ :
{
mPIPE_CHAR(true);
@@ -371,6 +375,10 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
mLINE_COMMENT(true);
theRetToken=_returnToken;
}
else if ((LA(1) == 0x22 /* '\"' */ ) && ((LA(2) >= 0x3 /* '\3' */ && LA(2) <= 0xff))) {
mSTRING(true);
theRetToken=_returnToken;
}
else if ((_tokenSet_0.member(LA(1)))) {
mWhitespace(true);
theRetToken=_returnToken;
@@ -379,6 +387,10 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
mNUMBER_SIGN(true);
theRetToken=_returnToken;
}
else if ((LA(1) == 0x22 /* '\"' */ ) && (true)) {
mDOUBLE_QUOTE(true);
theRetToken=_returnToken;
}
else {
if (LA(1)==EOF_CHAR)
{
@@ -423,11 +435,11 @@ void PFCfgLexer::mLINE_COMMENT(bool _createToken) {
}
}
else {
goto _loop95;
goto _loop140;
}
}
_loop95:;
_loop140:;
} // ( ... )*
mNEWLINE(false);
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
@@ -459,9 +471,9 @@ void PFCfgLexer::mNEWLINE(bool _createToken) {
}
if ( inputState->guessing==0 ) {
#line 765 "pf.g"
#line 958 "pf.g"
newline();
#line 465 "PFCfgLexer.cpp"
#line 477 "PFCfgLexer.cpp"
}
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
@@ -540,9 +552,9 @@ void PFCfgLexer::mWhitespace(bool _createToken) {
}
}
if ( inputState->guessing==0 ) {
#line 760 "pf.g"
#line 953 "pf.g"
_ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP;
#line 546 "PFCfgLexer.cpp"
#line 558 "PFCfgLexer.cpp"
}
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
@@ -652,7 +664,7 @@ void PFCfgLexer::mNUM_3DIGIT(bool _createToken) {
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
{
matchRange('1','9');
matchRange('0','9');
}
{
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
@@ -727,10 +739,10 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
_ttype = NUMBER_ADDRESS_OR_WORD;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
bool synPredMatched120 = false;
if ((((LA(1) >= 0x31 /* '1' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_2.member(LA(2))) && (_tokenSet_2.member(LA(3))))) {
int _m120 = mark();
synPredMatched120 = true;
bool synPredMatched165 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_2.member(LA(2))) && (_tokenSet_2.member(LA(3))))) {
int _m165 = mark();
synPredMatched165 = true;
inputState->guessing++;
try {
{
@@ -741,12 +753,12 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched120 = false;
synPredMatched165 = false;
}
rewind(_m120);
rewind(_m165);
inputState->guessing--;
}
if ( synPredMatched120 ) {
if ( synPredMatched165 ) {
{
mNUM_3DIGIT(false);
match('.' /* charlit */ );
@@ -757,419 +769,429 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
mNUM_3DIGIT(false);
}
if ( inputState->guessing==0 ) {
#line 802 "pf.g"
#line 995 "pf.g"
_ttype = IPV4;
#line 763 "PFCfgLexer.cpp"
#line 775 "PFCfgLexer.cpp"
}
}
else {
bool synPredMatched127 = false;
bool synPredMatched172 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_2.member(LA(2))) && (_tokenSet_2.member(LA(3))))) {
int _m127 = mark();
synPredMatched127 = true;
int _m172 = mark();
synPredMatched172 = true;
inputState->guessing++;
try {
{
{ // ( ... )+
int _cnt124=0;
int _cnt169=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt124>=1 ) { goto _loop124; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt169>=1 ) { goto _loop169; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt124++;
_cnt169++;
}
_loop124:;
_loop169:;
} // ( ... )+
match('.' /* charlit */ );
{ // ( ... )+
int _cnt126=0;
int _cnt171=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt126>=1 ) { goto _loop126; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt171>=1 ) { goto _loop171; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt126++;
_cnt171++;
}
_loop126:;
_loop171:;
} // ( ... )+
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched127 = false;
synPredMatched172 = false;
}
rewind(_m127);
rewind(_m172);
inputState->guessing--;
}
if ( synPredMatched127 ) {
if ( synPredMatched172 ) {
{
{ // ( ... )+
int _cnt130=0;
int _cnt175=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt130>=1 ) { goto _loop130; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt175>=1 ) { goto _loop175; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt130++;
_cnt175++;
}
_loop130:;
_loop175:;
} // ( ... )+
match('.' /* charlit */ );
{ // ( ... )+
int _cnt132=0;
int _cnt177=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt132>=1 ) { goto _loop132; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt177>=1 ) { goto _loop177; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt132++;
_cnt177++;
}
_loop132:;
_loop177:;
} // ( ... )+
}
if ( inputState->guessing==0 ) {
#line 805 "pf.g"
#line 998 "pf.g"
_ttype = NUMBER;
#line 846 "PFCfgLexer.cpp"
#line 858 "PFCfgLexer.cpp"
}
}
else {
bool synPredMatched138 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x30 /* '0' */ && LA(2) <= 0x3a /* ':' */ )) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x3a /* ':' */ )))) {
int _m138 = mark();
synPredMatched138 = true;
bool synPredMatched196 = false;
if (((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x39 /* '9' */ )))) {
int _m196 = mark();
synPredMatched196 = true;
inputState->guessing++;
try {
{
{ // ( ... )+
int _cnt135=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt135>=1 ) { goto _loop135; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt135++;
}
_loop135:;
} // ( ... )+
match(':' /* charlit */ );
{ // ( ... )+
int _cnt137=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt137>=1 ) { goto _loop137; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt137++;
}
_loop137:;
} // ( ... )+
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched138 = false;
}
rewind(_m138);
inputState->guessing--;
}
if ( synPredMatched138 ) {
{
{ // ( ... )+
int _cnt141=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt141>=1 ) { goto _loop141; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt141++;
}
_loop141:;
} // ( ... )+
match(':' /* charlit */ );
{ // ( ... )+
int _cnt143=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt143>=1 ) { goto _loop143; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt143++;
}
_loop143:;
} // ( ... )+
}
if ( inputState->guessing==0 ) {
#line 808 "pf.g"
_ttype = PORT_RANGE;
#line 929 "PFCfgLexer.cpp"
}
}
else {
bool synPredMatched162 = false;
if (((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x39 /* '9' */ )))) {
int _m162 = mark();
synPredMatched162 = true;
inputState->guessing++;
try {
{
match(':' /* charlit */ );
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched162 = false;
}
rewind(_m162);
inputState->guessing--;
}
if ( synPredMatched162 ) {
match(':' /* charlit */ );
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
{ // ( ... )*
for (;;) {
if ((LA(1) == 0x3a /* ':' */ )) {
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
}
else {
goto _loop164;
}
}
_loop164:;
} // ( ... )*
if ( inputState->guessing==0 ) {
#line 828 "pf.g"
_ttype = IPV6;
#line 971 "PFCfgLexer.cpp"
}
}
else {
bool synPredMatched147 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )))) {
int _m147 = mark();
synPredMatched147 = true;
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched196 = false;
}
rewind(_m196);
inputState->guessing--;
}
if ( synPredMatched196 ) {
match(':' /* charlit */ );
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
{ // ( ... )*
for (;;) {
if ((LA(1) == 0x3a /* ':' */ )) {
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
}
else {
goto _loop198;
}
}
_loop198:;
} // ( ... )*
if ( inputState->guessing==0 ) {
#line 1021 "pf.g"
_ttype = IPV6;
#line 900 "PFCfgLexer.cpp"
}
}
else {
bool synPredMatched181 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )))) {
int _m181 = mark();
synPredMatched181 = true;
inputState->guessing++;
try {
{
mNUM_HEX_4DIGIT(false);
match(':' /* charlit */ );
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched181 = false;
}
rewind(_m181);
inputState->guessing--;
}
if ( synPredMatched181 ) {
{
bool synPredMatched186 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x3a /* ':' */ )))) {
int _m186 = mark();
synPredMatched186 = true;
inputState->guessing++;
try {
{
mNUM_HEX_4DIGIT(false);
match(':' /* charlit */ );
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched147 = false;
}
rewind(_m147);
inputState->guessing--;
}
if ( synPredMatched147 ) {
{
bool synPredMatched152 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x3a /* ':' */ )))) {
int _m152 = mark();
synPredMatched152 = true;
inputState->guessing++;
try {
{
{ // ( ... )+
int _cnt151=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mNUM_HEX_4DIGIT(false);
match(':' /* charlit */ );
}
else {
if ( _cnt151>=1 ) { goto _loop151; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt151++;
}
_loop151:;
} // ( ... )+
match(':' /* charlit */ );
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched152 = false;
}
rewind(_m152);
inputState->guessing--;
}
if ( synPredMatched152 ) {
{
{ // ( ... )+
int _cnt155=0;
int _cnt185=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mNUM_HEX_4DIGIT(false);
match(':' /* charlit */ );
}
else {
if ( _cnt155>=1 ) { goto _loop155; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt185>=1 ) { goto _loop185; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt155++;
_cnt185++;
}
_loop155:;
_loop185:;
} // ( ... )+
match(':' /* charlit */ );
{
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mNUM_HEX_4DIGIT(false);
{ // ( ... )*
for (;;) {
if ((LA(1) == 0x3a /* ':' */ )) {
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
}
else {
goto _loop158;
}
}
_loop158:;
} // ( ... )*
}
else {
}
}
}
if ( inputState->guessing==0 ) {
#line 819 "pf.g"
_ttype = IPV6;
#line 1068 "PFCfgLexer.cpp"
}
}
else if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x3a /* ':' */ ))) {
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched186 = false;
}
rewind(_m186);
inputState->guessing--;
}
if ( synPredMatched186 ) {
{
{ // ( ... )+
int _cnt189=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mNUM_HEX_4DIGIT(false);
match(':' /* charlit */ );
}
else {
if ( _cnt189>=1 ) { goto _loop189; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt189++;
}
_loop189:;
} // ( ... )+
match(':' /* charlit */ );
{
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mNUM_HEX_4DIGIT(false);
{ // ( ... )+
int _cnt160=0;
{ // ( ... )*
for (;;) {
if ((LA(1) == 0x3a /* ':' */ )) {
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
}
else {
if ( _cnt160>=1 ) { goto _loop160; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
goto _loop192;
}
_cnt160++;
}
_loop160:;
} // ( ... )+
if ( inputState->guessing==0 ) {
#line 822 "pf.g"
_ttype = IPV6;
#line 1091 "PFCfgLexer.cpp"
}
_loop192:;
} // ( ... )*
}
else {
throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
}
}
}
if ( inputState->guessing==0 ) {
#line 824 "pf.g"
#line 1012 "pf.g"
_ttype = IPV6;
#line 1102 "PFCfgLexer.cpp"
#line 997 "PFCfgLexer.cpp"
}
}
else if ((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && (true)) {
match(':' /* charlit */ );
match(':' /* charlit */ );
if ( inputState->guessing==0 ) {
#line 831 "pf.g"
_ttype = IPV6;
#line 1111 "PFCfgLexer.cpp"
}
}
else if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (true) && (true)) {
else if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x3a /* ':' */ ))) {
mNUM_HEX_4DIGIT(false);
{ // ( ... )+
int _cnt145=0;
int _cnt194=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
if ((LA(1) == 0x3a /* ':' */ )) {
match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false);
}
else {
if ( _cnt145>=1 ) { goto _loop145; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt194>=1 ) { goto _loop194; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt145++;
_cnt194++;
}
_loop145:;
_loop194:;
} // ( ... )+
if ( inputState->guessing==0 ) {
#line 810 "pf.g"
_ttype = INT_CONST;
#line 1132 "PFCfgLexer.cpp"
#line 1015 "pf.g"
_ttype = IPV6;
#line 1020 "PFCfgLexer.cpp"
}
}
else if ((LA(1) == 0x3a /* ':' */ ) && (true)) {
match(':' /* charlit */ );
if ( inputState->guessing==0 ) {
#line 834 "pf.g"
_ttype = COLON;
#line 1140 "PFCfgLexer.cpp"
}
else {
throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
}
else if ((_tokenSet_3.member(LA(1)))) {
{
}
if ( inputState->guessing==0 ) {
#line 1017 "pf.g"
_ttype = IPV6;
#line 1031 "PFCfgLexer.cpp"
}
}
else if ((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && (true)) {
match(':' /* charlit */ );
match(':' /* charlit */ );
if ( inputState->guessing==0 ) {
#line 1024 "pf.g"
_ttype = IPV6;
#line 1040 "PFCfgLexer.cpp"
}
}
else if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (true) && (true)) {
{ // ( ... )+
int _cnt179=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt179>=1 ) { goto _loop179; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt179++;
}
_loop179:;
} // ( ... )+
if ( inputState->guessing==0 ) {
#line 1003 "pf.g"
_ttype = INT_CONST;
#line 1061 "PFCfgLexer.cpp"
}
}
else if ((LA(1) == 0x3a /* ':' */ ) && (true)) {
match(':' /* charlit */ );
if ( inputState->guessing==0 ) {
#line 1027 "pf.g"
_ttype = COLON;
#line 1069 "PFCfgLexer.cpp"
}
}
else if ((_tokenSet_3.member(LA(1)))) {
{
switch ( LA(1)) {
case 0x61 /* 'a' */ :
case 0x62 /* 'b' */ :
case 0x63 /* 'c' */ :
case 0x64 /* 'd' */ :
case 0x65 /* 'e' */ :
case 0x66 /* 'f' */ :
case 0x67 /* 'g' */ :
case 0x68 /* 'h' */ :
case 0x69 /* 'i' */ :
case 0x6a /* 'j' */ :
case 0x6b /* 'k' */ :
case 0x6c /* 'l' */ :
case 0x6d /* 'm' */ :
case 0x6e /* 'n' */ :
case 0x6f /* 'o' */ :
case 0x70 /* 'p' */ :
case 0x71 /* 'q' */ :
case 0x72 /* 'r' */ :
case 0x73 /* 's' */ :
case 0x74 /* 't' */ :
case 0x75 /* 'u' */ :
case 0x76 /* 'v' */ :
case 0x77 /* 'w' */ :
case 0x78 /* 'x' */ :
case 0x79 /* 'y' */ :
case 0x7a /* 'z' */ :
{
matchRange('a','z');
break;
}
case 0x41 /* 'A' */ :
case 0x42 /* 'B' */ :
case 0x43 /* 'C' */ :
case 0x44 /* 'D' */ :
case 0x45 /* 'E' */ :
case 0x46 /* 'F' */ :
case 0x47 /* 'G' */ :
case 0x48 /* 'H' */ :
case 0x49 /* 'I' */ :
case 0x4a /* 'J' */ :
case 0x4b /* 'K' */ :
case 0x4c /* 'L' */ :
case 0x4d /* 'M' */ :
case 0x4e /* 'N' */ :
case 0x4f /* 'O' */ :
case 0x50 /* 'P' */ :
case 0x51 /* 'Q' */ :
case 0x52 /* 'R' */ :
case 0x53 /* 'S' */ :
case 0x54 /* 'T' */ :
case 0x55 /* 'U' */ :
case 0x56 /* 'V' */ :
case 0x57 /* 'W' */ :
case 0x58 /* 'X' */ :
case 0x59 /* 'Y' */ :
case 0x5a /* 'Z' */ :
{
matchRange('A','Z');
break;
}
default:
{
throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
}
}
}
{ // ( ... )*
for (;;) {
switch ( LA(1)) {
case 0x61 /* 'a' */ :
case 0x62 /* 'b' */ :
case 0x63 /* 'c' */ :
case 0x64 /* 'd' */ :
case 0x65 /* 'e' */ :
case 0x66 /* 'f' */ :
case 0x67 /* 'g' */ :
case 0x68 /* 'h' */ :
case 0x69 /* 'i' */ :
case 0x6a /* 'j' */ :
case 0x6b /* 'k' */ :
case 0x6c /* 'l' */ :
case 0x6d /* 'm' */ :
case 0x6e /* 'n' */ :
case 0x6f /* 'o' */ :
case 0x70 /* 'p' */ :
case 0x71 /* 'q' */ :
case 0x72 /* 'r' */ :
case 0x73 /* 's' */ :
case 0x74 /* 't' */ :
case 0x75 /* 'u' */ :
case 0x76 /* 'v' */ :
case 0x77 /* 'w' */ :
case 0x78 /* 'x' */ :
case 0x79 /* 'y' */ :
case 0x7a /* 'z' */ :
case 0x22 /* '\"' */ :
{
matchRange('a','z');
match('\"' /* charlit */ );
break;
}
case 0x24 /* '$' */ :
{
match('$' /* charlit */ );
break;
}
case 0x25 /* '%' */ :
{
match('%' /* charlit */ );
break;
}
case 0x26 /* '&' */ :
{
match('&' /* charlit */ );
break;
}
case 0x2d /* '-' */ :
{
match('-' /* charlit */ );
break;
}
case 0x30 /* '0' */ :
case 0x31 /* '1' */ :
case 0x32 /* '2' */ :
case 0x33 /* '3' */ :
case 0x34 /* '4' */ :
case 0x35 /* '5' */ :
case 0x36 /* '6' */ :
case 0x37 /* '7' */ :
case 0x38 /* '8' */ :
case 0x39 /* '9' */ :
{
matchRange('0','9');
break;
}
case 0x3b /* ';' */ :
{
match(';' /* charlit */ );
break;
}
case 0x3f /* '?' */ :
{
match('?' /* charlit */ );
break;
}
case 0x40 /* '@' */ :
{
match('@' /* charlit */ );
break;
}
case 0x41 /* 'A' */ :
@@ -1202,157 +1224,74 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
matchRange('A','Z');
break;
}
case 0x5c /* '\\' */ :
{
match('\\' /* charlit */ );
break;
}
case 0x5e /* '^' */ :
{
match('^' /* charlit */ );
break;
}
case 0x5f /* '_' */ :
{
match('_' /* charlit */ );
break;
}
case 0x60 /* '`' */ :
{
match('`' /* charlit */ );
break;
}
case 0x61 /* 'a' */ :
case 0x62 /* 'b' */ :
case 0x63 /* 'c' */ :
case 0x64 /* 'd' */ :
case 0x65 /* 'e' */ :
case 0x66 /* 'f' */ :
case 0x67 /* 'g' */ :
case 0x68 /* 'h' */ :
case 0x69 /* 'i' */ :
case 0x6a /* 'j' */ :
case 0x6b /* 'k' */ :
case 0x6c /* 'l' */ :
case 0x6d /* 'm' */ :
case 0x6e /* 'n' */ :
case 0x6f /* 'o' */ :
case 0x70 /* 'p' */ :
case 0x71 /* 'q' */ :
case 0x72 /* 'r' */ :
case 0x73 /* 's' */ :
case 0x74 /* 't' */ :
case 0x75 /* 'u' */ :
case 0x76 /* 'v' */ :
case 0x77 /* 'w' */ :
case 0x78 /* 'x' */ :
case 0x79 /* 'y' */ :
case 0x7a /* 'z' */ :
{
matchRange('a','z');
break;
}
default:
{
throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
goto _loop201;
}
}
}
{ // ( ... )*
for (;;) {
switch ( LA(1)) {
case 0x24 /* '$' */ :
{
match('$' /* charlit */ );
break;
}
case 0x25 /* '%' */ :
{
match('%' /* charlit */ );
break;
}
case 0x26 /* '&' */ :
{
match('&' /* charlit */ );
break;
}
case 0x30 /* '0' */ :
case 0x31 /* '1' */ :
case 0x32 /* '2' */ :
case 0x33 /* '3' */ :
case 0x34 /* '4' */ :
case 0x35 /* '5' */ :
case 0x36 /* '6' */ :
case 0x37 /* '7' */ :
case 0x38 /* '8' */ :
case 0x39 /* '9' */ :
{
matchRange('0','9');
break;
}
case 0x3b /* ';' */ :
{
match(';' /* charlit */ );
break;
}
case 0x3f /* '?' */ :
{
match('?' /* charlit */ );
break;
}
case 0x40 /* '@' */ :
{
match('@' /* charlit */ );
break;
}
case 0x41 /* 'A' */ :
case 0x42 /* 'B' */ :
case 0x43 /* 'C' */ :
case 0x44 /* 'D' */ :
case 0x45 /* 'E' */ :
case 0x46 /* 'F' */ :
case 0x47 /* 'G' */ :
case 0x48 /* 'H' */ :
case 0x49 /* 'I' */ :
case 0x4a /* 'J' */ :
case 0x4b /* 'K' */ :
case 0x4c /* 'L' */ :
case 0x4d /* 'M' */ :
case 0x4e /* 'N' */ :
case 0x4f /* 'O' */ :
case 0x50 /* 'P' */ :
case 0x51 /* 'Q' */ :
case 0x52 /* 'R' */ :
case 0x53 /* 'S' */ :
case 0x54 /* 'T' */ :
case 0x55 /* 'U' */ :
case 0x56 /* 'V' */ :
case 0x57 /* 'W' */ :
case 0x58 /* 'X' */ :
case 0x59 /* 'Y' */ :
case 0x5a /* 'Z' */ :
{
matchRange('A','Z');
break;
}
case 0x5c /* '\\' */ :
{
match('\\' /* charlit */ );
break;
}
case 0x5e /* '^' */ :
{
match('^' /* charlit */ );
break;
}
case 0x5f /* '_' */ :
{
match('_' /* charlit */ );
break;
}
case 0x60 /* '`' */ :
{
match('`' /* charlit */ );
break;
}
case 0x61 /* 'a' */ :
case 0x62 /* 'b' */ :
case 0x63 /* 'c' */ :
case 0x64 /* 'd' */ :
case 0x65 /* 'e' */ :
case 0x66 /* 'f' */ :
case 0x67 /* 'g' */ :
case 0x68 /* 'h' */ :
case 0x69 /* 'i' */ :
case 0x6a /* 'j' */ :
case 0x6b /* 'k' */ :
case 0x6c /* 'l' */ :
case 0x6d /* 'm' */ :
case 0x6e /* 'n' */ :
case 0x6f /* 'o' */ :
case 0x70 /* 'p' */ :
case 0x71 /* 'q' */ :
case 0x72 /* 'r' */ :
case 0x73 /* 's' */ :
case 0x74 /* 't' */ :
case 0x75 /* 'u' */ :
case 0x76 /* 'v' */ :
case 0x77 /* 'w' */ :
case 0x78 /* 'x' */ :
case 0x79 /* 'y' */ :
case 0x7a /* 'z' */ :
{
matchRange('a','z');
break;
}
default:
{
goto _loop167;
}
}
}
_loop167:;
} // ( ... )*
if ( inputState->guessing==0 ) {
#line 845 "pf.g"
_ttype = WORD;
#line 1350 "PFCfgLexer.cpp"
}
}
_loop201:;
} // ( ... )*
if ( inputState->guessing==0 ) {
#line 1039 "pf.g"
_ttype = WORD;
#line 1289 "PFCfgLexer.cpp"
}
}
else {
throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
}
}}}}
}}}
_ttype = testLiteralsTable(_ttype);
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
@@ -1374,11 +1313,11 @@ void PFCfgLexer::mSTRING(bool _createToken) {
matchNot('\"' /* charlit */ );
}
else {
goto _loop170;
goto _loop204;
}
}
_loop170:;
_loop204:;
} // ( ... )*
match('\"' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
@@ -1767,17 +1706,33 @@ void PFCfgLexer::mGREATER_THAN(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mDOUBLE_QUOTE(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = DOUBLE_QUOTE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('\"' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
const unsigned long PFCfgLexer::_tokenSet_0_data_[] = { 4294958072UL, 1UL, 0UL, 2147483648UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xe 0xf 0x10 0x11 0x12 0x13 0x14
// 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f
// 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 0x7f 0x80 0x81
// 0x82 0x83 0x84
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_0(_tokenSet_0_data_,16);
const unsigned long PFCfgLexer::_tokenSet_1_data_[] = { 4294958072UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xe 0xf 0x10 0x11 0x12 0x13 0x14
// 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f ! \" # $ %
// & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G
// H I J K L M N O P Q R S T U V W X Y Z [ 0x5c ] ^ _ ` a b c d e f g h
// i j k l m n o p q r s t u v w x y z { | } ~
// i j k l m n o p q r s t u v w x y z { | } ~ 0x7f 0x80 0x81 0x82 0x83
// 0x84
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_1(_tokenSet_1_data_,16);
const unsigned long PFCfgLexer::_tokenSet_2_data_[] = { 0UL, 67059712UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// . 0 1 2 3 4 5 6 7 8 9
@@ -1791,6 +1746,7 @@ const unsigned long PFCfgLexer::_tokenSet_4_data_[] = { 4294967288UL, 4294967291
// 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f ! # $
// % & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F
// G H I J K L M N O P Q R S T U V W X Y Z [ 0x5c ] ^ _ ` a b c d e f g
// h i j k l m n o p q r s t u v w x y z { | } ~
// h i j k l m n o p q r s t u v w x y z { | } ~ 0x7f 0x80 0x81 0x82 0x83
// 0x84
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_4(_tokenSet_4_data_,16);

View File

@@ -88,6 +88,7 @@ public:
public: void mEXLAMATION(bool _createToken);
public: void mLESS_THAN(bool _createToken);
public: void mGREATER_THAN(bool _createToken);
public: void mDOUBLE_QUOTE(bool _createToken);
private:
static const unsigned long _tokenSet_0_data_[];

File diff suppressed because it is too large Load Diff

View File

@@ -96,6 +96,7 @@ public:
public: void queue_command();
public: void set_command();
public: void scrub_command();
public: void table_command();
public: void nat_command();
public: void rdr_command();
public: void binat_command();
@@ -108,27 +109,47 @@ public:
public: void logging();
public: void quick();
public: void intrface();
public: void route();
public: void address_family();
public: void protospec();
public: void hosts();
public: void filteropts();
public: void logopts();
public: void logopt();
public: void ifspec();
public: void interface_list();
public: void proto_def();
public: void proto_name();
public: void proto_number();
public: void proto_list();
public: void hosts_from();
public: void hosts_to();
public: void src_hosts_part();
public: void src_port_part();
public: void dst_hosts_part();
public: void dst_port_part();
public: void common_hosts_part();
public: void host();
public: void host_list();
public: void route_to();
public: void reply_to();
public: void routehost();
public: void routehost_list();
public: void filteropt();
public: void tcp_flags();
public: void icmp_type();
public: void icmp6_type();
public: void tagged();
public: void tag_clause();
public: void state();
public: void queue();
public: void unary_op();
public: void binary_op();
public: void op_list();
public: void label();
public: void icmp_type_code();
public: void icmp_list();
public: void port_op();
public: void port_op_list();
public: void unary_port_op();
public: void binary_port_op();
public: void port_def();
public:
ANTLR_USE_NAMESPACE(antlr)RefAST getAST()
@@ -141,10 +162,10 @@ protected:
private:
static const char* tokenNames[];
#ifndef NO_STATIC_CONSTS
static const int NUM_TOKENS = 127;
static const int NUM_TOKENS = 133;
#else
enum {
NUM_TOKENS = 127
NUM_TOKENS = 133
};
#endif
@@ -198,6 +219,18 @@ private:
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_23;
static const unsigned long _tokenSet_24_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_24;
static const unsigned long _tokenSet_25_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_25;
static const unsigned long _tokenSet_26_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_26;
static const unsigned long _tokenSet_27_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_27;
static const unsigned long _tokenSet_28_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_28;
static const unsigned long _tokenSet_29_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_29;
static const unsigned long _tokenSet_30_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_30;
};
#endif /*INC_PFCfgParser_hpp_*/

View File

@@ -21,120 +21,126 @@ struct CUSTOM_API PFCfgParserTokenTypes {
QUEUE = 10,
SET = 11,
SCRUB = 12,
NAT = 13,
BINAT = 14,
RDR = 15,
TIMEOUT = 16,
PASS = 17,
BLOCK = 18,
IN = 19,
OUT = 20,
LOG = 21,
COMMA = 22,
ALL = 23,
USER = 24,
TO = 25,
QUICK = 26,
ON = 27,
INET = 28,
INET6 = 29,
PROTO = 30,
IP = 31,
ICMP = 32,
IGMP = 33,
TCP = 34,
UDP = 35,
RDP = 36,
RSVP = 37,
GRE = 38,
ESP = 39,
AH = 40,
EIGRP = 41,
OSPF = 42,
IPIP = 43,
VRRP = 44,
L2TP = 45,
ISIS = 46,
INT_CONST = 47,
OPENING_BRACE = 48,
CLOSING_BRACE = 49,
FROM = 50,
ANY = 51,
SELF = 52,
EXCLAMATION = 53,
IPV4 = 54,
IPV6 = 55,
SLASH = 56,
NO = 57,
KEEP = 58,
MODULATE = 59,
SYNPROXY = 60,
STATE = 61,
OPENING_PAREN = 62,
CLOSING_PAREN = 63,
PORT = 64,
NOT_EQUAL = 65,
LESS_THAN = 66,
LESS_OR_EQUAL_THAN = 67,
GREATER_THAN = 68,
GREATER_OR_EQUAL_THAN = 69,
EXCEPT_RANGE = 70,
INSIDE_RANGE = 71,
COLON = 72,
PORT_RANGE = 73,
EXIT = 74,
QUIT = 75,
INTRFACE = 76,
ICMP6 = 77,
IGRP = 78,
IPSEC = 79,
NOS = 80,
PCP = 81,
PIM = 82,
PPTP = 83,
RIP = 84,
SNP = 85,
HOST = 86,
RANGE = 87,
LOG_LEVEL_ALERTS = 88,
LOG_LEVEL_CRITICAL = 89,
LOG_LEVEL_DEBUGGING = 90,
LOG_LEVEL_EMERGENCIES = 91,
LOG_LEVEL_ERRORS = 92,
LOG_LEVEL_INFORMATIONAL = 93,
LOG_LEVEL_NOTIFICATIONS = 94,
LOG_LEVEL_WARNINGS = 95,
LOG_LEVEL_DISABLE = 96,
LOG_LEVEL_INACTIVE = 97,
TRANSLATE_TO = 98,
Whitespace = 99,
HEX_CONST = 100,
NUMBER = 101,
NEG_INT_CONST = 102,
HEX_DIGIT = 103,
DIGIT = 104,
NUM_3DIGIT = 105,
NUM_HEX_4DIGIT = 106,
NUMBER_ADDRESS_OR_WORD = 107,
STRING = 108,
PIPE_CHAR = 109,
NUMBER_SIGN = 110,
PERCENT = 111,
AMPERSAND = 112,
APOSTROPHE = 113,
STAR = 114,
PLUS = 115,
MINUS = 116,
DOT = 117,
SEMICOLON = 118,
QUESTION = 119,
COMMERCIAL_AT = 120,
OPENING_SQUARE = 121,
CLOSING_SQUARE = 122,
CARET = 123,
UNDERLINE = 124,
TILDE = 125,
EXLAMATION = 126,
TABLE = 13,
NAT = 14,
BINAT = 15,
RDR = 16,
TIMEOUT = 17,
PASS = 18,
BLOCK = 19,
IN = 20,
OUT = 21,
LOG = 22,
OPENING_PAREN = 23,
COMMA = 24,
CLOSING_PAREN = 25,
ALL = 26,
USER = 27,
TO = 28,
QUICK = 29,
ON = 30,
EXLAMATION = 31,
OPENING_BRACE = 32,
CLOSING_BRACE = 33,
INET = 34,
INET6 = 35,
PROTO = 36,
IP = 37,
ICMP = 38,
IGMP = 39,
TCP = 40,
UDP = 41,
RDP = 42,
RSVP = 43,
GRE = 44,
ESP = 45,
AH = 46,
EIGRP = 47,
OSPF = 48,
IPIP = 49,
VRRP = 50,
L2TP = 51,
ISIS = 52,
INT_CONST = 53,
FROM = 54,
URPF_FAILED = 55,
ANY = 56,
SELF = 57,
NO_ROUTE = 58,
IPV4 = 59,
IPV6 = 60,
SLASH = 61,
LESS_THAN = 62,
GREATER_THAN = 63,
ROUTE_TO = 64,
REPLY_TO = 65,
FLAGS = 66,
ICMP_TYPE = 67,
ICMP_CODE = 68,
ICMP6_TYPE = 69,
TAGGED = 70,
TAG = 71,
NO = 72,
KEEP = 73,
MODULATE = 74,
SYNPROXY = 75,
STATE = 76,
LABEL = 77,
STRING = 78,
PORT = 79,
COLON = 80,
EXIT = 81,
QUIT = 82,
INTRFACE = 83,
ICMP6 = 84,
IGRP = 85,
IPSEC = 86,
NOS = 87,
PCP = 88,
PIM = 89,
PPTP = 90,
RIP = 91,
SNP = 92,
HOST = 93,
RANGE = 94,
LOG_LEVEL_ALERTS = 95,
LOG_LEVEL_CRITICAL = 96,
LOG_LEVEL_DEBUGGING = 97,
LOG_LEVEL_EMERGENCIES = 98,
LOG_LEVEL_ERRORS = 99,
LOG_LEVEL_INFORMATIONAL = 100,
LOG_LEVEL_NOTIFICATIONS = 101,
LOG_LEVEL_WARNINGS = 102,
LOG_LEVEL_DISABLE = 103,
LOG_LEVEL_INACTIVE = 104,
TRANSLATE_TO = 105,
Whitespace = 106,
HEX_CONST = 107,
NUMBER = 108,
NEG_INT_CONST = 109,
HEX_DIGIT = 110,
DIGIT = 111,
NUM_3DIGIT = 112,
NUM_HEX_4DIGIT = 113,
NUMBER_ADDRESS_OR_WORD = 114,
PIPE_CHAR = 115,
NUMBER_SIGN = 116,
PERCENT = 117,
AMPERSAND = 118,
APOSTROPHE = 119,
STAR = 120,
PLUS = 121,
MINUS = 122,
DOT = 123,
SEMICOLON = 124,
QUESTION = 125,
COMMERCIAL_AT = 126,
OPENING_SQUARE = 127,
CLOSING_SQUARE = 128,
CARET = 129,
UNDERLINE = 130,
TILDE = 131,
DOUBLE_QUOTE = 132,
NULL_TREE_LOOKAHEAD = 3
};
#ifdef __cplusplus

View File

@@ -9,117 +9,123 @@ ALTQ="altq"=9
QUEUE="queue"=10
SET="set"=11
SCRUB="scrub"=12
NAT="nat"=13
BINAT="binat"=14
RDR="rdr"=15
TIMEOUT="timeout"=16
PASS="pass"=17
BLOCK="block"=18
IN="in"=19
OUT="out"=20
LOG="log"=21
COMMA=22
ALL=23
USER=24
TO="to"=25
QUICK="quick"=26
ON="on"=27
INET="inet"=28
INET6="inet6"=29
PROTO="proto"=30
IP="ip"=31
ICMP="icmp"=32
IGMP="igmp"=33
TCP="tcp"=34
UDP="udp"=35
RDP="rdp"=36
RSVP="rsvp"=37
GRE="gre"=38
ESP="esp"=39
AH="ah"=40
EIGRP="eigrp"=41
OSPF="ospf"=42
IPIP="ipip"=43
VRRP="vrrp"=44
L2TP="l2tp"=45
ISIS="isis"=46
INT_CONST=47
OPENING_BRACE=48
CLOSING_BRACE=49
FROM="from"=50
ANY="any"=51
SELF=52
EXCLAMATION=53
IPV4=54
IPV6=55
SLASH=56
NO="no"=57
KEEP="keep"=58
MODULATE="modulate"=59
SYNPROXY="synproxy"=60
STATE="state"=61
OPENING_PAREN=62
CLOSING_PAREN=63
PORT="port"=64
NOT_EQUAL="!="=65
LESS_THAN=66
LESS_OR_EQUAL_THAN="<="=67
GREATER_THAN=68
GREATER_OR_EQUAL_THAN=">="=69
EXCEPT_RANGE="<>"=70
INSIDE_RANGE="><"=71
COLON=72
PORT_RANGE=73
EXIT="exit"=74
QUIT="quit"=75
INTRFACE="interface"=76
ICMP6="icmp6"=77
IGRP="igrp"=78
IPSEC="ipsec"=79
NOS="nos"=80
PCP="pcp"=81
PIM="pim"=82
PPTP="pptp"=83
RIP="rip"=84
SNP="snp"=85
HOST="host"=86
RANGE="range"=87
LOG_LEVEL_ALERTS="alerts"=88
LOG_LEVEL_CRITICAL="critical"=89
LOG_LEVEL_DEBUGGING="debugging"=90
LOG_LEVEL_EMERGENCIES="emergencies"=91
LOG_LEVEL_ERRORS="errors"=92
LOG_LEVEL_INFORMATIONAL="informational"=93
LOG_LEVEL_NOTIFICATIONS="notifications"=94
LOG_LEVEL_WARNINGS="warnings"=95
LOG_LEVEL_DISABLE="disable"=96
LOG_LEVEL_INACTIVE="inactive"=97
TRANSLATE_TO="->"=98
Whitespace=99
HEX_CONST=100
NUMBER=101
NEG_INT_CONST=102
HEX_DIGIT=103
DIGIT=104
NUM_3DIGIT=105
NUM_HEX_4DIGIT=106
NUMBER_ADDRESS_OR_WORD=107
STRING=108
PIPE_CHAR=109
NUMBER_SIGN=110
PERCENT=111
AMPERSAND=112
APOSTROPHE=113
STAR=114
PLUS=115
MINUS=116
DOT=117
SEMICOLON=118
QUESTION=119
COMMERCIAL_AT=120
OPENING_SQUARE=121
CLOSING_SQUARE=122
CARET=123
UNDERLINE=124
TILDE=125
EXLAMATION=126
TABLE="table"=13
NAT="nat"=14
BINAT="binat"=15
RDR="rdr"=16
TIMEOUT="timeout"=17
PASS="pass"=18
BLOCK="block"=19
IN="in"=20
OUT="out"=21
LOG="log"=22
OPENING_PAREN=23
COMMA=24
CLOSING_PAREN=25
ALL="all"=26
USER="user"=27
TO="to"=28
QUICK="quick"=29
ON="on"=30
EXLAMATION=31
OPENING_BRACE=32
CLOSING_BRACE=33
INET="inet"=34
INET6="inet6"=35
PROTO="proto"=36
IP="ip"=37
ICMP="icmp"=38
IGMP="igmp"=39
TCP="tcp"=40
UDP="udp"=41
RDP="rdp"=42
RSVP="rsvp"=43
GRE="gre"=44
ESP="esp"=45
AH="ah"=46
EIGRP="eigrp"=47
OSPF="ospf"=48
IPIP="ipip"=49
VRRP="vrrp"=50
L2TP="l2tp"=51
ISIS="isis"=52
INT_CONST=53
FROM="from"=54
URPF_FAILED="urpf-failed"=55
ANY="any"=56
SELF="self"=57
NO_ROUTE="no-route"=58
IPV4=59
IPV6=60
SLASH=61
LESS_THAN=62
GREATER_THAN=63
ROUTE_TO="route-to"=64
REPLY_TO="reply-to"=65
FLAGS="flags"=66
ICMP_TYPE="icmp-type"=67
ICMP_CODE="code"=68
ICMP6_TYPE="icmp6-type"=69
TAGGED="tagged"=70
TAG="tag"=71
NO="no"=72
KEEP="keep"=73
MODULATE="modulate"=74
SYNPROXY="synproxy"=75
STATE="state"=76
LABEL="label"=77
STRING=78
PORT="port"=79
COLON=80
EXIT="exit"=81
QUIT="quit"=82
INTRFACE="interface"=83
ICMP6="icmp6"=84
IGRP="igrp"=85
IPSEC="ipsec"=86
NOS="nos"=87
PCP="pcp"=88
PIM="pim"=89
PPTP="pptp"=90
RIP="rip"=91
SNP="snp"=92
HOST="host"=93
RANGE="range"=94
LOG_LEVEL_ALERTS="alerts"=95
LOG_LEVEL_CRITICAL="critical"=96
LOG_LEVEL_DEBUGGING="debugging"=97
LOG_LEVEL_EMERGENCIES="emergencies"=98
LOG_LEVEL_ERRORS="errors"=99
LOG_LEVEL_INFORMATIONAL="informational"=100
LOG_LEVEL_NOTIFICATIONS="notifications"=101
LOG_LEVEL_WARNINGS="warnings"=102
LOG_LEVEL_DISABLE="disable"=103
LOG_LEVEL_INACTIVE="inactive"=104
TRANSLATE_TO="->"=105
Whitespace=106
HEX_CONST=107
NUMBER=108
NEG_INT_CONST=109
HEX_DIGIT=110
DIGIT=111
NUM_3DIGIT=112
NUM_HEX_4DIGIT=113
NUMBER_ADDRESS_OR_WORD=114
PIPE_CHAR=115
NUMBER_SIGN=116
PERCENT=117
AMPERSAND=118
APOSTROPHE=119
STAR=120
PLUS=121
MINUS=122
DOT=123
SEMICOLON=124
QUESTION=125
COMMERCIAL_AT=126
OPENING_SQUARE=127
CLOSING_SQUARE=128
CARET=129
UNDERLINE=130
TILDE=131
DOUBLE_QUOTE=132

View File

@@ -124,6 +124,8 @@ cfgfile :
set_command
|
scrub_command
|
table_command
|
nat_command
|
@@ -172,7 +174,7 @@ altq_command : ALTQ
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'altq' commands is not supported."));
QString("Error: import of 'altq' commands is not supported."));
consumeUntil(NEWLINE);
}
;
@@ -183,7 +185,7 @@ queue_command : QUEUE
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'queue' commands is not supported."));
QString("Error: import of 'queue' commands is not supported."));
consumeUntil(NEWLINE);
}
;
@@ -210,6 +212,17 @@ scrub_command : SCRUB
}
;
//****************************************************************
table_command : TABLE
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'table' commands has not been implemented yet."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
nat_command : NAT
{
@@ -227,7 +240,7 @@ binat_command : BINAT
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'binat' commands is not supported."));
QString("Error: import of 'binat' commands is not supported."));
consumeUntil(NEWLINE);
}
;
@@ -267,7 +280,7 @@ unknown_command : WORD
//****************************************************************
pass_command: PASS
pass_command : PASS
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
@@ -277,13 +290,11 @@ pass_command: PASS
}
rule_extended NEWLINE
{
importer->setInterfaceAndDirectionForRuleSet(
"", importer->iface, importer->direction);
importer->pushRule();
}
;
block_command: BLOCK
block_command : BLOCK
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
@@ -293,68 +304,91 @@ block_command: BLOCK
}
rule_extended NEWLINE
{
importer->setInterfaceAndDirectionForRuleSet(
"", importer->iface, importer->direction);
importer->pushRule();
}
;
rule_extended:
direction
(logging)?
(quick)?
(intrface)?
(
(address_family)?
(protospec)?
hosts
filteropts
)?
rule_extended :
( direction )?
( logging )?
( quick )?
( intrface )?
( route )?
( address_family )?
( protospec )?
( hosts )?
( filteropts )?
;
direction: (IN | OUT)
direction : ( IN | OUT )
{
importer->direction = LT(0)->getText();
}
;
logging: LOG logopts
logging :
LOG (logopts)?
{
importer->logging = true;
}
;
logopts:
logopts :
OPENING_PAREN
logopt
(
COMMA
COMMA { importer->logopts += ","; }
logopt
)*
CLOSING_PAREN
;
logopt: ALL | USER | TO WORD
logopt : ALL | USER | TO WORD
{
importer->logopts += LT(0)->getText();
}
;
quick: QUICK
quick : QUICK
{
importer->quick = true;
}
;
intrface: ON WORD
intrface : ON ( ifspec | interface_list )
;
ifspec { InterfaceSpec is; } :
( EXLAMATION { is.neg = true; } )?
WORD
{
importer->iface = LT(0)->getText();
importer->newInterface(importer->iface);
is.name = LT(0)->getText();
importer->iface_group.push_back(is);
importer->newInterface(is.name);
}
;
address_family: INET | INET6
interface_list :
OPENING_BRACE
ifspec
(
( COMMA )?
ifspec
)*
CLOSING_BRACE
;
address_family : INET | INET6
{
importer->address_family = LT(0)->getText();
}
;
protospec: PROTO
protospec : PROTO proto_def
;
proto_def :
(
proto_name
|
@@ -364,63 +398,59 @@ protospec: PROTO
)
;
proto_name: (IP | ICMP | IGMP | TCP | UDP | RDP | RSVP | GRE | ESP | AH |
proto_name : (IP | ICMP | IGMP | TCP | UDP | RDP | RSVP | GRE | ESP | AH |
EIGRP | OSPF | IPIP | VRRP | L2TP | ISIS )
{
importer->proto_list.push_back(LT(0)->getText());
}
;
proto_number: INT_CONST
proto_number : INT_CONST
{
importer->proto_list.push_back(LT(0)->getText());
}
;
proto_list:
proto_list :
OPENING_BRACE
protospec
proto_def
(
COMMA
protospec
( COMMA )?
proto_def
)*
CLOSING_BRACE
;
hosts:
hosts :
ALL
{
importer->src_group.push_back(
AddressSpec(AddressSpec::ANY, "0.0.0.0", "0.0.0.0"));
importer->dst_group.push_back(
AddressSpec(AddressSpec::ANY, "0.0.0.0", "0.0.0.0"));
}
|
(
(
FROM
( src_hosts_part )?
( src_port_part )?
)?
(
TO
( dst_hosts_part )?
( dst_port_part )?
)
)
( hosts_from )? ( hosts_to )?
;
src_hosts_part:
hosts_from :
FROM ( src_hosts_part )? ( src_port_part )?
;
hosts_to :
TO ( dst_hosts_part )? ( dst_port_part )?
;
src_hosts_part :
(
ANY
common_hosts_part
|
URPF_FAILED
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("0.0.0.0", "0.0.0.0"));
AddressSpec(AddressSpec::SPECIAL_ADDRESS,
"urpf-failed", ""));
}
|
SELF
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("self", "255.255.255.255"));
}
|
host
|
host_list
)
{
importer->src_neg = importer->tmp_neg;
@@ -429,35 +459,42 @@ src_hosts_part:
}
;
dst_hosts_part:
(
ANY
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("0.0.0.0", "0.0.0.0"));
}
|
SELF
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("self", "255.255.255.255"));
}
|
host
|
host_list
)
dst_hosts_part :
common_hosts_part
{
importer->dst_neg = importer->tmp_neg;
importer->dst_group.splice(importer->src_group.begin(),
importer->dst_group.splice(importer->dst_group.begin(),
importer->tmp_group);
}
;
common_hosts_part :
ANY
{
importer->tmp_group.push_back(
AddressSpec(AddressSpec::ANY, "0.0.0.0", "0.0.0.0"));
}
|
SELF
{
importer->tmp_group.push_back(
AddressSpec(AddressSpec::SPECIAL_ADDRESS, "self", ""));
}
|
NO_ROUTE
{
importer->tmp_group.push_back(
AddressSpec(AddressSpec::SPECIAL_ADDRESS, "no-route", ""));
}
|
host
|
host_list
;
host :
(
EXCLAMATION
EXLAMATION
{
importer->tmp_neg = true;
}
@@ -468,7 +505,7 @@ host :
if (v6)
{
importer->addMessageToLog(
QString("Warning: IPv6 import is not supported. "));
QString("Error: IPv6 import is not supported. "));
consumeUntil(NEWLINE);
} else
{
@@ -477,7 +514,8 @@ host :
if (h) addr = h->getText();
if (nm) netm = nm->getText();
importer->tmp_group.push_back(
std::pair<std::string, std::string>(addr, netm));
AddressSpec(AddressSpec::NETWORK_ADDRESS,
addr, netm));
}
}
|
@@ -485,10 +523,15 @@ host :
{
// This should be an interface name
importer->tmp_group.push_back(
std::pair<std::string, std::string>(
LT(0)->getText(), "255.255.255.255"));
AddressSpec(AddressSpec::INTERFACE_NAME,
LT(0)->getText(), ""));
}
|
LESS_THAN tn:WORD GREATER_THAN
{
importer->tmp_group.push_back(
AddressSpec(AddressSpec::TABLE, tn->getText(), ""));
}
// Add table matching here
)
;
@@ -502,20 +545,160 @@ host_list :
CLOSING_BRACE
;
filteropts:
// ************************************************************************
route :
route_to | reply_to
;
route_to :
ROUTE_TO ( routehost | routehost_list )
{
importer->route_type = PFImporter::ROUTE_TO;
}
;
reply_to :
REPLY_TO ( routehost | routehost_list )
{
importer->route_type = PFImporter::REPLY_TO;
}
;
routehost { RouteSpec rs; } :
OPENING_PAREN
WORD { rs.iface = LT(0)->getText(); }
(h:IPV4 | v6:IPV6) (SLASH (nm:IPV4 | nm6:INT_CONST))?
{
if (v6)
{
importer->addMessageToLog(
QString("Error: IPv6 import is not supported. "));
consumeUntil(NEWLINE);
} else
{
if (h) rs.address = h->getText();
if (nm) rs.netmask = nm->getText();
importer->route_group.push_back(rs);
}
}
CLOSING_PAREN
;
routehost_list :
OPENING_BRACE
routehost
(
( COMMA )?
routehost
)*
CLOSING_BRACE
;
// ************************************************************************
filteropts :
filteropt
(
COMMA
( COMMA )?
filteropt
)*
;
filteropt:
(state)?
(queue)?
filteropt :
tcp_flags
|
icmp_type
|
icmp6_type
|
tagged
|
tag_clause
|
state
|
queue
|
label
;
state:
tcp_flags :
FLAGS
(
ANY
{
importer->flags_check = "any";
importer->flags_mask = "all";
}
|
( check:WORD )? SLASH ( mask:WORD )?
{
if (check)
importer->flags_check = check->getText();
else
importer->flags_check = "any";
if (mask)
importer->flags_mask = mask->getText();
else
importer->flags_mask = "all";
}
)
;
icmp_type :
ICMP_TYPE
(
icmp_type_code
|
icmp_list
)
;
icmp_type_code { std::string icmp_type, icmp_code; } :
( WORD | INT_CONST ) { icmp_type = LT(0)->getText(); }
(
ICMP_CODE ( WORD | INT_CONST ) { icmp_code = LT(0)->getText(); }
)?
{
importer->icmp_type_code_group.push_back(
str_tuple(icmp_type, icmp_code));
}
;
icmp_list :
OPENING_BRACE
icmp_type_code
(
( COMMA )?
icmp_type_code
)*
CLOSING_BRACE
;
icmp6_type :
ICMP6_TYPE
{
importer->addMessageToLog(
QString("Error: ICMP6 import is not supported. "));
consumeUntil(NEWLINE);
}
;
tagged :
TAGGED WORD
{
importer->tagged = LT(0)->getText();
}
;
tag_clause :
TAG WORD
{
importer->tag = LT(0)->getText();
}
;
state :
(
NO
|
@@ -531,25 +714,29 @@ state:
STATE
;
queue:
queue :
QUEUE
(
WORD { importer->queue += LT(0)->getText(); }
|
OPENING_PAREN { importer->queue += "("; }
OPENING_PAREN
WORD { importer->queue += LT(0)->getText(); }
(
COMMA { importer->queue += ","; }
WORD { importer->queue += LT(0)->getText(); }
)*
CLOSING_PAREN { importer->queue += ")"; }
CLOSING_PAREN
)
;
label :
LABEL STRING
;
//****************************************************************
src_port_part :
PORT ( unary_op | binary_op | op_list )
PORT ( port_op | port_op_list )
{
importer->src_port_group.splice(importer->src_port_group.begin(),
importer->tmp_port_group);
@@ -557,86 +744,77 @@ src_port_part :
;
dst_port_part :
PORT ( unary_op | binary_op | op_list )
PORT ( port_op | port_op_list )
{
importer->dst_port_group.splice(importer->dst_port_group.begin(),
importer->tmp_port_group);
}
;
unary_op :
{
std::string op = "=";
}
unary_port_op :
(
(
EQUAL
|
NOT_EQUAL
|
LESS_THAN
|
LESS_OR_EQUAL_THAN
|
GREATER_THAN
|
GREATER_OR_EQUAL_THAN
)
{
op = LT(0)->getText();
}
)?
port_def
{
std::vector<std::string> tuple;
tuple.push_back(op);
tuple.push_back(importer->tmp_port_def);
importer->tmp_port_group.push_back(tuple);
}
EQUAL { importer->tmp_port_op = "="; }
|
EXLAMATION EQUAL { importer->tmp_port_op = "!="; }
|
LESS_THAN { importer->tmp_port_op = "<"; }
|
LESS_THAN EQUAL { importer->tmp_port_op = "<="; }
|
GREATER_THAN { importer->tmp_port_op = ">"; }
|
GREATER_THAN EQUAL { importer->tmp_port_op = ">="; }
)
;
binary_op :
{
std::string op;
std::string arg1;
std::vector<std::string> tuple;
}
port_def
{
arg1 = importer->tmp_port_def;
}
binary_port_op :
(
EXCEPT_RANGE
LESS_THAN GREATER_THAN { importer->tmp_port_op = "<>"; }
|
INSIDE_RANGE
GREATER_THAN LESS_THAN { importer->tmp_port_op = "><"; }
|
COLON
COLON { importer->tmp_port_op = ":"; }
)
;
port_op { PortSpec ps; } :
(
unary_port_op { ps.port_op = importer->tmp_port_op; }
port_def
{
ps.port1 = importer->tmp_port_def;
ps.port2 = importer->tmp_port_def;
}
|
port_def
{
ps.port1 = importer->tmp_port_def;
ps.port2 = ps.port1;
ps.port_op = "=";
}
(
binary_port_op { ps.port_op = importer->tmp_port_op; }
port_def { ps.port2 = LT(0)->getText(); }
)?
)
{
op = LT(0)->getText();
}
port_def
{
tuple.push_back(op);
tuple.push_back(arg1);
tuple.push_back(importer->tmp_port_def);
importer->tmp_port_group.push_back(tuple);
importer->tmp_port_group.push_back(ps);
}
;
port_def :
( WORD | INT_CONST | PORT_RANGE )
WORD | INT_CONST
{
importer->tmp_port_def = LT(0)->getText();
}
;
op_list :
port_op_list :
OPENING_BRACE
( unary_op | binary_op )
port_op
(
COMMA
( unary_op | binary_op )
( COMMA )?
port_op
)*
CLOSING_BRACE
;
@@ -709,13 +887,20 @@ tokens
ISIS = "isis";
HOST = "host";
ANY = "any";
ANY = "any";
ALL = "all";
USER = "user";
PORT = "port";
RANGE = "range";
LOG = "log";
NO_ROUTE = "no-route";
SELF = "self";
URPF_FAILED = "urpf-failed";
LOG_LEVEL_ALERTS = "alerts";
LOG_LEVEL_CRITICAL = "critical";
LOG_LEVEL_DEBUGGING = "debugging";
@@ -737,14 +922,17 @@ tokens
NAT = "nat";
RDR = "rdr";
BINAT = "binat";
TABLE = "table";
QUEUE = "queue";
NOT_EQUAL = "!=" ;
LESS_OR_EQUAL_THAN = "<=" ;
GREATER_OR_EQUAL_THAN = ">=" ;
EXCEPT_RANGE = "<>";
INSIDE_RANGE = "><";
LABEL = "label";
ROUTE_TO = "route-to";
REPLY_TO = "reply-to";
TAG = "tag";
TAGGED = "tagged";
TRANSLATE_TO = "->";
@@ -752,6 +940,11 @@ tokens
KEEP = "keep";
MODULATE = "modulate";
SYNPROXY = "synproxy";
FLAGS = "flags";
ICMP_TYPE = "icmp-type";
ICMP6_TYPE = "icmp6-type";
ICMP_CODE = "code";
}
LINE_COMMENT : "#" (~('\r' | '\n'))* NEWLINE ;
@@ -786,7 +979,7 @@ protected
DIGIT : '0'..'9' ;
protected
NUM_3DIGIT: ('1'..'9') (('0'..'9') ('0'..'9')?)? ;
NUM_3DIGIT: ('0'..'9') (('0'..'9') ('0'..'9')?)? ;
protected
NUM_HEX_4DIGIT: HEX_DIGIT ((HEX_DIGIT) ((HEX_DIGIT) (HEX_DIGIT)?)?)? ;
@@ -803,9 +996,9 @@ options {
|
( (DIGIT)+ '.' (DIGIT)+ )=> ( (DIGIT)+ '.' (DIGIT)+ )
{ $setType(NUMBER); }
|
( (DIGIT)+ ':' (DIGIT)+ )=> ( (DIGIT)+ ':' (DIGIT)+ )
{ $setType(PORT_RANGE); }
// |
// ( (DIGIT)+ ':' (DIGIT)+ )=> ( (DIGIT)+ ':' (DIGIT)+ )
// { $setType(PORT_RANGE); }
|
( DIGIT )+ { $setType(INT_CONST); }
@@ -835,12 +1028,13 @@ options {
|
// making sure ',' '(' ')' '=' '<' '>' '-' '+' are not part of WORD do
// making sure ',' '(' ')' '=' '<' '>' '+' are not part of WORD do
// not start WORD with '$' since we expand macros in PFImporterRun
// using regex.
// double quote " should be included, without it STRING does not match
( 'a'..'z' | 'A'..'Z' )
( '$' | '%' | '&' | '0'..'9' | ';' |
( '"' | '$' | '%' | '&' | '-' | '0'..'9' | ';' |
'?' | '@' | 'A'..'Z' | '\\' | '^' | '_' | '`' | 'a'..'z' )*
{ $setType(WORD); }
;
@@ -860,9 +1054,10 @@ MINUS : '-' ;
DOT : '.' ;
SLASH : '/' ;
// COLON : ':' ;
//COLON : ':' ;
SEMICOLON : ';' ;
EQUAL : '=' ;
EQUAL : '=';
QUESTION : '?' ;
COMMERCIAL_AT : '@' ;
@@ -885,3 +1080,5 @@ EXLAMATION : '!';
LESS_THAN : '<' ;
GREATER_THAN : '>' ;
DOUBLE_QUOTE : '"';