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)))) (route-nexthop (cdr route))))
routes))))) 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. ;; 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 (define mail
(make-channel)) (make-channel))
@ -126,8 +135,7 @@
(rt-dump router) (rt-dump router)
(for/list ([pc (in-list peer-conns)] (for/list ([pc (in-list peer-conns)]
#:when (not (eq? (peer-conn-info pc) src-peer))) #:when (not (eq? (peer-conn-info pc) src-peer)))
(match-define (peer-conn peer _ _) pc) (cons pc (router-format-update (peer-conn-info pc) r asn)))]
(cons pc (msg:update (peer-ip->own-ip (peer-ip peer)) (peer-ip peer) r)))]
[(msg:data src dst data) [(msg:data src dst data)
(match (router-find-best router dst) (match (router-find-best router dst)
@ -156,7 +164,7 @@
(loop))) (loop)))
;; Str [Listof Peer] -> ;; Int [Listof Peer] ->
;; Router main ;; Router main
(define (run-router asn peers) (define (run-router asn peers)
(displayln asn) (displayln asn)
@ -182,7 +190,7 @@
#:exists 'replace #:exists 'replace
(λ () (λ ()
;; Run the router ;; Run the router
(run-router asn (map string->peer peers)))))) (run-router (string->number asn) (map string->peer peers))))))
(module+ test (module+ test