Move align to a common module.
Makefile.am
| 7 | 7 | netlink/message.scm \ | |
| 8 | 8 | netlink/standard.scm \ | |
| 9 | 9 | netlink/deserialize.scm \ | |
| 10 | + | netlink/route.scm \ | |
| 10 | 11 | netlink/route/addr.scm \ | |
| 11 | 12 | netlink/route/attrs.scm \ | |
| 12 | 13 | netlink/route/link.scm \ |
netlink/route.scm unknown status 1
| 1 | + | ;;;; Copyright (C) 2021 Julien Lepiller <julien@lepiller.eu> | |
| 2 | + | ;;;; | |
| 3 | + | ;;;; This library is free software; you can redistribute it and/or | |
| 4 | + | ;;;; modify it under the terms of the GNU Lesser General Public | |
| 5 | + | ;;;; License as published by the Free Software Foundation; either | |
| 6 | + | ;;;; version 3 of the License, or (at your option) any later version. | |
| 7 | + | ;;;; | |
| 8 | + | ;;;; This library is distributed in the hope that it will be useful, | |
| 9 | + | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10 | + | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 11 | + | ;;;; Lesser General Public License for more details. | |
| 12 | + | ;;;; | |
| 13 | + | ;;;; You should have received a copy of the GNU Lesser General Public | |
| 14 | + | ;;;; License along with this library; if not, write to the Free Software | |
| 15 | + | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 16 | + | ;;;; | |
| 17 | + | ||
| 18 | + | (define-module (netlink route) | |
| 19 | + | #:export (align)) | |
| 20 | + | ||
| 21 | + | (define (align pos to) | |
| 22 | + | (+ pos -1 (- to (modulo (- pos 1) to)))) |
netlink/route/addr.scm
| 18 | 18 | (define-module (netlink route addr) | |
| 19 | 19 | #:use-module (ice-9 match) | |
| 20 | 20 | #:use-module (netlink data) | |
| 21 | + | #:use-module (netlink route) | |
| 21 | 22 | #:use-module (netlink route attrs) | |
| 22 | 23 | #:use-module (srfi srfi-9) | |
| 23 | 24 | #:use-module (rnrs bytevectors) | |
… | |||
| 31 | 32 | addr-message-attrs | |
| 32 | 33 | deserialize-addr-message)) | |
| 33 | 34 | ||
| 34 | - | (define (align pos to) | |
| 35 | - | (+ pos -1 (- to (modulo (- pos 1) to)))) | |
| 36 | - | ||
| 37 | 35 | (define-data-type addr-message | |
| 38 | 36 | (lambda (msg) | |
| 39 | 37 | (+ 8 (apply + (map (lambda (d) (align (data-size d) 4)) attrs)))) | |
netlink/route/link.scm
| 18 | 18 | (define-module (netlink route link) | |
| 19 | 19 | #:use-module (ice-9 match) | |
| 20 | 20 | #:use-module (netlink data) | |
| 21 | + | #:use-module (netlink route) | |
| 21 | 22 | #:use-module (netlink route attrs) | |
| 22 | 23 | #:use-module (srfi srfi-9) | |
| 23 | 24 | #:use-module (rnrs bytevectors) | |
… | |||
| 30 | 31 | link-message-attrs | |
| 31 | 32 | deserialize-link-message)) | |
| 32 | 33 | ||
| 33 | - | (define (align pos to) | |
| 34 | - | (+ pos -1 (- to (modulo (- pos 1) to)))) | |
| 35 | - | ||
| 36 | 34 | (define-data-type link-message | |
| 37 | 35 | (lambda (msg) | |
| 38 | 36 | (+ 16 (apply + (map (lambda (d) (align (data-size d) 4)) attrs)))) | |
netlink/route/route.scm
| 18 | 18 | (define-module (netlink route route) | |
| 19 | 19 | #:use-module (ice-9 match) | |
| 20 | 20 | #:use-module (netlink data) | |
| 21 | + | #:use-module (netlink route) | |
| 21 | 22 | #:use-module (netlink route attrs) | |
| 22 | 23 | #:use-module (srfi srfi-9) | |
| 23 | 24 | #:use-module (rnrs bytevectors) | |
… | |||
| 35 | 36 | route-message-attrs | |
| 36 | 37 | deserialize-route-message)) | |
| 37 | 38 | ||
| 38 | - | (define (align pos to) | |
| 39 | - | (+ pos -1 (- to (modulo (- pos 1) to)))) | |
| 40 | - | ||
| 41 | 39 | (define-data-type route-message | |
| 42 | 40 | (lambda (msg) | |
| 43 | 41 | (+ 12 (apply + (map (lambda (d) (align (data-size d) 4)) attrs)))) | |