public static void addMatchDstMac(MatchBuilder match, final String dstMac) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder(); ethDestinationBuilder.setAddress(new MacAddress(dstMac)); ethernetMatch.setEthernetDestination(ethDestinationBuilder.build()); match.setEthernetMatch(mergeEthernetMatch(match, ethernetMatch)); }
/** * Creates {@link EthernetMatch} containing ARP ether-type and the given destination MAC address * * @param destinationMacAddress the destination MAC address * @return {@link EthernetMatch} */ public static EthernetMatch createEthernetMatch(MacAddress destinationMacAddress) { return new EthernetMatchBuilder().setEthernetType( new EthernetTypeBuilder().setType(new EtherType(Long.valueOf(EtherTypes.ARP.intValue()))).build()) .setEthernetDestination(new EthernetDestinationBuilder().setAddress(destinationMacAddress).build()) .build(); }
@Override public Optional<MatchBuilder> process(@Nonnull EthDstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final EthernetMatchBuilder ethMatchBuilder = data.getEthernetMatchBuilder(); final EthDst ethDstCase = source.getEthDst(); if (ethDstCase != null) { EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder(); ethDestinationBuilder.setAddress(ethDstCase.getMacAddress()); byte[] destinationMask = ethDstCase.getMask(); if (destinationMask != null) { ethDestinationBuilder.setMask(new MacAddress(macAddressToString(destinationMask))); } ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build()); matchBuilder.setEthernetMatch(ethMatchBuilder.build()); } return Optional.of(matchBuilder); } }
/** * Create Ethernet Destination Match * * @param matchBuilder MatchBuilder Object without a match yet * @param dMacAddr String representing a destination MAC * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createDestEthMatch(MatchBuilder matchBuilder, MacAddress dMacAddr, MacAddress mask) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder(); ethDestinationBuilder.setAddress(dMacAddr); if (mask != null) { ethDestinationBuilder.setMask(mask); } ethernetMatch.setEthernetDestination(ethDestinationBuilder.build()); matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
/** * Create Ethernet Source Match * * @param matchBuilder MatchBuilder Object without a match yet * @param srcMac String representing a source MAC * @param dstMac String representing a destination MAC * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createEthMatch(MatchBuilder matchBuilder, MacAddress srcMac, MacAddress dstMac) { Preconditions.checkNotNull(matchBuilder); EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); if (srcMac != null) { EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder(); ethSourceBuilder.setAddress(srcMac); ethernetMatch.setEthernetSource(ethSourceBuilder.build()); } if (dstMac != null) { EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder(); ethDestinationBuilder.setAddress(dstMac); ethernetMatch.setEthernetDestination(ethDestinationBuilder.build()); } matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
/** * Create Ethernet Destination Match * * @param matchBuilder MatchBuilder Object without a match yet * @param dMacAddr String representing a destination MAC * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createEthDstMatch(MatchBuilder matchBuilder, MacAddress dMacAddr, MacAddress mask) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder(); ethDestinationBuilder.setAddress(new MacAddress(dMacAddr)); if (mask != null) { ethDestinationBuilder.setMask(mask); } ethernetMatch.setEthernetDestination(ethDestinationBuilder.build()); matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
/** * Creates {@link EthernetMatch} containing ARP ether-type and the given destination MAC address */ public static EthernetMatch createEthernetMatch(MacAddress destinationMacAddress) { return new EthernetMatchBuilder().setEthernetType( new EthernetTypeBuilder().setType(new EtherType((long) EtherTypes.ARP.intValue())).build()) .setEthernetDestination(new EthernetDestinationBuilder().setAddress(destinationMacAddress).build()) .build(); }
public static EthernetMatch ethernetMatch(MacAddress srcMac, MacAddress dstMac, Long etherType) { EthernetMatchBuilder emb = new EthernetMatchBuilder(); if (srcMac != null) emb.setEthernetSource(new EthernetSourceBuilder().setAddress(srcMac).build()); if (dstMac != null) emb.setEthernetDestination(new EthernetDestinationBuilder().setAddress(dstMac).build()); if (etherType != null) emb.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(etherType)).build()); return emb.build(); }
public static Action createActionSetDlDst(String dstMac, int order) { EthernetDestinationBuilder ethDst = new EthernetDestinationBuilder(); ethDst.setAddress(new MacAddress(dstMac)); EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder(); ethMatchBuilder.setEthernetDestination(ethDst.build()); SetFieldCaseBuilder setFieldCase = new SetFieldCaseBuilder(); setFieldCase.setSetField( new SetFieldBuilder().setEthernetMatch(ethMatchBuilder.build()) .build()); ActionBuilder ab = createActionBuilder(order); ab.setAction(setFieldCase.build()); return ab.build(); }
private Match createMacMatch(MacAddress srcMac, MacAddress dstMac) { EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder(); if (dstMac != null) { ethernetMatchBuilder.setEthernetDestination(new EthernetDestinationBuilder() .setAddress(dstMac) .build()); } if (srcMac != null) { ethernetMatchBuilder.setEthernetSource(new EthernetSourceBuilder() .setAddress(srcMac) .build()); } EthernetMatch ethernetMatch = ethernetMatchBuilder.build(); if (ethernetMatch != null) { return new MatchBuilder() .setEthernetMatch(ethernetMatch) .build(); } else { return null; } }
public static EthernetMatch ethernetMatch(MacAddress srcMac, MacAddress dstMac, Long etherType) { EthernetMatchBuilder emb = new EthernetMatchBuilder(); if (srcMac != null) emb.setEthernetSource(new EthernetSourceBuilder() .setAddress(srcMac) .build()); if (dstMac != null) emb.setEthernetDestination(new EthernetDestinationBuilder() .setAddress(dstMac) .build()); if (etherType != null) emb.setEthernetType(new EthernetTypeBuilder() .setType(new EtherType(etherType)) .build()); return emb.build(); } }
public static EthernetMatch ethernetMatch(MacAddress srcMac, MacAddress dstMac, Long etherType) { EthernetMatchBuilder emb = new EthernetMatchBuilder(); if (srcMac != null) { emb.setEthernetSource(new EthernetSourceBuilder() .setAddress(srcMac) .build()); } if (dstMac != null) { emb.setEthernetDestination(new EthernetDestinationBuilder() .setAddress(dstMac) .build()); } if (etherType != null) { emb.setEthernetType(new EthernetTypeBuilder() .setType(new EtherType(etherType)) .build()); } return emb.build(); }
public static MatchBuilder createEthSrcDstMatch(MatchBuilder matchBuilder, MacAddress srcMac, MacAddress dstMac) { EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder(); if (srcMac != null) { EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder(); ethSourceBuilder.setAddress(srcMac); ethernetMatch.setEthernetSource(ethSourceBuilder.build()); } if (dstMac != null) { EthernetDestinationBuilder ethDestinationBuild = new EthernetDestinationBuilder(); ethDestinationBuild.setAddress(dstMac); ethernetMatch.setEthernetDestination(ethDestinationBuild.build()); } if (matchBuilder.getEthernetMatch() != null && matchBuilder.getEthernetMatch().getEthernetType() != null) { ethernetMatch.setEthernetType(matchBuilder.getEthernetMatch().getEthernetType()); } matchBuilder.setEthernetMatch(ethernetMatch.build()); return matchBuilder; }
/** * Creates a ether net match with ether type set to 0x0800L. * @param matchBuilder MatchBuilder Object * @param srcMac The source macAddress * @param dstMac The destination mac address * @return matchBuilder Map Object with a match */ public static MatchBuilder createV4EtherMatchWithType(MatchBuilder matchBuilder,String srcMac, String dstMac, Long type) { EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(type)); EthernetMatchBuilder eth = new EthernetMatchBuilder(); eth.setEthernetType(ethTypeBuilder.build()); if (null != srcMac) { eth.setEthernetSource(new EthernetSourceBuilder() .setAddress(new MacAddress(srcMac)).build()); } if (null != dstMac) { eth.setEthernetDestination(new EthernetDestinationBuilder() .setAddress(new MacAddress(dstMac)).build()); } matchBuilder.setEthernetMatch(eth.build()); return matchBuilder; }
/** * Creates a ether net match with ether type set to 0x86DDL. * @param matchBuilder MatchBuilder Object * @param srcMac The source macAddress * @param dstMac The destination mac address * @return matchBuilder Map Object with a match */ public static MatchBuilder createV6EtherMatchWithType(MatchBuilder matchBuilder,String srcMac, String dstMac) { EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x86DDL)); EthernetMatchBuilder eth = new EthernetMatchBuilder(); eth.setEthernetType(ethTypeBuilder.build()); if (null != srcMac) { eth.setEthernetSource(new EthernetSourceBuilder() .setAddress(new MacAddress(srcMac)).build()); } if (null != dstMac) { eth.setEthernetDestination(new EthernetDestinationBuilder() .setAddress(new MacAddress(dstMac)).build()); } matchBuilder.setEthernetMatch(eth.build()); return matchBuilder; }
private static MatchBuilder createEthernetMatch() { MatchBuilder match = new MatchBuilder(); byte[] mask1 = new byte[]{(byte) -1, (byte) -1, 0, 0, 0, 0}; byte[] mask2 = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0}; EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype // match EthernetTypeBuilder ethtype = new EthernetTypeBuilder(); EtherType type = new EtherType(0x0800L); ethmatch.setEthernetType(ethtype.setType(type).build()); EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet // macaddress // match MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff"); ethdest.setAddress(macdest); // ethdest.setMask(mask1); ethmatch.setEthernetDestination(ethdest.build()); EthernetSourceBuilder ethsrc = new EthernetSourceBuilder(); MacAddress macsrc = new MacAddress("00:00:00:00:23:ae"); ethsrc.setAddress(macsrc); // ethsrc.setMask(mask2); ethmatch.setEthernetSource(ethsrc.build()); match.setEthernetMatch(ethmatch.build()); return match; }
private static MatchBuilder createEthernetMatch() { MatchBuilder match = new MatchBuilder(); byte[] mask1 = new byte[]{(byte) -1, (byte) -1, 0, 0, 0, 0}; byte[] mask2 = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0}; EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype // match EthernetTypeBuilder ethtype = new EthernetTypeBuilder(); EtherType type = new EtherType(0x0800L); ethmatch.setEthernetType(ethtype.setType(type).build()); EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet // macaddress // match MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff"); ethdest.setAddress(macdest); // ethdest.setMask(mask1); ethmatch.setEthernetDestination(ethdest.build()); EthernetSourceBuilder ethsrc = new EthernetSourceBuilder(); MacAddress macsrc = new MacAddress("00:00:00:00:23:ae"); ethsrc.setAddress(macsrc); // ethsrc.setMask(mask2); ethmatch.setEthernetSource(ethsrc.build()); match.setEthernetMatch(ethmatch.build()); return match; }
/** * * @param order An integer representing the order of the Action * within the table. * @param macAddress Destination MAC address * @return Action with an order */ public static Action createSetFieldDestinationMacAddress(int order, String macAddress) { Action action; ActionBuilder ab = new ActionBuilder(); MacAddress address = MacAddress.getDefaultInstance(macAddress); EthernetDestination destination = new EthernetDestinationBuilder().setAddress(address).build(); EthernetMatchBuilder builder = new EthernetMatchBuilder(); builder.setEthernetDestination(destination); EthernetMatch ethernetMatch = builder.build(); SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); setFieldBuilder.setEthernetMatch(ethernetMatch); SetField setField = setFieldBuilder.build(); org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action acction = new SetFieldCaseBuilder(). setSetField(setField).build(); ab.setOrder(order).setKey(new ActionKey(order)).setAction(acction); action = ab.build(); return action; } }
private static MatchBuilder createEthernetMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype // match final EthernetTypeBuilder ethtype = new EthernetTypeBuilder(); final EtherType type = new EtherType(0x0800L); ethmatch.setEthernetType(ethtype.setType(type).build()); final EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet // macaddress // match final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS); ethdest.setAddress(macdest); ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00")); ethmatch.setEthernetDestination(ethdest.build()); final EthernetSourceBuilder ethsrc = new EthernetSourceBuilder(); final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS); ethsrc.setAddress(macsrc); ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00")); ethmatch.setEthernetSource(ethsrc.build()); match.setEthernetMatch(ethmatch.build()); return match; }
private static EthernetMatch ethernetMatch(final Match sourceMatch) { final EthernetMatchBuilder targetEthMatchBuild = new EthernetMatchBuilder(); if(sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) { EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder() .setAddress(ethernetSourceAddress(sourceMatch)); targetEthMatchBuild.setEthernetSource(ethSourBuild.build()); } if(sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null) { EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder() .setAddress(ethernetDestAddress(sourceMatch)); targetEthMatchBuild.setEthernetDestination(ethDestBuild.build()); } final MatchField dataLinkType = sourceMatch.getField(MatchType.DL_TYPE); if (dataLinkType != null && dataLinkType.getValue() != null) { EtherType etherType = new EtherType((long) NetUtils.getUnsignedShort((Short) dataLinkType.getValue())); EthernetTypeBuilder ethType = new EthernetTypeBuilder() .setType(etherType); targetEthMatchBuild.setEthernetType(ethType.build()); } if((sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) || (sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null)|| dataLinkType != null ) { return targetEthMatchBuild.build(); } return null; }