From 255f420f6ce1d9561d5ab486cbd5841c8846c1ba Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Mon, 2 Nov 2009 14:44:20 +0000 Subject: [PATCH] test files upgrade and some formatting for code style --- build_num | 2 +- src/pflib/PolicyCompiler_pf.cpp | 2 +- src/pflib/PolicyCompiler_pf_writers.cpp | 53 +- test/ipf/objects-for-regression-tests.fwb | 306 +++++--- test/ipfw/objects-for-regression-tests.fwb | 866 ++++++++++----------- 5 files changed, 668 insertions(+), 561 deletions(-) diff --git a/build_num b/build_num index eecec7bba..7d0a428ba 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 1670 +#define BUILD_NUM 1671 diff --git a/src/pflib/PolicyCompiler_pf.cpp b/src/pflib/PolicyCompiler_pf.cpp index e9665b31b..e435309dc 100644 --- a/src/pflib/PolicyCompiler_pf.cpp +++ b/src/pflib/PolicyCompiler_pf.cpp @@ -351,7 +351,7 @@ bool PolicyCompiler_pf::fillDirection::processNext() * as long as it misses interface - we need to determine direction * again anyway. */ - if (rule->getDirection() == PolicyRule::Undefined) // || rule->getInterfaceId()==-1 ) + if (rule->getDirection() == PolicyRule::Undefined) rule->setDirection( PolicyRule::Both ); /* diff --git a/src/pflib/PolicyCompiler_pf_writers.cpp b/src/pflib/PolicyCompiler_pf_writers.cpp index 38e981eca..d8f39fbbb 100644 --- a/src/pflib/PolicyCompiler_pf_writers.cpp +++ b/src/pflib/PolicyCompiler_pf_writers.cpp @@ -77,7 +77,8 @@ void PolicyCompiler_pf::PrintRule::_printAction(PolicyRule *rule) FWOptions *ruleopt =rule->getOptionsObject(); Service *srv=compiler->getFirstSrv(rule); assert(srv); - switch (rule->getAction()) { + switch (rule->getAction()) + { case PolicyRule::Accept: case PolicyRule::Tag: case PolicyRule::Classify: @@ -92,18 +93,22 @@ void PolicyCompiler_pf::PrintRule::_printAction(PolicyRule *rule) case PolicyRule::Reject: if (TCPService::isA(srv)) compiler->output << "block return-rst "; - else { + else + { string aor=ruleopt->getStr("action_on_reject"); string code; - if ( aor.find("ICMP")!=string::npos ) { + if ( aor.find("ICMP")!=string::npos ) + { code="return-icmp "; - if (aor.find("unreachable")!=string::npos ) { + if (aor.find("unreachable")!=string::npos ) + { if (aor.find("net")!=string::npos) code=code+"( 0 ) "; if (aor.find("host")!=string::npos) code=code+"( 1 ) "; if (aor.find("protocol")!=string::npos) code=code+"( 2 ) "; if (aor.find("port")!=string::npos) code=code+"( 3 ) "; } - if (aor.find("prohibited")!=string::npos ) { + if (aor.find("prohibited")!=string::npos ) + { if (aor.find("net")!=string::npos) code=code+"( 9 ) "; if (aor.find("host")!=string::npos) code=code+"( 10 ) "; } @@ -397,14 +402,17 @@ string PolicyCompiler_pf::PrintRule::_printLogPrefix(PolicyRule *rule, * %C - chain name */ string::size_type n; - if (rule && (n=s.find("%N"))!=string::npos ) { + if (rule && (n=s.find("%N"))!=string::npos ) + { std::ostringstream s1; s1 << rule->getPosition(); s.replace(n,2,s1.str()); } - if (rule && (n=s.find("%A"))!=string::npos ) { + if (rule && (n=s.find("%A"))!=string::npos ) + { std::ostringstream s1; - switch (rule->getAction()) { + switch (rule->getAction()) + { case PolicyRule::Accept: s1 << "ACCEPT"; break; case PolicyRule::Deny: s1 << "DROP"; break; case PolicyRule::Reject: s1 << "REJECT"; break; @@ -413,7 +421,8 @@ string PolicyCompiler_pf::PrintRule::_printLogPrefix(PolicyRule *rule, } s.replace(n,2,s1.str()); } - if (rule && (n=s.find("%I"))!=string::npos ) { + if (rule && (n=s.find("%I"))!=string::npos ) + { std::ostringstream s1; string rule_iface = rule->getInterfaceStr(); if (rule_iface!="") @@ -423,17 +432,17 @@ string PolicyCompiler_pf::PrintRule::_printLogPrefix(PolicyRule *rule, } else s.replace(n,2,"global"); } - if (rule && (n=s.find("%C"))!=string::npos ) { + if (rule && (n=s.find("%C"))!=string::npos ) + { s.replace(n,2,""); // there is no chain in PF and friends } return "\"" + s + "\" "; } - void PolicyCompiler_pf::PrintRule::_printInterface(PolicyRule *rule) { - string iface_name = rule->getInterfaceStr(); + string iface_name = rule->getInterfaceStr(); if (iface_name!="") compiler->output << "on " << iface_name << " "; } @@ -481,8 +490,8 @@ string PolicyCompiler_pf::PrintRule::_printPort(int rs,int re,bool neg) if (rs<0) rs=0; if (re<0) re=0; - if (!neg) { - + if (!neg) + { if (rs>0 || re>0) { if (rs>re && re==0) re=rs; @@ -492,7 +501,8 @@ string PolicyCompiler_pf::PrintRule::_printPort(int rs,int re,bool neg) if (rs==0 && re!=0) str << "<= " << re; else if (rs!=0 && re==65535) str << ">= " << rs; - else { + else + { /* * port range. Operator '><' defines range in a such way that boundaries * are not included. Since we assume it is inclusive, let's move boundaries @@ -502,15 +512,17 @@ string PolicyCompiler_pf::PrintRule::_printPort(int rs,int re,bool neg) str << rs << " >< " << re; } } - } else { - - if (rs>0 || re>0) { + } else + { + if (rs>0 || re>0) + { if (rs==re) str << "!= " << rs; else if (rs==0 && re!=0) str << "> " << re; else if (rs!=0 && re==65535) str << "< " << rs; - else { + else + { str << rs << " <> " << re; } } @@ -887,7 +899,8 @@ bool PolicyCompiler_pf::PrintRule::processNext() string comm = rule->getComment(); string::size_type c1,c2; c1=0; - while ( (c2=comm.find('\n',c1))!=string::npos ) { + while ( (c2=comm.find('\n',c1))!=string::npos ) + { compiler->output << "# " << comm.substr(c1,c2-c1) << endl; c1=c2+1; } diff --git a/test/ipf/objects-for-regression-tests.fwb b/test/ipf/objects-for-regression-tests.fwb index fbb3e0a24..872e64903 100644 --- a/test/ipf/objects-for-regression-tests.fwb +++ b/test/ipf/objects-for-regression-tests.fwb @@ -1,6 +1,6 @@ - + @@ -116,6 +116,7 @@ + @@ -124,6 +125,7 @@ + @@ -141,6 +143,7 @@ + @@ -157,6 +160,7 @@ + @@ -174,6 +178,7 @@ + @@ -191,6 +196,7 @@ + @@ -204,6 +210,7 @@ + @@ -213,6 +220,7 @@ + @@ -227,6 +235,7 @@ + @@ -243,6 +252,7 @@ + @@ -256,6 +266,7 @@ + @@ -269,6 +280,7 @@ + @@ -277,6 +289,7 @@ + @@ -290,6 +303,7 @@ + @@ -298,6 +312,7 @@ + @@ -315,6 +330,7 @@ + @@ -332,6 +348,7 @@ + @@ -349,6 +366,7 @@ + @@ -366,6 +384,7 @@ + @@ -383,6 +402,7 @@ + @@ -400,6 +420,7 @@ + @@ -417,6 +438,7 @@ + @@ -425,6 +447,7 @@ + @@ -438,6 +461,7 @@ + @@ -452,6 +476,7 @@ + @@ -468,6 +493,7 @@ + @@ -481,6 +507,7 @@ + @@ -494,6 +521,7 @@ + @@ -507,6 +535,7 @@ + @@ -520,6 +549,7 @@ + @@ -533,6 +563,7 @@ + @@ -546,6 +577,7 @@ + @@ -559,6 +591,7 @@ + @@ -679,7 +712,7 @@ - + @@ -700,7 +733,7 @@ - + @@ -721,7 +754,7 @@ - + @@ -742,7 +775,7 @@ - + @@ -764,7 +797,7 @@ - + @@ -1275,12 +1308,15 @@ + + + @@ -1373,7 +1409,7 @@ - + @@ -1394,7 +1430,7 @@ - + @@ -1415,7 +1451,7 @@ - + @@ -1436,7 +1472,7 @@ - + @@ -1457,7 +1493,7 @@ - + @@ -1479,7 +1515,7 @@ - + @@ -1500,7 +1536,7 @@ - + @@ -1521,7 +1557,7 @@ - + @@ -1542,7 +1578,7 @@ - + @@ -1563,7 +1599,7 @@ - + @@ -1584,7 +1620,7 @@ - + @@ -1605,7 +1641,7 @@ - + @@ -1626,7 +1662,7 @@ - + @@ -2010,18 +2046,23 @@ + + + + + @@ -2112,7 +2153,7 @@ - + @@ -2135,7 +2176,7 @@ - + @@ -2159,7 +2200,7 @@ - + @@ -2181,7 +2222,7 @@ - + @@ -2202,7 +2243,7 @@ - + @@ -2223,7 +2264,7 @@ - + @@ -2245,7 +2286,7 @@ - + @@ -2266,7 +2307,7 @@ - + @@ -2288,7 +2329,7 @@ - + @@ -2311,7 +2352,7 @@ - + @@ -2332,7 +2373,7 @@ - + @@ -2353,7 +2394,7 @@ - + @@ -2374,7 +2415,7 @@ - + @@ -2395,7 +2436,7 @@ - + @@ -2418,7 +2459,7 @@ - + @@ -2439,7 +2480,7 @@ - + @@ -2460,7 +2501,7 @@ - + @@ -2481,7 +2522,7 @@ - + @@ -2502,7 +2543,7 @@ - + @@ -2523,7 +2564,7 @@ - + @@ -2544,7 +2585,7 @@ - + @@ -2566,7 +2607,7 @@ - + @@ -2587,7 +2628,7 @@ - + @@ -2608,7 +2649,7 @@ - + @@ -2867,18 +2908,23 @@ + + + + + @@ -2956,7 +3002,7 @@ - + @@ -2979,7 +3025,7 @@ - + @@ -3002,7 +3048,7 @@ - + @@ -3025,7 +3071,7 @@ - + @@ -3048,7 +3094,7 @@ - + @@ -3071,7 +3117,7 @@ - + @@ -3092,7 +3138,7 @@ - + @@ -3114,7 +3160,7 @@ - + @@ -3136,7 +3182,7 @@ - + @@ -3158,7 +3204,7 @@ - + @@ -3179,7 +3225,7 @@ - + @@ -3423,18 +3469,23 @@ + + + + + @@ -3581,18 +3632,23 @@ + + + + + @@ -3805,9 +3861,11 @@ + + @@ -3872,7 +3930,7 @@ - + @@ -3893,7 +3951,7 @@ - + @@ -3914,7 +3972,7 @@ - + @@ -3935,7 +3993,7 @@ - + @@ -3956,7 +4014,7 @@ - + @@ -3977,7 +4035,7 @@ - + @@ -3998,7 +4056,7 @@ - + @@ -4019,7 +4077,7 @@ - + @@ -4040,7 +4098,7 @@ - + @@ -4159,15 +4217,20 @@ + + + + + + - @@ -4204,7 +4267,7 @@ - + @@ -4225,7 +4288,7 @@ - + @@ -4246,7 +4309,7 @@ - + @@ -4267,7 +4330,7 @@ - + @@ -4288,7 +4351,7 @@ - + @@ -4309,7 +4372,7 @@ - + @@ -4330,7 +4393,7 @@ - + @@ -4351,7 +4414,7 @@ - + @@ -4372,7 +4435,7 @@ - + @@ -4393,7 +4456,7 @@ - + @@ -4574,12 +4637,15 @@ + + + @@ -4821,15 +4887,19 @@ + + + + @@ -4872,7 +4942,7 @@ - + @@ -4951,14 +5021,22 @@ - - - + + + + + + + + + + + @@ -5003,7 +5081,7 @@ - + @@ -5024,7 +5102,7 @@ - + @@ -5045,7 +5123,7 @@ - + @@ -5066,7 +5144,7 @@ - + @@ -5087,7 +5165,7 @@ - + @@ -5108,7 +5186,7 @@ - + @@ -5129,7 +5207,7 @@ - + @@ -5150,7 +5228,7 @@ - + @@ -5171,7 +5249,7 @@ - + @@ -5308,15 +5386,20 @@ + + + + + + - @@ -5367,7 +5450,7 @@ - + @@ -5388,7 +5471,7 @@ - + @@ -5409,7 +5492,7 @@ - + @@ -5431,7 +5514,7 @@ - + @@ -5682,12 +5765,16 @@ - + + + + + @@ -5781,7 +5868,7 @@ - + @@ -5802,7 +5889,7 @@ - + @@ -6022,12 +6109,16 @@ - + + + + + @@ -6121,7 +6212,7 @@ - + @@ -6142,7 +6233,7 @@ - + @@ -6163,7 +6254,7 @@ - + @@ -6184,7 +6275,7 @@ - + @@ -6205,7 +6296,7 @@ - + @@ -6226,7 +6317,7 @@ - + @@ -6247,7 +6338,7 @@ - + @@ -6268,7 +6359,7 @@ - + @@ -6289,7 +6380,7 @@ - + @@ -6310,7 +6401,7 @@ - + @@ -6431,12 +6522,15 @@ + + + diff --git a/test/ipfw/objects-for-regression-tests.fwb b/test/ipfw/objects-for-regression-tests.fwb index f59e37f6c..3188842cb 100644 --- a/test/ipfw/objects-for-regression-tests.fwb +++ b/test/ipfw/objects-for-regression-tests.fwb @@ -1,6 +1,6 @@ - + @@ -138,9 +138,9 @@ - - - + @@ -156,9 +156,9 @@ - - - + @@ -173,9 +173,9 @@ - - - + @@ -191,9 +191,9 @@ - - - + @@ -248,9 +248,9 @@ - - - + @@ -325,9 +325,9 @@ - - - + @@ -343,9 +343,9 @@ - - - + @@ -361,9 +361,9 @@ - - - + @@ -379,9 +379,9 @@ - - - + @@ -397,9 +397,9 @@ - - - + @@ -415,9 +415,9 @@ - - - + @@ -433,9 +433,9 @@ - - - + @@ -489,9 +489,9 @@ - - - + @@ -600,26 +600,26 @@ - - - - - - + + + + + + -m ip_conntrack_talk -m ip_nat_talk - - - + + + - - - + + + established - - - - + + + + @@ -627,7 +627,7 @@ - + @@ -648,7 +648,7 @@ - + @@ -669,7 +669,7 @@ - + @@ -690,7 +690,7 @@ - + @@ -712,7 +712,7 @@ - + @@ -844,10 +844,10 @@ - + - - + @@ -870,7 +870,7 @@ - + @@ -913,10 +913,10 @@ - - + - + @@ -936,10 +936,10 @@ - - + - + @@ -962,10 +962,10 @@ - - + - + @@ -985,10 +985,10 @@ - - + - + @@ -1009,10 +1009,10 @@ - - + - + @@ -1033,10 +1033,10 @@ - - + - + @@ -1057,10 +1057,10 @@ - - + - + @@ -1081,10 +1081,10 @@ - - + - + @@ -1108,10 +1108,10 @@ - - + - + @@ -1150,10 +1150,10 @@ - - + - + @@ -1173,11 +1173,11 @@ - - + - - + @@ -1200,37 +1200,37 @@ - + - - + - + - - + - - - - + - - + - - - + - - + @@ -1250,7 +1250,7 @@ - + @@ -1263,23 +1263,23 @@ - + - - - + - - - - + - + @@ -1300,7 +1300,7 @@ - + @@ -1321,7 +1321,7 @@ - + @@ -1342,7 +1342,7 @@ - + @@ -1363,7 +1363,7 @@ - + @@ -1384,7 +1384,7 @@ - + @@ -1405,7 +1405,7 @@ - + @@ -1426,7 +1426,7 @@ - + @@ -1447,7 +1447,7 @@ - + @@ -1468,7 +1468,7 @@ - + @@ -1489,7 +1489,7 @@ - + @@ -1510,7 +1510,7 @@ - + @@ -1699,10 +1699,10 @@ - + - + @@ -1942,29 +1942,29 @@ - - + - - - - + - - + - - - + - - + @@ -1981,7 +1981,7 @@ - + @@ -1991,17 +1991,17 @@ - - - - + - + @@ -2021,10 +2021,10 @@ - + - + @@ -2045,10 +2045,10 @@ - + - + @@ -2070,7 +2070,7 @@ - + @@ -2091,7 +2091,7 @@ - + @@ -2112,7 +2112,7 @@ - + @@ -2134,7 +2134,7 @@ - + @@ -2156,7 +2156,7 @@ - + @@ -2179,7 +2179,7 @@ - + @@ -2200,7 +2200,7 @@ - + @@ -2221,7 +2221,7 @@ - + @@ -2242,7 +2242,7 @@ - + @@ -2263,7 +2263,7 @@ - + @@ -2283,10 +2283,10 @@ - + - + @@ -2307,7 +2307,7 @@ - + @@ -2328,7 +2328,7 @@ - + @@ -2349,7 +2349,7 @@ - + @@ -2370,7 +2370,7 @@ - + @@ -2391,7 +2391,7 @@ - + @@ -2412,7 +2412,7 @@ - + @@ -2509,8 +2509,8 @@ - - + @@ -2531,8 +2531,8 @@ - - + @@ -2555,7 +2555,7 @@ - + @@ -2579,7 +2579,7 @@ - + @@ -2602,10 +2602,10 @@ - + - + @@ -2666,7 +2666,7 @@ - + @@ -2722,7 +2722,7 @@ - + @@ -2759,26 +2759,26 @@ - - + - - - - + - - - + - - + @@ -2814,17 +2814,17 @@ - - - - + - + @@ -2844,10 +2844,10 @@ - + - + @@ -2867,10 +2867,10 @@ - + - + @@ -2890,10 +2890,10 @@ - + - + @@ -2913,10 +2913,10 @@ - + - + @@ -2936,10 +2936,10 @@ - + - + @@ -2960,7 +2960,7 @@ - + @@ -2982,7 +2982,7 @@ - + @@ -3004,7 +3004,7 @@ - + @@ -3115,7 +3115,7 @@ - + @@ -3136,7 +3136,7 @@ - + @@ -3158,7 +3158,7 @@ - + @@ -3181,7 +3181,7 @@ - + @@ -3202,7 +3202,7 @@ - + @@ -3241,7 +3241,7 @@ - + @@ -3278,8 +3278,8 @@ - - + @@ -3288,16 +3288,16 @@ - - + - - - + - - + @@ -3314,7 +3314,7 @@ - + @@ -3324,10 +3324,10 @@ - - - - + @@ -3425,25 +3425,25 @@ - - + - - - + - - - + - - + @@ -3460,7 +3460,7 @@ - + @@ -3470,10 +3470,10 @@ - - - - + @@ -3643,24 +3643,24 @@ - - + - - - + - - - + - - + @@ -3675,9 +3675,9 @@ - + - + @@ -3686,17 +3686,17 @@ - - - - + - + @@ -3717,7 +3717,7 @@ - + @@ -3738,7 +3738,7 @@ - + @@ -3759,7 +3759,7 @@ - + @@ -3780,7 +3780,7 @@ - + @@ -3801,7 +3801,7 @@ - + @@ -3822,7 +3822,7 @@ - + @@ -3843,7 +3843,7 @@ - + @@ -3864,7 +3864,7 @@ - + @@ -3998,20 +3998,20 @@ - - + - - - + - - + @@ -4019,14 +4019,14 @@ - - - + - + @@ -4047,7 +4047,7 @@ - + @@ -4068,7 +4068,7 @@ - + @@ -4089,7 +4089,7 @@ - + @@ -4110,7 +4110,7 @@ - + @@ -4131,7 +4131,7 @@ - + @@ -4152,7 +4152,7 @@ - + @@ -4173,7 +4173,7 @@ - + @@ -4194,7 +4194,7 @@ - + @@ -4368,7 +4368,7 @@ - + @@ -4410,20 +4410,20 @@ - - + - - - + - - + @@ -4433,9 +4433,9 @@ - - - + @@ -4578,20 +4578,20 @@ - - + - - - + - - + @@ -4603,18 +4603,18 @@ - - + - - - + - + @@ -4635,7 +4635,7 @@ - + @@ -4656,7 +4656,7 @@ - + @@ -4678,7 +4678,7 @@ - + @@ -4949,50 +4949,50 @@ - - - + - - + - - + - - - + - - - - - - - - - - - - - - - - + - - - - + @@ -5006,20 +5006,20 @@ - + - + - + - - - - - + @@ -5032,7 +5032,7 @@ - + @@ -5053,7 +5053,7 @@ - + @@ -5074,7 +5074,7 @@ - + @@ -5095,7 +5095,7 @@ - + @@ -5116,7 +5116,7 @@ - + @@ -5137,7 +5137,7 @@ - + @@ -5158,7 +5158,7 @@ - + @@ -5179,7 +5179,7 @@ - + @@ -5200,7 +5200,7 @@ - + @@ -5240,29 +5240,29 @@ - - - - - + - - + - + - - + - + - + @@ -5282,27 +5282,27 @@ - - + - - + - - + - + - - + - + @@ -5323,15 +5323,15 @@ - - - + - + - + @@ -5351,16 +5351,16 @@ - - - + - + - + @@ -5380,17 +5380,17 @@ - - - + - + - + @@ -5410,14 +5410,14 @@ - - + - + - + @@ -5458,42 +5458,42 @@ - + - - + - - + - + - - - + - - + - + - + - - - - - + @@ -5599,9 +5599,9 @@ - + established - + established -m state --state ESTABLISHED,RELATED