see #2394 creating policy rules with src and dst populated; parsing and creating address tables and groups of addresses

This commit is contained in:
Vadim Kurland
2011-05-25 23:57:27 -07:00
parent ea9c28fda1
commit e10ab65393
11 changed files with 1293 additions and 847 deletions
+17 -27
View File
@@ -586,48 +586,38 @@ void Importer::setDstSelf()
dst_a = "self"; dst_a = "self";
} }
FWObject* Importer::makeSrcObj() FWObject* Importer::makeAddressObj(const std::string addr, const std::string netm)
{ {
if (src_a == "self") if (addr == "self")
{ {
return getFirewallObject(); return getFirewallObject();
} }
if ( (src_a=="" && src_nm=="") || if ( (addr=="" && netm=="") ||
(src_a==InetAddr::getAny().toString() && (addr==InetAddr::getAny().toString() &&
src_nm==InetAddr::getAny().toString())) netm==InetAddr::getAny().toString()))
return NULL; // this is 'any' return NULL; // this is 'any'
if (src_nm=="") src_nm = InetAddr::getAllOnes().toString();
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
sig.type_name = Address::TYPENAME; sig.type_name = Address::TYPENAME;
sig.setAddress(src_a.c_str()); sig.setAddress(addr.c_str());
sig.setNetmask(src_nm.c_str(), address_maker->getInvertedNetmasks()); if (netm=="")
sig.setNetmask(InetAddr::getAllOnes().toString().c_str(),
address_maker->getInvertedNetmasks());
else
sig.setNetmask(netm.c_str(), address_maker->getInvertedNetmasks());
return commitObject(address_maker->createObject(sig)); return commitObject(address_maker->createObject(sig));
} }
FWObject* Importer::makeSrcObj()
{
return makeAddressObj(src_a, src_nm);
}
FWObject* Importer::makeDstObj() FWObject* Importer::makeDstObj()
{ {
if (dst_a == "self") return makeAddressObj(dst_a, dst_nm);
{
return getFirewallObject();
}
if ( (dst_a=="" && dst_nm=="") ||
(dst_a==InetAddr::getAny().toString() &&
dst_nm==InetAddr::getAny().toString()))
return NULL; // this is 'any'
if (dst_nm=="") dst_nm=InetAddr::getAllOnes().toString();
ObjectSignature sig(error_tracker);
sig.type_name = Address::TYPENAME;
sig.setAddress(dst_a.c_str());
sig.setNetmask(dst_nm.c_str(), address_maker->getInvertedNetmasks());
return commitObject(address_maker->createObject(sig));
} }
FWObject* Importer::makeSrvObj() FWObject* Importer::makeSrvObj()
+3
View File
@@ -182,6 +182,9 @@ protected:
virtual libfwbuilder::FWObject* createGroupOfInterfaces( virtual libfwbuilder::FWObject* createGroupOfInterfaces(
const std::string &ruleset_name, std::list<std::string> &interfaces); const std::string &ruleset_name, std::list<std::string> &interfaces);
virtual libfwbuilder::FWObject* makeAddressObj(const std::string addr,
const std::string netm);
virtual libfwbuilder::FWObject* makeSrcObj(); virtual libfwbuilder::FWObject* makeSrcObj();
virtual libfwbuilder::FWObject* makeDstObj(); virtual libfwbuilder::FWObject* makeDstObj();
virtual libfwbuilder::FWObject* makeSrvObj(); virtual libfwbuilder::FWObject* makeSrvObj();
+141 -27
View File
@@ -35,6 +35,7 @@
#include "fwbuilder/FWObjectDatabase.h" #include "fwbuilder/FWObjectDatabase.h"
#include "fwbuilder/AddressRange.h" #include "fwbuilder/AddressRange.h"
#include "fwbuilder/AddressTable.h"
#include "fwbuilder/Resources.h" #include "fwbuilder/Resources.h"
#include "fwbuilder/Network.h" #include "fwbuilder/Network.h"
#include "fwbuilder/Address.h" #include "fwbuilder/Address.h"
@@ -90,6 +91,7 @@ void PFImporter::clear()
iface_group.clear(); iface_group.clear();
proto_list.clear(); proto_list.clear();
tmp_group.clear();
src_group.clear(); src_group.clear();
dst_group.clear(); dst_group.clear();
@@ -124,35 +126,81 @@ void PFImporter::clearTempVars()
Importer::clear(); Importer::clear();
} }
FWObject* PFImporter::makeSrcObj() void PFImporter::addSrc()
{ {
if (src_nm == "interface") PolicyRule *rule = PolicyRule::cast(current_rule);
{ RuleElement *re = rule->getSrc();
Interface *intf = getInterfaceByName(src_a);
if (intf) return intf;
reportError(
QString("Cannot find interface with label '%1'").arg(src_a.c_str()));
}
return Importer::makeSrcObj(); list<AddressSpec>::iterator it;
for (it=src_group.begin(); it!=src_group.end(); ++it)
{
FWObject *obj = makeAddressObj(*it);
if (obj) re->addRef(obj);
}
} }
FWObject* PFImporter::makeDstObj() void PFImporter::addDst()
{ {
if (dst_nm == "interface") PolicyRule *rule = PolicyRule::cast(current_rule);
{ RuleElement *re = rule->getDst();
Interface *intf = getInterfaceByName(dst_a);
if (intf) return intf;
reportError(
QString("Cannot find interface with label '%1'").arg(dst_a.c_str()));
}
return Importer::makeDstObj(); list<AddressSpec>::iterator it;
for (it=dst_group.begin(); it!=dst_group.end(); ++it)
{
FWObject *obj = makeAddressObj(*it);
if (obj) re->addRef(obj);
}
} }
FWObject* PFImporter::makeSrvObj() void PFImporter::addSrv()
{ {
return Importer::makeSrvObj(); PolicyRule *rule = PolicyRule::cast(current_rule);
RuleElement *re = rule->getSrv();
// list<AddressSpec>::iterator it;
// for (it=dst_group.begin(); it!=dst_group.end(); ++it)
// {
// FWObject *obj = makeAddressObj(*it);
// if (obj) re->addRef(obj);
// }
}
FWObject* PFImporter::makeAddressObj(AddressSpec &as)
{
if (as.at == AddressSpec::ANY) return NULL;
if (as.at == AddressSpec::INTERFACE_NAME)
{
Interface *intf = getInterfaceByName(as.address);
assert(intf!=NULL);
return intf;
}
if (as.at == AddressSpec::HOST_ADDRESS)
{
return Importer::makeAddressObj(as.address, "");
}
if (as.at == AddressSpec::NETWORK_ADDRESS)
{
return Importer::makeAddressObj(as.address, as.netmask);
}
if (as.at == AddressSpec::SPECIAL_ADDRESS)
{
if (as.address == "self") return getFirewallObject();
{
addMessageToLog(
QObject::tr("Warning: matching '%1' is not supported")
.arg(as.address.c_str()));
return NULL;
}
}
if (as.at == AddressSpec::TABLE)
{
return address_table_registry[as.address.c_str()];
}
} }
void PFImporter::addLogging() void PFImporter::addLogging()
@@ -260,10 +308,8 @@ void PFImporter::pushPolicyRule()
// importer->setInterfaceAndDirectionForRuleSet( // importer->setInterfaceAndDirectionForRuleSet(
// "", importer->iface, importer->direction); // "", importer->iface, importer->direction);
QString message_str =
addMessageToLog( QString("filtering rule: action %1; interfaces: %2");
QString("filtering rule: action %1")
.arg(action.c_str()));
PolicyRule *rule = PolicyRule::cast(current_rule); PolicyRule *rule = PolicyRule::cast(current_rule);
@@ -272,7 +318,10 @@ void PFImporter::pushPolicyRule()
if (action=="pass") if (action=="pass")
{ {
rule->setAction(PolicyRule::Accept); if (quick)
rule->setAction(PolicyRule::Accept);
else
rule->setAction(PolicyRule::Continue);
ropt->setBool("stateless", false); ropt->setBool("stateless", false);
} }
@@ -282,7 +331,35 @@ void PFImporter::pushPolicyRule()
ropt->setBool("stateless", true); ropt->setBool("stateless", true);
} }
rule->setDirection(PolicyRule::Both); if (direction == "in") rule->setDirection(PolicyRule::Inbound);
if (direction == "out") rule->setDirection(PolicyRule::Outbound);
if (direction == "") rule->setDirection(PolicyRule::Both);
QStringList interfaces;
list<InterfaceSpec>::iterator it;
for (it=iface_group.begin(); it!=iface_group.end(); ++it)
{
Interface *intf = getInterfaceByName(it->name);
assert(intf!=NULL);
RuleElement *re =rule->getItf();
re->addRef(intf);
interfaces << it->name.c_str();
}
/*
* Set state-related rule options using variable state_op
*/
/*
* Set tagging rule option using variable tag
*/
/*
* Set queueing rule option using variable queue
*/
/* /*
* Protocols are in proto_list * Protocols are in proto_list
@@ -290,17 +367,23 @@ void PFImporter::pushPolicyRule()
* Destination addresses are in dst_group * Destination addresses are in dst_group
*/ */
addSrc(); addSrc();
addDst(); addDst();
addSrv(); addSrv();
/*
* Set logging options using variables logging and logopts
*/
addLogging(); addLogging();
// then add it to the current ruleset // then add it to the current ruleset
current_ruleset->ruleset->add(current_rule); current_ruleset->ruleset->add(current_rule);
addStandardImportComment( addStandardImportComment(
current_rule, QString::fromUtf8(rule_comment.c_str())); current_rule, QString::fromUtf8(rule_comment.c_str()));
addMessageToLog(message_str.arg(action.c_str()).arg(interfaces.join(",")));
} }
Firewall* PFImporter::finalize() Firewall* PFImporter::finalize()
@@ -364,3 +447,34 @@ Interface* PFImporter::getInterfaceByName(const string &name)
return NULL; return NULL;
} }
void PFImporter::newAddressTableObject(const string &name, const string &file)
{
ObjectMaker maker(Library::cast(library), error_tracker);
AddressTable *at = AddressTable::cast(
commitObject(maker.createObject(AddressTable::TYPENAME, name.c_str())));
assert(at!=NULL);
at->setRunTime(true);
at->setSourceName(file);
address_table_registry[name.c_str()] = at;
addMessageToLog(QString("Address Table: <%1> file %2")
.arg(name.c_str()).arg(file.c_str()));
}
void PFImporter::newAddressTableObject(const string &name,
list<AddressSpec> &addresses)
{
ObjectMaker maker(Library::cast(library), error_tracker);
FWObject *og =
commitObject(maker.createObject(ObjectGroup::TYPENAME, name.c_str()));
assert(og!=NULL);
address_table_registry[name.c_str()] = og;
list<AddressSpec>::iterator it;
for (it=addresses.begin(); it!=addresses.end(); ++it)
{
FWObject *obj = makeAddressObj(*it);
if (obj) og->addRef(obj);
}
}
+18 -7
View File
@@ -70,28 +70,31 @@ public:
typedef enum { typedef enum {
UNKNOWN, UNKNOWN,
ANY, ANY,
HOST_NAME,
HOST_ADDRESS, HOST_ADDRESS,
NETWORK_ADDRESS, NETWORK_ADDRESS,
SPECIAL_ADDRESS, SPECIAL_ADDRESS,
INTERFACE_NAME, INTERFACE_NAME,
TABLE } address_type; TABLE } address_type;
address_type at; address_type at;
bool neg;
std::string address; std::string address;
std::string netmask; std::string netmask;
AddressSpec() AddressSpec()
{ at = UNKNOWN; address = ""; netmask = ""; } { at = UNKNOWN; neg = false; address = ""; netmask = ""; }
AddressSpec(const AddressSpec &other) AddressSpec(const AddressSpec &other)
{ {
at = other.at; at = other.at;
neg = other.neg;
address = other.address; address = other.address;
netmask = other.netmask; netmask = other.netmask;
} }
AddressSpec(address_type _at, const std::string _addr, const std::string _nm) AddressSpec(address_type _at, bool _neg, const std::string _addr, const std::string _nm)
{ at = _at; address = _addr; netmask = _nm; } { at = _at; neg= _neg; address = _addr; netmask = _nm; }
}; };
@@ -154,6 +157,8 @@ public:
REPLY_TO, REPLY_TO,
DUP_TO} route_op_type; DUP_TO} route_op_type;
QMap<QString,libfwbuilder::FWObject*> address_table_registry;
std::string direction; std::string direction;
std::string address_family; std::string address_family;
bool quick; bool quick;
@@ -211,13 +216,19 @@ public:
// and does final clean up. // and does final clean up.
virtual libfwbuilder::Firewall* finalize(); virtual libfwbuilder::Firewall* finalize();
virtual libfwbuilder::FWObject* makeSrcObj(); virtual libfwbuilder::FWObject* makeAddressObj(AddressSpec &as);
virtual libfwbuilder::FWObject* makeDstObj();
virtual libfwbuilder::FWObject* makeSrvObj(); virtual void addSrc();
virtual void addDst();
virtual void addSrv();
virtual void addLogging(); virtual void addLogging();
libfwbuilder::Interface* getInterfaceByName(const std::string &name); libfwbuilder::Interface* getInterfaceByName(const std::string &name);
void newAddressTableObject(const std::string &name, const std::string &file);
void newAddressTableObject(const std::string &name,
std::list<AddressSpec> &addresses);
}; };
#endif #endif
+181 -178
View File
@@ -1,4 +1,4 @@
/* $ANTLR 2.7.7 (20100319): "pf.g" -> "PFCfgLexer.cpp"$ */ /* $ANTLR 2.7.7 (20090306): "pf.g" -> "PFCfgLexer.cpp"$ */
#line 42 "pf.g" #line 42 "pf.g"
// gets inserted before the antlr generated includes in the cpp // gets inserted before the antlr generated includes in the cpp
@@ -44,90 +44,93 @@ PFCfgLexer::PFCfgLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& st
void PFCfgLexer::initLiterals() void PFCfgLexer::initLiterals()
{ {
literals["vrrp"] = 50; literals["vrrp"] = 61;
literals["critical"] = 96; literals["critical"] = 100;
literals["ospf"] = 48; literals["ospf"] = 59;
literals["rdp"] = 42; literals["rdp"] = 53;
literals["disable"] = 103; literals["disable"] = 107;
literals["scrub"] = 12; literals["scrub"] = 12;
literals["ipsec"] = 86; literals["ipsec"] = 90;
literals["inet"] = 34; literals["inet"] = 45;
literals["pcp"] = 88; literals["pcp"] = 92;
literals["emergencies"] = 98; literals["emergencies"] = 102;
literals["debugging"] = 97; literals["debugging"] = 101;
literals["snp"] = 92; literals["persist"] = 16;
literals["timeout"] = 17; literals["snp"] = 96;
literals["to"] = 28; literals["timeout"] = 32;
literals["flags"] = 66; literals["to"] = 42;
literals["isis"] = 52; literals["flags"] = 71;
literals["icmp6-type"] = 69; literals["isis"] = 63;
literals["pptp"] = 90; literals["icmp6-type"] = 74;
literals["pass"] = 18; literals["const"] = 17;
literals["no"] = 72; literals["pptp"] = 94;
literals["from"] = 54; literals["pass"] = 33;
literals["igrp"] = 85; literals["no"] = 77;
literals["pim"] = 89; literals["from"] = 64;
literals["tagged"] = 70; literals["igrp"] = 89;
literals["rsvp"] = 43; literals["pim"] = 93;
literals["route-to"] = 64; literals["tagged"] = 75;
literals["nos"] = 87; literals["rsvp"] = 54;
literals["quit"] = 82; literals["route-to"] = 69;
literals["->"] = 105; literals["nos"] = 91;
literals["icmp-type"] = 67; literals["quit"] = 86;
literals["exit"] = 81; literals["->"] = 109;
literals["modulate"] = 74; literals["icmp-type"] = 72;
literals["nat"] = 14; literals["exit"] = 85;
literals["range"] = 94; literals["modulate"] = 79;
literals["urpf-failed"] = 55; literals["nat"] = 29;
literals["out"] = 21; literals["range"] = 98;
literals["urpf-failed"] = 65;
literals["out"] = 36;
literals["queue"] = 10; literals["queue"] = 10;
literals["gre"] = 44; literals["gre"] = 55;
literals["set"] = 11; literals["set"] = 11;
literals["warnings"] = 102; literals["warnings"] = 106;
literals["ah"] = 46; literals["ah"] = 57;
literals["host"] = 93; literals["host"] = 97;
literals["interface"] = 83; literals["interface"] = 87;
literals["rip"] = 91; literals["rip"] = 95;
literals["icmp6"] = 84; literals["icmp6"] = 88;
literals["notifications"] = 101; literals["notifications"] = 105;
literals["synproxy"] = 75; literals["file"] = 19;
literals["synproxy"] = 80;
literals["altq"] = 9; literals["altq"] = 9;
literals["any"] = 56; literals["any"] = 66;
literals["esp"] = 45; literals["esp"] = 56;
literals["alerts"] = 95; literals["alerts"] = 99;
literals["all"] = 26; literals["all"] = 40;
literals["inet6"] = 35; literals["inet6"] = 46;
literals["inactive"] = 104; literals["inactive"] = 108;
literals["label"] = 77; literals["label"] = 82;
literals["udp"] = 41; literals["no-route"] = 67;
literals["no-route"] = 58; literals["udp"] = 52;
literals["reply-to"] = 65; literals["reply-to"] = 70;
literals["tag"] = 71; literals["tag"] = 76;
literals["port"] = 79; literals["port"] = 83;
literals["code"] = 68; literals["code"] = 73;
literals["ip"] = 37; literals["ip"] = 48;
literals["table"] = 13; literals["table"] = 13;
literals["eigrp"] = 47; literals["eigrp"] = 58;
literals["errors"] = 99; literals["errors"] = 103;
literals["ipip"] = 49; literals["ipip"] = 60;
literals["antispoof"] = 8; literals["antispoof"] = 8;
literals["binat"] = 15; literals["binat"] = 30;
literals["igmp"] = 39; literals["igmp"] = 50;
literals["on"] = 30; literals["on"] = 44;
literals["state"] = 76; literals["state"] = 81;
literals["proto"] = 36; literals["proto"] = 47;
literals["log"] = 22; literals["log"] = 37;
literals["rdr"] = 16; literals["rdr"] = 31;
literals["informational"] = 100; literals["informational"] = 104;
literals["in"] = 20; literals["self"] = 25;
literals["self"] = 57; literals["in"] = 35;
literals["keep"] = 73; literals["keep"] = 78;
literals["block"] = 19; literals["block"] = 34;
literals["l2tp"] = 51; literals["l2tp"] = 62;
literals["quick"] = 29; literals["quick"] = 43;
literals["user"] = 27; literals["user"] = 41;
literals["icmp"] = 38; literals["icmp"] = 49;
literals["tcp"] = 40; literals["tcp"] = 51;
} }
ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken() ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
@@ -435,11 +438,11 @@ void PFCfgLexer::mLINE_COMMENT(bool _createToken) {
} }
} }
else { else {
goto _loop140; goto _loop152;
} }
} }
_loop140:; _loop152:;
} // ( ... )* } // ( ... )*
mNEWLINE(false); mNEWLINE(false);
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) { if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
@@ -471,9 +474,9 @@ void PFCfgLexer::mNEWLINE(bool _createToken) {
} }
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 958 "pf.g" #line 1010 "pf.g"
newline(); newline();
#line 477 "PFCfgLexer.cpp" #line 480 "PFCfgLexer.cpp"
} }
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) { if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype); _token = makeToken(_ttype);
@@ -552,9 +555,9 @@ void PFCfgLexer::mWhitespace(bool _createToken) {
} }
} }
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 953 "pf.g" #line 1005 "pf.g"
_ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP; _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP;
#line 558 "PFCfgLexer.cpp" #line 561 "PFCfgLexer.cpp"
} }
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) { if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype); _token = makeToken(_ttype);
@@ -739,10 +742,10 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
_ttype = NUMBER_ADDRESS_OR_WORD; _ttype = NUMBER_ADDRESS_OR_WORD;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex; ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
bool synPredMatched165 = false; bool synPredMatched177 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_2.member(LA(2))) && (_tokenSet_2.member(LA(3))))) { if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_2.member(LA(2))) && (_tokenSet_2.member(LA(3))))) {
int _m165 = mark(); int _m177 = mark();
synPredMatched165 = true; synPredMatched177 = true;
inputState->guessing++; inputState->guessing++;
try { try {
{ {
@@ -753,12 +756,12 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
} }
} }
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) { catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched165 = false; synPredMatched177 = false;
} }
rewind(_m165); rewind(_m177);
inputState->guessing--; inputState->guessing--;
} }
if ( synPredMatched165 ) { if ( synPredMatched177 ) {
{ {
mNUM_3DIGIT(false); mNUM_3DIGIT(false);
match('.' /* charlit */ ); match('.' /* charlit */ );
@@ -769,99 +772,99 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
mNUM_3DIGIT(false); mNUM_3DIGIT(false);
} }
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 995 "pf.g" #line 1047 "pf.g"
_ttype = IPV4; _ttype = IPV4;
#line 775 "PFCfgLexer.cpp" #line 778 "PFCfgLexer.cpp"
} }
} }
else { else {
bool synPredMatched172 = false; bool synPredMatched184 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_2.member(LA(2))) && (_tokenSet_2.member(LA(3))))) { if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_2.member(LA(2))) && (_tokenSet_2.member(LA(3))))) {
int _m172 = mark(); int _m184 = mark();
synPredMatched172 = true; synPredMatched184 = true;
inputState->guessing++; inputState->guessing++;
try { try {
{ {
{ // ( ... )+ { // ( ... )+
int _cnt169=0; int _cnt181=0;
for (;;) { for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) { if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false); mDIGIT(false);
} }
else { else {
if ( _cnt169>=1 ) { goto _loop169; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt181>=1 ) { goto _loop181; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt169++; _cnt181++;
} }
_loop169:; _loop181:;
} // ( ... )+ } // ( ... )+
match('.' /* charlit */ ); match('.' /* charlit */ );
{ // ( ... )+ { // ( ... )+
int _cnt171=0; int _cnt183=0;
for (;;) { for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) { if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false); mDIGIT(false);
} }
else { else {
if ( _cnt171>=1 ) { goto _loop171; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt183>=1 ) { goto _loop183; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt171++; _cnt183++;
} }
_loop171:; _loop183:;
} // ( ... )+ } // ( ... )+
} }
} }
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) { catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched172 = false; synPredMatched184 = false;
} }
rewind(_m172); rewind(_m184);
inputState->guessing--; inputState->guessing--;
} }
if ( synPredMatched172 ) { if ( synPredMatched184 ) {
{ {
{ // ( ... )+ { // ( ... )+
int _cnt175=0; int _cnt187=0;
for (;;) { for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) { if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false); mDIGIT(false);
} }
else { else {
if ( _cnt175>=1 ) { goto _loop175; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt187>=1 ) { goto _loop187; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt175++; _cnt187++;
} }
_loop175:; _loop187:;
} // ( ... )+ } // ( ... )+
match('.' /* charlit */ ); match('.' /* charlit */ );
{ // ( ... )+ { // ( ... )+
int _cnt177=0; int _cnt189=0;
for (;;) { for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) { if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false); mDIGIT(false);
} }
else { else {
if ( _cnt177>=1 ) { goto _loop177; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt189>=1 ) { goto _loop189; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt177++; _cnt189++;
} }
_loop177:; _loop189:;
} // ( ... )+ } // ( ... )+
} }
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 998 "pf.g" #line 1050 "pf.g"
_ttype = NUMBER; _ttype = NUMBER;
#line 858 "PFCfgLexer.cpp" #line 861 "PFCfgLexer.cpp"
} }
} }
else { else {
bool synPredMatched196 = false; bool synPredMatched208 = false;
if (((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x39 /* '9' */ )))) { if (((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && ((LA(3) >= 0x30 /* '0' */ && LA(3) <= 0x39 /* '9' */ )))) {
int _m196 = mark(); int _m208 = mark();
synPredMatched196 = true; synPredMatched208 = true;
inputState->guessing++; inputState->guessing++;
try { try {
{ {
@@ -871,12 +874,12 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
} }
} }
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) { catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched196 = false; synPredMatched208 = false;
} }
rewind(_m196); rewind(_m208);
inputState->guessing--; inputState->guessing--;
} }
if ( synPredMatched196 ) { if ( synPredMatched208 ) {
match(':' /* charlit */ ); match(':' /* charlit */ );
match(':' /* charlit */ ); match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false); mNUM_HEX_4DIGIT(false);
@@ -887,23 +890,23 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
mNUM_HEX_4DIGIT(false); mNUM_HEX_4DIGIT(false);
} }
else { else {
goto _loop198; goto _loop210;
} }
} }
_loop198:; _loop210:;
} // ( ... )* } // ( ... )*
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1021 "pf.g" #line 1073 "pf.g"
_ttype = IPV6; _ttype = IPV6;
#line 900 "PFCfgLexer.cpp" #line 903 "PFCfgLexer.cpp"
} }
} }
else { else {
bool synPredMatched181 = false; bool synPredMatched193 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )))) { if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && ((LA(2) >= 0x61 /* 'a' */ && LA(2) <= 0x66 /* 'f' */ )))) {
int _m181 = mark(); int _m193 = mark();
synPredMatched181 = true; synPredMatched193 = true;
inputState->guessing++; inputState->guessing++;
try { try {
{ {
@@ -912,60 +915,60 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
} }
} }
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) { catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched181 = false; synPredMatched193 = false;
} }
rewind(_m181); rewind(_m193);
inputState->guessing--; inputState->guessing--;
} }
if ( synPredMatched181 ) { if ( synPredMatched193 ) {
{ {
bool synPredMatched186 = false; bool synPredMatched198 = 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 /* ':' */ )))) { 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(); int _m198 = mark();
synPredMatched186 = true; synPredMatched198 = true;
inputState->guessing++; inputState->guessing++;
try { try {
{ {
{ // ( ... )+ { // ( ... )+
int _cnt185=0; int _cnt197=0;
for (;;) { for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) { if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mNUM_HEX_4DIGIT(false); mNUM_HEX_4DIGIT(false);
match(':' /* charlit */ ); match(':' /* charlit */ );
} }
else { else {
if ( _cnt185>=1 ) { goto _loop185; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt197>=1 ) { goto _loop197; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt185++; _cnt197++;
} }
_loop185:; _loop197:;
} // ( ... )+ } // ( ... )+
match(':' /* charlit */ ); match(':' /* charlit */ );
} }
} }
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) { catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched186 = false; synPredMatched198 = false;
} }
rewind(_m186); rewind(_m198);
inputState->guessing--; inputState->guessing--;
} }
if ( synPredMatched186 ) { if ( synPredMatched198 ) {
{ {
{ // ( ... )+ { // ( ... )+
int _cnt189=0; int _cnt201=0;
for (;;) { for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) { if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mNUM_HEX_4DIGIT(false); mNUM_HEX_4DIGIT(false);
match(':' /* charlit */ ); match(':' /* charlit */ );
} }
else { else {
if ( _cnt189>=1 ) { goto _loop189; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt201>=1 ) { goto _loop201; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt189++; _cnt201++;
} }
_loop189:; _loop201:;
} // ( ... )+ } // ( ... )+
match(':' /* charlit */ ); match(':' /* charlit */ );
{ {
@@ -978,11 +981,11 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
mNUM_HEX_4DIGIT(false); mNUM_HEX_4DIGIT(false);
} }
else { else {
goto _loop192; goto _loop204;
} }
} }
_loop192:; _loop204:;
} // ( ... )* } // ( ... )*
} }
else { else {
@@ -991,32 +994,32 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
} }
} }
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1012 "pf.g" #line 1064 "pf.g"
_ttype = IPV6; _ttype = IPV6;
#line 997 "PFCfgLexer.cpp" #line 1000 "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 /* ':' */ ))) { 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); mNUM_HEX_4DIGIT(false);
{ // ( ... )+ { // ( ... )+
int _cnt194=0; int _cnt206=0;
for (;;) { for (;;) {
if ((LA(1) == 0x3a /* ':' */ )) { if ((LA(1) == 0x3a /* ':' */ )) {
match(':' /* charlit */ ); match(':' /* charlit */ );
mNUM_HEX_4DIGIT(false); mNUM_HEX_4DIGIT(false);
} }
else { else {
if ( _cnt194>=1 ) { goto _loop194; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt206>=1 ) { goto _loop206; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt194++; _cnt206++;
} }
_loop194:; _loop206:;
} // ( ... )+ } // ( ... )+
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1015 "pf.g" #line 1067 "pf.g"
_ttype = IPV6; _ttype = IPV6;
#line 1020 "PFCfgLexer.cpp" #line 1023 "PFCfgLexer.cpp"
} }
} }
else { else {
@@ -1025,47 +1028,47 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
} }
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1017 "pf.g" #line 1069 "pf.g"
_ttype = IPV6; _ttype = IPV6;
#line 1031 "PFCfgLexer.cpp" #line 1034 "PFCfgLexer.cpp"
} }
} }
else if ((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && (true)) { else if ((LA(1) == 0x3a /* ':' */ ) && (LA(2) == 0x3a /* ':' */ ) && (true)) {
match(':' /* charlit */ ); match(':' /* charlit */ );
match(':' /* charlit */ ); match(':' /* charlit */ );
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1024 "pf.g" #line 1076 "pf.g"
_ttype = IPV6; _ttype = IPV6;
#line 1040 "PFCfgLexer.cpp" #line 1043 "PFCfgLexer.cpp"
} }
} }
else if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (true) && (true)) { else if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (true) && (true)) {
{ // ( ... )+ { // ( ... )+
int _cnt179=0; int _cnt191=0;
for (;;) { for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) { if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false); mDIGIT(false);
} }
else { else {
if ( _cnt179>=1 ) { goto _loop179; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} if ( _cnt191>=1 ) { goto _loop191; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
} }
_cnt179++; _cnt191++;
} }
_loop179:; _loop191:;
} // ( ... )+ } // ( ... )+
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1003 "pf.g" #line 1055 "pf.g"
_ttype = INT_CONST; _ttype = INT_CONST;
#line 1061 "PFCfgLexer.cpp" #line 1064 "PFCfgLexer.cpp"
} }
} }
else if ((LA(1) == 0x3a /* ':' */ ) && (true)) { else if ((LA(1) == 0x3a /* ':' */ ) && (true)) {
match(':' /* charlit */ ); match(':' /* charlit */ );
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1027 "pf.g" #line 1079 "pf.g"
_ttype = COLON; _ttype = COLON;
#line 1069 "PFCfgLexer.cpp" #line 1072 "PFCfgLexer.cpp"
} }
} }
else if ((_tokenSet_3.member(LA(1)))) { else if ((_tokenSet_3.member(LA(1)))) {
@@ -1276,16 +1279,16 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
} }
default: default:
{ {
goto _loop201; goto _loop213;
} }
} }
} }
_loop201:; _loop213:;
} // ( ... )* } // ( ... )*
if ( inputState->guessing==0 ) { if ( inputState->guessing==0 ) {
#line 1039 "pf.g" #line 1091 "pf.g"
_ttype = WORD; _ttype = WORD;
#line 1289 "PFCfgLexer.cpp" #line 1292 "PFCfgLexer.cpp"
} }
} }
else { else {
@@ -1313,11 +1316,11 @@ void PFCfgLexer::mSTRING(bool _createToken) {
matchNot('\"' /* charlit */ ); matchNot('\"' /* charlit */ );
} }
else { else {
goto _loop204; goto _loop216;
} }
} }
_loop204:; _loop216:;
} // ( ... )* } // ( ... )*
match('\"' /* charlit */ ); match('\"' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) { if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
@@ -1724,7 +1727,7 @@ void PFCfgLexer::mDOUBLE_QUOTE(bool _createToken) {
const unsigned long PFCfgLexer::_tokenSet_0_data_[] = { 4294958072UL, 1UL, 0UL, 2147483648UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL }; 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 // 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 0x7f 0x80 0x81 // 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f 0x7f 0x80 0x81
// 0x82 0x83 0x84 // 0x82 0x83 0x84 0x85 0x86 0x87 0x88
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_0(_tokenSet_0_data_,16); 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 }; 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 // 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xe 0xf 0x10 0x11 0x12 0x13 0x14
@@ -1732,7 +1735,7 @@ const unsigned long PFCfgLexer::_tokenSet_1_data_[] = { 4294958072UL, 4294967295
// & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G // & \' ( ) * + , - . / 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 // 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 { | } ~ 0x7f 0x80 0x81 0x82 0x83 // i j k l m n o p q r s t u v w x y z { | } ~ 0x7f 0x80 0x81 0x82 0x83
// 0x84 // 0x84 0x85 0x86 0x87 0x88
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_1(_tokenSet_1_data_,16); 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 }; 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 // . 0 1 2 3 4 5 6 7 8 9
@@ -1747,6 +1750,6 @@ const unsigned long PFCfgLexer::_tokenSet_4_data_[] = { 4294967288UL, 4294967291
// % & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F // % & \' ( ) * + , - . / 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 // 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 { | } ~ 0x7f 0x80 0x81 0x82 0x83 // 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 // 0x84 0x85 0x86 0x87 0x88
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_4(_tokenSet_4_data_,16); const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_4(_tokenSet_4_data_,16);
+1 -1
View File
@@ -9,7 +9,7 @@
#line 11 "PFCfgLexer.hpp" #line 11 "PFCfgLexer.hpp"
#include <antlr/config.hpp> #include <antlr/config.hpp>
/* $ANTLR 2.7.7 (20100319): "pf.g" -> "PFCfgLexer.hpp"$ */ /* $ANTLR 2.7.7 (20090306): "pf.g" -> "PFCfgLexer.hpp"$ */
#include <antlr/CommonToken.hpp> #include <antlr/CommonToken.hpp>
#include <antlr/InputBuffer.hpp> #include <antlr/InputBuffer.hpp>
#include <antlr/BitSet.hpp> #include <antlr/BitSet.hpp>
File diff suppressed because it is too large Load Diff
+8 -3
View File
@@ -9,7 +9,7 @@
#line 11 "PFCfgParser.hpp" #line 11 "PFCfgParser.hpp"
#include <antlr/config.hpp> #include <antlr/config.hpp>
/* $ANTLR 2.7.7 (20100319): "pf.g" -> "PFCfgParser.hpp"$ */ /* $ANTLR 2.7.7 (20090306): "pf.g" -> "PFCfgParser.hpp"$ */
#include <antlr/TokenStream.hpp> #include <antlr/TokenStream.hpp>
#include <antlr/TokenBuffer.hpp> #include <antlr/TokenBuffer.hpp>
#include "PFCfgParserTokenTypes.hpp" #include "PFCfgParserTokenTypes.hpp"
@@ -104,6 +104,7 @@ public:
public: void block_command(); public: void block_command();
public: void timeout_command(); public: void timeout_command();
public: void unknown_command(); public: void unknown_command();
public: void tableaddr_spec();
public: void rule_extended(); public: void rule_extended();
public: void direction(); public: void direction();
public: void logging(); public: void logging();
@@ -162,10 +163,10 @@ protected:
private: private:
static const char* tokenNames[]; static const char* tokenNames[];
#ifndef NO_STATIC_CONSTS #ifndef NO_STATIC_CONSTS
static const int NUM_TOKENS = 133; static const int NUM_TOKENS = 137;
#else #else
enum { enum {
NUM_TOKENS = 133 NUM_TOKENS = 137
}; };
#endif #endif
@@ -231,6 +232,10 @@ private:
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_29; static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_29;
static const unsigned long _tokenSet_30_data_[]; static const unsigned long _tokenSet_30_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_30; static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_30;
static const unsigned long _tokenSet_31_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_31;
static const unsigned long _tokenSet_32_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_32;
}; };
#endif /*INC_PFCfgParser_hpp_*/ #endif /*INC_PFCfgParser_hpp_*/
+124 -120
View File
@@ -1,7 +1,7 @@
#ifndef INC_PFCfgParserTokenTypes_hpp_ #ifndef INC_PFCfgParserTokenTypes_hpp_
#define INC_PFCfgParserTokenTypes_hpp_ #define INC_PFCfgParserTokenTypes_hpp_
/* $ANTLR 2.7.7 (20100319): "pf.g" -> "PFCfgParserTokenTypes.hpp"$ */ /* $ANTLR 2.7.7 (20090306): "pf.g" -> "PFCfgParserTokenTypes.hpp"$ */
#ifndef CUSTOM_API #ifndef CUSTOM_API
# define CUSTOM_API # define CUSTOM_API
@@ -22,125 +22,129 @@ struct CUSTOM_API PFCfgParserTokenTypes {
SET = 11, SET = 11,
SCRUB = 12, SCRUB = 12,
TABLE = 13, TABLE = 13,
NAT = 14, LESS_THAN = 14,
BINAT = 15, GREATER_THAN = 15,
RDR = 16, PERSIST = 16,
TIMEOUT = 17, CONST = 17,
PASS = 18, COUNTERS = 18,
BLOCK = 19, FILE = 19,
IN = 20, STRING = 20,
OUT = 21, OPENING_BRACE = 21,
LOG = 22, COMMA = 22,
OPENING_PAREN = 23, CLOSING_BRACE = 23,
COMMA = 24, EXLAMATION = 24,
CLOSING_PAREN = 25, SELF = 25,
ALL = 26, IPV4 = 26,
USER = 27, SLASH = 27,
TO = 28, INT_CONST = 28,
QUICK = 29, NAT = 29,
ON = 30, BINAT = 30,
EXLAMATION = 31, RDR = 31,
OPENING_BRACE = 32, TIMEOUT = 32,
CLOSING_BRACE = 33, PASS = 33,
INET = 34, BLOCK = 34,
INET6 = 35, IN = 35,
PROTO = 36, OUT = 36,
IP = 37, LOG = 37,
ICMP = 38, OPENING_PAREN = 38,
IGMP = 39, CLOSING_PAREN = 39,
TCP = 40, ALL = 40,
UDP = 41, USER = 41,
RDP = 42, TO = 42,
RSVP = 43, QUICK = 43,
GRE = 44, ON = 44,
ESP = 45, INET = 45,
AH = 46, INET6 = 46,
EIGRP = 47, PROTO = 47,
OSPF = 48, IP = 48,
IPIP = 49, ICMP = 49,
VRRP = 50, IGMP = 50,
L2TP = 51, TCP = 51,
ISIS = 52, UDP = 52,
INT_CONST = 53, RDP = 53,
FROM = 54, RSVP = 54,
URPF_FAILED = 55, GRE = 55,
ANY = 56, ESP = 56,
SELF = 57, AH = 57,
NO_ROUTE = 58, EIGRP = 58,
IPV4 = 59, OSPF = 59,
IPV6 = 60, IPIP = 60,
SLASH = 61, VRRP = 61,
LESS_THAN = 62, L2TP = 62,
GREATER_THAN = 63, ISIS = 63,
ROUTE_TO = 64, FROM = 64,
REPLY_TO = 65, URPF_FAILED = 65,
FLAGS = 66, ANY = 66,
ICMP_TYPE = 67, NO_ROUTE = 67,
ICMP_CODE = 68, IPV6 = 68,
ICMP6_TYPE = 69, ROUTE_TO = 69,
TAGGED = 70, REPLY_TO = 70,
TAG = 71, FLAGS = 71,
NO = 72, ICMP_TYPE = 72,
KEEP = 73, ICMP_CODE = 73,
MODULATE = 74, ICMP6_TYPE = 74,
SYNPROXY = 75, TAGGED = 75,
STATE = 76, TAG = 76,
LABEL = 77, NO = 77,
STRING = 78, KEEP = 78,
PORT = 79, MODULATE = 79,
COLON = 80, SYNPROXY = 80,
EXIT = 81, STATE = 81,
QUIT = 82, LABEL = 82,
INTRFACE = 83, PORT = 83,
ICMP6 = 84, COLON = 84,
IGRP = 85, EXIT = 85,
IPSEC = 86, QUIT = 86,
NOS = 87, INTRFACE = 87,
PCP = 88, ICMP6 = 88,
PIM = 89, IGRP = 89,
PPTP = 90, IPSEC = 90,
RIP = 91, NOS = 91,
SNP = 92, PCP = 92,
HOST = 93, PIM = 93,
RANGE = 94, PPTP = 94,
LOG_LEVEL_ALERTS = 95, RIP = 95,
LOG_LEVEL_CRITICAL = 96, SNP = 96,
LOG_LEVEL_DEBUGGING = 97, HOST = 97,
LOG_LEVEL_EMERGENCIES = 98, RANGE = 98,
LOG_LEVEL_ERRORS = 99, LOG_LEVEL_ALERTS = 99,
LOG_LEVEL_INFORMATIONAL = 100, LOG_LEVEL_CRITICAL = 100,
LOG_LEVEL_NOTIFICATIONS = 101, LOG_LEVEL_DEBUGGING = 101,
LOG_LEVEL_WARNINGS = 102, LOG_LEVEL_EMERGENCIES = 102,
LOG_LEVEL_DISABLE = 103, LOG_LEVEL_ERRORS = 103,
LOG_LEVEL_INACTIVE = 104, LOG_LEVEL_INFORMATIONAL = 104,
TRANSLATE_TO = 105, LOG_LEVEL_NOTIFICATIONS = 105,
Whitespace = 106, LOG_LEVEL_WARNINGS = 106,
HEX_CONST = 107, LOG_LEVEL_DISABLE = 107,
NUMBER = 108, LOG_LEVEL_INACTIVE = 108,
NEG_INT_CONST = 109, TRANSLATE_TO = 109,
HEX_DIGIT = 110, Whitespace = 110,
DIGIT = 111, HEX_CONST = 111,
NUM_3DIGIT = 112, NUMBER = 112,
NUM_HEX_4DIGIT = 113, NEG_INT_CONST = 113,
NUMBER_ADDRESS_OR_WORD = 114, HEX_DIGIT = 114,
PIPE_CHAR = 115, DIGIT = 115,
NUMBER_SIGN = 116, NUM_3DIGIT = 116,
PERCENT = 117, NUM_HEX_4DIGIT = 117,
AMPERSAND = 118, NUMBER_ADDRESS_OR_WORD = 118,
APOSTROPHE = 119, PIPE_CHAR = 119,
STAR = 120, NUMBER_SIGN = 120,
PLUS = 121, PERCENT = 121,
MINUS = 122, AMPERSAND = 122,
DOT = 123, APOSTROPHE = 123,
SEMICOLON = 124, STAR = 124,
QUESTION = 125, PLUS = 125,
COMMERCIAL_AT = 126, MINUS = 126,
OPENING_SQUARE = 127, DOT = 127,
CLOSING_SQUARE = 128, SEMICOLON = 128,
CARET = 129, QUESTION = 129,
UNDERLINE = 130, COMMERCIAL_AT = 130,
TILDE = 131, OPENING_SQUARE = 131,
DOUBLE_QUOTE = 132, CLOSING_SQUARE = 132,
CARET = 133,
UNDERLINE = 134,
TILDE = 135,
DOUBLE_QUOTE = 136,
NULL_TREE_LOOKAHEAD = 3 NULL_TREE_LOOKAHEAD = 3
}; };
#ifdef __cplusplus #ifdef __cplusplus
+124 -120
View File
@@ -1,4 +1,4 @@
// $ANTLR 2.7.7 (20100319): pf.g -> PFCfgParserTokenTypes.txt$ // $ANTLR 2.7.7 (20090306): pf.g -> PFCfgParserTokenTypes.txt$
PFCfgParser // output token vocab name PFCfgParser // output token vocab name
NEWLINE=4 NEWLINE=4
LINE_COMMENT=5 LINE_COMMENT=5
@@ -10,122 +10,126 @@ QUEUE="queue"=10
SET="set"=11 SET="set"=11
SCRUB="scrub"=12 SCRUB="scrub"=12
TABLE="table"=13 TABLE="table"=13
NAT="nat"=14 LESS_THAN=14
BINAT="binat"=15 GREATER_THAN=15
RDR="rdr"=16 PERSIST="persist"=16
TIMEOUT="timeout"=17 CONST="const"=17
PASS="pass"=18 COUNTERS=18
BLOCK="block"=19 FILE="file"=19
IN="in"=20 STRING=20
OUT="out"=21 OPENING_BRACE=21
LOG="log"=22 COMMA=22
OPENING_PAREN=23 CLOSING_BRACE=23
COMMA=24 EXLAMATION=24
CLOSING_PAREN=25 SELF="self"=25
ALL="all"=26 IPV4=26
USER="user"=27 SLASH=27
TO="to"=28 INT_CONST=28
QUICK="quick"=29 NAT="nat"=29
ON="on"=30 BINAT="binat"=30
EXLAMATION=31 RDR="rdr"=31
OPENING_BRACE=32 TIMEOUT="timeout"=32
CLOSING_BRACE=33 PASS="pass"=33
INET="inet"=34 BLOCK="block"=34
INET6="inet6"=35 IN="in"=35
PROTO="proto"=36 OUT="out"=36
IP="ip"=37 LOG="log"=37
ICMP="icmp"=38 OPENING_PAREN=38
IGMP="igmp"=39 CLOSING_PAREN=39
TCP="tcp"=40 ALL="all"=40
UDP="udp"=41 USER="user"=41
RDP="rdp"=42 TO="to"=42
RSVP="rsvp"=43 QUICK="quick"=43
GRE="gre"=44 ON="on"=44
ESP="esp"=45 INET="inet"=45
AH="ah"=46 INET6="inet6"=46
EIGRP="eigrp"=47 PROTO="proto"=47
OSPF="ospf"=48 IP="ip"=48
IPIP="ipip"=49 ICMP="icmp"=49
VRRP="vrrp"=50 IGMP="igmp"=50
L2TP="l2tp"=51 TCP="tcp"=51
ISIS="isis"=52 UDP="udp"=52
INT_CONST=53 RDP="rdp"=53
FROM="from"=54 RSVP="rsvp"=54
URPF_FAILED="urpf-failed"=55 GRE="gre"=55
ANY="any"=56 ESP="esp"=56
SELF="self"=57 AH="ah"=57
NO_ROUTE="no-route"=58 EIGRP="eigrp"=58
IPV4=59 OSPF="ospf"=59
IPV6=60 IPIP="ipip"=60
SLASH=61 VRRP="vrrp"=61
LESS_THAN=62 L2TP="l2tp"=62
GREATER_THAN=63 ISIS="isis"=63
ROUTE_TO="route-to"=64 FROM="from"=64
REPLY_TO="reply-to"=65 URPF_FAILED="urpf-failed"=65
FLAGS="flags"=66 ANY="any"=66
ICMP_TYPE="icmp-type"=67 NO_ROUTE="no-route"=67
ICMP_CODE="code"=68 IPV6=68
ICMP6_TYPE="icmp6-type"=69 ROUTE_TO="route-to"=69
TAGGED="tagged"=70 REPLY_TO="reply-to"=70
TAG="tag"=71 FLAGS="flags"=71
NO="no"=72 ICMP_TYPE="icmp-type"=72
KEEP="keep"=73 ICMP_CODE="code"=73
MODULATE="modulate"=74 ICMP6_TYPE="icmp6-type"=74
SYNPROXY="synproxy"=75 TAGGED="tagged"=75
STATE="state"=76 TAG="tag"=76
LABEL="label"=77 NO="no"=77
STRING=78 KEEP="keep"=78
PORT="port"=79 MODULATE="modulate"=79
COLON=80 SYNPROXY="synproxy"=80
EXIT="exit"=81 STATE="state"=81
QUIT="quit"=82 LABEL="label"=82
INTRFACE="interface"=83 PORT="port"=83
ICMP6="icmp6"=84 COLON=84
IGRP="igrp"=85 EXIT="exit"=85
IPSEC="ipsec"=86 QUIT="quit"=86
NOS="nos"=87 INTRFACE="interface"=87
PCP="pcp"=88 ICMP6="icmp6"=88
PIM="pim"=89 IGRP="igrp"=89
PPTP="pptp"=90 IPSEC="ipsec"=90
RIP="rip"=91 NOS="nos"=91
SNP="snp"=92 PCP="pcp"=92
HOST="host"=93 PIM="pim"=93
RANGE="range"=94 PPTP="pptp"=94
LOG_LEVEL_ALERTS="alerts"=95 RIP="rip"=95
LOG_LEVEL_CRITICAL="critical"=96 SNP="snp"=96
LOG_LEVEL_DEBUGGING="debugging"=97 HOST="host"=97
LOG_LEVEL_EMERGENCIES="emergencies"=98 RANGE="range"=98
LOG_LEVEL_ERRORS="errors"=99 LOG_LEVEL_ALERTS="alerts"=99
LOG_LEVEL_INFORMATIONAL="informational"=100 LOG_LEVEL_CRITICAL="critical"=100
LOG_LEVEL_NOTIFICATIONS="notifications"=101 LOG_LEVEL_DEBUGGING="debugging"=101
LOG_LEVEL_WARNINGS="warnings"=102 LOG_LEVEL_EMERGENCIES="emergencies"=102
LOG_LEVEL_DISABLE="disable"=103 LOG_LEVEL_ERRORS="errors"=103
LOG_LEVEL_INACTIVE="inactive"=104 LOG_LEVEL_INFORMATIONAL="informational"=104
TRANSLATE_TO="->"=105 LOG_LEVEL_NOTIFICATIONS="notifications"=105
Whitespace=106 LOG_LEVEL_WARNINGS="warnings"=106
HEX_CONST=107 LOG_LEVEL_DISABLE="disable"=107
NUMBER=108 LOG_LEVEL_INACTIVE="inactive"=108
NEG_INT_CONST=109 TRANSLATE_TO="->"=109
HEX_DIGIT=110 Whitespace=110
DIGIT=111 HEX_CONST=111
NUM_3DIGIT=112 NUMBER=112
NUM_HEX_4DIGIT=113 NEG_INT_CONST=113
NUMBER_ADDRESS_OR_WORD=114 HEX_DIGIT=114
PIPE_CHAR=115 DIGIT=115
NUMBER_SIGN=116 NUM_3DIGIT=116
PERCENT=117 NUM_HEX_4DIGIT=117
AMPERSAND=118 NUMBER_ADDRESS_OR_WORD=118
APOSTROPHE=119 PIPE_CHAR=119
STAR=120 NUMBER_SIGN=120
PLUS=121 PERCENT=121
MINUS=122 AMPERSAND=122
DOT=123 APOSTROPHE=123
SEMICOLON=124 STAR=124
QUESTION=125 PLUS=125
COMMERCIAL_AT=126 MINUS=126
OPENING_SQUARE=127 DOT=127
CLOSING_SQUARE=128 SEMICOLON=128
CARET=129 QUESTION=129
UNDERLINE=130 COMMERCIAL_AT=130
TILDE=131 OPENING_SQUARE=131
DOUBLE_QUOTE=132 CLOSING_SQUARE=132
CARET=133
UNDERLINE=134
TILDE=135
DOUBLE_QUOTE=136
+65 -13
View File
@@ -213,13 +213,62 @@ scrub_command : SCRUB
; ;
//**************************************************************** //****************************************************************
table_command : TABLE table_command :
TABLE
{ {
importer->clear(); importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine()); importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog( }
QString("Warning: import of 'table' commands has not been implemented yet.")); LESS_THAN
consumeUntil(NEWLINE); name:WORD
GREATER_THAN
( PERSIST ) ?
( CONST ) ?
( COUNTERS )?
(
FILE file:STRING
{
importer->newAddressTableObject(name->getText(), file->getText());
}
|
OPENING_BRACE
tableaddr_spec
(
( COMMA )?
tableaddr_spec
)*
CLOSING_BRACE
{
importer->newAddressTableObject(name->getText(), importer->tmp_group);
}
)
;
tableaddr_spec { AddressSpec as; } :
( EXLAMATION { as.neg = true; } )?
(
WORD { as.at = AddressSpec::INTERFACE_NAME; as.address = LT(0)->getText(); }
|
SELF { as.at = AddressSpec::SPECIAL_ADDRESS; as.address = "self"; }
|
IPV4
{
as.at = AddressSpec::HOST_ADDRESS;
as.address = LT(0)->getText();
}
(
SLASH
{
as.at = AddressSpec::NETWORK_ADDRESS;
}
( IPV4 | INT_CONST )
{
as.netmask = LT(0)->getText();
}
)?
)
{
importer->tmp_group.push_back(as);
} }
; ;
@@ -425,9 +474,9 @@ hosts :
ALL ALL
{ {
importer->src_group.push_back( importer->src_group.push_back(
AddressSpec(AddressSpec::ANY, "0.0.0.0", "0.0.0.0")); AddressSpec(AddressSpec::ANY, false, "0.0.0.0", "0.0.0.0"));
importer->dst_group.push_back( importer->dst_group.push_back(
AddressSpec(AddressSpec::ANY, "0.0.0.0", "0.0.0.0")); AddressSpec(AddressSpec::ANY, false, "0.0.0.0", "0.0.0.0"));
} }
| |
( hosts_from )? ( hosts_to )? ( hosts_from )? ( hosts_to )?
@@ -448,7 +497,7 @@ src_hosts_part :
URPF_FAILED URPF_FAILED
{ {
importer->tmp_group.push_back( importer->tmp_group.push_back(
AddressSpec(AddressSpec::SPECIAL_ADDRESS, AddressSpec(AddressSpec::SPECIAL_ADDRESS, false,
"urpf-failed", "")); "urpf-failed", ""));
} }
) )
@@ -472,19 +521,19 @@ common_hosts_part :
ANY ANY
{ {
importer->tmp_group.push_back( importer->tmp_group.push_back(
AddressSpec(AddressSpec::ANY, "0.0.0.0", "0.0.0.0")); AddressSpec(AddressSpec::ANY, false, "0.0.0.0", "0.0.0.0"));
} }
| |
SELF SELF
{ {
importer->tmp_group.push_back( importer->tmp_group.push_back(
AddressSpec(AddressSpec::SPECIAL_ADDRESS, "self", "")); AddressSpec(AddressSpec::SPECIAL_ADDRESS, false, "self", ""));
} }
| |
NO_ROUTE NO_ROUTE
{ {
importer->tmp_group.push_back( importer->tmp_group.push_back(
AddressSpec(AddressSpec::SPECIAL_ADDRESS, "no-route", "")); AddressSpec(AddressSpec::SPECIAL_ADDRESS, false, "no-route", ""));
} }
| |
host host
@@ -514,7 +563,7 @@ host :
if (h) addr = h->getText(); if (h) addr = h->getText();
if (nm) netm = nm->getText(); if (nm) netm = nm->getText();
importer->tmp_group.push_back( importer->tmp_group.push_back(
AddressSpec(AddressSpec::NETWORK_ADDRESS, AddressSpec(AddressSpec::NETWORK_ADDRESS, false,
addr, netm)); addr, netm));
} }
} }
@@ -523,14 +572,14 @@ host :
{ {
// This should be an interface name // This should be an interface name
importer->tmp_group.push_back( importer->tmp_group.push_back(
AddressSpec(AddressSpec::INTERFACE_NAME, AddressSpec(AddressSpec::INTERFACE_NAME, false,
LT(0)->getText(), "")); LT(0)->getText(), ""));
} }
| |
LESS_THAN tn:WORD GREATER_THAN LESS_THAN tn:WORD GREATER_THAN
{ {
importer->tmp_group.push_back( importer->tmp_group.push_back(
AddressSpec(AddressSpec::TABLE, tn->getText(), "")); AddressSpec(AddressSpec::TABLE, false, tn->getText(), ""));
} }
) )
; ;
@@ -923,6 +972,9 @@ tokens
RDR = "rdr"; RDR = "rdr";
BINAT = "binat"; BINAT = "binat";
TABLE = "table"; TABLE = "table";
CONST = "const";
PERSIST = "persist";
FILE = "file";
QUEUE = "queue"; QUEUE = "queue";