use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage in project openflowplugin by opendaylight.
the class PortStatusMessageFactory method deserialize.
@Override
public PortStatusMessage deserialize(final ByteBuf rawMessage) {
PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
builder.setPortNo(rawMessage.readUnsignedInt());
rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_1);
builder.setHwAddr(ByteBufUtils.readIetfMacAddress(rawMessage));
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()));
builder.setAdvertisedFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
builder.setSupportedFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
builder.setPeerFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
builder.setCurrSpeed(rawMessage.readUnsignedInt());
builder.setMaxSpeed(rawMessage.readUnsignedInt());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage in project openflowplugin by opendaylight.
the class DeviceContextImplTest method testPortStatusMessage.
@Test
public void testPortStatusMessage() throws Exception {
final PortStatusMessage mockedPortStatusMessage = mock(PortStatusMessage.class);
final Class dummyClass = Class.class;
when(mockedPortStatusMessage.getImplementedInterface()).thenReturn(dummyClass);
final GetFeaturesOutput mockedFeature = mock(GetFeaturesOutput.class);
when(mockedFeature.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
when(mockedPortStatusMessage.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
when(mockedPortStatusMessage.getReason()).thenReturn(PortReason.OFPPRADD);
when(mockedPortStatusMessage.getPortNo()).thenReturn(42L);
deviceContextSpy.processPortStatusMessage(mockedPortStatusMessage);
verify(messageSpy).spyMessage(any(), any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerFullImplTest method testOnPortStatusMessage.
/**
* Test method for
* {@link OpenflowProtocolListenerFullImpl#onPortStatusMessage(
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)}.
*/
@Test
public void testOnPortStatusMessage() {
PortStatusMessage portStatusMessage = new PortStatusMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build();
ofProtocolListener.onPortStatusMessage(portStatusMessage);
Mockito.verify(deviceReplyProcessor).processPortStatusMessage(Matchers.any(PortStatusMessage.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage in project openflowplugin by opendaylight.
the class ConnectionAdapterImplTest method testConsume.
/**
* Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications.
*/
@Test
public void testConsume() {
DataObject message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
message = new ErrorMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message);
message = new ExperimenterMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message);
message = new FlowRemovedMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message);
message = new HelloMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onHelloMessage((HelloMessage) message);
message = new MultipartReplyMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message);
message = new PacketInMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message);
message = new PortStatusMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message);
message = new SwitchIdleEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message);
message = new DisconnectEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message);
message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage in project openflowplugin by opendaylight.
the class OF10PortStatusMessageFactory method deserialize.
@Override
public PortStatusMessage deserialize(final ByteBuf rawMessage) {
PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
deserializePort(rawMessage, builder);
return builder.build();
}
Aggregations