use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitRedistribute_static_bgp_tail.
@Override
public void exitRedistribute_static_bgp_tail(Redistribute_static_bgp_tailContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
// Intentional identity comparison
if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
RoutingProtocol sourceProtocol = RoutingProtocol.STATIC;
BgpRedistributionPolicy r = new BgpRedistributionPolicy(sourceProtocol);
proc.getRedistributionPolicies().put(sourceProtocol, r);
if (ctx.metric != null) {
long metric = toLong(ctx.metric);
r.setMetric(metric);
}
if (ctx.map != null) {
String map = ctx.map.getText();
int mapLine = ctx.map.getStart().getLine();
r.setRouteMap(map);
r.setRouteMapLine(mapLine);
}
} else if (_currentIpPeerGroup != null || _currentNamedPeerGroup != null) {
throw new BatfishException("do not currently handle per-neighbor redistribution policies");
}
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterAf_group_rb_stanza.
@Override
public void enterAf_group_rb_stanza(Af_group_rb_stanzaContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
String name = ctx.name.getText();
int definitionLine = ctx.name.getStart().getLine();
// String af = ctx.bgp_address_family().getText();
NamedBgpPeerGroup afGroup = proc.getAfGroups().get(name);
if (afGroup == null) {
proc.addNamedPeerGroup(name, definitionLine);
afGroup = proc.getNamedPeerGroups().get(name);
}
pushPeer(afGroup);
_currentNamedPeerGroup = afGroup;
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitNo_redistribute_connected_rb_stanza.
@Override
public void exitNo_redistribute_connected_rb_stanza(No_redistribute_connected_rb_stanzaContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
// Intentional identity comparison
if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
RoutingProtocol sourceProtocol = RoutingProtocol.CONNECTED;
proc.getRedistributionPolicies().remove(sourceProtocol);
} else if (_currentIpPeerGroup != null || _currentNamedPeerGroup != null) {
throw new BatfishException("do not currently handle per-neighbor redistribution policies");
}
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitNetwork_bgp_tail.
@Override
public void exitNetwork_bgp_tail(Network_bgp_tailContext ctx) {
Prefix prefix;
if (ctx.prefix != null) {
prefix = Prefix.parse(ctx.prefix.getText());
} else {
Ip address = toIp(ctx.ip);
Ip mask = (ctx.mask != null) ? toIp(ctx.mask) : address.getClassMask();
int prefixLength = mask.numSubnetBits();
prefix = new Prefix(address, prefixLength);
}
String map = null;
Integer mapLine = null;
if (ctx.mapname != null) {
map = ctx.mapname.getText();
mapLine = ctx.mapname.getStart().getLine();
}
BgpNetwork bgpNetwork = new BgpNetwork(prefix, map, mapLine);
BgpProcess proc = currentVrf().getBgpProcess();
proc.getIpNetworks().put(prefix, bgpNetwork);
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitAggregate_address_rb_stanza.
@Override
public void exitAggregate_address_rb_stanza(Aggregate_address_rb_stanzaContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
// Intentional identity comparison
if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
boolean summaryOnly = ctx.summary_only != null;
boolean asSet = ctx.as_set != null;
if (ctx.network != null || ctx.prefix != null) {
// ipv4
Prefix prefix;
if (ctx.network != null) {
Ip network = toIp(ctx.network);
Ip subnet = toIp(ctx.subnet);
int prefixLength = subnet.numSubnetBits();
prefix = new Prefix(network, prefixLength);
} else {
// ctx.prefix != null
prefix = Prefix.parse(ctx.prefix.getText());
}
BgpAggregateIpv4Network net = new BgpAggregateIpv4Network(prefix);
net.setAsSet(asSet);
net.setSummaryOnly(summaryOnly);
if (ctx.mapname != null) {
String mapName = ctx.mapname.getText();
int mapLine = ctx.mapname.getStart().getLine();
net.setAttributeMap(mapName);
net.setAttributeMapLine(mapLine);
}
proc.getAggregateNetworks().put(prefix, net);
} else if (ctx.ipv6_prefix != null) {
// ipv6
Prefix6 prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
BgpAggregateIpv6Network net = new BgpAggregateIpv6Network(prefix6);
net.setAsSet(asSet);
net.setSummaryOnly(summaryOnly);
if (ctx.mapname != null) {
String mapName = ctx.mapname.getText();
int mapLine = ctx.mapname.getStart().getLine();
net.setAttributeMap(mapName);
net.setAttributeMapLine(mapLine);
}
proc.getAggregateIpv6Networks().put(prefix6, net);
}
} else if (_currentIpPeerGroup != null || _currentIpv6PeerGroup != null || _currentDynamicIpPeerGroup != null || _currentDynamicIpv6PeerGroup != null || _currentNamedPeerGroup != null) {
throw new BatfishException("unexpected occurrence in peer group/neighbor context");
} else if (ctx.mapname != null) {
String map = ctx.mapname.getText();
int line = ctx.mapname.getStart().getLine();
_configuration.getBgpVrfAggregateAddressRouteMaps().add(map);
_configuration.referenceStructure(CiscoStructureType.ROUTE_MAP, map, CiscoStructureUsage.BGP_VRF_AGGREGATE_ROUTE_MAP, line);
}
}
Aggregations