736e8eb5716c398b7fe9264e06044e65c0be8d42
[bgpcep.git] / bgp / evpn / src / test / java / org / opendaylight / protocol / bgp / evpn / impl / attributes / tunnel / identifier / PMSITunnelAttributeHandlerTestUtil.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
10
11 import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.IPV6;
12 import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MPLS_LABEL;
13 import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.OpaqueUtilTest.OPAQUE_TEST;
14 import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.OpaqueUtilTest.OPAQUE_TEST2;
15
16 import java.util.ArrayList;
17 import java.util.Collections;
18 import java.util.List;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.L2vpnAddressFamily;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.PmsiTunnelAugmentation;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.evpn.route.PmsiTunnelAugmentationBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.PAddressPMulticastGroup;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.PmsiTunnelBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.BidirPimTreeBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.IngressReplicationBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpMp2mpLspBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpP2mpLspBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.PimSmTreeBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.PimSsmTreeBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.RsvpTeP2mpLspBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValue;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder;
41 import org.opendaylight.yangtools.yang.binding.DataContainer;
42
43 final class PMSITunnelAttributeHandlerTestUtil {
44     /**
45      * ATT - TYPE - ATT LENGTH
46      * PMSI FLAG - PMSI TYPE 0- MPLS LABEL
47      * No tunnel information present
48      */
49     static final byte[] NO_TUNNEL_INFORMATION_PRESENT_EXPECTED = {
50         (byte) 0x80, (byte) 0x16, (byte) 0x05,
51         (byte) 0x01, (byte) 0x00, (byte) 0x05, (byte) 0xdc, (byte) 0x10
52     };
53     /**
54      * ATT - TYPE - ATT LENGTH
55      * PMSI FLAG - PMSI TYPE 1- MPLS LABEL
56      * mLDP P2MP LSP
57      */
58     static final byte[] RSVP_TE_P2MP_LSP_LSP_EXPECTED = {
59         (byte) 0x80, (byte) 0x16, (byte) 0x11,
60         (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
61         (byte) 0x00, (byte) 0x00, (byte) 0x0d, (byte) 0x82,
62         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0f,
63         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
64     };
65     /**
66      * ATT - TYPE - ATT LENGTH
67      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
68      * mLDP P2MP LSP
69      */
70     static final byte[] M_LDP_P2MP_LSP_EXPECTED_IPV4 = {
71         (byte) 0x80, (byte) 0x16, (byte) 0x35,
72         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
73         (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x04,
74         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
75         (byte) 0x00, (byte) 0x26, //Opaque Values Length
76         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
77         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
78         (byte) 0x00, (byte) 0x00, (byte) 0x01,
79         (byte) 0x00, (byte) 0x00, (byte) 0x00,
80         (byte) 0x01, (byte) 0x00, (byte) 0x00,
81         (byte) 0x00, (byte) 0x00,
82         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
83         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
84         (byte) 0x00, (byte) 0x00, (byte) 0x01,
85         (byte) 0x00, (byte) 0x00, (byte) 0x00,
86         (byte) 0x01, (byte) 0x00, (byte) 0x00,
87         (byte) 0x00, (byte) 0x00, (byte) 0x01,
88         (byte) 0x02
89     };
90     /**
91      * ATT - TYPE - ATT LENGTH
92      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
93      * mLDP P2MP LSP
94      */
95     static final byte[] M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY = {
96         (byte) 0x80, (byte) 0x16, (byte) 0x20,
97         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
98         (byte) 0x06, (byte) 0x00, (byte) 0xfc, (byte) 0x04,
99         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
100         (byte) 0x00, (byte) 0x11, //Opaque Values Length
101         (byte) 0x01, (byte) 0x00, (byte) 0x03, // Opaque Type - Length
102         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d,  //Value
103         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x06, // Opaque Type -Ext Type - Length
104         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d, (byte) 0xd7, (byte) 0x6d, (byte) 0xf8, //Value
105     };
106     /**
107      * ATT - TYPE - ATT LENGTH
108      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
109      * mLDP P2MP LSP L2VPN
110      */
111     static final byte[] M_LDP_P2MP_LSP_EXPECTED_L2VPN = {
112         (byte) 0x80, (byte) 0x16, (byte) 0x35,
113         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
114         (byte) 0x06, (byte) 0x00, (byte) 0x19, (byte) 0x04,
115         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
116         (byte) 0x00, (byte) 0x26, //Opaque Values Length
117         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
118         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
119         (byte) 0x00, (byte) 0x00, (byte) 0x01,
120         (byte) 0x00, (byte) 0x00, (byte) 0x00,
121         (byte) 0x01, (byte) 0x00, (byte) 0x00,
122         (byte) 0x00, (byte) 0x00,
123         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
124         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
125         (byte) 0x00, (byte) 0x00, (byte) 0x01,
126         (byte) 0x00, (byte) 0x00, (byte) 0x00,
127         (byte) 0x01, (byte) 0x00, (byte) 0x00,
128         (byte) 0x00, (byte) 0x00, (byte) 0x01,
129         (byte) 0x02
130     };
131     /**
132      * ATT - TYPE - ATT LENGTH
133      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
134      * mLDP P2MP LSP IPV4
135      */
136     static final byte[] M_LDP_P2MP_LSP_EXPECTED_IPV4_2 = {
137         (byte) 0x80, (byte) 0x16, (byte) 0x3b,
138         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
139         (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x04,
140         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
141         (byte) 0x00, (byte) 0x2c, //Opaque Values Length
142         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
143         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
144         (byte) 0x00, (byte) 0x00, (byte) 0x01,
145         (byte) 0x00, (byte) 0x00, (byte) 0x00,
146         (byte) 0x01, (byte) 0x00, (byte) 0x00,
147         (byte) 0x00, (byte) 0x00,
148         (byte) 0xfc, (byte) 0x00, (byte) 0x03, // Wrong Opaque Type - Length
149         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d,  //Value
150         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
151         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
152         (byte) 0x00, (byte) 0x00, (byte) 0x01,
153         (byte) 0x00, (byte) 0x00, (byte) 0x00,
154         (byte) 0x01, (byte) 0x00, (byte) 0x00,
155         (byte) 0x00, (byte) 0x00, (byte) 0x01,
156         (byte) 0x02
157     };
158     /**
159      * ATT - TYPE - ATT LENGTH
160      * PMSI FLAG - PMSI TYPE 2- MPLS LABEL
161      * mLDP P2MP LSP IPV6
162      */
163     static final byte[] M_LDP_P2MP_LSP_EXPECTED_IPV6 = {
164         (byte) 0x80, (byte) 0x16, (byte) 0x41,
165         (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
166         (byte) 0x06, (byte) 0x00, (byte) 0x02, (byte) 0x10,
167         (byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00,
168         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
169         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
170         (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
171         (byte) 0x00, (byte) 0x26, //Opaque Values Length
172         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
173         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
174         (byte) 0x00, (byte) 0x00, (byte) 0x01,
175         (byte) 0x00, (byte) 0x00, (byte) 0x00,
176         (byte) 0x01, (byte) 0x00, (byte) 0x00,
177         (byte) 0x00, (byte) 0x00,
178         (byte) 0xff, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x10, // Opaque Type -Ext Type - Length
179         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
180         (byte) 0x00, (byte) 0x00, (byte) 0x01,
181         (byte) 0x00, (byte) 0x00, (byte) 0x00,
182         (byte) 0x01, (byte) 0x00, (byte) 0x00,
183         (byte) 0x00, (byte) 0x00, (byte) 0x01,
184         (byte) 0x02
185     };
186     /**
187      * ATT - TYPE - ATT LENGTH
188      * PMSI FLAG - PMSI TYPE 3- MPLS LABEL
189      * PIM-SSM Tree
190      */
191     static final byte[] PIM_SSM_TREE_EXPECTED = {
192         (byte) 0x80, (byte) 0x16, (byte) 0x0d,
193         (byte) 0x01, (byte) 0x03, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
194         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
195         (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
196     };
197     /**
198      * ATT - TYPE - ATT LENGTH
199      * PMSI FLAG - PMSI TYPE 4- MPLS LABEL
200      * PIM-SM Tree
201      */
202     static final byte[] PIM_SM_TREE_EXPECTED = {
203         (byte) 0x80, (byte) 0x16, (byte) 0x0d,
204         (byte) 0x01, (byte) 0x04, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
205         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
206         (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
207     };
208     /**
209      * ATT - TYPE - ATT LENGTH
210      * PMSI FLAG - PMSI TYPE 5- MPLS LABEL
211      * BIDIR-PIM Tree
212      */
213     static final byte[] BIDIR_PIM_EXPECTED = {
214         (byte) 0x80, (byte) 0x16, (byte) 0x0d,
215         (byte) 0x01, (byte) 0x05, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
216         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
217         (byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
218     };
219     /**
220      * ATT - TYPE - ATT LENGTH
221      * PMSI FLAG - PMSI TYPE 6- MPLS LABEL
222      * Ingress Replication
223      */
224     static final byte[] INGRESS_REPLICATION_EXPECTED = {
225         (byte) 0x80, (byte) 0x16, (byte) 0x09,
226         (byte) 0x01, (byte) 0x06, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
227         (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01
228     };
229     /**
230      * ATT - TYPE - ATT LENGTH
231      * PMSI FLAG - PMSI TYPE 7- MPLS LABEL
232      * mLDP MP2MP LSP
233      */
234     static final byte[] M_LDP_MP_2_MP_LSP_EXPECTED = {
235         (byte) 0x80, (byte) 0x16, (byte) 0x16,
236         (byte) 0x01, (byte) 0x07, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
237         (byte) 0x01, (byte) 0x00, (byte) 0x0e, // Opaque Type - Length
238         (byte) 0x07, (byte) 0x00, (byte) 0x0B, //Value
239         (byte) 0x00, (byte) 0x00, (byte) 0x01,
240         (byte) 0x00, (byte) 0x00, (byte) 0x00,
241         (byte) 0x01, (byte) 0x00, (byte) 0x00,
242         (byte) 0x00, (byte) 0x00
243     };
244     /**
245      * ATT - TYPE - ATT LENGTH
246      * PMSI FLAG - PMSI TYPE 7- MPLS LABEL
247      * mLDP MP2MP LSP
248      */
249     static final byte[] M_LDP_MP_2_MP_LSP_WRONG = {
250         (byte) 0x80, (byte) 0x16, (byte) 0x0b,
251         (byte) 0x01, (byte) 0x07, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
252         (byte) 0xfc, (byte) 0x00, (byte) 0x03, // Opaque Type - Length
253         (byte) 0xb5, (byte) 0xeb, (byte) 0x2d,  //Value
254     };
255
256     static final IpAddress P_MULTICAST = new IpAddress(new Ipv4Address("23.1.1.1"));
257     static final IpAddress P_ADDRESS = new IpAddress(new Ipv4Address("1.1.1.1"));
258     private static final Short NO_SUPPORTED_OPAQUE = 200;
259
260     static class MockTunnelIdentifier implements TunnelIdentifier {
261         @Override
262         public Class<? extends DataContainer> getImplementedInterface() {
263             return MockTunnelIdentifier.class;
264         }
265     }
266
267     static abstract class NonSupportedAddressFamily extends AddressFamily {
268     }
269
270     private static PAddressPMulticastGroup buildPAddressPMulticastGroup() {
271         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier
272             .bidir.pim.tree.BidirPimTreeBuilder().setPAddress(P_ADDRESS).setPMulticastGroup(P_MULTICAST).build();
273     }
274
275     private static PmsiTunnelBuilder getPmsiTunnelBuilder() {
276         final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
277         pmsiTunnelBuilder.setLeafInformationRequired(true);
278         pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL);
279         return pmsiTunnelBuilder;
280     }
281
282     private static Attributes buildAttribute(final PmsiTunnelBuilder pmsiTunnelBuilder) {
283         return new AttributesBuilder().setUnrecognizedAttributes(Collections.emptyList()).addAugmentation(PmsiTunnelAugmentation.class,
284             new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build()).build();
285     }
286
287     static Attributes buildBidirPimTreeAttribute() {
288         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
289         pmsiTunnelBuilder.setTunnelIdentifier(new BidirPimTreeBuilder().setBidirPimTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
290             .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
291         return buildAttribute(pmsiTunnelBuilder);
292     }
293
294     static Attributes buildPimSMTreeAttribute() {
295         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
296         pmsiTunnelBuilder.setTunnelIdentifier(new PimSmTreeBuilder().setPimSmTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
297             .yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.sm.tree.PimSmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
298         return buildAttribute(pmsiTunnelBuilder);
299     }
300
301     static Attributes buildPimSSMTreeAttribute() {
302         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
303         pmsiTunnelBuilder.setTunnelIdentifier(new PimSsmTreeBuilder().setPimSsmTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
304             .yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.ssm.tree.PimSsmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
305         return buildAttribute(pmsiTunnelBuilder);
306     }
307
308     static Attributes buildNoSupportedOpaqueAttribute() {
309         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
310         final List<OpaqueValue> nonSupported = Collections.singletonList(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build());
311         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, Ipv4AddressFamily.class, nonSupported));
312         return buildAttribute(pmsiTunnelBuilder);
313     }
314
315     static Attributes buildNoSupportedFamilyAttribute() {
316         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
317         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, NonSupportedAddressFamily.class, createOpaqueList()));
318         return buildAttribute(pmsiTunnelBuilder);
319     }
320
321     static Attributes buildMLDPP2MPLSPIpv4Attribute() {
322         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
323         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, Ipv4AddressFamily.class, createOpaqueList()));
324         return buildAttribute(pmsiTunnelBuilder);
325     }
326
327     static Attributes buildMLDPP2MPLSPIpv6Attribute() {
328         final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
329         pmsiTunnelBuilder.setLeafInformationRequired(true);
330         pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL);
331         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IPV6, Ipv6AddressFamily.class, createOpaqueList()));
332         return buildAttribute(pmsiTunnelBuilder);
333     }
334
335     static Attributes buildMLDPP2MPLSPL2vpnAttribute() {
336         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
337         pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, L2vpnAddressFamily.class, createOpaqueList()));
338         return buildAttribute(pmsiTunnelBuilder);
339     }
340
341     private static TunnelIdentifier buildMldpP2mpLsp(final IpAddress pAddress, final Class<? extends AddressFamily> family, final List<OpaqueValue> opaqueList) {
342         return new MldpP2mpLspBuilder().setMldpP2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
343             .ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder()
344             .setRootNodeAddress(pAddress).setAddressFamily(family).setOpaqueValue(opaqueList).build()).build();
345     }
346
347     static Attributes buildRSVPTEP2MPLSPLSPAttribute() {
348         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
349         pmsiTunnelBuilder.setTunnelIdentifier(new RsvpTeP2mpLspBuilder().setRsvpTeP2mpLps(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
350             .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLpsBuilder()
351             .setP2mpId(3458L).setTunnelId(15).setExtendedTunnelId(P_ADDRESS).build()).build());
352         return buildAttribute(pmsiTunnelBuilder);
353     }
354
355     static Attributes buildINGRESSREPLICATIONAttribute() {
356         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
357         pmsiTunnelBuilder.setTunnelIdentifier(new IngressReplicationBuilder().setIngressReplication(new org.opendaylight.yang.gen.v1.urn
358             .opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
359             .setReceivingEndpointAddress(P_ADDRESS).build()).build());
360         return buildAttribute(pmsiTunnelBuilder);
361     }
362
363     static Attributes buildMLDPMP2MPLSPWrongAttribute() {
364         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
365         pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
366             .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp
367             .MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build()).build());
368         return buildAttribute(pmsiTunnelBuilder);
369     }
370
371     static Attributes buildMLDPMP2MPLSPAttribute() {
372         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
373         pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
374             .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp
375             .MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()).build());
376         return buildAttribute(pmsiTunnelBuilder);
377     }
378
379     private static List<OpaqueValue> createOpaqueList() {
380         final List<OpaqueValue> opaqueValues = new ArrayList<>();
381         opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build());
382         opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2).setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE)
383             .setOpaqueExtendedType(4).build());
384         return opaqueValues;
385     }
386
387     static Attributes buildWOTunnelInfAttribute() {
388         final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
389         return buildAttribute(pmsiTunnelBuilder);
390     }
391 }