Decode cacheinfo structure
ip/addr.scm
201 | 201 | (when cacheinfo | |
202 | 202 | (if (member 'IFA_F_PERMANENT flags) | |
203 | 203 | (format #t " valid_lft forever preferred_lft forever~%") | |
204 | - | (format #t " valid_lft ??sec preferred_lft ??sec~%")))))) | |
204 | + | (format #t " valid_lft ~asec preferred_lft ~asec~%" | |
205 | + | (route-cache-info-attr-type-valid cacheinfo) | |
206 | + | (route-cache-info-attr-type-prefered cacheinfo))))))) | |
205 | 207 | ||
206 | 208 | ||
207 | 209 | (define* (addr-show #:optional (device #f)) |
netlink/route/attrs.scm
28 | 28 | route-attr-kind | |
29 | 29 | route-attr-data | |
30 | 30 | route-attr-size | |
31 | + | make-route-cache-info-attr | |
32 | + | route-cache-info-attr? | |
33 | + | route-cache-info-attr-prefered | |
34 | + | route-cache-info-attr-valid | |
35 | + | route-cache-info-attr-cstamp | |
36 | + | route-cache-info-attr-tstamp | |
37 | + | route-cache-info-attr-type-prefered | |
38 | + | route-cache-info-attr-type-valid | |
39 | + | route-cache-info-attr-type-cstamp | |
40 | + | route-cache-info-attr-type-tstamp | |
31 | 41 | make-u8-route-attr | |
32 | 42 | make-u16-route-attr | |
33 | 43 | make-u32-route-attr | |
… | |||
37 | 47 | make-ethernet-route-attr | |
38 | 48 | make-ipv4-route-attr | |
39 | 49 | make-ipv6-route-attr | |
50 | + | make-addr-cache-info-attr | |
40 | 51 | make-bv-route-attr | |
41 | 52 | deserialize-route-attr | |
42 | 53 | deserialize-route-attr-data-u8 | |
… | |||
48 | 59 | deserialize-route-attr-data-ethernet | |
49 | 60 | deserialize-route-attr-data-ipv4 | |
50 | 61 | deserialize-route-attr-data-ipv6 | |
62 | + | deserialize-route-attr-data-route-cache-info | |
51 | 63 | deserialize-route-attr-data-bv | |
52 | 64 | %default-route-addr-ipv4-attr-decoder | |
53 | 65 | %default-route-addr-ipv6-attr-decoder | |
… | |||
79 | 91 | (define (attr-type-size attr) | |
80 | 92 | (+ 4 (data-size (route-attr-type-data attr)))) | |
81 | 93 | ||
94 | + | (define-data-type route-cache-info-attr | |
95 | + | (const 16) | |
96 | + | (lambda (attr pos bv) | |
97 | + | (match attr | |
98 | + | (($ route-cache-info-attr-type prefered valid cstamp tstamp) | |
99 | + | (bytevector-u32-set! bv pos prefered (native-endianness)) | |
100 | + | (bytevector-u32-set! bv (+ pos 4) valid (native-endianness)) | |
101 | + | (bytevector-u32-set! bv (+ pos 8) cstamp (native-endianness)) | |
102 | + | (bytevector-u32-set! bv (+ pos 12) tstamp (native-endianness))))) | |
103 | + | (prefered route-cache-info-attr-prefered route-cache-info-attr-type-prefered) | |
104 | + | (valid route-cache-info-attr-valid route-cache-info-attr-type-valid) | |
105 | + | (cstamp route-cache-info-attr-cstamp route-cache-info-attr-type-cstamp) | |
106 | + | (tstamp route-cache-info-attr-tstamp route-cache-info-attr-type-tstamp)) | |
107 | + | ||
82 | 108 | (define (make-u8-route-attr num) | |
83 | 109 | (make-nl-data | |
84 | 110 | num | |
… | |||
231 | 257 | (make-ipv6-route-attr | |
232 | 258 | (inet-ntop AF_INET6 (ipv6->number bv)))) | |
233 | 259 | ||
260 | + | (define (deserialize-route-attr-data-route-cache-info decoder bv pos) | |
261 | + | (make-route-cache-info-attr | |
262 | + | (bytevector-u32-ref bv pos (native-endianness)) | |
263 | + | (bytevector-u32-ref bv (+ pos 4) (native-endianness)) | |
264 | + | (bytevector-u32-ref bv (+ pos 8) (native-endianness)) | |
265 | + | (bytevector-u32-ref bv (+ pos 12) (native-endianness)))) | |
266 | + | ||
234 | 267 | (define %default-route-link-attr-decoder | |
235 | 268 | `((,IFLA_ADDRESS . ,deserialize-route-attr-data-ethernet) | |
236 | 269 | (,IFLA_BROADCAST . ,deserialize-route-attr-data-ethernet) | |
… | |||
258 | 291 | (,IFA_BROADCAST . ,address-decoder) | |
259 | 292 | (,IFA_ANYCAST . ,address-decoder) | |
260 | 293 | (,IFA_FLAGS . ,deserialize-route-attr-data-u32) | |
261 | - | ;; TODO: struct ifa_cacheinfo | |
262 | - | ;(,IFA_CACHEINFO . ,deserialize-route-attr-data-cache-info) | |
294 | + | (,IFA_CACHEINFO . ,deserialize-route-attr-data-route-cache-info) | |
263 | 295 | (default . ,deserialize-route-attr-data-bv))) | |
264 | 296 | ||
265 | 297 | (define (default-route-route-attr-decoder address-decoder) |