2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.flowspec;
10 import io.netty.buffer.ByteBuf;
11 import java.util.List;
12 import org.opendaylight.protocol.bgp.flowspec.ipv4.FlowspecIpv4NlriParserHelper;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.Flowspec;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.FlowspecBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv4.DestinationFlowspecIpv4;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.ipv4.DestinationFlowspecIpv4Builder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
20 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
22 public final class SimpleFlowspecIpv4NlriParser extends AbstractFlowspecNlriParser {
24 public SimpleFlowspecIpv4NlriParser(final SimpleFlowspecTypeRegistry flowspecTypeRegistry) {
25 super(flowspecTypeRegistry);
29 public DestinationType createWithdrawnDestinationType(final Object[] nlriFields, final PathId pathId) {
30 final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
31 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
32 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCaseBuilder()
33 .setDestinationFlowspecIpv4(
34 new DestinationFlowspecIpv4Builder()
35 .setFlowspec(flowspecList)
42 public DestinationType createAdvertizedRoutesDestinationType(final Object[] nlriFields, final PathId pathId) {
43 final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[0];
44 return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update
45 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCaseBuilder()
46 .setDestinationFlowspecIpv4(new DestinationFlowspecIpv4Builder()
47 .setFlowspec(flowspecList)
53 protected void serializeMpReachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
54 if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
55 .update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationFlowspecCase) {
56 final DestinationFlowspecIpv4 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
57 .yang.bgp.flowspec.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
58 .DestinationFlowspecCase) dstType).getDestinationFlowspecIpv4();
59 serializeNlri(new Object[] {destFlowspec.getFlowspec()}, destFlowspec.getPathId(), byteAggregator);
64 public void extractSpecificFlowspec(final ChoiceNode fsType, final FlowspecBuilder fsBuilder) {
65 FlowspecIpv4NlriParserHelper.extractFlowspec(fsType, fsBuilder);
69 protected void stringSpecificFSNlriType(final FlowspecType value, final StringBuilder buffer) {
70 FlowspecIpv4NlriParserHelper.buildFlowspecString(value, buffer);
74 protected void serializeMpUnreachNlri(final DestinationType dstType, final ByteBuf byteAggregator) {
75 if (dstType instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
76 .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecCase) {
77 final DestinationFlowspecIpv4 destFlowspec = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
78 .yang.bgp.flowspec.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
79 .DestinationFlowspecCase) dstType).getDestinationFlowspecIpv4();
80 serializeNlri(new Object[] {destFlowspec.getFlowspec()}, destFlowspec.getPathId(), byteAggregator);