transparent
This commit is contained in:
parent
1c04209328
commit
8ac13a0c31
|
@ -14,6 +14,7 @@
|
||||||
(require rackunit))
|
(require rackunit))
|
||||||
|
|
||||||
(struct peer [ip type]
|
(struct peer [ip type]
|
||||||
|
#:transparent
|
||||||
#:methods gen:custom-write
|
#:methods gen:custom-write
|
||||||
[(define write-proc
|
[(define write-proc
|
||||||
(make-constructor-style-printer
|
(make-constructor-style-printer
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
(lambda (x) (list (ip->string (peer-ip x)) (peer-type x)))))])
|
(lambda (x) (list (ip->string (peer-ip x)) (peer-type x)))))])
|
||||||
|
|
||||||
(struct subnet [ip mask]
|
(struct subnet [ip mask]
|
||||||
|
#:transparent
|
||||||
#:methods gen:custom-write
|
#:methods gen:custom-write
|
||||||
[(define write-proc
|
[(define write-proc
|
||||||
(make-constructor-style-printer
|
(make-constructor-style-printer
|
||||||
|
|
31
msg.rkt
31
msg.rkt
|
@ -4,6 +4,9 @@
|
||||||
(require json
|
(require json
|
||||||
"iputil.rkt")
|
"iputil.rkt")
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(require rackunit))
|
||||||
|
|
||||||
;; src, dst : IP
|
;; src, dst : IP
|
||||||
;; data : Any
|
;; data : Any
|
||||||
(struct msg [src dst]
|
(struct msg [src dst]
|
||||||
|
@ -86,13 +89,21 @@
|
||||||
(jsexpr->msg bs)))
|
(jsexpr->msg bs)))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(jsexpr->msg
|
(check-equal? (jsexpr->msg
|
||||||
(hash 'src "1.2.3.4"
|
(hash 'src "1.2.3.4"
|
||||||
'dst "1.2.3.7"
|
'dst "1.2.3.7"
|
||||||
'type "update"
|
'type "update"
|
||||||
'msg (hash 'network "1.2.3.5"
|
'msg (hash 'network "1.2.3.5"
|
||||||
'netmask "255.255.255.128"
|
'netmask "255.255.255.128"
|
||||||
'localpref 100
|
'localpref 100
|
||||||
'selfOrigin #t
|
'selfOrigin #t
|
||||||
'ASPath '(1 2)
|
'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)))
|
||||||
|
|
Loading…
Reference in New Issue