public ArpTargetHardwareAddress build() { return new ArpTargetHardwareAddressImpl(this); }
public ArpSourceHardwareAddress build() { return new ArpSourceHardwareAddressImpl(this); }
public ArpTargetHardwareAddressBuilder(ArpTargetHardwareAddress base) { this._address = base.getAddress(); this._mask = base.getMask(); if (base instanceof ArpTargetHardwareAddressImpl) { ArpTargetHardwareAddressImpl _impl = (ArpTargetHardwareAddressImpl) base; this.augmentation = new HashMap<>(_impl.augmentation); } }
/** * Builds the arp match with src and destintion mac address. * @param matchBuilder the match builder * @param srcMac the src mac address , will not be added to match if null. * @param dstMac the destination mac address, will not be added to match if null. * @return the match builder with the matches */ public static MatchBuilder addArpMacMatch(MatchBuilder matchBuilder, String srcMac, String dstMac) { ArpMatchBuilder arpMatch = new ArpMatchBuilder(); if (null != srcMac) { ArpSourceHardwareAddressBuilder arpSrc = new ArpSourceHardwareAddressBuilder(); arpSrc.setAddress(new MacAddress(srcMac)); arpMatch.setArpSourceHardwareAddress(arpSrc.build()); } if (null != dstMac) { ArpTargetHardwareAddressBuilder arpDst = new ArpTargetHardwareAddressBuilder(); arpDst.setAddress(new MacAddress(dstMac)); arpMatch.setArpTargetHardwareAddress(arpDst.build()); } matchBuilder.setLayer3Match(arpMatch.build()); return matchBuilder; }
final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder(); arpsrc.setAddress(macsrc); arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00")); final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder(); arpdst.setAddress(macdest); arpdst.setMask(new MacAddress("ff:ff:00:00:00:00")); arpmatch.setArpOp(2); arpmatch.setArpSourceHardwareAddress(arpsrc.build()); arpmatch.setArpTargetHardwareAddress(arpdst.build()); arpmatch.setArpSourceTransportAddress(srcip); arpmatch.setArpTargetTransportAddress(dstip);
/** * Set ARP_SHA Instructions * @param ib Map InstructionBuilder * @param macsrc the macsrc * @return instructionbuilder with new instructions */ public static InstructionBuilder createSrcArpMacInstructions(InstructionBuilder ib, MacAddress macsrc) { List<Action> actionList = new ArrayList<>(); ActionBuilder ab = new ActionBuilder(); SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); ArpMatchBuilder arpmatch = new ArpMatchBuilder(); ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder(); arpsrc.setAddress(macsrc); arpmatch.setArpSourceHardwareAddress(arpsrc.build()); setFieldBuilder.setLayer3Match(arpmatch.build()); ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build()); ab.setOrder(0); ab.setKey(new ActionKey(0)); actionList.add(ab.build()); ApplyActionsBuilder aab = new ApplyActionsBuilder(); aab.setAction(actionList); // Wrap our Apply Action in an Instruction ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); return ib; }
@Override public Optional<MatchBuilder> process(@Nonnull ArpThaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder(); ArpTha arpTha = source.getArpTha(); MacAddress macAddress = arpTha.getMacAddress(); if (macAddress != null) { ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder(); arpTargetHardwareAddressBuilder.setAddress(macAddress); byte[] mask = arpTha.getMask(); if (mask != null) { arpTargetHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils .macAddressToString(mask))); } arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build()); matchBuilder.setLayer3Match(arpMatchBuilder.build()); } return Optional.of(matchBuilder); } }
@Override public Optional<MatchBuilder> process(@Nonnull ArpShaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder(); ArpSha arpSha = source.getArpSha(); MacAddress macAddress = arpSha.getMacAddress(); if (macAddress != null) { ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder(); arpSourceHardwareAddressBuilder.setAddress(macAddress); byte[] mask = arpSha.getMask(); if (mask != null) { arpSourceHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils .macAddressToString(mask))); } arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build()); matchBuilder.setLayer3Match(arpMatchBuilder.build()); } return Optional.of(matchBuilder); } }
/** * Set ARP_THA Instructions * @param ib Map InstructionBuilder * @param macdst the macdst * @return instructionbuilder with new attributes */ public static InstructionBuilder createDstArpMacInstructions(InstructionBuilder ib, MacAddress macdst) { List<Action> actionList = Lists.newArrayList(); ActionBuilder ab = new ActionBuilder(); SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); ArpMatchBuilder arpmatch = new ArpMatchBuilder(); ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder(); arpdst.setAddress(macdst); setFieldBuilder.setLayer3Match(arpmatch.build()); ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build()); ab.setOrder(0); ab.setKey(new ActionKey(0)); actionList.add(ab.build()); ApplyActionsBuilder aab = new ApplyActionsBuilder(); aab.setAction(actionList); // Wrap our Apply Action in an Instruction ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); return ib; }
/** * Creates {@link ArpMatch} containing Reply ARP operation, THA and TPA for the given target * address and SPA for the given sender protocol address */ public static ArpMatch createArpMatch(ArpMessageAddress targetAddress, Ipv4Address senderProtocolAddress) { return new ArpMatchBuilder().setArpOp(ArpOperation.REPLY.intValue()) .setArpTargetHardwareAddress( new ArpTargetHardwareAddressBuilder().setAddress(targetAddress.getHardwareAddress()).build()) .setArpTargetTransportAddress(new Ipv4Prefix(targetAddress.getProtocolAddress().getValue() + HOST_MASK)) .setArpSourceTransportAddress(new Ipv4Prefix(senderProtocolAddress.getValue() + HOST_MASK)) .build(); }
public ArpSourceHardwareAddressBuilder(ArpSourceHardwareAddress base) { this._address = base.getAddress(); this._mask = base.getMask(); if (base instanceof ArpSourceHardwareAddressImpl) { ArpSourceHardwareAddressImpl _impl = (ArpSourceHardwareAddressImpl) base; this.augmentation = new HashMap<>(_impl.augmentation); } }
if (other.getAddress() != null) { return false; } else if(!_address.equals(other.getAddress())) { return false; if (other.getMask() != null) { return false; } else if(!_mask.equals(other.getMask())) { return false; if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { return false;
if (other.getAddress() != null) { return false; } else if(!_address.equals(other.getAddress())) { return false; if (other.getMask() != null) { return false; } else if(!_mask.equals(other.getMask())) { return false; if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { return false;
private static void fillFromArp(Match target, ArpMatch source) { Ipv4Prefix sourceAddress = source.getArpSourceTransportAddress(); if (sourceAddress != null) { target.setField(NW_SRC, inetAddressFrom(sourceAddress), null); } Ipv4Prefix destAddress = source.getArpTargetTransportAddress(); if (destAddress != null) { target.setField(NW_DST, inetAddressFrom(destAddress), null); } ArpSourceHardwareAddress sourceHwAddress = source.getArpSourceHardwareAddress(); if (sourceHwAddress != null) { target.setField(DL_SRC, bytesFrom(sourceHwAddress.getAddress())); } ArpTargetHardwareAddress targetHwAddress = source.getArpTargetHardwareAddress(); if (targetHwAddress != null) { target.setField(DL_DST, bytesFrom(targetHwAddress.getAddress())); } target.setField(DL_TYPE, ETHERNET_ARP); }
private ArpSourceHardwareAddressImpl(ArpSourceHardwareAddressBuilder base) { this._address = base.getAddress(); this._mask = base.getMask(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
private ArpTargetHardwareAddressImpl(ArpTargetHardwareAddressBuilder base) { this._address = base.getAddress(); this._mask = base.getMask(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
private static Layer3Match setLayer3MatchAsArp(final Match sourceMatch, final Inet4Address inetSourceAddress, final Inet4Address inetDestAddress) { String inetSourceAddressStr = InetAddresses .toAddrString(inetSourceAddress); Ipv4Prefix ipv4SourcePrefix = new Ipv4Prefix(inetSourceAddressStr + "/32"); String inetDestAddressValue = InetAddresses .toAddrString(inetDestAddress); Ipv4Prefix ipv4DestPrefix = new Ipv4Prefix(inetDestAddressValue + "/32"); ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder(); arpMatchBuilder.setArpSourceTransportAddress(ipv4SourcePrefix); arpMatchBuilder.setArpTargetTransportAddress(ipv4DestPrefix); ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder(); arpSourceHardwareAddressBuilder .setAddress(ethernetSourceAddress(sourceMatch)); arpMatchBuilder .setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder .build()); ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new ArpTargetHardwareAddressBuilder(); arpTargetHardwareAddressBuilder .setAddress(ethernetDestAddress(sourceMatch)); arpMatchBuilder .setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder .build()); return arpMatchBuilder.build(); }
/** * Set ARP_SHA Instructions * @param ib Map InstructionBuilder * @param macsrc the macsrc * @return instructionbuilder with new instructions */ public static InstructionBuilder createSrcArpMacInstructions(InstructionBuilder ib, MacAddress macsrc) { List<Action> actionList = Lists.newArrayList(); ActionBuilder ab = new ActionBuilder(); SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); ArpMatchBuilder arpmatch = new ArpMatchBuilder(); ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder(); arpsrc.setAddress(macsrc); arpmatch.setArpSourceHardwareAddress(arpsrc.build()); setFieldBuilder.setLayer3Match(arpmatch.build()); ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build()); ab.setOrder(0); ab.setKey(new ActionKey(0)); actionList.add(ab.build()); ApplyActionsBuilder aab = new ApplyActionsBuilder(); aab.setAction(actionList); // Wrap our Apply Action in an Instruction ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); return ib; }
/** * Set ARP_THA Instructions * @param ib Map InstructionBuilder * @param macdst the macdst * @return instructionbuilder with new attributes */ public static InstructionBuilder createDstArpMacInstructions(InstructionBuilder ib, MacAddress macdst) { List<Action> actionList = new ArrayList<>(); ActionBuilder ab = new ActionBuilder(); SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); ArpMatchBuilder arpmatch = new ArpMatchBuilder(); ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder(); arpdst.setAddress(macdst); setFieldBuilder.setLayer3Match(arpmatch.build()); ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build()); ab.setOrder(0); ab.setKey(new ActionKey(0)); actionList.add(ab.build()); ApplyActionsBuilder aab = new ApplyActionsBuilder(); aab.setAction(actionList); // Wrap our Apply Action in an Instruction ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); return ib; }
final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder(); final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder(); final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder(); arpsrc.setAddress(macsrc); final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder(); arpdst.setAddress(macdest); arpmatch.setArpOp(2); arpmatch1.setArpSourceHardwareAddress(arpsrc.build()); arpmatch2.setArpTargetHardwareAddress(arpdst.build()); arpmatch3.setArpSourceTransportAddress(srciparp); arpmatch4.setArpTargetTransportAddress(dstiparp);