This commit is contained in:
Milo 2020-01-31 17:30:07 -05:00
parent 0af140b70f
commit d7d6f2bdfc
1 changed files with 4 additions and 3 deletions

View File

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