use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method serializePortDescBody.
private void serializePortDescBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
MultipartReplyPortDescCase portCase = (MultipartReplyPortDescCase) body;
MultipartReplyPortDesc portDesc = portCase.getMultipartReplyPortDesc();
for (Ports port : portDesc.getPorts()) {
// Assuming PortNo
outBuffer.writeInt(port.getPortNo().intValue());
// = PortId
outBuffer.writeZero(PORT_DESC_PADDING_1);
outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(port.getHwAddr()));
outBuffer.writeZero(PORT_DESC_PADDING_2);
writeName(port.getName(), outBuffer);
writePortConfig(port.getConfig(), outBuffer);
writePortState(port.getState(), outBuffer);
writePortFeatures(port.getCurrentFeatures(), outBuffer);
writePortFeatures(port.getAdvertisedFeatures(), outBuffer);
writePortFeatures(port.getSupportedFeatures(), outBuffer);
writePortFeatures(port.getPeerFeatures(), outBuffer);
outBuffer.writeInt(port.getCurrSpeed().intValue());
outBuffer.writeInt(port.getMaxSpeed().intValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class MultipartReplyPortDescDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
final List<Ports> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final PortsBuilder itemBuilder = new PortsBuilder();
itemBuilder.setPortNumber(new PortNumberUni(message.readUnsignedInt()));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
itemBuilder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message));
message.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
items.add(itemBuilder.setName(ByteBufUtils.decodeNullTerminatedString(message, EncodeConstants.MAX_PORT_NAME_LENGTH)).setConfiguration(readPortConfig(message)).setState(readPortState(message)).setCurrentFeature(readPortFeatures(message)).setAdvertisedFeatures(readPortFeatures(message)).setSupported(readPortFeatures(message)).setPeerFeatures(readPortFeatures(message)).setCurrentSpeed(message.readUnsignedInt()).setMaximumSpeed(message.readUnsignedInt()).build());
}
return builder.setPorts(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createPortList.
private static List<Ports> createPortList() {
PortsBuilder builder = new PortsBuilder();
builder.setPortNo(1L);
builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
builder.setName("Port name");
builder.setConfig(new PortConfig(true, false, true, false));
builder.setState(new PortState(true, false, true));
builder.setCurrentFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setAdvertisedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setSupportedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
builder.setCurrSpeed(1234L);
builder.setMaxSpeed(1234L);
List<Ports> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class OF10FeaturesReplyMessageFactoryTest method createPorts.
private static List<PhyPort> createPorts() {
final List<PhyPort> ports = new ArrayList<>();
PhyPortBuilder builder = new PhyPortBuilder();
builder.setPortNo(1L);
builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
builder.setName("Port name");
builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true));
builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false));
builder.setCurrentFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
builder.setAdvertisedFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
builder.setSupportedFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
builder.setPeerFeaturesV10(new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false));
ports.add(builder.build());
return ports;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class PortConvertor method toPortDesc.
/**
* This method is called as a reply to OFPMP_PORT_DESCRIPTION message(OF1.3.1).
*
* @param source FlowCapablePort
* @param version openflow version
* @return OF:Ports
*/
@VisibleForTesting
static Ports toPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.FlowCapablePort source, short version) {
PortsBuilder ofPortDescDataBuilder = new PortsBuilder();
ofPortDescDataBuilder.setPortNo(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(version), // portNO
source.getPortNumber()));
ofPortDescDataBuilder.setHwAddr(source.getHardwareAddress());
ofPortDescDataBuilder.setName(source.getName());
PortConfig config = maskPortConfigFields(source.getConfiguration());
ofPortDescDataBuilder.setConfig(config);
PortState portState = getPortState(source.getState());
ofPortDescDataBuilder.setState(portState);
ofPortDescDataBuilder.setCurrentFeatures(getPortFeatures(source.getCurrentFeature()));
ofPortDescDataBuilder.setAdvertisedFeatures(getPortFeatures(source.getAdvertisedFeatures()));
ofPortDescDataBuilder.setSupportedFeatures(getPortFeatures(source.getSupported()));
ofPortDescDataBuilder.setPeerFeatures(getPortFeatures(source.getPeerFeatures()));
ofPortDescDataBuilder.setCurrSpeed(source.getCurrentSpeed());
ofPortDescDataBuilder.setMaxSpeed(source.getMaximumSpeed());
return ofPortDescDataBuilder.build();
}
Aggregations