/** @see #addWarning(ParserRuleContext, String, BatfishCombinedParser, String) */ public void todo( @Nonnull ParserRuleContext ctx, @Nonnull String line, @Nonnull BatfishCombinedParser<?, ?> parser) { addWarning(ctx, line, parser, "This feature is not currently supported"); }
@VisibleForTesting long sanitizeAsn(long asn, int bytes, ParserRuleContext ctx) { long mask; if (bytes == 2) { mask = 0xFFFF; } else { assert bytes == 4; mask = 0xFFFFFFFF; } if ((asn & mask) != asn) { _w.addWarning( ctx, ctx.getText(), _parser, String.format("AS number %s is out of the legal %s-byte AS range", asn, bytes)); return 0; } return asn; }
@Override public void exitIf_no_security_level(If_no_security_levelContext ctx) { if (_currentInterfaces.size() != 1) { _w.addWarning( ctx, getFullText(ctx), _parser, "Security level can only be configured in single-interface context"); return; } _currentInterfaces.get(0).setSecurityLevel(0); }
@Override public void exitIf_security_level(If_security_levelContext ctx) { if (_currentInterfaces.size() != 1) { _w.addWarning( ctx, getFullText(ctx), _parser, "Security level can only be configured in single-interface context"); return; } _currentInterfaces.get(0).setSecurityLevel(toInteger(ctx.level)); }
@Override public void exitReafi_passive_interface(Reafi_passive_interfaceContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } // In interface context if (_currentEigrpInterface == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP interface available"); return; } boolean passive = (ctx.NO() == null); if (_currentEigrpInterface.equals("default")) { _currentEigrpProcess.setPassiveInterfaceDefault(passive); } else { _currentEigrpProcess.getInterfacePassiveStatus().put(_currentEigrpInterface, passive); } }
@Override public void exitRe_passive_interface_default(Re_passive_interface_defaultContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } boolean passive = (ctx.NO() == null); _currentEigrpProcess.setPassiveInterfaceDefault(passive); }
@Override public void exitRe_autonomous_system(Re_autonomous_systemContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } Long asn = (ctx.NO() == null) ? toLong(ctx.asnum) : null; _currentEigrpProcess.setAsn(asn); }
@Override public void exitRe_redistribute_isis(Re_redistribute_isisContext ctx) { if (ctx.map != null) { String mapname = ctx.map.getText(); _configuration.referenceStructure( ROUTE_MAP, mapname, EIGRP_REDISTRIBUTE_ISIS_MAP, ctx.map.getStart().getLine()); } _w.addWarning( ctx, getFullText(ctx), _parser, "ISIS redistribution in EIGRP is not implemented"); }
@Override public void exitRe_network(Re_networkContext ctx) { if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } // In process context Ip address = toIp(ctx.address); Ip mask = (ctx.mask != null) ? toIp(ctx.mask) : address.getClassMask().inverted(); _currentEigrpProcess.getWildcardNetworks().add(new IpWildcard(address, mask)); }
@Override public void exitRe_eigrp_router_id(Re_eigrp_router_idContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } if (ctx.NO() == null) { Ip routerId = toIp(ctx.id); _currentEigrpProcess.setRouterId(routerId); } else { _currentEigrpProcess.setRouterId(null); } }
@Override public void exitRe_default_metric(Re_default_metricContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } if (ctx.NO() == null) { EigrpMetric metric = toEigrpMetric(ctx, ctx.bw_kbps, ctx.delay_10us, ctx.reliability, ctx.eff_bw, ctx.mtu); _currentEigrpProcess.setDefaultMetric(metric); } else { _currentEigrpProcess.setDefaultMetric(null); } }
@Override public void exitRe_passive_interface(Re_passive_interfaceContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } boolean passive = (ctx.NO() == null); String interfaceName = getCanonicalInterfaceName(ctx.i.getText()); _currentEigrpProcess.getInterfacePassiveStatus().put(interfaceName, passive); _configuration.referenceStructure( INTERFACE, interfaceName, EIGRP_PASSIVE_INTERFACE, ctx.i.getStart().getLine()); }
_w.addWarning( ctx, getFullText(ctx), _w.addWarning( ctx, getFullText(ctx),
@Override public void exitRe_redistribute_static(Re_redistribute_staticContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } RoutingProtocol sourceProtocol = RoutingProtocol.STATIC; EigrpRedistributionPolicy r = new EigrpRedistributionPolicy(sourceProtocol); _currentEigrpProcess.getRedistributionPolicies().put(sourceProtocol, r); if (!ctx.METRIC().isEmpty()) { EigrpMetric metric = toEigrpMetric(ctx, ctx.bw_kbps, ctx.delay_10us, ctx.reliability, ctx.eff_bw, ctx.mtu); r.setMetric(metric); } if (ctx.map != null) { String mapname = ctx.map.getText(); int mapLine = ctx.map.getStart().getLine(); r.setRouteMap(mapname); r.setRouteMapLine(mapLine); _configuration.referenceStructure(ROUTE_MAP, mapname, EIGRP_REDISTRIBUTE_STATIC_MAP, mapLine); } }
@Override public void exitRe_redistribute_connected(Re_redistribute_connectedContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } RoutingProtocol sourceProtocol = RoutingProtocol.CONNECTED; EigrpRedistributionPolicy r = new EigrpRedistributionPolicy(sourceProtocol); _currentEigrpProcess.getRedistributionPolicies().put(sourceProtocol, r); if (!ctx.METRIC().isEmpty()) { EigrpMetric metric = toEigrpMetric(ctx, ctx.bw_kbps, ctx.delay_10us, ctx.reliability, ctx.eff_bw, ctx.mtu); r.setMetric(metric); } if (ctx.map != null) { String mapname = ctx.map.getText(); int mapLine = ctx.map.getStart().getLine(); r.setRouteMap(mapname); r.setRouteMapLine(mapLine); _configuration.referenceStructure( ROUTE_MAP, mapname, EIGRP_REDISTRIBUTE_CONNECTED_MAP, mapLine); } }
@Override public void exitRe_redistribute_eigrp(Re_redistribute_eigrpContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } RoutingProtocol sourceProtocol = RoutingProtocol.EIGRP; EigrpRedistributionPolicy r = new EigrpRedistributionPolicy(sourceProtocol); _currentEigrpProcess.getRedistributionPolicies().put(sourceProtocol, r); long asn = toLong(ctx.asn); r.getSpecialAttributes().put(EigrpRedistributionPolicy.EIGRP_AS_NUMBER, asn); if (!ctx.METRIC().isEmpty()) { EigrpMetric metric = toEigrpMetric(ctx, ctx.bw_kbps, ctx.delay_10us, ctx.reliability, ctx.eff_bw, ctx.mtu); r.setMetric(metric); } if (ctx.map != null) { String mapname = ctx.map.getText(); int mapLine = ctx.map.getStart().getLine(); r.setRouteMap(mapname); r.setRouteMapLine(mapLine); _configuration.referenceStructure(ROUTE_MAP, mapname, EIGRP_REDISTRIBUTE_EIGRP_MAP, mapLine); } }
@Override public void exitRe_redistribute_rip(Re_redistribute_ripContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } RoutingProtocol sourceProtocol = RoutingProtocol.RIP; EigrpRedistributionPolicy r = new EigrpRedistributionPolicy(sourceProtocol); _currentEigrpProcess.getRedistributionPolicies().put(sourceProtocol, r); if (!ctx.METRIC().isEmpty()) { EigrpMetric metric = toEigrpMetric(ctx, ctx.bw_kbps, ctx.delay_10us, ctx.reliability, ctx.eff_bw, ctx.mtu); r.setMetric(metric); } if (ctx.map != null) { String mapname = ctx.map.getText(); int mapLine = ctx.map.getStart().getLine(); r.setRouteMap(mapname); r.setRouteMapLine(mapLine); _configuration.referenceStructure(ROUTE_MAP, mapname, EIGRP_REDISTRIBUTE_RIP_MAP, mapLine); } }
@Override public void exitRe_redistribute_bgp(Re_redistribute_bgpContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } RoutingProtocol sourceProtocol = RoutingProtocol.BGP; EigrpRedistributionPolicy r = new EigrpRedistributionPolicy(sourceProtocol); _currentEigrpProcess.getRedistributionPolicies().put(sourceProtocol, r); long as = toAsNum(ctx.asn); r.getSpecialAttributes().put(EigrpRedistributionPolicy.BGP_AS, as); if (!ctx.METRIC().isEmpty()) { EigrpMetric metric = toEigrpMetric(ctx, ctx.bw_kbps, ctx.delay_10us, ctx.reliability, ctx.eff_bw, ctx.mtu); r.setMetric(metric); } if (ctx.map != null) { String mapname = ctx.map.getText(); int mapLine = ctx.map.getStart().getLine(); r.setRouteMap(mapname); r.setRouteMapLine(mapLine); _configuration.referenceStructure(ROUTE_MAP, mapname, EIGRP_REDISTRIBUTE_BGP_MAP, mapLine); } }
@Override public void exitRe_redistribute_ospf(Re_redistribute_ospfContext ctx) { // In process context if (_currentEigrpProcess == null) { _w.addWarning(ctx, getFullText(ctx), _parser, "No EIGRP process available"); return; } RoutingProtocol sourceProtocol = RoutingProtocol.OSPF; EigrpRedistributionPolicy r = new EigrpRedistributionPolicy(sourceProtocol); _currentEigrpProcess.getRedistributionPolicies().put(sourceProtocol, r); int procNum = toInteger(ctx.proc); r.getSpecialAttributes().put(EigrpRedistributionPolicy.OSPF_PROCESS_NUMBER, procNum); if (ctx.MATCH() != null) { todo(ctx); } if (!ctx.METRIC().isEmpty()) { EigrpMetric metric = toEigrpMetric(ctx, ctx.bw_kbps, ctx.delay_10us, ctx.reliability, ctx.eff_bw, ctx.mtu); r.setMetric(metric); } if (ctx.map != null) { String mapname = ctx.map.getText(); int mapLine = ctx.map.getStart().getLine(); r.setRouteMap(mapname); r.setRouteMapLine(mapLine); _configuration.referenceStructure(ROUTE_MAP, mapname, EIGRP_REDISTRIBUTE_OSPF_MAP, mapLine); } }
@Override public void exitRs_packet_location(Rs_packet_locationContext ctx) { NatPacketLocation packetLocation; if (ctx.FROM() != null) { packetLocation = _currentNatRuleSet.getFromLocation(); } else { // TO if (_currentNat.getType() != Nat.Type.SOURCE) { _w.addWarning( ctx, getFullText(ctx), _parser, "'to' is illegal for non-source NATs. Ignoring statement."); return; } packetLocation = _currentNatRuleSet.getToLocation(); } if (ctx.rs_interface() != null) { packetLocation.setInterface(ctx.rs_interface().name.getText()); } else if (ctx.rs_routing_instance() != null) { packetLocation.setRoutingInstance(ctx.rs_routing_instance().name.getText()); } else if (ctx.rs_zone() != null) { packetLocation.setZone(ctx.rs_zone().name.getText()); } }