@Test(expected = IllegalArgumentException.class) public void testToTransformationStepsNotStaticNat() { NatRuleThenPrefixName thenPrefix1 = new NatRuleThenPrefixName("prefix", DESTINATION); thenPrefix1.toTransformationSteps(new Nat(Type.SOURCE), null, null, null); }
@Override public List<TransformationStep> toTransformationSteps( Nat nat, @Nullable Map<String, AddressBookEntry> addressBookEntryMap, Ip interfaceIp, Warnings warnings) { checkArgument(nat.getType() == Type.STATIC, "prefix name is only supported in static nat"); checkArgument(addressBookEntryMap != null, "address book cannot be null"); AddressBookEntry addressBookEntry = addressBookEntryMap.get(_name); if (!(addressBookEntry instanceof AddressAddressBookEntry)) { throw new BatfishException("unknown address book entry"); } AddressAddressBookEntry addressAddressBookEntry = (AddressAddressBookEntry) addressBookEntry; Prefix subnet = addressAddressBookEntry.getIpWildcard().toPrefix(); return ImmutableList.of( new ShiftIpAddressIntoSubnet(TransformationType.STATIC_NAT, _ipField, subnet)); }
NatRuleThenPrefixName implements NatRuleThen, Serializable { @Override public List<TransformationStep> toTransformationSteps( Nat nat, @Nullable Map<String, AddressBookEntry> addressBookEntryMap, Ip interfaceIp, Warnings warnings) { checkArgument(nat.getType() == Type.STATIC, "prefix name is only supported in static nat"); checkArgument(addressBookEntryMap != null, "address book cannot be null"); AddressBookEntry addressBookEntry = addressBookEntryMap.get(_name); if (!(addressBookEntry instanceof AddressAddressBookEntry)) { throw new BatfishException("unknown address book entry"); } AddressAddressBookEntry addressAddressBookEntry = (AddressAddressBookEntry) addressBookEntry; Prefix subnet = addressAddressBookEntry.getIpWildcard().toPrefix(); return ImmutableList.of( new ShiftIpAddressIntoSubnet(TransformationType.STATIC_NAT, _ipField, subnet)); } }
NatRuleThenPrefixName implements NatRuleThen, Serializable { @Override public List<TransformationStep> toTransformationSteps( Nat nat, @Nullable Map<String, AddressBookEntry> addressBookEntryMap, Ip interfaceIp, Warnings warnings) { checkArgument(nat.getType() == Type.STATIC, "prefix name is only supported in static nat"); checkArgument(addressBookEntryMap != null, "address book cannot be null"); AddressBookEntry addressBookEntry = addressBookEntryMap.get(_name); if (!(addressBookEntry instanceof AddressAddressBookEntry)) { throw new BatfishException("unknown address book entry"); } AddressAddressBookEntry addressAddressBookEntry = (AddressAddressBookEntry) addressBookEntry; Prefix subnet = addressAddressBookEntry.getIpWildcard().toPrefix(); return ImmutableList.of( new ShiftIpAddressIntoSubnet(TransformationType.STATIC_NAT, _ipField, subnet)); } NatRuleThenPrefixName(String name, IpField ipField); }
NatRuleThenPrefixName implements NatRuleThen, Serializable { @Override public List<TransformationStep> toTransformationSteps( Nat nat, @Nullable Map<String, AddressBookEntry> addressBookEntryMap, Ip interfaceIp, Warnings warnings) { checkArgument(nat.getType() == Type.STATIC, "prefix name is only supported in static nat"); checkArgument(addressBookEntryMap != null, "address book cannot be null"); AddressBookEntry addressBookEntry = addressBookEntryMap.get(_name); if (!(addressBookEntry instanceof AddressAddressBookEntry)) { throw new BatfishException("unknown address book entry"); } AddressAddressBookEntry addressAddressBookEntry = (AddressAddressBookEntry) addressBookEntry; Prefix subnet = addressAddressBookEntry.getIpWildcard().toPrefix(); return ImmutableList.of( new ShiftIpAddressIntoSubnet(TransformationType.STATIC_NAT, _ipField, subnet)); } NatRuleThenPrefixName(String name, IpField ipField); String getName(); @Override boolean equals(Object o); @Override int hashCode(); @Override List<TransformationStep> toTransformationSteps(
      Nat nat,
      @Nullable Map<String, AddressBookEntry> addressBookEntryMap,
      Ip interfaceIp,
      Warnings warnings); }
NatRuleThenPrefixName implements NatRuleThen, Serializable { @Override public List<TransformationStep> toTransformationSteps( Nat nat, @Nullable Map<String, AddressBookEntry> addressBookEntryMap, Ip interfaceIp, Warnings warnings) { checkArgument(nat.getType() == Type.STATIC, "prefix name is only supported in static nat"); checkArgument(addressBookEntryMap != null, "address book cannot be null"); AddressBookEntry addressBookEntry = addressBookEntryMap.get(_name); if (!(addressBookEntry instanceof AddressAddressBookEntry)) { throw new BatfishException("unknown address book entry"); } AddressAddressBookEntry addressAddressBookEntry = (AddressAddressBookEntry) addressBookEntry; Prefix subnet = addressAddressBookEntry.getIpWildcard().toPrefix(); return ImmutableList.of( new ShiftIpAddressIntoSubnet(TransformationType.STATIC_NAT, _ipField, subnet)); } NatRuleThenPrefixName(String name, IpField ipField); String getName(); @Override boolean equals(Object o); @Override int hashCode(); @Override List<TransformationStep> toTransformationSteps(
      Nat nat,
      @Nullable Map<String, AddressBookEntry> addressBookEntryMap,
      Ip interfaceIp,
      Warnings warnings);  }