use of org.batfish.representation.cisco.StaticRoute in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitIp_route_tail.
@Override
public void exitIp_route_tail(Ip_route_tailContext ctx) {
Prefix prefix;
if (ctx.prefix != null) {
prefix = Prefix.parse(ctx.prefix.getText());
} else {
Ip address = toIp(ctx.address);
Ip mask = toIp(ctx.mask);
int prefixLength = mask.numSubnetBits();
prefix = new Prefix(address, prefixLength);
}
Ip nextHopIp = Route.UNSET_ROUTE_NEXT_HOP_IP;
String nextHopInterface = null;
int distance = DEFAULT_STATIC_ROUTE_DISTANCE;
Integer tag = null;
Integer track = null;
boolean permanent = ctx.perm != null;
if (ctx.nexthopip != null) {
nextHopIp = toIp(ctx.nexthopip);
} else if (ctx.nexthopprefix != null) {
Prefix nextHopPrefix = Prefix.parse(ctx.nexthopprefix.getText());
nextHopIp = nextHopPrefix.getStartIp();
}
if (ctx.nexthopint != null) {
try {
nextHopInterface = getCanonicalInterfaceName(ctx.nexthopint.getText());
} catch (BatfishException e) {
_w.redFlag("Error fetching interface name at: " + getLocation(ctx) + getFullText(ctx) + " : " + e.getMessage());
_currentInterfaces = ImmutableList.of();
return;
}
}
if (ctx.distance != null) {
distance = toInteger(ctx.distance);
}
if (ctx.tag != null) {
tag = toInteger(ctx.tag);
}
if (ctx.track != null) {
track = toInteger(ctx.track);
}
StaticRoute route = new StaticRoute(prefix, nextHopIp, nextHopInterface, distance, tag, track, permanent);
currentVrf().getStaticRoutes().add(route);
}
use of org.batfish.representation.cisco.StaticRoute in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitRs_route.
@Override
public void exitRs_route(Rs_routeContext ctx) {
if (ctx.prefix != null) {
Prefix prefix = Prefix.parse(ctx.prefix.getText());
Ip nextHopIp = Route.UNSET_ROUTE_NEXT_HOP_IP;
String nextHopInterface = null;
if (ctx.nhip != null) {
nextHopIp = new Ip(ctx.nhip.getText());
}
if (ctx.nhint != null) {
nextHopInterface = getCanonicalInterfaceName(ctx.nhint.getText());
}
int distance = DEFAULT_STATIC_ROUTE_DISTANCE;
if (ctx.distance != null) {
distance = toInteger(ctx.distance);
}
Integer tag = null;
if (ctx.tag != null) {
tag = toInteger(ctx.tag);
}
boolean permanent = ctx.PERMANENT() != null;
Integer track = null;
if (ctx.track != null) {
// TODO: handle named instead of numbered track
}
StaticRoute route = new StaticRoute(prefix, nextHopIp, nextHopInterface, distance, tag, track, permanent);
currentVrf().getStaticRoutes().add(route);
} else if (ctx.prefix6 != null) {
// TODO: ipv6 static route
}
}
Aggregations