use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createPorts.
private static List<Ports> createPorts(final UnkeyedListNode portsData) {
final List<Ports> ports = new ArrayList<>();
for (final UnkeyedListEntryNode node : portsData.getValue()) {
final PortsBuilder portsBuilder = new PortsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
portsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
portsBuilder.setValue((Integer) valueNode.get().getValue());
}
ports.add(portsBuilder.build());
}
return ports;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project bgpcep by opendaylight.
the class SimpleFlowspecIpv4NlriParserTest method testExtractFlowspecPorts.
@Test
public void testExtractFlowspecPorts() {
final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry = Builders.mapEntryBuilder();
entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.choiceBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID).withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID).withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID).withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.LESS_THAN_VALUE)).build()).withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID).withValue(100).build()).build()).build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new PortCaseBuilder().setPorts(Lists.newArrayList(new PortsBuilder().setValue(100).setOp(new NumericOperand(true, true, false, false, true)).build())).build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
assertEquals(expected, this.FS_PARSER.extractFlowspec(entry.build()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project bgpcep by opendaylight.
the class NumericOperandParserTest method testSerializeTwoByte.
@Test
public void testSerializeTwoByte() {
final ByteBuf nlriByteBuf = Unpooled.buffer();
final List<Ports> ports = new ArrayList<>();
// create 3 ports without end-of-list bit set
for (int i = 0; i < 3; i++) {
ports.add(new PortsBuilder().setOp(new NumericOperand(false, false, true, false, false)).setValue(100 + i).build());
}
NumericTwoByteOperandParser.INSTANCE.serialize(ports, nlriByteBuf);
assertArrayEquals(ONE_BYTE_CODE_LIST, ByteArray.readAllBytes(nlriByteBuf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.port._case.PortsBuilder in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv4NlriParserTest method testExtractFlowspecPorts.
@Test
public void testExtractFlowspecPorts() {
final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry = Builders.mapEntryBuilder();
entry.withNodeIdentifier(new NodeIdentifierWithPredicates(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.choiceBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID).withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID).withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID).withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE, AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.LESS_THAN_VALUE)).build()).withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID).withValue(100).build()).build()).build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new PortCaseBuilder().setPorts(Lists.newArrayList(new PortsBuilder().setValue(100).setOp(new NumericOperand(true, true, false, false, true)).build())).build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
assertEquals(expected, this.FS_PARSER.extractFlowspec(entry.build()));
}
Aggregations