deserialize.scm
1 | ;;;; Copyright (C) 2020 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 deserialize) |
19 | #:use-module (netlink constant) |
20 | #:use-module ((netlink route attrs) #:prefix route:) |
21 | #:use-module ((netlink route link) #:prefix route:) |
22 | #:use-module (netlink standard) |
23 | #:use-module (netlink message) |
24 | #:export (%default-message-decoder |
25 | %default-route-decoder)) |
26 | |
27 | (define %default-message-decoder |
28 | `((,NLMSG_NOOP . ,deserialize-no-data) |
29 | (,NLMSG_ERROR . ,deserialize-error-message) |
30 | (,NLMSG_DONE . ,deserialize-no-data))) |
31 | |
32 | ;; for RTNETLINK |
33 | (define %default-route-decoder |
34 | `((message ,deserialize-message |
35 | ,@%default-message-decoder |
36 | (,RTM_NEWLINK . ,route:deserialize-link-message) |
37 | (,RTM_DELLINK . ,route:deserialize-link-message) |
38 | (,RTM_GETLINK . ,route:deserialize-link-message) |
39 | (,RTM_SETLINK . ,route:deserialize-link-message)) |
40 | (attr ,route:deserialize-route-attr |
41 | ,@route:%default-route-attr-decoder))) |
42 |