From 41d67905924b5f9f0896d724acdf0a316349a387 Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Mon, 19 May 2008 23:06:34 +0000 Subject: [PATCH] compiler for ipfw works with getAddressPtr --- src/pflib/PolicyCompiler_ipfw_writers.cpp | 41 ++++++++------ test/iosacl/objects.fwb | 26 +++------ test/ipfw/objects-for-regression-tests.fwb | 66 +++++++--------------- test/ipfw/run.all | 2 + test/pix/objects.fwb | 41 +++++--------- 5 files changed, 70 insertions(+), 106 deletions(-) diff --git a/src/pflib/PolicyCompiler_ipfw_writers.cpp b/src/pflib/PolicyCompiler_ipfw_writers.cpp index cc1f3b591..91747126d 100644 --- a/src/pflib/PolicyCompiler_ipfw_writers.cpp +++ b/src/pflib/PolicyCompiler_ipfw_writers.cpp @@ -291,26 +291,33 @@ void PolicyCompiler_ipfw::PrintRule::_printAddr(Address *o,bool neg) } const InetAddr *addr = o->getAddressPtr(); - InetAddr mask = *(o->getNetmaskPtr()); - - if (Interface::cast(o)!=NULL) - mask = InetAddr(InetAddr::getAllOnes()); - - if (o->dimension()==1) - mask = InetAddr(InetAddr::getAllOnes()); - - if (addr->isAny() && mask.isAny()) + if (Interface::cast(o)!=NULL && addr==NULL) { - compiler->output << "any "; - } else + compiler->output << "me "; + } + if (addr) { - if (neg) compiler->output << "not "; - compiler->output << addr->toString(); - if (!mask.isHostMask()) + InetAddr mask = *(o->getNetmaskPtr()); + + if (Interface::cast(o)!=NULL) + mask = InetAddr(InetAddr::getAllOnes()); + + if (o->dimension()==1) + mask = InetAddr(InetAddr::getAllOnes()); + + if (addr->isAny() && mask.isAny()) { - compiler->output << "/" << mask.getLength(); - } - compiler->output << " "; + compiler->output << "any "; + } else + { + if (neg) compiler->output << "not "; + compiler->output << addr->toString(); + if (!mask.isHostMask()) + { + compiler->output << "/" << mask.getLength(); + } + compiler->output << " "; + } } } diff --git a/test/iosacl/objects.fwb b/test/iosacl/objects.fwb index 4091cc73f..a48f8f502 100644 --- a/test/iosacl/objects.fwb +++ b/test/iosacl/objects.fwb @@ -1,6 +1,6 @@ - + @@ -86,15 +86,10 @@ - - - - + - - - - + + @@ -1880,8 +1875,7 @@ - - + @@ -1889,21 +1883,18 @@ - - + - - + - - + @@ -1913,6 +1904,7 @@ + diff --git a/test/ipfw/objects-for-regression-tests.fwb b/test/ipfw/objects-for-regression-tests.fwb index 46bba7fc3..0d6a9a5c5 100644 --- a/test/ipfw/objects-for-regression-tests.fwb +++ b/test/ipfw/objects-for-regression-tests.fwb @@ -1,6 +1,6 @@ - + @@ -17,13 +17,8 @@ - - - - - - - + + @@ -448,8 +443,7 @@ - - + @@ -502,15 +496,12 @@ - - + - - + - - + @@ -520,11 +511,9 @@ - - + - - + @@ -540,6 +529,7 @@ + @@ -4876,14 +4866,9 @@ - - - - - - - - + + + @@ -4912,13 +4897,8 @@ - - - - - - - + + @@ -4930,8 +4910,7 @@ - - + @@ -4971,15 +4950,13 @@ - - + - - + @@ -4990,15 +4967,13 @@ - - + - - + @@ -5009,6 +4984,7 @@ + diff --git a/test/ipfw/run.all b/test/ipfw/run.all index bdd3d6bf5..b12f77a8b 100755 --- a/test/ipfw/run.all +++ b/test/ipfw/run.all @@ -8,6 +8,8 @@ while (<>) { while ( $str=~ /]+name="([^"]*).*$"/; $fw=$1; + printf "\n"; + printf "echo '********* $fw'\n"; printf "fwb_ipfw -v -f $XMLFILE $fw\n"; $str=~ s/^.*]+name="$fw"[^>]+>//; } diff --git a/test/pix/objects.fwb b/test/pix/objects.fwb index 13e6d1e56..4e6ff826e 100644 --- a/test/pix/objects.fwb +++ b/test/pix/objects.fwb @@ -1,6 +1,6 @@ - + @@ -742,8 +742,7 @@ - - + @@ -810,17 +809,14 @@ - - + - - + - - + @@ -832,15 +828,14 @@ - - - + -m ip_conntrack_talk -m ip_nat_talk + @@ -12929,13 +12924,8 @@ no sysopt nodnsalias outbound - - - - - - - + + @@ -12945,8 +12935,7 @@ no sysopt nodnsalias outbound - - + @@ -12984,20 +12973,17 @@ no sysopt nodnsalias outbound - - + - - + - - + @@ -13009,6 +12995,7 @@ no sysopt nodnsalias outbound +