1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const log_1 = require("../common/log");
|
4 | const log = log_1.create('dragon');
|
5 | const relation_1 = require("./relation");
|
6 | function canDragonFilter(routingTable, getRelation, prefix, route) {
|
7 | for (const parentPrefix of routingTable.getKeysPrefixesOf(prefix)) {
|
8 | const parentRouteUpdate = routingTable.get(parentPrefix);
|
9 | if (!parentRouteUpdate || !parentRouteUpdate.route) {
|
10 | log.warn('found a parent prefix, but no parent route; this should never happen. prefix=%s parentPrefix=%s', prefix, parentPrefix);
|
11 | continue;
|
12 | }
|
13 | const parentRoute = parentRouteUpdate.route;
|
14 | if (parentRoute.nextHop === '') {
|
15 | continue;
|
16 | }
|
17 | const parentRelation = getRelation(parentRoute.nextHop);
|
18 | const childRelation = getRelation(route.nextHop);
|
19 | if (relation_1.getRelationPriority(parentRelation) < relation_1.getRelationPriority(childRelation)) {
|
20 | continue;
|
21 | }
|
22 | log.trace('applied DRAGON route filter. prefix=%s parentPrefix=%s', prefix, parentPrefix);
|
23 | return true;
|
24 | }
|
25 | return false;
|
26 | }
|
27 | exports.canDragonFilter = canDragonFilter;
|
28 |
|
\ | No newline at end of file |