Pass level 4, 5
This commit is contained in:
parent
d49d02f504
commit
79af76ed19
26
router
26
router
|
@ -114,6 +114,13 @@
|
||||||
(peer-ip peer)
|
(peer-ip peer)
|
||||||
(update-aspath r asn)))
|
(update-aspath r asn)))
|
||||||
|
|
||||||
|
;; Peer Peer -> Bool
|
||||||
|
;; Checks if we should send a route update from the given src peer to the dst peer
|
||||||
|
(define (router-should-update? src-peer dst-peer)
|
||||||
|
(match (peer-type src-peer)
|
||||||
|
['cust #t]
|
||||||
|
[_ (symbol=? 'cust (peer-type dst-peer))]))
|
||||||
|
|
||||||
;; Int [Listof Peer-Conn] -> Void
|
;; Int [Listof Peer-Conn] -> Void
|
||||||
;; --
|
;; --
|
||||||
;; Runs router logic, given a list of peer connections.
|
;; Runs router logic, given a list of peer connections.
|
||||||
|
@ -170,26 +177,29 @@
|
||||||
(ip->peer src))
|
(ip->peer src))
|
||||||
(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))
|
||||||
|
#:when (router-should-update? src-peer (peer-conn-info pc)))
|
||||||
(cons pc (router-format-update (peer-conn-info pc) r asn)))]
|
(cons pc (router-format-update (peer-conn-info pc) r asn)))]
|
||||||
|
|
||||||
[(msg:revoke src dst networks)
|
[(msg:revoke src dst networks)
|
||||||
(for ([net (in-list networks)]) (router-revoke! router net (ip->peer src)))
|
(for ([net (in-list networks)]) (router-revoke! router net (ip->peer src)))
|
||||||
(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))
|
||||||
|
#:when (router-should-update? src-peer (peer-conn-info pc)))
|
||||||
(let ([pip (peer-ip (peer-conn-info pc))])
|
(let ([pip (peer-ip (peer-conn-info pc))])
|
||||||
(cons pc (msg:revoke (peer-ip->own-ip pip) pip networks))))]
|
(cons pc (msg:revoke (peer-ip->own-ip pip) pip networks))))]
|
||||||
|
|
||||||
[(msg:data src dst data)
|
[(msg:data src dst data)
|
||||||
(match (router-find-best router dst)
|
(match (router-find-best router dst)
|
||||||
[#f
|
[(? peer? dst-peer) #:when (ormap (compose (curry symbol=? 'cust) peer-type)
|
||||||
(list (cons (peer->peer-conn src-peer)
|
(list dst-peer src-peer))
|
||||||
(msg:no-route (peer-ip->own-ip src)
|
|
||||||
src)))]
|
|
||||||
[dst-peer
|
|
||||||
(list (cons (peer->peer-conn dst-peer)
|
(list (cons (peer->peer-conn dst-peer)
|
||||||
msg))])]
|
msg))]
|
||||||
|
[_
|
||||||
|
(list (cons (peer->peer-conn src-peer)
|
||||||
|
(msg:no-route (peer-ip->own-ip (peer-ip src-peer))
|
||||||
|
src)))])]
|
||||||
[(msg:dump src dst)
|
[(msg:dump src dst)
|
||||||
(list (cons (peer->peer-conn src-peer) (router-dump router src dst)))]
|
(list (cons (peer->peer-conn src-peer) (router-dump router src dst)))]
|
||||||
[_
|
[_
|
||||||
|
|
Loading…
Reference in New Issue