Search in sources :

Example 1 with ArpSourceHardwareAddress

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

the class ArpSourceHardwareAddressEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final Layer3Match layer3Match = builder.getLayer3Match();
    final ArpSourceHardwareAddressBuilder arpBuilder = new ArpSourceHardwareAddressBuilder().setAddress(OxmDeserializerHelper.convertMacAddress(message));
    if (hasMask) {
        arpBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
    }
    if (Objects.isNull(layer3Match)) {
        builder.setLayer3Match(new ArpMatchBuilder().setArpSourceHardwareAddress(arpBuilder.build()).build());
    } else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpSourceHardwareAddress())) {
        builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpSourceHardwareAddress(arpBuilder.build()).build());
    } else {
        throwErrorOnMalformed(builder, "layer3Match", "arpSourceHardwareAddress");
    }
}
Also used : Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) ArpSourceHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)

Example 2 with ArpSourceHardwareAddress

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

the class ArpSourceHardwareAddressEntrySerializer method serialize.

@Override
public void serialize(Match match, ByteBuf outBuffer) {
    super.serialize(match, outBuffer);
    final ArpSourceHardwareAddress arpSourceHardwareAddress = ArpMatch.class.cast(match.getLayer3Match()).getArpSourceHardwareAddress();
    writeMacAddress(arpSourceHardwareAddress.getAddress(), outBuffer);
    if (getHasMask(match)) {
        writeMask(ByteBufUtils.macAddressToBytes(arpSourceHardwareAddress.getMask().getValue()), outBuffer, getValueLength());
    }
}
Also used : ArpSourceHardwareAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)

Example 3 with ArpSourceHardwareAddress

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

the class SalToOfArpMatchCase method process.

@Override
public Optional<List<MatchEntry>> process(@Nonnull ArpMatch source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
    List<MatchEntry> result = new ArrayList<>();
    if (source.getArpOp() != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setHasMask(false);
        matchEntryBuilder.setOxmMatchField(ArpOp.class);
        ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();
        ArpOpBuilder arpOpBuilder = new ArpOpBuilder();
        arpOpBuilder.setOpCode(source.getArpOp());
        arpOpCaseBuilder.setArpOp(arpOpBuilder.build());
        matchEntryBuilder.setMatchEntryValue(arpOpCaseBuilder.build());
        result.add(matchEntryBuilder.build());
    }
    if (source.getArpSourceTransportAddress() != null) {
        Ipv4Prefix ipv4Prefix = source.getArpSourceTransportAddress();
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(ArpSpa.class);
        ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
        Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
        Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
        arpSpaBuilder.setIpv4Address(ipv4Address);
        boolean hasMask = false;
        byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
        if (null != mask) {
            arpSpaBuilder.setMask(mask);
            hasMask = true;
        }
        matchEntryBuilder.setHasMask(hasMask);
        ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
        arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
        matchEntryBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
        result.add(matchEntryBuilder.build());
    }
    if (source.getArpTargetTransportAddress() != null) {
        Ipv4Prefix ipv4Prefix = source.getArpTargetTransportAddress();
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(ArpTpa.class);
        ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
        Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
        Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
        arpTpaBuilder.setIpv4Address(ipv4Address);
        boolean hasMask = false;
        byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
        if (null != mask) {
            arpTpaBuilder.setMask(mask);
            hasMask = true;
        }
        matchEntryBuilder.setHasMask(hasMask);
        ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
        arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
        matchEntryBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
        result.add(matchEntryBuilder.build());
    }
    ArpSourceHardwareAddress arpSourceHardwareAddress = source.getArpSourceHardwareAddress();
    if (arpSourceHardwareAddress != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(ArpSha.class);
        ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
        ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
        arpShaBuilder.setMacAddress(arpSourceHardwareAddress.getAddress());
        boolean hasMask = false;
        if (null != arpSourceHardwareAddress.getMask()) {
            arpShaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpSourceHardwareAddress.getMask().getValue()));
            hasMask = true;
        }
        arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
        matchEntryBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
        matchEntryBuilder.setHasMask(hasMask);
        result.add(matchEntryBuilder.build());
    }
    ArpTargetHardwareAddress arpTargetHardwareAddress = source.getArpTargetHardwareAddress();
    if (arpTargetHardwareAddress != null) {
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(ArpTha.class);
        ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
        ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
        arpThaBuilder.setMacAddress(arpTargetHardwareAddress.getAddress());
        boolean hasMask = false;
        if (null != arpTargetHardwareAddress.getMask()) {
            arpThaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpTargetHardwareAddress.getMask().getValue()));
            hasMask = true;
        }
        arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
        matchEntryBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
        matchEntryBuilder.setHasMask(hasMask);
        result.add(matchEntryBuilder.build());
    }
    return Optional.of(result);
}
Also used : ArpSourceHardwareAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) ArpOpCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder) ArrayList(java.util.ArrayList) ArpOpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder) ArpSpaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder) ArpThaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder) ArpTargetHardwareAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress) ArpTpaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ArpShaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder) ArpTpaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder) ArpSpaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder) ArpShaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder) ArpThaCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 4 with ArpSourceHardwareAddress

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

the class ArpSourceHardwareAddressEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final MacAddress arpSourceHardwareAddress = new MacAddress("00:01:02:03:04:05");
    final MacAddress arpSourceHardwareAddressMask = new MacAddress("00:00:00:00:00:00");
    writeHeader(in, false);
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddress));
    assertEquals(arpSourceHardwareAddress.getValue(), ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceHardwareAddress().getAddress().getValue());
    assertEquals(0, in.readableBytes());
    writeHeader(in, true);
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddress));
    in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddressMask));
    final ArpSourceHardwareAddress desAddress = ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceHardwareAddress();
    assertEquals(arpSourceHardwareAddress.getValue(), desAddress.getAddress().getValue());
    assertEquals(arpSourceHardwareAddressMask.getValue(), desAddress.getMask().getValue());
    assertEquals(0, in.readableBytes());
}
Also used : ArpSourceHardwareAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Aggregations

ArpSourceHardwareAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress)3 ArpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)3 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 ArpSourceHardwareAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder)1 ArpTargetHardwareAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress)1 Layer3Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match)1 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)1 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)1 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)1 ArpOpCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder)1 ArpShaCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder)1 ArpSpaCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder)1 ArpThaCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder)1 ArpTpaCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder)1 ArpOpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder)1