ip: move get-attr to utils
ip/link.scm
56 | 56 | (addr link-addr) | |
57 | 57 | (brd link-brd)) | |
58 | 58 | ||
59 | - | (define (get-attr attrs type) | |
60 | - | (let ((attrs (filter (lambda (attr) (equal? (route-attr-kind attr) type)) attrs))) | |
61 | - | (match attrs | |
62 | - | (() #f) | |
63 | - | ((attr) (nl-data-data (route-attr-data attr)))))) | |
64 | - | ||
65 | 59 | (define (split-flags flags) | |
66 | 60 | (let loop ((max-flag 262144) (flags flags) (result '())) | |
67 | 61 | (cond |
ip/utils.scm
16 | 16 | ;;;; | |
17 | 17 | ||
18 | 18 | (define-module (ip utils) | |
19 | + | #:use-module (ice-9 match) | |
19 | 20 | #:use-module (netlink constant) | |
20 | 21 | #:use-module (netlink data) | |
21 | 22 | #:use-module (netlink message) | |
23 | + | #:use-module (netlink route attrs) | |
22 | 24 | #:use-module (netlink standard) | |
23 | - | #:export (answer-ok?)) | |
25 | + | #:export (answer-ok? | |
26 | + | get-attr)) | |
24 | 27 | ||
25 | 28 | (define (answer-ok? answer) | |
26 | 29 | (cond | |
… | |||
36 | 39 | (format #t "RTNETLINK answers: ~a~%" (strerror (- err))) | |
37 | 40 | #f))) | |
38 | 41 | #f))))) | |
42 | + | ||
43 | + | (define (get-attr attrs type) | |
44 | + | (let ((attrs (filter (lambda (attr) (equal? (route-attr-kind attr) type)) attrs))) | |
45 | + | (match attrs | |
46 | + | (() #f) | |
47 | + | ((attr) (nl-data-data (route-attr-data attr)))))) |