use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method createEthernetMatch.
private static MatchBuilder createEthernetMatch() {
// ethernettype
EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
// match
EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
EtherType type = new EtherType(0x0800L);
ethmatch.setEthernetType(ethtype.setType(type).build());
// ethernet
EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder();
// macaddress
// match
MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
ethdest.setAddress(macdest);
// ethdest.setMask(mask1);
ethmatch.setEthernetDestination(ethdest.build());
EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
ethsrc.setAddress(macsrc);
// ethsrc.setMask(mask2);
ethmatch.setEthernetSource(ethsrc.build());
MatchBuilder match = new MatchBuilder();
match.setEthernetMatch(ethmatch.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project openflowplugin by opendaylight.
the class OF13InstructionsSerializerTest method test.
/**
* Testing instructions translation.
*/
@Test
public void test() {
final List<Instruction> instructions = new ArrayList<>();
// Goto_table instruction
InstructionBuilder builder = new InstructionBuilder();
GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
GotoTableBuilder instructionBuilder = new GotoTableBuilder();
instructionBuilder.setTableId((short) 5);
gotoCaseBuilder.setGotoTable(instructionBuilder.build());
builder.setInstructionChoice(gotoCaseBuilder.build());
instructions.add(builder.build());
// Write_metadata instruction
builder = new InstructionBuilder();
WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
builder.setInstructionChoice(metadataCaseBuilder.build());
instructions.add(builder.build());
// Clear_actions instruction
builder = new InstructionBuilder();
builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
instructions.add(builder.build());
// Meter instruction
builder = new InstructionBuilder();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId(42L);
meterCaseBuilder.setMeter(meterBuilder.build());
builder.setInstructionChoice(meterCaseBuilder.build());
instructions.add(builder.build());
// Write_actions instruction
builder = new InstructionBuilder();
final WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
final WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(45L));
outputBuilder.setMaxLength(55);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder();
SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder();
ttlActionBuilder.setNwTtl((short) 64);
ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
actionBuilder.setActionChoice(ttlCaseBuilder.build());
actions.add(actionBuilder.build());
writeActionsBuilder.setAction(actions);
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
builder.setInstructionChoice(writeActionsCaseBuilder.build());
instructions.add(builder.build());
// Apply_actions instruction
builder = new InstructionBuilder();
final ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
final ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder();
vlanBuilder.setEthertype(new EtherType(new EtherType(14)));
vlanCaseBuilder.setPushVlanAction(vlanBuilder.build());
actionBuilder.setActionChoice(vlanCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
applyActionsBuilder.setAction(actions);
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
builder.setInstructionChoice(applyActionsCaseBuilder.build());
instructions.add(builder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(instructions, TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out);
Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort());
out.skipBytes(4);
byte[] actual = new byte[8];
out.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", ByteBufUtils.bytesToHexString(actual));
actual = new byte[8];
out.readBytes(actual);
Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", ByteBufUtils.bytesToHexString(actual));
Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction meter-id", 42, out.readUnsignedInt());
Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 32, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 45, out.readUnsignedInt());
Assert.assertEquals("Wrong action type", 55, out.readUnsignedShort());
out.skipBytes(6);
Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 64, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action ethertype", 14, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertTrue("Not all data were read", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertorTest method pushVlanCase.
private static PushVlanCase pushVlanCase() {
PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
pushVlanActionBuilder.setEthertype(new EtherType(1));
pushVlanCaseBuilder.setPushVlanAction(pushVlanActionBuilder.build());
return pushVlanCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertorTest method createPushPbbCase.
private static PushPbbCase createPushPbbCase() {
PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
PushPbbActionBuilder pushPbbActionBuilder = new PushPbbActionBuilder();
pushPbbActionBuilder.setEthertype(new EtherType(1));
pushPbbCaseBuilder.setPushPbbAction(pushPbbActionBuilder.build());
return pushPbbCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType in project openflowplugin by opendaylight.
the class BulkOMaticUtils method getMatch.
public static Match getMatch(final int sourceIp) {
Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build();
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setLayer3Match(ipv4Match);
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
ethTypeBuilder.setType(new EtherType(2048L));
ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
return matchBuilder.build();
}
Aggregations