transparent

This commit is contained in:
Milo 2020-01-30 19:47:32 -05:00
parent 1c04209328
commit 8ac13a0c31
2 changed files with 23 additions and 10 deletions

View File

@ -14,6 +14,7 @@
(require rackunit))
(struct peer [ip type]
#:transparent
#:methods gen:custom-write
[(define write-proc
(make-constructor-style-printer
@ -21,6 +22,7 @@
(lambda (x) (list (ip->string (peer-ip x)) (peer-type x)))))])
(struct subnet [ip mask]
#:transparent
#:methods gen:custom-write
[(define write-proc
(make-constructor-style-printer

15
msg.rkt
View File

@ -4,6 +4,9 @@
(require json
"iputil.rkt")
(module+ test
(require rackunit))
;; src, dst : IP
;; data : Any
(struct msg [src dst]
@ -86,7 +89,7 @@
(jsexpr->msg bs)))
(module+ test
(jsexpr->msg
(check-equal? (jsexpr->msg
(hash 'src "1.2.3.4"
'dst "1.2.3.7"
'type "update"
@ -95,4 +98,12 @@
'localpref 100
'selfOrigin #t
'ASPath '(1 2)
'origin "UNK"))))
'origin "UNK")))
(msg:update
(string->ip "1.2.3.4")
(string->ip "1.2.3.7")
(subnet (string->ip "1.2.3.5") 7)
100
#t
'(1 2)
'UNK)))