public enum Direction { IN, OUT }
public boolean isHost(String router) { Configuration peerConf = _configurations.get(router); String vendor = peerConf.getConfigurationFormat().getVendorString(); return "host".equals(vendor); }
public Interface(String name, Configuration owner) { this(name, owner, InterfaceType.UNKNOWN); // Determine interface type after setting owner _interfaceType = ((_key == null) || (_owner == null)) ? InterfaceType.UNKNOWN : computeInterfaceType(_key, _owner.getConfigurationFormat()); }
@Override protected ConfigurationFormat featureValueOf(Configuration actual) { return actual.getConfigurationFormat(); } }
private int defaultAdminDistance(Configuration conf, Protocol proto) { RoutingProtocol rp = Protocol.toRoutingProtocol(proto); return rp.getDefaultAdministrativeCost(conf.getConfigurationFormat()); }
public boolean isLoopback(GraphEdge ge) { Configuration conf = _configurations.get(ge.getRouter()); ConfigurationFormat format = conf.getConfigurationFormat(); return ge.getStart().isLoopback(format); }
/** Initialize RIP routes from the interface prefixes */ @VisibleForTesting void initBaseRipRoutes() { if (_vrf.getRipProcess() == null) { return; // nothing to do } // init internal routes from connected routes for (String ifaceName : _vrf.getRipProcess().getInterfaces()) { Interface iface = _vrf.getInterfaces().get(ifaceName); if (iface.getActive()) { Set<Prefix> allNetworkPrefixes = iface.getAllAddresses().stream() .map(InterfaceAddress::getPrefix) .collect(Collectors.toSet()); long cost = RipProcess.DEFAULT_RIP_COST; for (Prefix prefix : allNetworkPrefixes) { RipInternalRoute route = new RipInternalRoute( prefix, Route.UNSET_ROUTE_NEXT_HOP_IP, RoutingProtocol.RIP.getDefaultAdministrativeCost(_c.getConfigurationFormat()), cost); _ripInternalRib.mergeRouteGetDelta(route); } } } }
private void identifyDeviceTypes(Collection<Configuration> configurations) { for (Configuration c : configurations) { if (c.getDeviceType() != null) { continue; } // Set device type to host iff the configuration format is HOST if (c.getConfigurationFormat() == ConfigurationFormat.HOST) { c.setDeviceType(DeviceType.HOST); } else if (c.getVrfs().values().stream() .anyMatch( vrf -> vrf.getBgpProcess() != null || !vrf.getEigrpProcesses().isEmpty() || vrf.getOspfProcess() != null || vrf.getRipProcess() != null)) { // If any vrf on device has BGP, EIGRP, OSPF, or RIP, set device type to router c.setDeviceType(DeviceType.ROUTER); } else { // If device was not a host or router, call it a switch c.setDeviceType(DeviceType.SWITCH); } } }
(nodeName, node) -> { for (Interface iface : node.getAllInterfaces().values()) { if (iface.isLoopback(node.getConfigurationFormat()) || !iface.getActive()) { continue;
int adminCost = RoutingProtocol.OSPF.getDefaultAdministrativeCost(_c.getConfigurationFormat()); SortedSet<Edge> edges = topology.getNodeEdges().get(node); if (edges == null) {
String interfaceName = e2.getKey(); Interface iface = e2.getValue(); if (iface.isLoopback(c.getConfigurationFormat())) { boolean exported = false;
VirtualEigrpProcess(final EigrpProcess process, final String vrfName, final Configuration c) { _asn = process.getAsn(); _defaultExternalAdminCost = RoutingProtocol.EIGRP_EX.getDefaultAdministrativeCost(c.getConfigurationFormat()); _defaultInternalAdminCost = RoutingProtocol.EIGRP.getDefaultAdministrativeCost(c.getConfigurationFormat()); _externalRib = new EigrpExternalRib(); _externalStagingRib = new EigrpExternalRib(); .setAdmin( RoutingProtocol.EIGRP.getDefaultAdministrativeCost( c.getConfigurationFormat())) .setEigrpMetric(iface.getEigrp().getMetric()) .setNetwork(prefix)
if (ge.getStart().isLoopback(conf.getConfigurationFormat())) { return proto.isConnected();
int admin = RoutingProtocol.RIP.getDefaultAdministrativeCost(_c.getConfigurationFormat()); SortedSet<Edge> edges = topology.getNodeEdges().get(node); if (edges == null) {
.setAdmin( RoutingProtocol.OSPF.getDefaultAdministrativeCost( _c.getConfigurationFormat())) .setMetric(cost) .setArea(areaNum)
switch (_c.getConfigurationFormat()) { case JUNIPER: case JUNIPER_SWITCH:
.getOspfMetricType() .toRoutingProtocol() .getDefaultAdministrativeCost(_c.getConfigurationFormat())); outputRouteBuilder.setNetwork(potentialExportRoute.getNetwork()); Long maxMetricExternalNetworks = proc.getMaxMetricExternalNetworks();
int l1Admin = RoutingProtocol.ISIS_L1.getDefaultAdministrativeCost(_c.getConfigurationFormat()); int l2Admin = RoutingProtocol.ISIS_L2.getDefaultAdministrativeCost(_c.getConfigurationFormat()); _isisIncomingRoutes.forEach( (edge, queue) -> {
private void postProcessConfiguration(Configuration c) { // Set device type to host iff the configuration format is HOST if (c.getConfigurationFormat() == ConfigurationFormat.HOST) { c.setDeviceType(DeviceType.HOST); } for (Vrf vrf : c.getVrfs().values()) { // If vrf has BGP, OSPF, or RIP process and device isn't a host, set device type to router if (c.getDeviceType() == null && (vrf.getBgpProcess() != null || vrf.getOspfProcess() != null || vrf.getRipProcess() != null)) { c.setDeviceType(DeviceType.ROUTER); } // Compute OSPF interface costs where they are missing OspfProcess proc = vrf.getOspfProcess(); if (proc != null) { proc.initInterfaceCosts(c); } } // If device was not a host or router, call it a switch if (c.getDeviceType() == null) { c.setDeviceType(DeviceType.SWITCH); } } }
int l1Admin = RoutingProtocol.ISIS_L1.getDefaultAdministrativeCost(_c.getConfigurationFormat()); int l2Admin = RoutingProtocol.ISIS_L2.getDefaultAdministrativeCost(_c.getConfigurationFormat()); IsisLevelSettings l1Settings = proc.getLevel1(); IsisLevelSettings l2Settings = proc.getLevel2();