use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder in project openflowplugin by opendaylight.
the class OfToSalIcmpv4CodeCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull Icmpv4CodeCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final Icmpv4MatchBuilder icmpv4MatchBuilder = data.getIcmpv4MatchBuilder();
Icmpv4Code icmpv4Code = source.getIcmpv4Code();
Short v4code = icmpv4Code.getIcmpv4Code();
if (v4code != null) {
icmpv4MatchBuilder.setIcmpv4Code(v4code);
matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build());
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder in project openflowplugin by opendaylight.
the class MatchResponseConvertor method convert.
@Override
public MatchBuilder convert(MatchEntriesGrouping source, VersionDatapathIdConvertorData datapathIdConvertorData) {
final MatchBuilder matchBuilder = new MatchBuilder();
final MatchResponseConvertorData data = new MatchResponseConvertorData(datapathIdConvertorData.getVersion());
data.setDatapathId(datapathIdConvertorData.getDatapathId());
data.setMatchBuilder(matchBuilder);
data.setEthernetMatchBuilder(new EthernetMatchBuilder());
data.setVlanMatchBuilder(new VlanMatchBuilder());
data.setIpMatchBuilder(new IpMatchBuilder());
data.setTcpMatchBuilder(new TcpMatchBuilder());
data.setUdpMatchBuilder(new UdpMatchBuilder());
data.setSctpMatchBuilder(new SctpMatchBuilder());
data.setIcmpv4MatchBuilder(new Icmpv4MatchBuilder());
data.setIcmpv6MatchBuilder(new Icmpv6MatchBuilder());
data.setIpv4MatchBuilder(new Ipv4MatchBuilder());
data.setIpv4MatchArbitraryBitMaskBuilder(new Ipv4MatchArbitraryBitMaskBuilder());
data.setIpv6MatchArbitraryBitMaskBuilder(new Ipv6MatchArbitraryBitMaskBuilder());
data.setArpMatchBuilder(new ArpMatchBuilder());
data.setIpv6MatchBuilder(new Ipv6MatchBuilder());
data.setProtocolMatchFieldsBuilder(new ProtocolMatchFieldsBuilder());
data.setTunnelIpv4MatchBuilder(new TunnelIpv4MatchBuilder());
data.setTcpFlagsMatchBuilder(new TcpFlagsMatchBuilder());
for (MatchEntry ofMatch : source.getMatchEntry()) {
if (TunnelIpv4Dst.class.isAssignableFrom(ofMatch.getOxmMatchField()) || TunnelIpv4Src.class.isAssignableFrom(ofMatch.getOxmMatchField())) {
/*
* TODO: Fix TunnelIpv4Src and Ipv4Dst, because current implementation do not work
* TunnelIpv4Src and TunnelIpv4Dst are not compatible with
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField
* and so you cannot even set them to OxmMatchField.
* Creation of TunnelIpv4SrcCase and TunnelIpv4DstCase in
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value
* .grouping.match.entry.value
* and proper use of it can fix this bug.
*/
OF_TO_SAL_TUNNEL_PROCESSOR.process(ofMatch.getMatchEntryValue(), data, getConvertorExecutor());
} else {
data.setOxmMatchField(ofMatch.getOxmMatchField());
OF_TO_SAL_PROCESSOR.process(ofMatch.getMatchEntryValue(), data, getConvertorExecutor());
}
}
return matchBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction42.
private static InstructionsBuilder createAppyActionInstruction42() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final ActionBuilder ab1 = new ActionBuilder();
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Icmpv4
final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
final Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
icmpv4match.setIcmpv4Type((short) 8);
icmpv4match1.setIcmpv4Code((short) 0);
setFieldBuilder.setIcmpv4Match(icmpv4match.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
final InstructionsBuilder isb = new InstructionsBuilder();
final List<Instruction> instructions = new ArrayList<>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder in project openflowplugin by opendaylight.
the class SetTpDstActionSerializer method buildAction.
@Override
protected SetFieldCase buildAction(Action input) {
final SetTpDstAction setTpDstAction = SetTpDstActionCase.class.cast(input).getSetTpDstAction();
final PortNumber port = setTpDstAction.getPort();
final SetFieldBuilder builder = new SetFieldBuilder();
Optional.ofNullable(IPProtocols.fromProtocolNum(setTpDstAction.getIpProtocol())).ifPresent(proto -> {
switch(proto) {
case ICMP:
{
builder.setIcmpv4Match(new Icmpv4MatchBuilder().setIcmpv4Code((short) (0xFF & port.getValue())).build());
break;
}
case ICMPV6:
{
builder.setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Code((short) (0xFF & port.getValue())).build());
break;
}
case TCP:
{
builder.setLayer4Match(new TcpMatchBuilder().setTcpDestinationPort(port).build());
break;
}
case UDP:
{
builder.setLayer4Match(new UdpMatchBuilder().setUdpDestinationPort(port).build());
break;
}
default:
}
});
return new SetFieldCaseBuilder().setSetField(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder in project openflowplugin by opendaylight.
the class MatchConvertorV10Test method testConvertIcmpv4.
@Test
public void testConvertIcmpv4() {
MatchBuilder matchBuilder = createMatchBuilderWithDefaults();
Match match = matchBuilder.build();
Optional<MatchV10> matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
MatchV10 matchV10 = matchV10Optional.get();
final Integer zero = 0;
assertEquals(ZERO_MAC, matchV10.getDlDst());
assertEquals(FF_MAC, matchV10.getDlSrc());
assertEquals(0, matchV10.getDlType().intValue());
assertEquals(0xffff, matchV10.getDlVlan().intValue());
assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
assertEquals(0, matchV10.getNwTos().shortValue());
assertEquals(zero, matchV10.getTpSrc());
assertEquals(zero, matchV10.getTpDst());
boolean wcTpSrc = true;
boolean wcTpDst = true;
FlowWildcardsV10 wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
assertEquals(wc, matchV10.getWildcards());
// Specify ICMP type only.
Integer icmpType = 55;
Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue());
wcTpSrc = false;
wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
matchV10 = matchV10Optional.get();
assertEquals(ZERO_MAC, matchV10.getDlDst());
assertEquals(FF_MAC, matchV10.getDlSrc());
assertEquals(0, matchV10.getDlType().intValue());
assertEquals(0xffff, matchV10.getDlVlan().intValue());
assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
assertEquals(0, matchV10.getNwTos().shortValue());
assertEquals(icmpType, matchV10.getTpSrc());
assertEquals(zero, matchV10.getTpDst());
assertEquals(wc, matchV10.getWildcards());
// Specify ICMP code only.
Integer icmpCode = 31;
icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(null).setIcmpv4Code(icmpCode.shortValue());
wcTpSrc = true;
wcTpDst = false;
wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
matchV10 = matchV10Optional.get();
assertEquals(ZERO_MAC, matchV10.getDlDst());
assertEquals(FF_MAC, matchV10.getDlSrc());
assertEquals(0, matchV10.getDlType().intValue());
assertEquals(0xffff, matchV10.getDlVlan().intValue());
assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
assertEquals(0, matchV10.getNwTos().shortValue());
assertEquals(zero, matchV10.getTpSrc());
assertEquals(icmpCode, matchV10.getTpDst());
assertEquals(wc, matchV10.getWildcards());
// Specify both ICMP type and code.
icmpType = 11;
icmpCode = 22;
icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue()).setIcmpv4Code(icmpCode.shortValue());
wcTpSrc = false;
wcTpDst = false;
wc = new FlowWildcardsV10(false, false, false, true, true, false, false, false, wcTpDst, wcTpSrc);
match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
matchV10Optional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
matchV10 = matchV10Optional.get();
assertEquals(ZERO_MAC, matchV10.getDlDst());
assertEquals(FF_MAC, matchV10.getDlSrc());
assertEquals(0, matchV10.getDlType().intValue());
assertEquals(0xffff, matchV10.getDlVlan().intValue());
assertEquals(Integer.parseInt(NODE_CONNECTOR_ID), matchV10.getInPort().intValue());
assertEquals(DEFAULT_IPV4_ADDRESS.getValue(), matchV10.getNwDst().getValue());
assertEquals(DEFAULT_MASK, matchV10.getNwDstMask().shortValue());
assertEquals(0, matchV10.getNwTos().shortValue());
assertEquals(icmpType, matchV10.getTpSrc());
assertEquals(icmpCode, matchV10.getTpDst());
assertEquals(wc, matchV10.getWildcards());
}
Aggregations