private static final List<FlowLabel> createFlowLabels(final UnkeyedListNode flowLabelsData) { final List<FlowLabel> flowLabels = new ArrayList<>(); for (final UnkeyedListEntryNode node : flowLabelsData.getValue()) { final FlowLabelBuilder flowLabelsBuilder = new FlowLabelBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(AbstractFlowspecNlriParser.OP_NID); if (opValue.isPresent()) { flowLabelsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(AbstractFlowspecNlriParser.VALUE_NID); if (valueNode.isPresent()) { flowLabelsBuilder.setValue((Long) valueNode.get().getValue()); } flowLabels.add(flowLabelsBuilder.build()); } return flowLabels; }
public final List<Flowspec> extractFlowspec(final DataContainerNode<?> route) { Preconditions.checkNotNull(route, "Cannot extract flowspec from null route."); final List<Flowspec> fsList = new ArrayList<>(); final Optional<DataContainerChild<? extends PathArgument, ?>> flowspecs = route.getChild(FLOWSPEC_NID); if (flowspecs.isPresent()) { for (final UnkeyedListEntryNode flowspec : ((UnkeyedListNode) flowspecs.get()).getValue()) { final FlowspecBuilder fsBuilder = new FlowspecBuilder(); final Optional<DataContainerChild<?, ?>> flowspecType = flowspec.getChild(FLOWSPEC_TYPE_NID); if (flowspecType.isPresent()) { final ChoiceNode fsType = (ChoiceNode) flowspecType.get(); processFlowspecType(fsType, fsBuilder); } fsList.add(fsBuilder.build()); } } return fsList; }
/** * Prefix and Path Id are the route key * * @param prefixes UnkeyedListEntryNode containing route * @return Nid with Route Key */ private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode prefixes) { final Optional<DataContainerChild<? extends PathArgument, ?>> maybePrefixLeaf = prefixes.getChild(routePrefixIdentifier()); final Optional<DataContainerChild<? extends PathArgument, ?>> maybePathIdLeaf = prefixes.getChild(routePathIdNid()); Preconditions.checkState(maybePrefixLeaf.isPresent()); final Object prefixValue = (maybePrefixLeaf.get()).getValue(); return PathIdUtil.createNidKey(routeQName(), routeKeyQName(), pathIdQName(), prefixValue, maybePathIdLeaf); } }
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; }
private static List<SourcePorts> createSourcePorts(final UnkeyedListNode sourcePortsData) { final List<SourcePorts> sourcePorts = new ArrayList<>(); for (final UnkeyedListEntryNode node : sourcePortsData.getValue()) { final SourcePortsBuilder sourcePortsBuilder = new SourcePortsBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { sourcePortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { sourcePortsBuilder.setValue((Integer) valueNode.get().getValue()); } sourcePorts.add(sourcePortsBuilder.build()); } return sourcePorts; }
private static List<Codes> createCodes(final UnkeyedListNode codesData) { final List<Codes> codes = new ArrayList<>(); for (final UnkeyedListEntryNode node : codesData.getValue()) { final CodesBuilder codesBuilder = new CodesBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { codesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { codesBuilder.setValue((Short) valueNode.get().getValue()); } codes.add(codesBuilder.build()); } return codes; }
private static List<TcpFlags> createTcpFlags(final UnkeyedListNode tcpFlagsData) { final List<TcpFlags> tcpFlags = new ArrayList<>(); for (final UnkeyedListEntryNode node : tcpFlagsData.getValue()) { final TcpFlagsBuilder tcpFlagsBuilder = new TcpFlagsBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { tcpFlagsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { tcpFlagsBuilder.setValue((Integer) valueNode.get().getValue()); } tcpFlags.add(tcpFlagsBuilder.build()); } return tcpFlags; }
private static List<PacketLengths> createPacketLengths(final UnkeyedListNode packetLengthsData) { final List<PacketLengths> packetLengths = new ArrayList<>(); for (final UnkeyedListEntryNode node : packetLengthsData.getValue()) { final PacketLengthsBuilder packetLengthsBuilder = new PacketLengthsBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { packetLengthsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { packetLengthsBuilder.setValue((Integer) valueNode.get().getValue()); } packetLengths.add(packetLengthsBuilder.build()); } return packetLengths; }
private static final List<ProtocolIps> createProtocolsIps(final UnkeyedListNode protocolIpsData) { final List<ProtocolIps> protocolIps = new ArrayList<>(); for (final UnkeyedListEntryNode node : protocolIpsData.getValue()) { final ProtocolIpsBuilder ipsBuilder = new ProtocolIpsBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(AbstractFlowspecNlriParser.OP_NID); if (opValue.isPresent()) { ipsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(AbstractFlowspecNlriParser.VALUE_NID); if (valueNode.isPresent()) { ipsBuilder.setValue((Short) valueNode.get().getValue()); } protocolIps.add(ipsBuilder.build()); } return protocolIps; }
private static List<DestinationPorts> createDestinationPorts(final UnkeyedListNode destinationPortsData) { final List<DestinationPorts> destinationPorts = new ArrayList<>(); for (final UnkeyedListEntryNode node : destinationPortsData.getValue()) { final DestinationPortsBuilder destPortsBuilder = new DestinationPortsBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { destPortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { destPortsBuilder.setValue((Integer) valueNode.get().getValue()); } destinationPorts.add(destPortsBuilder.build()); } return destinationPorts; }
private static List<Types> createTypes(final UnkeyedListNode typesData) { final List<Types> types = new ArrayList<>(); for (final UnkeyedListEntryNode node : typesData.getValue()) { final TypesBuilder typesBuilder = new TypesBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { typesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { typesBuilder.setValue((Short) valueNode.get().getValue()); } types.add(typesBuilder.build()); } return types; }
private static final List<NextHeaders> createNextHeaders(final UnkeyedListNode nextHeadersData) { final List<NextHeaders> nextHeaders = new ArrayList<>(); for (final UnkeyedListEntryNode node : nextHeadersData.getValue()) { final NextHeadersBuilder nextHeadersBuilder = new NextHeadersBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(AbstractFlowspecNlriParser.OP_NID); if (opValue.isPresent()) { nextHeadersBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(AbstractFlowspecNlriParser.VALUE_NID); if (valueNode.isPresent()) { nextHeadersBuilder.setValue((Short) valueNode.get().getValue()); } nextHeaders.add(nextHeadersBuilder.build()); } return nextHeaders; }
private static List<Dscps> createDscpsLengths(final UnkeyedListNode dscpLengthsData) { final List<Dscps> dscpsLengths = new ArrayList<>(); for (final UnkeyedListEntryNode node : dscpLengthsData.getValue()) { final DscpsBuilder dscpsLengthsBuilder = new DscpsBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { dscpsLengthsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { dscpsLengthsBuilder.setValue(new Dscp((Short) valueNode.get().getValue())); } dscpsLengths.add(dscpsLengthsBuilder.build()); } return dscpsLengths; }
private static List<Fragments> createFragments(final UnkeyedListNode fragmentsData) { final List<Fragments> fragments = new ArrayList<>(); for (final UnkeyedListEntryNode node : fragmentsData.getValue()) { final FragmentsBuilder fragmentsBuilder = new FragmentsBuilder(); final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID); if (opValue.isPresent()) { fragmentsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue())); } final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID); if (valueNode.isPresent()) { fragmentsBuilder.setValue(createFragment((Set<String>) valueNode.get().getValue())); } fragments.add(fragmentsBuilder.build()); } return fragments; }