Implement revoke
This commit is contained in:
parent
0902781626
commit
30b1460d4d
|
@ -124,6 +124,12 @@
|
||||||
'netmask (ip->string (netmask-ip (subnet-mask (first entry))))
|
'netmask (ip->string (netmask-ip (subnet-mask (first entry))))
|
||||||
'peer (ip->string (second entry))))]
|
'peer (ip->string (second entry))))]
|
||||||
|
|
||||||
|
[(msg:revoke _ _ networks)
|
||||||
|
(map (lambda (net)
|
||||||
|
(hash 'network (ip->string (subnet-ip net))
|
||||||
|
'netmask (ip->string (netmask-ip (subnet-mask net)))))
|
||||||
|
networks)]
|
||||||
|
|
||||||
[_ (error 'msg->jsexpr
|
[_ (error 'msg->jsexpr
|
||||||
(format "unimplemented ~a" (msg-type msg)))])))
|
(format "unimplemented ~a" (msg-type msg)))])))
|
||||||
|
|
||||||
|
|
22
router
22
router
|
@ -35,6 +35,20 @@
|
||||||
(lambda (rst) (cons (cons peer r) rst))
|
(lambda (rst) (cons (cons peer r) rst))
|
||||||
(lambda () '())))
|
(lambda () '())))
|
||||||
|
|
||||||
|
;; Router Route Peer -> Void
|
||||||
|
;; Tries to find the given route and removes it from the routing database
|
||||||
|
(define (router-revoke! rt subnet peer)
|
||||||
|
;; [Listof [Cons Peer Route]] -> [Listof [Cons Peer Route]]
|
||||||
|
;; Removes route r from the given list, if present
|
||||||
|
(define (remove-route routes)
|
||||||
|
(filter (lambda (el) (not (and (equal? (car el) peer)
|
||||||
|
(equal? (route-subnet (cdr el)) subnet))))
|
||||||
|
routes))
|
||||||
|
(rt-update! rt
|
||||||
|
(subnet->bl subnet)
|
||||||
|
(lambda (lst) (remove-route lst))
|
||||||
|
(lambda () '())))
|
||||||
|
|
||||||
;; IP -> IP
|
;; IP -> IP
|
||||||
;; Calculates our local IP on the subnet with peer p
|
;; Calculates our local IP on the subnet with peer p
|
||||||
(define (peer-ip->own-ip p)
|
(define (peer-ip->own-ip p)
|
||||||
|
@ -159,6 +173,14 @@
|
||||||
#:when (not (eq? (peer-conn-info pc) src-peer)))
|
#:when (not (eq? (peer-conn-info pc) src-peer)))
|
||||||
(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)
|
||||||
|
(for ([net (in-list networks)]) (router-revoke! router net (ip->peer src)))
|
||||||
|
(rt-dump router)
|
||||||
|
(for/list ([pc (in-list peer-conns)]
|
||||||
|
#:when (not (eq? (peer-conn-info pc) src-peer)))
|
||||||
|
(let ([pip (peer-ip (peer-conn-info pc))])
|
||||||
|
(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
|
[#f
|
||||||
|
|
Loading…
Reference in New Issue