serialize update

This commit is contained in:
Milo 2020-01-31 23:41:10 -05:00
parent a914535c7d
commit d24df65c34
1 changed files with 18 additions and 3 deletions

21
msg.rkt
View File

@ -101,6 +101,21 @@
'msg (match msg 'msg (match msg
[(msg:data _ _ data) data] [(msg:data _ _ data) data]
[(msg:no-route _ _) (hash)] [(msg:no-route _ _) (hash)]
[(msg:update _ _
(route _
net
pref
self-orig?
as
org))
(hash 'network (ip->string (subnet-ip net))
'netmask (ip->string (netmask-ip (subnet-mask net)))
'localpref pref
'selfOrigin self-orig?
'ASPath as
'origin (symbol->string org))]
[_ (error 'msg->jsexpr [_ (error 'msg->jsexpr
(format "unimplemented ~a" (msg-type msg)))]))) (format "unimplemented ~a" (msg-type msg)))])))
@ -109,12 +124,12 @@
(jsexpr->bytes (msg->jsexpr msg))) (jsexpr->bytes (msg->jsexpr msg)))
(module+ test (module+ test
#;
(check-equal? (msg->jsexpr (check-equal? (msg->jsexpr
(msg:update (msg:update
(string->ip "1.2.3.4") (string->ip "1.2.3.4")
(string->ip "1.2.3.7") (string->ip "1.2.3.7")
(route (subnet (string->ip "1.2.3.5") 7) (route (string->ip "1.2.3.4")
(subnet (string->ip "1.2.3.5") 25)
100 100
#t #t
'(1 2) '(1 2)
@ -143,7 +158,7 @@
(string->ip "1.2.3.4") (string->ip "1.2.3.4")
(string->ip "1.2.3.7") (string->ip "1.2.3.7")
(route (string->ip "1.2.3.4") (route (string->ip "1.2.3.4")
(subnet (string->ip "1.2.3.5") 7) (subnet (string->ip "1.2.3.5") 25)
100 100
#t #t
'(1 2) '(1 2)