use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.
the class OF10PacketOutInputMessageFactoryTest method testPacketOutInputWithNoData.
/**
* Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testPacketOutInputWithNoData() throws Exception {
PacketOutInputBuilder builder = new PacketOutInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setBufferId(256L);
builder.setInPort(new PortNumber(257L));
List<Action> actions = new ArrayList<>();
builder.setAction(actions);
builder.setData(null);
PacketOutInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
packetOutFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 13, 16);
// skip packet out message to data index
out.skipBytes(8);
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.
the class PacketOutInputMessageFactoryTest method testPacketOutInputWithNoData.
/**
* Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testPacketOutInputWithNoData() throws Exception {
PacketOutInputBuilder builder = new PacketOutInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setBufferId(256L);
builder.setInPort(new PortNumber(256L));
List<Action> actions = new ArrayList<>();
builder.setAction(actions);
builder.setData(null);
PacketOutInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
packetOutFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 24);
// skip packet out message to data index
out.skipBytes(16);
Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.
the class PortTranslatorUtil method translatePort.
public static NodeConnectorUpdated translatePort(final Short version, final BigInteger datapathId, final Long portNumber, final PortGrouping port) {
OpenflowVersion ofVersion = OpenflowVersion.get(version);
final NodeConnectorUpdatedBuilder builder = InventoryDataServiceUtil.nodeConnectorUpdatedBuilderFromDatapathIdPortNo(datapathId, port.getPortNo(), ofVersion);
FlowCapableNodeConnectorUpdatedBuilder fcncub = new FlowCapableNodeConnectorUpdatedBuilder();
if (ofVersion == OpenflowVersion.OF13) {
fcncub.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(port.getAdvertisedFeatures()));
fcncub.setConfiguration(PortTranslatorUtil.translatePortConfig(port.getConfig()));
fcncub.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(port.getCurrentFeatures()));
fcncub.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(port.getPeerFeatures()));
fcncub.setState(PortTranslatorUtil.translatePortState(port.getState()));
fcncub.setSupported(PortTranslatorUtil.translatePortFeatures(port.getSupportedFeatures()));
} else if (ofVersion == OpenflowVersion.OF10) {
fcncub.setAdvertisedFeatures(PortTranslatorUtil.translatePortFeatures(port.getAdvertisedFeaturesV10()));
fcncub.setConfiguration(PortTranslatorUtil.translatePortConfig(port.getConfigV10()));
fcncub.setCurrentFeature(PortTranslatorUtil.translatePortFeatures(port.getCurrentFeaturesV10()));
fcncub.setPeerFeatures(PortTranslatorUtil.translatePortFeatures(port.getPeerFeaturesV10()));
fcncub.setState(PortTranslatorUtil.translatePortState(port.getStateV10()));
fcncub.setSupported(PortTranslatorUtil.translatePortFeatures(port.getSupportedFeaturesV10()));
}
if (port instanceof PortStatusMessage) {
if (((PortStatusMessage) port).getReason() != null) {
fcncub.setReason(PortReason.forValue(((PortStatusMessage) port).getReason().getIntValue()));
} else {
LOG.debug("PortStatus Message has reason as null");
}
}
fcncub.setCurrentSpeed(port.getCurrSpeed());
fcncub.setHardwareAddress(port.getHwAddr());
fcncub.setMaximumSpeed(port.getMaxSpeed());
fcncub.setName(port.getName());
fcncub.setPortNumber(OpenflowPortsUtil.getProtocolAgnosticPort(ofVersion, portNumber));
builder.addAugmentation(FlowCapableNodeConnectorUpdated.class, fcncub.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.
the class UdpSrcCodec method deserialize.
@Override
public MatchEntry deserialize(ByteBuf message) {
MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message);
matchEntryBuilder.setHasMask(true);
int portNo = message.readUnsignedShort();
int mask = message.readUnsignedShort();
UdpSrcCaseValueBuilder caseBuilder = new UdpSrcCaseValueBuilder();
UdpSrcValuesBuilder udpSrcValuesBuilder = new UdpSrcValuesBuilder();
udpSrcValuesBuilder.setPort(new PortNumber(portNo));
udpSrcValuesBuilder.setMask(mask);
caseBuilder.setUdpSrcValues(udpSrcValuesBuilder.build());
matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
return matchEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createFlowStats.
private static List<FlowStats> createFlowStats() {
FlowStatsBuilder builder = new FlowStatsBuilder();
builder.setTableId((short) 1);
builder.setDurationSec(1L);
builder.setDurationNsec(1L);
builder.setPriority(1);
builder.setIdleTimeout(1);
builder.setHardTimeout(1);
builder.setCookie(BigInteger.valueOf(1234L));
builder.setPacketCount(BigInteger.valueOf(1234L));
builder.setByteCount(BigInteger.valueOf(1234L));
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPhyPort.class);
entriesBuilder.setHasMask(false);
InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
inPhyPortBuilder.setPortNumber(new PortNumber(42L));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpEcn.class);
entriesBuilder.setHasMask(false);
IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
ipEcnBuilder.setEcn((short) 4);
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entriesBuilder.build());
matchBuilder.setMatchEntry(entries);
builder.setMatch(matchBuilder.build());
final List<Instruction> instructions = new ArrayList<>();
// Goto_table instruction
InstructionBuilder builderInstruction = new InstructionBuilder();
GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
GotoTableBuilder instructionBuilder = new GotoTableBuilder();
instructionBuilder.setTableId((short) 5);
gotoCaseBuilder.setGotoTable(instructionBuilder.build());
builderInstruction.setInstructionChoice(gotoCaseBuilder.build());
instructions.add(builderInstruction.build());
// Write_metadata instruction
builderInstruction = 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());
builderInstruction.setInstructionChoice(metadataCaseBuilder.build());
instructions.add(builderInstruction.build());
// Clear_actions instruction
builderInstruction = new InstructionBuilder();
builderInstruction.setInstructionChoice(new ClearActionsCaseBuilder().build());
instructions.add(builderInstruction.build());
// Meter instruction
builderInstruction = new InstructionBuilder();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId(42L);
meterCaseBuilder.setMeter(meterBuilder.build());
builderInstruction.setInstructionChoice(meterCaseBuilder.build());
instructions.add(builderInstruction.build());
// Write_actions instruction
builderInstruction = 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());
builderInstruction.setInstructionChoice(writeActionsCaseBuilder.build());
instructions.add(builderInstruction.build());
// Apply_actions instruction
builderInstruction = 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());
builderInstruction.setInstructionChoice(applyActionsCaseBuilder.build());
instructions.add(builderInstruction.build());
builder.setInstruction(instructions);
List<FlowStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
Aggregations