use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures in project openflowplugin by opendaylight.
the class PortUpdateTranslatorTest method assemblePortStatusMessage.
private PortStatusMessageBuilder assemblePortStatusMessage(long portNoValue, long speed) {
final PortFeatures portFeatures13 = PortFeatures.getDefaultInstance("_100gbFd");
final PortFeaturesV10 portFeatures10 = PortFeaturesV10.getDefaultInstance("_100mbFd");
final PortConfig portConfig13 = PortConfig.getDefaultInstance("noFwd");
final PortConfigV10 portConfig10 = PortConfigV10.getDefaultInstance("noFwd");
final PortState portState13 = PortState.getDefaultInstance("live");
final PortStateV10 portState10 = PortStateV10.getDefaultInstance("live");
return new PortStatusMessageBuilder().setPortNo(portNoValue).setReason(PortReason.OFPPRADD).setAdvertisedFeatures(portFeatures13).setAdvertisedFeaturesV10(portFeatures10).setConfig(portConfig13).setConfigV10(portConfig10).setCurrentFeatures(portFeatures13).setCurrentFeaturesV10(portFeatures10).setPeerFeatures(portFeatures13).setPeerFeaturesV10(portFeatures10).setState(portState13).setStateV10(portState10).setSupportedFeatures(portFeatures13).setSupportedFeaturesV10(portFeatures10).setCurrSpeed(speed).setHwAddr(new MacAddress("01:02:03:04:05:06")).setMaxSpeed(2 * speed).setName("utPortName:" + portNoValue);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures in project openflowplugin by opendaylight.
the class PortModInputMessageFactoryTest method testPortModInput.
/**
* Testing of {@link PortModInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testPortModInput() throws Exception {
PortModInputBuilder builder = new PortModInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setPortNo(new PortNumber(9L));
builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));
builder.setConfig(new PortConfig(true, false, true, false));
builder.setMask(new PortConfig(false, true, false, true));
builder.setAdvertise(new PortFeatures(true, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false));
final PortModInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
// simulate parent message
out.writeInt(1);
out.writeZero(2);
out.writeShort(3);
portModFactory.serialize(message, out);
// read parent message
out.readInt();
out.skipBytes(2);
out.readShort();
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
byte[] address = new byte[6];
out.readBytes(address);
Assert.assertEquals("Wrong MacAddress", message.getHwAddress().getValue(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue());
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);
Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(out.readInt()));
Assert.assertEquals("Wrong mask", message.getMask(), createPortConfig(out.readInt()));
Assert.assertEquals("Wrong advertise", message.getAdvertise(), createPortFeatures(out.readInt()));
out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures in project openflowplugin by opendaylight.
the class PortStatusMessageFactoryTest method test.
/**
* Testing {@link PortStatusMessageFactory} for correct translation into POJO.
*/
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer(// reason
"01 " + // padding
"00 00 00 00 00 00 00 " + // port no
"00 01 02 03 " + // padding in ofp_port1
"00 00 00 00 " + // mac address
"08 00 27 00 B0 EB " + // padding in ofp_port2
"00 00 " + // port name, String "s1-eth1"
"73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port config
"00 00 00 41 " + // port state
"00 00 00 05 " + // current features
"00 00 00 81 " + // advertised features
"00 00 00 A1 " + // supported features
"00 00 00 B1 " + // peer features
"00 00 00 81 " + // curr speed
"00 00 00 81 " + // max speed
"00 00 00 80");
PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());
Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), builtByFactory.getHwAddr());
Assert.assertEquals("Wrong name", "s1-eth1", builtByFactory.getName());
Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig());
Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState());
Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), builtByFactory.getCurrentFeatures());
Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, true, true, false, false, true, false, false, false, false, false, false), builtByFactory.getAdvertisedFeatures());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, true, true, true, false, true, false, false, false, false, false, false), builtByFactory.getSupportedFeatures());
Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), builtByFactory.getPeerFeatures());
Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());
Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures in project openflowplugin by opendaylight.
the class MultipartReplyPortDescTest method testMultipartReplyPortDesc.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyPortDesc() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0D 00 00 00 00 00 00 " + // first port desc
"00 01 02 03 00 00 00 00 " + // portNo, padding
"08 00 27 00 B0 EB 00 00 " + // mac address, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
"00 00 00 65 " + // port config
"00 00 00 07 " + // port state
"00 00 00 81 " + // current features
"00 00 FF FF " + // advertised features
"00 00 C1 89 " + // supported features
"00 00 C5 8D " + // peer features
"00 00 00 81 " + // curr speed
"00 00 00 80 " + // second port desc
"00 00 00 01 00 00 00 00 " + // portNo, padding
"08 00 27 00 B0 EB 00 00 " + // mac address, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
"00 00 00 00 " + // port config
"00 00 00 00 " + // port state
"00 00 00 00 " + // current features
"00 00 00 00 " + // advertised features
"00 00 00 00 " + // supported features
"00 00 00 00 " + // peer features
"00 00 00 05 " + // curr speed
"00 00 00 06");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size());
Ports port = message.getPorts().get(0);
Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue());
Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig());
Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState());
Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures());
Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures());
Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, false, false, true, false, false, false, true, true, true), port.getPeerFeatures());
Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue());
Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue());
port = message.getPorts().get(1);
Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue());
Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig());
Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState());
Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getCurrentFeatures());
Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures());
Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getSupportedFeatures());
Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getPeerFeatures());
Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue());
Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures in project openflowplugin by opendaylight.
the class PortTranslatorUtilTest method testTranslatePortFeaturesV10.
/**
* Test method for
* {@link PortTranslatorUtil#translatePortFeatures(org.opendaylight.yang.gen.v1.urn
* .opendaylight.openflow.common.types.rev130731.PortFeaturesV10)}.
*/
@Test
public void testTranslatePortFeaturesV10() {
for (int i = 0; i < pfV10Bls.length; i++) {
pfV10Bls[i] = true;
final PortFeaturesV10 apfV10 = getPortFeaturesV10();
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures npf = PortTranslatorUtil.translatePortFeatures(apfV10);
assertEqualsPortFeaturesV10(apfV10, npf);
pfV10Bls[i] = false;
}
}
Aggregations