Tabnine Logo
IpSpaceAssignment$Entry
Code IndexAdd Tabnine to your IDE (free)

How to use
IpSpaceAssignment$Entry
in
org.batfish.specifier

Best Java code snippets using org.batfish.specifier.IpSpaceAssignment$Entry (Showing top 13 results out of 315)

origin: batfish/batfish

    .filter(e -> !e.getIpSpace().equals(EmptyIpSpace.INSTANCE))
    .collect(ImmutableList.toImmutableList());
checkArgument(
  headerSrcIp,
  nonEmptyIpSpaces);
IpSpace space = srcIps.getEntries().iterator().next().getIpSpace();
Optional<Ip> srcIp = _ipSpaceRepresentative.getRepresentative(space);
    .filter(e -> e.getLocations().contains(srcLocation))
    .findFirst();
  "Cannot resolve a source IP address from location %s",
  _sourceLocationStr);
Optional<Ip> srcIp = _ipSpaceRepresentative.getRepresentative(entry.get().getIpSpace());
checkArgument(
  srcIp.isPresent(),
origin: batfish/batfish

public Builder assign(Set<Location> locations, IpSpace ipSpace) {
 int oldSize = _allLocations.size();
 _allLocations.addAll(locations);
 checkArgument(_allLocations.size() == oldSize + locations.size(), "duplicate location(s)");
 _entries.add(new Entry(ipSpace, locations));
 return this;
}
origin: batfish/batfish

.flatMap(entry -> entry.getLocations().stream())
.collect(ImmutableSet.toImmutableSet());
origin: batfish/batfish

    .filter(e -> !e.getIpSpace().equals(EmptyIpSpace.INSTANCE))
    .collect(ImmutableList.toImmutableList());
checkArgument(
  nonEmptyIpSpaces);
IpSpace space = nonEmptyIpSpaces.iterator().next().getIpSpace();
Optional<Ip> srcIp = _ipSpaceRepresentative.getRepresentative(space);
checkArgument(srcIp.isPresent(), "Specified source: %s has no IPs", headerSrcIp);
    .filter(e -> e.getLocations().contains(srcLocation))
    .findFirst();
Optional<Ip> srcIp = _ipSpaceRepresentative.getRepresentative(entry.get().getIpSpace());
checkArgument(
  srcIp.isPresent(),
origin: batfish/batfish

entry ->
  entry
    .getLocations()
    .forEach(
      location ->
        ipSpacePerLocation.merge(
          location.accept(toIngressLocation),
          entry.getIpSpace(),
          ((ipSpace1, ipSpace2) -> AclIpSpace.union(ipSpace1, ipSpace2)))));
origin: batfish/batfish

private void setDstIp(PacketHeaderConstraints constraints, Builder builder) {
 String headerDstIp = constraints.getDstIps();
 if (headerDstIp != null) {
  IpSpaceSpecifier dstIpSpecifier =
    IpSpaceSpecifierFactory.load(IP_SPECIFIER_FACTORY).buildIpSpaceSpecifier(headerDstIp);
  IpSpaceAssignment dstIps =
    dstIpSpecifier.resolve(ImmutableSet.of(), _batfish.specifierContext());
  // Filter out empty IP assignments
  ImmutableList<Entry> nonEmptyIpSpaces =
    dstIps.getEntries().stream()
      .filter(e -> !e.getIpSpace().equals(EmptyIpSpace.INSTANCE))
      .collect(ImmutableList.toImmutableList());
  checkArgument(
    nonEmptyIpSpaces.size() > 0,
    "At least one destination IP is required, could not resolve any");
  checkArgument(
    nonEmptyIpSpaces.size() == 1,
    "Specified destination: %s, resolves to more than one IP",
    headerDstIp);
  IpSpace space = nonEmptyIpSpaces.iterator().next().getIpSpace();
  Optional<Ip> dstIp = _ipSpaceRepresentative.getRepresentative(space);
  checkArgument(dstIp.isPresent(), "Specified destination: %s has no IPs", headerDstIp);
  builder.setDstIp(dstIp.get());
 } else {
  builder.setDstIp(DEFAULT_IP_ADDRESS);
 }
}
origin: batfish/batfish

private Map<StateExpr, BDD> rootConstraints(
  IpSpaceAssignment srcIpSpaceAssignment, BDD initialHeaderSpaceBdd) {
 LocationVisitor<Optional<StateExpr>> locationToStateExpr = getLocationToStateExpr();
 IpSpaceToBDD srcIpSpaceToBDD =
   new MemoizedIpSpaceToBDD(_bddPacket.getSrcIp(), ImmutableMap.of());
 // convert Locations to StateExprs, and merge srcIp constraints
 Map<StateExpr, BDD> rootConstraints = new HashMap<>();
 for (IpSpaceAssignment.Entry entry : srcIpSpaceAssignment.getEntries()) {
  BDD srcIpSpaceBDD = entry.getIpSpace().accept(srcIpSpaceToBDD);
  entry.getLocations().stream()
    .map(locationToStateExpr::visit)
    .filter(Optional::isPresent)
    .map(Optional::get)
    .forEach(root -> rootConstraints.merge(root, srcIpSpaceBDD, BDD::or));
 }
 // add the global initial HeaderSpace and remove unsat entries
 Map<StateExpr, BDD> finalRootConstraints =
   rootConstraints.entrySet().stream()
     .map(
       entry ->
         Maps.immutableEntry(
           entry.getKey(), entry.getValue().and(initialHeaderSpaceBdd)))
     .filter(entry -> !entry.getValue().isZero())
     .collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue));
 // make sure there is at least one possible source
 checkArgument(
   !finalRootConstraints.isEmpty(),
   "No sources are compatible with the headerspace constraint");
 return finalRootConstraints;
}
origin: batfish/batfish

 @Test
 public void resolve() {
  ReferenceBook book =
    ReferenceBook.builder("book1")
      .setAddressGroups(
        ImmutableList.of(
          new AddressGroup(
            ImmutableSortedSet.of("1.1.1.1", "2.2.2.2:0.0.0.8"), "group1")))
      .build();
  MockSpecifierContext ctxt =
    MockSpecifierContext.builder().setReferenceBooks(ImmutableSortedSet.of(book)).build();

  ReferenceAddressGroupIpSpaceSpecifier specifier =
    new ReferenceAddressGroupIpSpaceSpecifier("group1", "book1");
  IpSpace resolvedSpace =
    AclIpSpace.union(
      specifier.resolve(ImmutableSet.of(), ctxt).getEntries().stream()
        .map(e -> e.getIpSpace())
        .collect(Collectors.toSet()));

  assertThat(
    resolvedSpace,
    equalTo(
      AclIpSpace.union(
        new IpWildcard("1.1.1.1").toIpSpace(),
        new IpWildcard("2.2.2.2:0.0.0.8").toIpSpace())));
 }
}
origin: batfish/batfish

@VisibleForTesting
static TableAnswerElement resolveIpSpaceOfLocation(
  SpecifiersQuestion question, SpecifierContext context) {
 List<ColumnMetadata> columns =
   ImmutableList.of(
     new ColumnMetadata(COL_LOCATIONS, Schema.STRING, "Resolution", false, false),
     new ColumnMetadata(COL_IP_SPACE, Schema.STRING, "IP space", false, false));
 TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns));
 Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap();
 Set<Location> locations = question.getLocationSpecifier().resolve(context);
 IpSpaceAssignment ipSpaceAssignment =
   question.getIpSpaceSpecifier().resolve(locations, context);
 for (IpSpaceAssignment.Entry entry : ipSpaceAssignment.getEntries()) {
  table.addRow(
    Row.of(
      columnMap,
      COL_LOCATIONS,
      entry.getLocations().toString(),
      COL_IP_SPACE,
      Objects.toString(entry.getIpSpace())));
 }
 return table;
}
origin: batfish/batfish

@VisibleForTesting
IpSpaceAssignment resolveSourceIpSpaceAssignment() throws InvalidReachabilityParametersException {
 Set<Location> sourceLocations =
   _params.getSourceLocationSpecifier().resolve(_context).stream()
     .filter(l -> isActive(l, _configs))
     .collect(ImmutableSet.toImmutableSet());
 if (sourceLocations.isEmpty()) {
  throw new InvalidReachabilityParametersException("No matching source locations");
 }
 // resolve the IpSpaceSpecifier, and filter out entries with empty IpSpaces
 IpSpaceAssignment sourceIpSpaceAssignment =
   IpSpaceAssignment.of(
     _params.getSourceIpSpaceSpecifier().resolve(sourceLocations, _context).getEntries()
       .stream()
       .filter(
         entry ->
           _ipSpaceRepresentative.getRepresentative(entry.getIpSpace()).isPresent())
       .collect(ImmutableList.toImmutableList()));
 if (sourceIpSpaceAssignment.getEntries().isEmpty()) {
  throw new InvalidReachabilityParametersException("All sources have empty source IpSpaces");
 }
 return sourceIpSpaceAssignment;
}
origin: batfish/batfish

private void setDstIp(PacketHeaderConstraints constraints, Flow.Builder builder) {
 String headerDstIp = constraints.getDstIps();
 checkArgument(
   constraints.getDstIps() != null, "Cannot perform traceroute without a destination");
 IpSpaceSpecifier dstIpSpecifier =
   IpSpaceSpecifierFactory.load(IP_SPECIFIER_FACTORY).buildIpSpaceSpecifier(headerDstIp);
 IpSpaceAssignment dstIps = dstIpSpecifier.resolve(ImmutableSet.of(), _specifierContext);
 checkArgument(
   dstIps.getEntries().size() == 1,
   "Specified destination: %s, resolves to more than one IP",
   headerDstIp);
 IpSpace space = dstIps.getEntries().iterator().next().getIpSpace();
 Optional<Ip> dstIp = _ipSpaceRepresentative.getRepresentative(space);
 checkArgument(dstIp.isPresent(), "At least one destination IP is required");
 builder.setDstIp(dstIp.get());
}
origin: batfish/batfish

@VisibleForTesting
static TableAnswerElement resolveIpSpace(SpecifiersQuestion question, SpecifierContext context) {
 List<ColumnMetadata> columns =
   ImmutableList.of(new ColumnMetadata(COL_IP_SPACE, Schema.STRING, "IP space", false, false));
 TableAnswerElement table = new TableAnswerElement(new TableMetadata(columns));
 Map<String, ColumnMetadata> columnMap = table.getMetadata().toColumnMap();
 // this will yield all default locations for the factory
 Set<Location> locations = question.getLocationSpecifier().resolve(context);
 IpSpaceAssignment ipSpaceAssignment =
   question.getIpSpaceSpecifier().resolve(locations, context);
 for (IpSpaceAssignment.Entry entry : ipSpaceAssignment.getEntries()) {
  table.addRow(Row.of(columnMap, COL_IP_SPACE, Objects.toString(entry.getIpSpace())));
 }
 return table;
}
origin: batfish/batfish

public Builder assign(Location location, IpSpace ipSpace) {
 checkArgument(_allLocations.add(location), "duplicate location: %s", location);
 _entries.add(new Entry(ipSpace, ImmutableSet.of(location)));
 return this;
}
org.batfish.specifierIpSpaceAssignment$Entry

Most used methods

  • getIpSpace
  • getLocations
  • <init>

Popular in Java

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JButton (javax.swing)
  • Runner (org.openjdk.jmh.runner)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now