Browse Source

serialize update

master
Milo 10 months ago
parent
commit
d24df65c34
1 changed files with 18 additions and 3 deletions
  1. +18
    -3
      msg.rkt

+ 18
- 3
msg.rkt View File

@@ -101,6 +101,21 @@
'msg (match msg
[(msg:data _ _ data) data]
[(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
(format "unimplemented ~a" (msg-type msg)))])))

@@ -109,12 +124,12 @@
(jsexpr->bytes (msg->jsexpr msg)))

(module+ test
#;
(check-equal? (msg->jsexpr
(msg:update
(string->ip "1.2.3.4")
(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
#t
'(1 2)
@@ -143,7 +158,7 @@
(string->ip "1.2.3.4")
(string->ip "1.2.3.7")
(route (string->ip "1.2.3.4")
(subnet (string->ip "1.2.3.5") 7)
(subnet (string->ip "1.2.3.5") 25)
100
#t
'(1 2)


Loading…
Cancel
Save