Fix asn handling in update forwarding

This commit is contained in:
xenia 2020-02-01 22:41:23 -05:00
parent 222d9ce31c
commit ce744d9983
1 changed files with 14 additions and 6 deletions

20
router
View File

@ -79,10 +79,19 @@
(route-nexthop (cdr route))))
routes)))))
;; Str [Listof Peer-Conn] -> Void
(define (router-format-update peer r asn)
;; Route -> Route
(define (update-aspath r asn)
(struct-copy route r [as-path (append (route-as-path r) (list asn))]))
(msg:update
(peer-ip->own-ip (peer-ip peer))
(peer-ip peer)
(update-aspath r asn)))
;; Int [Listof Peer-Conn] -> Void
;; --
;; Runs router logic, given a list of peer connections.
(define (run-router/conns ans peer-conns)
(define (run-router/conns asn peer-conns)
(define mail
(make-channel))
@ -126,8 +135,7 @@
(rt-dump router)
(for/list ([pc (in-list peer-conns)]
#:when (not (eq? (peer-conn-info pc) src-peer)))
(match-define (peer-conn peer _ _) pc)
(cons pc (msg:update (peer-ip->own-ip (peer-ip peer)) (peer-ip peer) r)))]
(cons pc (router-format-update (peer-conn-info pc) r asn)))]
[(msg:data src dst data)
(match (router-find-best router dst)
@ -156,7 +164,7 @@
(loop)))
;; Str [Listof Peer] ->
;; Int [Listof Peer] ->
;; Router main
(define (run-router asn peers)
(displayln asn)
@ -182,7 +190,7 @@
#:exists 'replace
(λ ()
;; Run the router
(run-router asn (map string->peer peers))))))
(run-router (string->number asn) (map string->peer peers))))))
(module+ test