ip: Move cidr utils to utils.scm
ip/addr.scm
45 | 45 | (brd addr-brd) | |
46 | 46 | (cacheinfo addr-cacheinfo)) | |
47 | 47 | ||
48 | - | (define (cidr->addr str) | |
49 | - | (match (string-split str #\/) | |
50 | - | ((addr) addr) | |
51 | - | ((addr prefix) addr) | |
52 | - | (_ (throw 'incorrect-cidr-notation str)))) | |
53 | - | ||
54 | - | (define (cidr->prefix str) | |
55 | - | (match (string-split str #\/) | |
56 | - | ((addr) #f) | |
57 | - | ((addr prefix) (string->number prefix)) | |
58 | - | (_ (throw 'incorrect-cidr-notation str)))) | |
59 | - | ||
60 | 48 | (define* (addr-del device cidr #:key (ipv6? #f)) | |
61 | 49 | (define request-num (random 65535)) | |
62 | 50 | (define prefix (cidr->prefix cidr)) |
ip/utils.scm
24 | 24 | #:use-module (netlink standard) | |
25 | 25 | #:export (answer-ok? | |
26 | 26 | get-attr | |
27 | - | split-flags)) | |
27 | + | split-flags | |
28 | + | cidr->addr | |
29 | + | cidr->prefix)) | |
28 | 30 | ||
29 | 31 | (define (answer-ok? answer) | |
30 | 32 | (cond | |
… | |||
59 | 61 | (else | |
60 | 62 | (loop (/ max-flag 2) (- flags max-flag) | |
61 | 63 | (cons max-flag result)))))) | |
64 | + | ||
65 | + | (define (cidr->addr str) | |
66 | + | (match (string-split str #\/) | |
67 | + | ((addr) addr) | |
68 | + | ((addr prefix) addr) | |
69 | + | (_ (throw 'incorrect-cidr-notation str)))) | |
70 | + | ||
71 | + | (define (cidr->prefix str) | |
72 | + | (match (string-split str #\/) | |
73 | + | ((addr) #f) | |
74 | + | ((addr prefix) (string->number prefix)) | |
75 | + | (_ (throw 'incorrect-cidr-notation str)))) |