Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-28 Thread Brian J. Murrell
On Thu, 2007-12-20 at 15:03 -0800, Tom Eastep wrote: > Hence, the proposed function to compare two addresses: > > addr_comp() { > test $(bc < $1 > $2 > EOF > ) -eq 1 > > } > > That will sure make your parents proud. To compare two numbers, you only > have to fork(), pipe(), exec(), ... > >

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 13:12 -0800, Tom Eastep wrote: >> Please have a look at ip_range() and ip_range_explicit() in lib.base and try >> to envision recoding them to use that technique. > > I will admit to not having looked all of the use cases. > >> Maybe you want to spe

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Andrew Suffield
On Thu, Dec 20, 2007 at 03:03:24PM -0800, Tom Eastep wrote: > Hence, the proposed function to compare two addresses: > > addr_comp() { > test $(bc < $1 > $2 > EOF > ) -eq 1 > > } > > That will sure make your parents proud. To compare two numbers, you only > have to fork(), pipe(), exec(), ..

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Andrew Suffield wrote: > > Hrngh. You're right, busybox dc is not a correct implementation of > posix dc. I think that means you're screwed. To hell with it, and > depend on bc for arithmetic? Hence, the proposed function to compare two addresses: addr_comp() { test $(bc < $2 EOF ) -eq 1 }

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Andrew Suffield
On Thu, Dec 20, 2007 at 01:32:43PM -0800, Tom Eastep wrote: > Andrew Suffield wrote: > > On Thu, Dec 20, 2007 at 12:58:43PM -0800, Tom Eastep wrote: > >> Yes -- but that function can blow up the first time that it tries to touch > >> its arguments in a numeric context. So it would have to break the

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Andrew Suffield wrote: > On Thu, Dec 20, 2007 at 12:58:43PM -0800, Tom Eastep wrote: >> Yes -- but that function can blow up the first time that it tries to touch >> its arguments in a numeric context. So it would have to break them into two >> smaller integers without using arithmetic and without

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Andrew Suffield
On Thu, Dec 20, 2007 at 12:58:43PM -0800, Tom Eastep wrote: > Yes -- but that function can blow up the first time that it tries to touch > its arguments in a numeric context. So it would have to break them into two > smaller integers without using arithmetic and without the benefit of > ${foo:a:b}

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 13:12 -0800, Tom Eastep wrote: > > Please have a look at ip_range() and ip_range_explicit() in lib.base and try > to envision recoding them to use that technique. I will admit to not having looked all of the use cases. > Maybe you want to spend > your Christmas vacation tha

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 12:58 -0800, Tom Eastep wrote: >> Yes -- but that function can blow up the first time that it tries to touch >> its arguments in a numeric context. So it would have to break them into two >> smaller integers without using arithmetic and without the be

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 12:58 -0800, Tom Eastep wrote: > > Yes -- but that function can blow up the first time that it tries to touch > its arguments in a numeric context. So it would have to break them into two > smaller integers without using arithmetic and without the benefit of > ${foo:a:b} (the

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 12:31 -0800, Tom Eastep wrote: >> Ok -- you can probably make the obvious change to in_network(), replacing >> the '-eq' with '='. > > Ahhh. The subtle difference between -gt and =. :-) > >> That will take care of the immediate problem but, as yo

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 12:31 -0800, Tom Eastep wrote: > > Ok -- you can probably make the obvious change to in_network(), replacing > the '-eq' with '='. Ahhh. The subtle difference between -gt and =. :-) > That will take care of the immediate problem but, as you point out, there > are other c

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 12:22 -0800, Tom Eastep wrote: >> What does "[ $foo = 0 ]" do? > > # [ $foo = 0 ] > > and just to evidence that we are still in busybox's /bin/sh and that > $foo has our testing value in it: > > # echo $foo > 2953838592 > # eval [ $foo -eq 0 ] > sh

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 12:22 -0800, Tom Eastep wrote: > > What does "[ $foo = 0 ]" do? # [ $foo = 0 ] and just to evidence that we are still in busybox's /bin/sh and that $foo has our testing value in it: # echo $foo 2953838592 # eval [ $foo -eq 0 ] sh: 2953838592: out of range b. signature.

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 11:35 -0800, Tom Eastep wrote: >> I must be missing something -- you specifically tested that number in a "[ >> -eq ]". So what does this do? > > Aw crap. No you are not missing something I am. I did all of my > previous tests in a bash. I forgot

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 11:44 -0800, Tom Eastep wrote: > Then I have no clue how work around the bug. Could the concept of doing: a=decodeaddr A b=decodeaddr B test a -gt b be abstracted into a function in the following manner: compare_addrs A B and then let compare_addrs() handle the ugliness?

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 11:35 -0800, Tom Eastep wrote: >> I must be missing something -- you specifically tested that number in a "[ >> -eq ]". So what does this do? > > Aw crap. No you are not missing something I am. I did all of my > previous tests in a bash. I forgot

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 11:35 -0800, Tom Eastep wrote: > > I must be missing something -- you specifically tested that number in a "[ > -eq ]". So what does this do? Aw crap. No you are not missing something I am. I did all of my previous tests in a bash. I forgot to specifically change my inte

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 11:11 -0800, Tom Eastep wrote: >> The attached patch should work around the problem. > >> -test $(( $(decodeaddr $1) & $netmask)) -eq $(( $(decodeaddr ${2%/*}) & >> $netmask )) >> +[ $(( $(decodeaddr $1) & $netmask)) -eq $(( $(decodeaddr ${

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 11:11 -0800, Tom Eastep wrote: > > The attached patch should work around the problem. > -test $(( $(decodeaddr $1) & $netmask)) -eq $(( $(decodeaddr ${2%/*}) & > $netmask )) > +[ $(( $(decodeaddr $1) & $netmask)) -eq $(( $(decodeaddr ${2%/*}) & > $netmask )) ] >

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 10:50 -0800, Tom Eastep wrote: >> Ok -- one more test. What does this do? >> >> [ 16777216 -eq 2953838592 ] || echo foo > > # [ 16777216 -eq 2953838592 ] || echo foo > foo > Ok -- the bug appears to be in BusyBox 'test' then. The attached patch sh

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 10:50 -0800, Tom Eastep wrote: > Ok -- one more test. What does this do? > > [ 16777216 -eq 2953838592 ] || echo foo # [ 16777216 -eq 2953838592 ] || echo foo foo FWIW, BTW, I did file a bug with OpenWRT about this. Not sure it will go anywhere though. b. signature.asc

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 10:34 -0800, Tom Eastep wrote: >> Brian J. Murrell wrote: >>> On Thu, 2007-12-20 at 10:02 -0800, Tom Eastep wrote: Brian: If you modify /usr/share/shorewall-lite/lib.base using the attached patch, what does "shorewall-lite ipdecimal 176.16.0

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 10:34 -0800, Tom Eastep wrote: > Brian J. Murrell wrote: > > On Thu, 2007-12-20 at 10:02 -0800, Tom Eastep wrote: > >> Brian: If you modify /usr/share/shorewall-lite/lib.base using the attached > >> patch, what does "shorewall-lite ipdecimal 176.16.0.0" print? > > > > Same as

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Brian J. Murrell wrote: > On Thu, 2007-12-20 at 10:02 -0800, Tom Eastep wrote: >> Brian: If you modify /usr/share/shorewall-lite/lib.base using the attached >> patch, what does "shorewall-lite ipdecimal 176.16.0.0" print? > > Same as without the patch: > > before_patch:# shorewall-lite ipdecimal

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Brian J. Murrell
On Thu, 2007-12-20 at 10:02 -0800, Tom Eastep wrote: > Brian: If you modify /usr/share/shorewall-lite/lib.base using the attached > patch, what does "shorewall-lite ipdecimal 176.16.0.0" print? Same as without the patch: before_patch:# shorewall-lite ipdecimal 176.16.0.0 2953838592 after_patch

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-20 Thread Tom Eastep
Andrew Suffield wrote: > On Wed, Dec 19, 2007 at 03:54:55PM -0800, Tom Eastep wrote: >> Tom Eastep wrote: >> >>> 172.16.0.0 decodes to 0x10. Does BusyBox on that architecture only >>> support 20-bit arithmatic? >> What spelling -- and I hold an advanced degree in Mathematics :-( > > And perhap

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Andrew Suffield
On Wed, Dec 19, 2007 at 03:54:55PM -0800, Tom Eastep wrote: > Tom Eastep wrote: > > > 172.16.0.0 decodes to 0x10. Does BusyBox on that architecture only > > support 20-bit arithmatic? > > What spelling -- and I hold an advanced degree in Mathematics :-( And perhaps more significantly, it dec

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Tom Eastep
Tom Eastep wrote: > Brian J. Murrell wrote: >> On Wed, 2007-12-19 at 15:02 -0800, Tom Eastep wrote: >>> I don't have time for puzzles. What input did you give to Shorewall to >>> produce whatever problem you are trying to report? >> Sorry. I should have reproduced more of the subject into the mess

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Tom Eastep
Tom Eastep wrote: > 172.16.0.0 decodes to 0x10. Does BusyBox on that architecture only > support 20-bit arithmatic? What spelling -- and I hold an advanced degree in Mathematics :-( arithmetic arithmetic arithmetic ... -Tom -- Tom Eastep\ Nothing is foolproof to a sufficiently talented

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Tom Eastep
Brian J. Murrell wrote: > On Wed, 2007-12-19 at 15:02 -0800, Tom Eastep wrote: >> I don't have time for puzzles. What input did you give to Shorewall to >> produce whatever problem you are trying to report? > > Sorry. I should have reproduced more of the subject into the message. > The results wh

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Brian J. Murrell
On Wed, 2007-12-19 at 15:02 -0800, Tom Eastep wrote: > I don't have time for puzzles. What input did you give to Shorewall to > produce whatever problem you are trying to report? Sorry. I should have reproduced more of the subject into the message. The results which can be too large for busybox's

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Tom Eastep
Brian J. Murrell wrote: > On Wed, 2007-12-19 at 15:19 -0800, Tom Eastep wrote: >> Furthermore: >> >> BusyBox v1.1.3 (Debian 1:1.1.3-5ubuntu7) Built-in shell (ash) >> Enter 'help' for a list of built-in commands. >> >> ~ $ test 1107296256 -eq 2953838592 >> ~ $ > > Interesting. It would seem my bus

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Brian J. Murrell
On Wed, 2007-12-19 at 15:19 -0800, Tom Eastep wrote: > > Furthermore: > > BusyBox v1.1.3 (Debian 1:1.1.3-5ubuntu7) Built-in shell (ash) > Enter 'help' for a list of built-in commands. > > ~ $ test 1107296256 -eq 2953838592 > ~ $ Interesting. It would seem my busybox is newer than yours. It's

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Tom Eastep
Tom Eastep wrote: > Brian J. Murrell wrote: >> Bash does not seem to mind: >> >> $ test 1107296256 -eq 2953838592 >> >> however busybox's sh does: >> >> # /bin/sh >> >> >> BusyBox v1.8.2 (2007-12-11 14:13:35 EST) built-in shell (ash) >> Enter 'help' for a list of built-in commands. >> >> # test 110

Re: [Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Tom Eastep
Brian J. Murrell wrote: > Bash does not seem to mind: > > $ test 1107296256 -eq 2953838592 > > however busybox's sh does: > > # /bin/sh > > > BusyBox v1.8.2 (2007-12-11 14:13:35 EST) built-in shell (ash) > Enter 'help' for a list of built-in commands. > > # test 1107296256 -eq 2953838592 > sh

[Shorewall-users] result of decodeaddr gives "out of range" on busybox

2007-12-19 Thread Brian J. Murrell
Bash does not seem to mind: $ test 1107296256 -eq 2953838592 however busybox's sh does: # /bin/sh BusyBox v1.8.2 (2007-12-11 14:13:35 EST) built-in shell (ash) Enter 'help' for a list of built-in commands. # test 1107296256 -eq 2953838592 sh: 2953838592: out of range Not sure how much we car