route struct

This commit is contained in:
Milo 2020-01-31 21:31:03 -05:00
parent a603926b94
commit edc229cb07
1 changed files with 15 additions and 11 deletions

26
msg.rkt
View File

@ -12,7 +12,7 @@
(struct msg [src dst]
#:transparent)
(struct msg:update msg [subnet pref self-origin? as-path origin]
(struct route [subnet pref self-origin? as-path origin]
;; subnet : Subnet
;; pref : Int
;; self-origin? : Boolean
@ -20,6 +20,10 @@
;; origin : (U 'IGP 'EGP 'UNK)
#:transparent)
(struct msg:update msg [route]
;; route : Route
#:transparent)
(struct msg:revoke msg [networks]
;; networks : [Listof Subnet]
#:transparent)
@ -62,11 +66,11 @@
(match type
["update"
(msg:update src dst
(hash->subnet data)
(hash-ref data 'localpref)
(hash-ref data 'selfOrigin)
(hash-ref data 'ASPath)
(string->symbol (hash-ref data 'origin)))]
(route (hash->subnet data)
(hash-ref data 'localpref)
(hash-ref data 'selfOrigin)
(hash-ref data 'ASPath)
(string->symbol (hash-ref data 'origin))))]
["revoke"
(msg:revoke src dst
(map hash->subnet data))]
@ -101,8 +105,8 @@
(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)))
(route (subnet (string->ip "1.2.3.5") 7)
100
#t
'(1 2)
'UNK))))