-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FRR: route-map match source-protocol (#6618)
- Loading branch information
Showing
10 changed files
with
364 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...batfish/src/main/java/org/batfish/representation/cumulus/RouteMapMatchSourceProtocol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.batfish.representation.cumulus; | ||
|
||
import javax.annotation.Nonnull; | ||
import org.batfish.common.Warnings; | ||
import org.batfish.datamodel.Configuration; | ||
import org.batfish.datamodel.RoutingProtocol; | ||
import org.batfish.datamodel.routing_policy.expr.BooleanExpr; | ||
import org.batfish.datamodel.routing_policy.expr.BooleanExprs; | ||
import org.batfish.datamodel.routing_policy.expr.MatchProtocol; | ||
|
||
/** A {@link RouteMapMatch} that implements {@code route-map match source-protocol}. */ | ||
public final class RouteMapMatchSourceProtocol implements RouteMapMatch { | ||
|
||
public enum Protocol { | ||
BGP, | ||
CONNECTED, | ||
EIGRP, | ||
ISIS, | ||
KERNEL, | ||
OSPF, | ||
RIP, | ||
STATIC, | ||
} | ||
|
||
private final @Nonnull Protocol _protocol; | ||
|
||
public RouteMapMatchSourceProtocol(@Nonnull Protocol protocol) { | ||
_protocol = protocol; | ||
} | ||
|
||
@Override | ||
public @Nonnull BooleanExpr toBooleanExpr( | ||
Configuration c, CumulusNodeConfiguration vc, Warnings w) { | ||
switch (_protocol) { | ||
case BGP: | ||
return new MatchProtocol(RoutingProtocol.BGP, RoutingProtocol.IBGP); | ||
case CONNECTED: | ||
// TODO: cumulus local routes? | ||
return new MatchProtocol(RoutingProtocol.CONNECTED); | ||
case EIGRP: | ||
// TODO: verify subsets | ||
return new MatchProtocol(RoutingProtocol.EIGRP, RoutingProtocol.EIGRP_EX); | ||
case ISIS: | ||
// TODO: verify subsets | ||
return new MatchProtocol( | ||
RoutingProtocol.ISIS_EL1, | ||
RoutingProtocol.ISIS_EL2, | ||
RoutingProtocol.ISIS_L1, | ||
RoutingProtocol.ISIS_L2); | ||
case KERNEL: | ||
return new MatchProtocol(RoutingProtocol.KERNEL); | ||
case OSPF: | ||
// TODO: verify subsets | ||
return new MatchProtocol( | ||
RoutingProtocol.OSPF, | ||
RoutingProtocol.OSPF_E1, | ||
RoutingProtocol.OSPF_E2, | ||
RoutingProtocol.OSPF_IA); | ||
case RIP: | ||
return new MatchProtocol(RoutingProtocol.RIP); | ||
case STATIC: | ||
return new MatchProtocol(RoutingProtocol.STATIC); | ||
default: | ||
w.unimplemented(String.format("Matching protocol %s", _protocol)); | ||
return BooleanExprs.FALSE; | ||
} | ||
} | ||
|
||
public @Nonnull Protocol getProtocol() { | ||
return _protocol; | ||
} | ||
} |
Oops, something went wrong.