use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource in project openflowplugin by opendaylight.
the class EthernetSourceEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final MacAddress ethernetSourceAddress = new MacAddress("00:01:02:03:04:05");
final MacAddress ethernetSourceAddressMask = new MacAddress("00:00:00:00:00:00");
writeHeader(in, false);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddress));
assertEquals(ethernetSourceAddress.getValue(), deserialize(in).getEthernetMatch().getEthernetSource().getAddress().getValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddress));
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ethernetSourceAddressMask));
final EthernetSource desAddress = deserialize(in).getEthernetMatch().getEthernetSource();
assertEquals(ethernetSourceAddress.getValue(), desAddress.getAddress().getValue());
assertEquals(ethernetSourceAddressMask.getValue(), desAddress.getMask().getValue());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource 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");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource 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