use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination in project openflowplugin by opendaylight.
the class EthernetDestinationEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final EthernetMatch ethernetMatch = builder.getEthernetMatch();
final EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
ethernetDestinationBuilder.setAddress(OxmDeserializerHelper.convertMacAddress(message));
if (hasMask) {
ethernetDestinationBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
}
if (Objects.isNull(ethernetMatch)) {
builder.setEthernetMatch(new EthernetMatchBuilder().setEthernetDestination(ethernetDestinationBuilder.build()).build());
} else if (Objects.isNull(ethernetMatch.getEthernetDestination())) {
builder.setEthernetMatch(new EthernetMatchBuilder(ethernetMatch).setEthernetDestination(ethernetDestinationBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "ethernetMatch", "ethernetDestination");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination in project openflowplugin by opendaylight.
the class EthernetDestinationEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final MacAddress ethernetDestinationAddress = new MacAddress("00:01:02:03:04:05");
final MacAddress ethernetDestinationAddressMask = new MacAddress("00:00:00:00:00:00");
writeHeader(in, false);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddress));
assertEquals(ethernetDestinationAddress.getValue(), deserialize(in).getEthernetMatch().getEthernetDestination().getAddress().getValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddress));
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetDestinationAddressMask));
final EthernetDestination desAddress = deserialize(in).getEthernetMatch().getEthernetDestination();
assertEquals(ethernetDestinationAddress.getValue(), desAddress.getAddress().getValue());
assertEquals(ethernetDestinationAddressMask.getValue(), desAddress.getMask().getValue());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination 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()));
}
}
Aggregations