public InterfaceAddress(@Nonnull Ip ip, @Nonnull Ip networkMask) { _ip = ip; _networkBits = networkMask.numSubnetBits(); }
public static Prefix create(Ip address, Ip mask) { return create(address, mask.numSubnetBits()); }
public String networkString(Ip mask) { return toString() + "/" + mask.numSubnetBits(); }
@Override public void exitIf_ip_address_secondary(If_ip_address_secondaryContext ctx) { Ip ip; Ip mask; InterfaceAddress address; if (ctx.prefix != null) { address = new InterfaceAddress(ctx.prefix.getText()); } else { ip = toIp(ctx.ip); mask = toIp(ctx.subnet); address = new InterfaceAddress(ip, mask.numSubnetBits()); } for (Interface currentInterface : _currentInterfaces) { currentInterface.getSecondaryAddresses().add(address); } }
private void addNullRouteEdges() { for (Entry<String, List<StaticRoute>> entry : _nullStaticRoutes.entrySet()) { String router = entry.getKey(); List<StaticRoute> srs = entry.getValue(); for (StaticRoute sr : srs) { String name = sr.getNextHopInterface(); // Create null route interface Interface iface = new Interface(name); iface.setActive(true); iface.setAddress( new InterfaceAddress(sr.getNetwork().getStartIp(), sr.getNextHopIp().numSubnetBits())); iface.setBandwidth(0.); // Add static route to all static routes list Map<String, List<StaticRoute>> map = _staticRoutes.get(router); List<StaticRoute> routes = map.computeIfAbsent(name, k -> new ArrayList<>()); routes.add(sr); // Create and add graph edge for null route GraphEdge ge = new GraphEdge(iface, null, router, null, false, true); _allRealEdges.add(ge); _allEdges.add(ge); List<GraphEdge> edges = _edgeMap.computeIfAbsent(router, k -> new ArrayList<>()); edges.add(ge); } } }
private static RouteFilterLine toRouteFilterLine(ExtendedAccessListLine fromLine) { LineAction action = fromLine.getAction(); IpWildcard srcIpWildcard = ((WildcardAddressSpecifier) fromLine.getSourceAddressSpecifier()).getIpWildcard(); Ip ip = srcIpWildcard.getIp(); IpWildcard dstIpWildcard = ((WildcardAddressSpecifier) fromLine.getDestinationAddressSpecifier()).getIpWildcard(); long minSubnet = dstIpWildcard.getIp().asLong(); long maxSubnet = minSubnet | dstIpWildcard.getWildcard().asLong(); int minPrefixLength = dstIpWildcard.getIp().numSubnetBits(); int maxPrefixLength = Ip.create(maxSubnet).numSubnetBits(); int statedPrefixLength = srcIpWildcard.getWildcard().inverted().numSubnetBits(); int prefixLength = Math.min(statedPrefixLength, minPrefixLength); Prefix prefix = Prefix.create(ip, prefixLength); return new RouteFilterLine( action, new IpWildcard(prefix), new SubRange(minPrefixLength, maxPrefixLength)); }
@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 = Prefix.create(address, prefixLength); } String map = null; Integer mapLine = null; if (ctx.mapname != null) { map = ctx.mapname.getText(); mapLine = ctx.mapname.getStart().getLine(); _configuration.referenceStructure(ROUTE_MAP, map, BGP_NETWORK_ORIGINATION_ROUTE_MAP, mapLine); } BgpNetwork bgpNetwork = new BgpNetwork(map, mapLine); BgpProcess proc = currentVrf().getBgpProcess(); proc.getIpNetworks().put(prefix, bgpNetwork); }
Ip address = toIp(ctx.address); Ip mask = toIp(ctx.mask); int prefixLength = mask.numSubnetBits(); prefix = Prefix.create(address, prefixLength);
Ip network = toIp(ctx.network); Ip subnet = toIp(ctx.subnet); int prefixLength = subnet.numSubnetBits(); prefix = Prefix.create(network, prefixLength); } else {
if (ctx.mask != null) { Ip mask = toIp(ctx.mask); prefixLength = mask.numSubnetBits(); } else { prefixLength = toInteger(ctx.prefix);