use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder in project openflowplugin by opendaylight.
the class EthernetTypeEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final long ethType = 0xffffL;
final Match match = new MatchBuilder().setEthernetMatch(new EthernetMatchBuilder().setEthernetType(new EthernetTypeBuilder().setType(new EtherType(ethType)).build()).build()).build();
assertMatch(match, false, (out) -> assertEquals(out.readUnsignedShort(), ethType));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder in project openflowplugin by opendaylight.
the class AbstractDropTest method processPacket.
@SuppressWarnings("checkstyle:IllegalCatch")
private void processPacket(final PacketReceived notification) {
try {
final byte[] rawPacket = notification.getPayload();
final byte[] srcMac = Arrays.copyOfRange(rawPacket, 6, 12);
final MatchBuilder match = new MatchBuilder();
final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
// TODO: use HEX, use binary form
// Hex.decodeHex("000000000001".toCharArray());
ethSourceBuilder.setAddress(new MacAddress(macAddressToString(srcMac)));
ethernetMatch.setEthernetSource(ethSourceBuilder.build());
match.setEthernetMatch(ethernetMatch.build());
// Get the Ingress nodeConnectorRef
final NodeConnectorRef ncr = notification.getIngress();
// Get the instance identifier for the nodeConnectorRef
final InstanceIdentifier<?> ncri = ncr.getValue();
processPacket(ncri.firstIdentifierOf(Node.class), match.build(), DROP_INSTRUCTIONS);
SENT_UPDATER.incrementAndGet(this);
} catch (RuntimeException e) {
LOG.warn("Failed to process packet: {}", e.getMessage());
LOG.debug("Failed to process packet.. ", e);
EXCS_UPDATER.incrementAndGet(this);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createMatch3.
private static MatchBuilder createMatch3() {
MatchBuilder match = new MatchBuilder();
EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
ethernetMatch.setEthernetSource(ethSourceBuilder.build());
match.setEthernetMatch(ethernetMatch.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createMatch1.
private static MatchBuilder createMatch1() {
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
ipv4Match.setIpv4Destination(prefix);
Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
EthernetMatchBuilder eth = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder 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");
}
}
Aggregations