private static final byte PADDING_IN_PORT_STATUS_HEADER = 7;
private static final byte PADDING_IN_OFP_PORT_HEADER_1 = 4;
private static final byte PADDING_IN_OFP_PORT_HEADER_2 = 2;
+ private static final byte MAX_PORT_NAME_LEN = 16;
private PortStatusMessageFactory() {
// Singleton
rawMessage.readBytes(hwAddress);
builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_2);
+ builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));
builder.setConfig(createPortConfig(rawMessage.readUnsignedInt()));
builder.setState(createPortState(rawMessage.readUnsignedInt()));
builder.setCurrentFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
"00 00 00 00 " + //padding in ofp_port1
"08 00 27 00 B0 EB " + //mac address
"00 00 " + //padding in ofp_port2
+ "73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port name, String "s1-eth1"
"00 00 00 41 " + //port config
"00 00 00 05 " + //port state
"00 00 00 81 " + //current features
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(true, false, false, false,