diff --git a/iputil.rkt b/iputil.rkt index 02664df..ecc9474 100644 --- a/iputil.rkt +++ b/iputil.rkt @@ -44,9 +44,10 @@ (string-join parts ".")) (define (ip-netmask ip) - (for/sum ([i (in-range 32)]) - #:break (positive? (bitwise-and ip (arithmetic-shift 1 i))) - 1)) + (- 32 + (for/sum ([i (in-range 32)]) + #:break (positive? (bitwise-and ip (arithmetic-shift 1 i))) + 1))) (define (string->subnet str) (match-define (list ipstr maskstr) (string-split str "/"))