Search in sources :

Example 21 with EthernetMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch in project openflowplugin by opendaylight.

the class EthernetTypeEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    processHeader(message);
    final int type = message.readUnsignedShort();
    if (Objects.isNull(builder.getEthernetMatch())) {
        builder.setEthernetMatch(new EthernetMatchBuilder().setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Long.valueOf(type))).build()).build());
    } else if (Objects.isNull(builder.getEthernetMatch().getEthernetType())) {
        builder.setEthernetMatch(new EthernetMatchBuilder(builder.getEthernetMatch()).setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Long.valueOf(type))).build()).build());
    } else {
        throwErrorOnMalformed(builder, "ethernetMatch", "ethernetType");
    }
}
Also used : EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 22 with EthernetMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch in project openflowplugin by opendaylight.

the class EthernetSourceEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final EthernetMatch ethernetMatch = builder.getEthernetMatch();
    final EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
    ethernetSourceBuilder.setAddress(OxmDeserializerHelper.convertMacAddress(message));
    if (hasMask) {
        ethernetSourceBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
    }
    if (Objects.isNull(ethernetMatch)) {
        builder.setEthernetMatch(new EthernetMatchBuilder().setEthernetSource(ethernetSourceBuilder.build()).build());
    } else if (Objects.isNull(ethernetMatch.getEthernetSource())) {
        builder.setEthernetMatch(new EthernetMatchBuilder(ethernetMatch).setEthernetSource(ethernetSourceBuilder.build()).build());
    } else {
        throwErrorOnMalformed(builder, "ethernetMatch", "ethernetSource");
    }
}
Also used : EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) EthernetSourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 23 with EthernetMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch in project openflowplugin by opendaylight.

the class MatchConvertor method ethernetMatch.

private static void ethernetMatch(final List<MatchEntry> matchEntryList, final EthernetMatch ethernetMatch) {
    if (ethernetMatch == null) {
        return;
    }
    EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
    if (ethernetDestination != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(EthDst.class);
        EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
        EthDstBuilder ethDstBuilder = new EthDstBuilder();
        ethDstBuilder.setMacAddress(ethernetDestination.getAddress());
        boolean hasMask = ethernetDestination.getMask() != null;
        if (hasMask) {
            ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetDestination.getMask().getValue()));
        }
        ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
        matchEntryBuilder.setHasMask(hasMask);
        matchEntryList.add(matchEntryBuilder.build());
    }
    EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
    if (ethernetSource != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(EthSrc.class);
        EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
        EthSrcBuilder ethDstBuilder = new EthSrcBuilder();
        ethDstBuilder.setMacAddress(ethernetSource.getAddress());
        boolean hasMask = ethernetSource.getMask() != null;
        if (hasMask) {
            ethDstBuilder.setMask(ByteBufUtils.macAddressToBytes(ethernetSource.getMask().getValue()));
        }
        ethSrcCaseBuilder.setEthSrc(ethDstBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
        matchEntryBuilder.setHasMask(hasMask);
        matchEntryList.add(matchEntryBuilder.build());
    }
    if (ethernetMatch.getEthernetType() != null) {
        matchEntryList.add(toOfEthernetType(ethernetMatch.getEthernetType()));
    }
}
Also used : EthernetDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination) EthDstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder) EthSrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) EthernetSource(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource) EthDstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder) EthSrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder)

Example 24 with EthernetMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch in project openflowplugin by opendaylight.

the class FlowConvertorTest method createEthernetMatch.

private static EthernetMatch createEthernetMatch() {
    EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
    ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(33024L)).build());
    return ethernetMatchBuilder.build();
}
Also used : EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 25 with EthernetMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch in project openflowplugin by opendaylight.

the class MatchV10Convertor method convert.

@Override
public MatchV10 convert(final Match source, final VersionConvertorData data) {
    MatchV10Builder matchBuilder = new MatchV10Builder();
    boolean dlDst = true;
    boolean dlSsc = true;
    boolean dlType = true;
    boolean dlVlan = true;
    boolean dlVlanPcp = true;
    boolean ipPort = true;
    boolean nwProto = true;
    boolean nwTos = true;
    boolean tpDst = true;
    boolean tpSrc = true;
    matchBuilder.setInPort(0);
    matchBuilder.setDlDst(ZERO_MAC);
    matchBuilder.setDlSrc(ZERO_MAC);
    matchBuilder.setDlType(0);
    matchBuilder.setDlVlan(OFP_VLAN_NONE);
    matchBuilder.setDlVlanPcp((short) 0);
    matchBuilder.setNwDst(ZERO_IPV4);
    matchBuilder.setNwDstMask((short) 0);
    matchBuilder.setNwSrc(ZERO_IPV4);
    matchBuilder.setNwSrcMask((short) 0);
    matchBuilder.setNwProto((short) 0);
    matchBuilder.setNwTos((short) 0);
    matchBuilder.setTpSrc(0);
    matchBuilder.setTpDst(0);
    if (source != null) {
        EthernetMatch ethernetMatch = source.getEthernetMatch();
        if (ethernetMatch != null) {
            dlDst = convertEthernetDlDst(matchBuilder, ethernetMatch);
            dlSsc = convertEthernetDlSrc(matchBuilder, ethernetMatch);
            dlType = convertEthernetDlType(matchBuilder, ethernetMatch);
        }
        VlanMatch vlanMatch = source.getVlanMatch();
        if (vlanMatch != null) {
            dlVlan = convertDlVlan(matchBuilder, vlanMatch);
            dlVlanPcp = convertDlVlanPcp(matchBuilder, vlanMatch);
        }
        NodeConnectorId inPort = source.getInPort();
        if (inPort != null) {
            ipPort = convertInPortMatch(matchBuilder, inPort);
        }
        Layer3Match l3Match = source.getLayer3Match();
        if (l3Match != null) {
            if (l3Match instanceof Ipv4Match) {
                Ipv4Match ipv4 = (Ipv4Match) l3Match;
                convertL3Ipv4SrcMatch(matchBuilder, ipv4);
                convertL3Ipv4DstMatch(matchBuilder, ipv4);
            }
        }
        IpMatch ipMatch = source.getIpMatch();
        if (ipMatch != null) {
            nwProto = convertNwProto(matchBuilder, ipMatch);
            nwTos = convertNwTos(matchBuilder, ipMatch);
        }
        Layer4Match layer4Match = source.getLayer4Match();
        if (layer4Match != null) {
            if (layer4Match instanceof TcpMatch) {
                TcpMatch tcpMatch = (TcpMatch) layer4Match;
                tpSrc = convertL4TpSrcMatch(matchBuilder, tcpMatch);
                tpDst = convertL4TpDstMatch(matchBuilder, tcpMatch);
            } else if (layer4Match instanceof UdpMatch) {
                UdpMatch udpMatch = (UdpMatch) layer4Match;
                tpSrc = convertL4UdpSrcMatch(matchBuilder, udpMatch);
                tpDst = convertL4UdpDstMatch(matchBuilder, udpMatch);
            }
        } else {
            Icmpv4Match icmpv4Match = source.getIcmpv4Match();
            if (icmpv4Match != null) {
                Short type = icmpv4Match.getIcmpv4Type();
                if (type != null) {
                    matchBuilder.setTpSrc(type.intValue());
                    tpSrc = false;
                }
                Short code = icmpv4Match.getIcmpv4Code();
                if (code != null) {
                    matchBuilder.setTpDst(code.intValue());
                    tpDst = false;
                }
            }
        }
    }
    FlowWildcardsV10 wildCards = new FlowWildcardsV10(dlDst, dlSsc, dlType, dlVlan, dlVlanPcp, ipPort, nwProto, nwTos, tpDst, tpSrc);
    matchBuilder.setWildcards(wildCards);
    return matchBuilder.build();
}
Also used : Icmpv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match) Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) TcpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch) FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) MatchV10Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder) Layer4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match) UdpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch) VlanMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch)

Aggregations

EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)15 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)12 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)11 Test (org.junit.Test)9 EthernetSourceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)7 MatchesBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder)6 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)6 AceIpBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder)5 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)5 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)5 AceIpv4Builder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder)4 EtherType (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType)4 EthernetDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder)4 EthernetTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder)4 Icmpv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match)4 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)4 MatchV10Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder)4 BigInteger (java.math.BigInteger)3