diff options
Diffstat (limited to 'srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering')
6 files changed, 462 insertions, 0 deletions
diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/InterfaceCustomizer.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/InterfaceCustomizer.java new file mode 100644 index 000000000..9151a9822 --- /dev/null +++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/InterfaceCustomizer.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.srv6.read.steering; + +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.srv6.read.steering.request.L2SteeringRequest; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.List; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.segment.routing.traffic.engineering.policies.policy.autoroute.include.InterfacesBuilder; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.sr.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.sr.interfaces.InterfaceBuilder; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.sr.interfaces.InterfaceKey; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class InterfaceCustomizer extends FutureJVppCustomizer + implements ListReaderCustomizer<Interface, InterfaceKey, InterfaceBuilder> { + + private final NamingContext interfaceContext; + + public InterfaceCustomizer(@Nonnull final FutureJVppCore futureJVppCore, + @Nonnull final NamingContext interfaceContext) { + super(futureJVppCore); + this.interfaceContext = interfaceContext; + } + + @Nonnull + @Override + public List<InterfaceKey> getAllIds(@Nonnull InstanceIdentifier<Interface> id, @Nonnull ReadContext context) + throws ReadFailedException { + return + new L2SteeringRequest(getFutureJVpp(), interfaceContext).readAllKeys(id, context); + } + + @Override + public void merge(@Nonnull Builder<? extends DataObject> builder, @Nonnull List<Interface> readData) { + ((InterfacesBuilder) builder).setInterface(readData); + } + + @Nonnull + @Override + public InterfaceBuilder getBuilder(@Nonnull InstanceIdentifier<Interface> id) { + return new InterfaceBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull InstanceIdentifier<Interface> id, @Nonnull InterfaceBuilder builder, + @Nonnull ReadContext ctx) throws ReadFailedException { + L2SteeringRequest readRequest = new L2SteeringRequest(getFutureJVpp(), interfaceContext); + readRequest.readSpecific(id, ctx, builder); + } +} diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/PrefixCustomizer.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/PrefixCustomizer.java new file mode 100644 index 000000000..b0ee7c3f8 --- /dev/null +++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/PrefixCustomizer.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.srv6.read.steering; + +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.srv6.read.steering.request.L3SteeringRequest; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.List; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.PrefixesBuilder; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.Prefix; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.PrefixBuilder; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.PrefixKey; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class PrefixCustomizer extends FutureJVppCustomizer + implements ListReaderCustomizer<Prefix, PrefixKey, PrefixBuilder> { + + public PrefixCustomizer(@Nonnull final FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Nonnull + @Override + public List<PrefixKey> getAllIds(@Nonnull InstanceIdentifier<Prefix> id, @Nonnull ReadContext context) + throws ReadFailedException { + return + new L3SteeringRequest(getFutureJVpp()).readAllKeys(id, context); + } + + @Override + public void merge(@Nonnull Builder<? extends DataObject> builder, @Nonnull List<Prefix> readData) { + ((PrefixesBuilder) builder).setPrefix(readData); + } + + @Nonnull + @Override + public PrefixBuilder getBuilder(@Nonnull InstanceIdentifier<Prefix> id) { + return new PrefixBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull InstanceIdentifier<Prefix> id, @Nonnull PrefixBuilder builder, + @Nonnull ReadContext ctx) throws ReadFailedException { + L3SteeringRequest readRequest = new L3SteeringRequest(getFutureJVpp()); + readRequest.readSpecific(id, ctx, builder); + } +} diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/PrefixesStateCustomizer.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/PrefixesStateCustomizer.java new file mode 100644 index 000000000..b099939eb --- /dev/null +++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/PrefixesStateCustomizer.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.fd.hc2vpp.srv6.read.steering; + +import com.google.common.collect.ImmutableSet; +import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; +import io.fd.hc2vpp.srv6.read.steering.request.L3SteeringRequest; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; +import io.fd.honeycomb.translate.util.RWUtils; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.List; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.Prefixes; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.PrefixesBuilder; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.State; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.StateBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class PrefixesStateCustomizer extends FutureJVppCustomizer implements ReaderCustomizer<State, StateBuilder> { + + public PrefixesStateCustomizer(@Nonnull final FutureJVppCore futureJVppCore) { + super(futureJVppCore); + } + + @Nonnull + @Override + public StateBuilder getBuilder(@Nonnull final InstanceIdentifier<State> instanceIdentifier) { + return new StateBuilder(); + } + + @Override + public void readCurrentAttributes(@Nonnull final InstanceIdentifier<State> instanceIdentifier, + @Nonnull final StateBuilder stateBuilder, @Nonnull final ReadContext readContext) + throws ReadFailedException { + L3SteeringRequest request = new L3SteeringRequest(getFutureJVpp()); + List<IpPrefix> ipPrefixes = + request.readAllIpPrefixes(RWUtils.cutId(instanceIdentifier, Prefixes.class), readContext); + // checks whether L3 steering contains default routes to steer all traffic to SRv6 policy. If found sets + // allPrefixes flag to true in autoroute-include/prefixes/state + boolean allPrefixes = ipPrefixes.containsAll( + ImmutableSet.of(new IpPrefix(new Ipv4Prefix("0.0.0.0/0")), new IpPrefix(new Ipv6Prefix("::/0")))); + + stateBuilder.setPrefixesAll(allPrefixes); + } + + @Override + public void merge(@Nonnull final Builder<? extends DataObject> builder, @Nonnull final State state) { + ((PrefixesBuilder) builder).setState(state); + } +} diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/L2SteeringRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/L2SteeringRequest.java new file mode 100644 index 000000000..eb9370787 --- /dev/null +++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/L2SteeringRequest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.srv6.read.steering.request; + +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.srv6.read.ReadRequest; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.vpp.jvpp.core.dto.SrSteeringPolDetails; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.sr.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.sr.interfaces.InterfaceBuilder; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.sr.interfaces.InterfaceKey; +import org.opendaylight.yang.gen.v1.urn.hc2vpp.params.xml.ns.yang.vpp.oc.srte.policy.rev180514.sr.interfaces._interface.StateBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * Request for steering of L2 traffic + */ + +public class L2SteeringRequest extends SteeringRequest + implements ReadRequest<Interface, InterfaceKey, InterfaceBuilder> { + + static final int L2_TRAFFIC_TYPE = 2; + private final NamingContext ifcNamingContext; + + public L2SteeringRequest(FutureJVppCore api, NamingContext namingContext) { + super(api); + this.ifcNamingContext = namingContext; + } + + @Override + @Nonnull + public List<InterfaceKey> readAllKeys(@Nonnull InstanceIdentifier<Interface> identifier, @Nonnull ReadContext ctx) + throws ReadFailedException { + return dumpManager.getDump(identifier, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY) + .srSteeringPolDetails.stream() + .filter(srSteeringPolDetails -> ((int) srSteeringPolDetails.trafficType) == L2_TRAFFIC_TYPE) + .map(srSteeringPolDetails -> srSteeringPolDetails.swIfIndex) + .map(ifIndex -> new InterfaceKey(ifcNamingContext.getName(ifIndex, ctx.getMappingContext()))) + .collect(Collectors.toList()); + } + + @Override + public void readSpecific(@Nonnull InstanceIdentifier<Interface> identifier, @Nonnull ReadContext ctx, + @Nonnull InterfaceBuilder builder) throws ReadFailedException { + int index = + ifcNamingContext.getIndex(identifier.firstKeyOf(Interface.class).getInputInterface(), + ctx.getMappingContext()); + + dumpManager.getDump(identifier, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY) + .srSteeringPolDetails.stream() + .filter(srSteeringPolDetails -> ((int) srSteeringPolDetails.trafficType) == L2_TRAFFIC_TYPE) + .filter(srSteeringPolDetails -> srSteeringPolDetails.swIfIndex == index) + .findFirst() + .ifPresent(srSteeringPolDetails -> parseL2Steering(srSteeringPolDetails, builder, ctx)); + } + + private void parseL2Steering(SrSteeringPolDetails srSteeringPolDetails, final InterfaceBuilder builder, + ReadContext ctx) { + String name = ifcNamingContext.getName(srSteeringPolDetails.swIfIndex, ctx.getMappingContext()); + builder.setInputInterface(name).setKey(new InterfaceKey(name)) + .setState(new StateBuilder().setInputInterface(name).build()); + } +} + diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/L3SteeringRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/L3SteeringRequest.java new file mode 100644 index 000000000..1043746e9 --- /dev/null +++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/L3SteeringRequest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.srv6.read.steering.request; + +import com.google.common.base.Preconditions; +import io.fd.hc2vpp.srv6.read.ReadRequest; +import io.fd.honeycomb.translate.read.ReadContext; +import io.fd.honeycomb.translate.read.ReadFailedException; +import io.fd.vpp.jvpp.core.dto.SrSteeringPolDetails; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; +import java.util.List; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.include.prefix.StateBuilder; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.Prefixes; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.Prefix; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.PrefixBuilder; +import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.prefixes.properties.prefixes.PrefixKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * Request for steering of L3 traffic + */ + +public class L3SteeringRequest extends SteeringRequest + implements ReadRequest<Prefix, PrefixKey, PrefixBuilder> { + + private static final int L3_TRAFFIC_TYPE_IPV6 = 6; + private static final int L3_TRAFFIC_TYPE_IPV4 = 4; + + public L3SteeringRequest(final FutureJVppCore api) { + super(api); + } + + @Override + public void checkValid() { + super.checkValid(); + } + + @Override + @Nonnull + public List<PrefixKey> readAllKeys(@Nonnull InstanceIdentifier<Prefix> identifier, @Nonnull ReadContext ctx) + throws ReadFailedException { + return dumpManager.getDump(identifier, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY) + .srSteeringPolDetails.stream() + .filter( + srSteeringPolDetails -> ((int) srSteeringPolDetails.trafficType) != + L2SteeringRequest.L2_TRAFFIC_TYPE) + .map(this::parseL3SteeringKey) + .collect(Collectors.toList()); + } + + public List<IpPrefix> readAllIpPrefixes(@Nonnull InstanceIdentifier<Prefixes> identifier, @Nonnull ReadContext ctx) + throws ReadFailedException { + return dumpManager.getDump(identifier, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY) + .srSteeringPolDetails.stream() + .filter( + srSteeringPolDetails -> ((int) srSteeringPolDetails.trafficType) != + L2SteeringRequest.L2_TRAFFIC_TYPE) + .map(this::parseIpPrefix) + .collect(Collectors.toList()); + } + + @Override + public void readSpecific(@Nonnull InstanceIdentifier<Prefix> identifier, @Nonnull ReadContext ctx, + @Nonnull PrefixBuilder builder) throws ReadFailedException { + checkValid(); + PrefixKey key = identifier.firstKeyOf(Prefix.class); + dumpManager.getDump(identifier, ctx.getModificationCache()).or(STATIC_EMPTY_REPLY) + .srSteeringPolDetails.stream() + .filter( + srSteeringPolDetails -> ((int) srSteeringPolDetails.trafficType) != + L2SteeringRequest.L2_TRAFFIC_TYPE) + .filter(srSteeringPolDetails -> parseL3SteeringKey(srSteeringPolDetails).equals(key)) + .findFirst() + .ifPresent(srSteeringPolDetails1 -> parseL3Steering(srSteeringPolDetails1, builder)); + } + + private void parseL3Steering(SrSteeringPolDetails srSteeringPolDetails, final PrefixBuilder builder) { + PrefixKey key = parseL3SteeringKey(srSteeringPolDetails); + builder.setKey(key).setIpPrefix(key.getIpPrefix()) + .setState(new StateBuilder().setIpPrefix(key.getIpPrefix()).build()); + } + + private PrefixKey parseL3SteeringKey(SrSteeringPolDetails policyDetails) { + return new PrefixKey(parseIpPrefix(policyDetails)); + } + + private IpPrefix parseIpPrefix(final SrSteeringPolDetails policyDetails) { + boolean isIpv6 = isIpv6L3TrafficType(policyDetails.trafficType); + IpPrefix ipPrefix; + if (isIpv6) { + Ipv6Prefix ipv6Prefix = toIpv6Prefix(policyDetails.prefixAddr, policyDetails.maskWidth); + ipPrefix = new IpPrefix(ipv6Prefix); + } else { + Ipv4Prefix ipv4Prefix = toIpv4Prefix(policyDetails.prefixAddr, policyDetails.maskWidth); + ipPrefix = new IpPrefix(ipv4Prefix); + } + return ipPrefix; + } + + private boolean isIpv6L3TrafficType(final byte trafficType) { + Preconditions.checkArgument(trafficType == L3_TRAFFIC_TYPE_IPV4 || trafficType == L3_TRAFFIC_TYPE_IPV6, + "Unsupported traffic type for L3 steering"); + + return trafficType == L3_TRAFFIC_TYPE_IPV6; + } +} diff --git a/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/SteeringRequest.java b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/SteeringRequest.java new file mode 100644 index 000000000..04b67f67e --- /dev/null +++ b/srv6/srv6-impl/src/main/java/io/fd/hc2vpp/srv6/read/steering/request/SteeringRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.srv6.read.steering.request; + +import io.fd.hc2vpp.srv6.util.JVppRequest; +import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; +import io.fd.vpp.jvpp.core.dto.SrSteeringPolDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.SrSteeringPolDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; + +/** + * General template for steering requests + */ +abstract class SteeringRequest extends JVppRequest { + + static final SrSteeringPolDetailsReplyDump STATIC_EMPTY_REPLY = new SrSteeringPolDetailsReplyDump(); + private static final SrSteeringPolDump STATIC_DUMP_REQUEST = new SrSteeringPolDump(); + final DumpCacheManager<SrSteeringPolDetailsReplyDump, Void> dumpManager; + + SteeringRequest(final FutureJVppCore api) { + super(api); + this.dumpManager = + new DumpCacheManager.DumpCacheManagerBuilder<SrSteeringPolDetailsReplyDump, Void>().acceptOnly( + SrSteeringPolDetailsReplyDump.class) + .withExecutor((identifier, params) -> getReplyForRead( + getApi().srSteeringPolDump(STATIC_DUMP_REQUEST).toCompletableFuture(), identifier)) + .build(); + } +} |