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
9 package org.opendaylight.groupbasedpolicy.neutron.ovsdb;
11 import java.util.Collections;
12 import java.util.HashMap;
13 import java.util.List;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.overlay.rev150105.TunnelTypeBase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.overlay.rev150105.TunnelTypeVxlanGpe;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options;
23 public class VxlanGpeTunnelType extends AbstractTunnelType {
25 private static final String VXLAN_GPE_TUNNEL_PREFIX = "vxlangpe-";
26 private static final Integer VXLAN_GPE_PORT_NUMBER = 6633;
28 private static final String NSH_NSI_KEY = "nsi";
29 private static final String NSH_NSI_VALUE = "flow";
30 private static final String NSH_NSP_KEY = "nsp";
31 private static final String NSH_NSP_VALUE = "flow";
32 private static final String NSH_NSHC1_KEY = "nshc1";
33 private static final String NSH_NSHC1_VALUE = "flow";
34 private static final String NSH_NSHC2_KEY = "nshc2";
35 private static final String NSH_NSHC2_VALUE = "flow";
36 private static final String NSH_NSHC3_KEY = "nshc3";
37 private static final String NSH_NSHC3_VALUE = "flow";
38 private static final String NSH_NSHC4_KEY = "nshc4";
39 private static final String NSH_NSHC4_VALUE = "flow";
40 private static final String DESTPORT_KEY = "dst_port";
41 private static final String DESTPORT_VALUE = VXLAN_GPE_PORT_NUMBER.toString();
43 private final PortNumber udpTunnelPort;
44 private final List<Options> optionsList;
45 private static final Class<? extends TunnelTypeBase> tunnelType = TunnelTypeVxlanGpe.class;
47 public VxlanGpeTunnelType() {
48 optionsList = createOptionsList(optsMap);
49 udpTunnelPort = new PortNumber(VXLAN_GPE_PORT_NUMBER);
52 private static final Map<String, String> optsMap;
54 Map<String, String> opts = new HashMap<String, String>();
55 opts.put(VNID_KEY, VNID_VALUE);
56 opts.put(REMOTE_IP_KEY, REMOTE_IP_VALUE);
57 opts.put(NSH_NSI_KEY, NSH_NSI_VALUE);
58 opts.put(NSH_NSP_KEY, NSH_NSP_VALUE);
59 opts.put(NSH_NSHC1_KEY, NSH_NSHC1_VALUE);
60 opts.put(NSH_NSHC2_KEY, NSH_NSHC2_VALUE);
61 opts.put(NSH_NSHC3_KEY, NSH_NSHC3_VALUE);
62 opts.put(NSH_NSHC4_KEY, NSH_NSHC4_VALUE);
63 opts.put(DESTPORT_KEY, DESTPORT_VALUE);
64 optsMap = Collections.unmodifiableMap(opts);
68 public List<Options> getOptions() {
73 public Class<? extends TunnelTypeBase> getTunnelType() {
78 public PortNumber getPortNumber() {
83 public String getTunnelPrefix() {
84 return VXLAN_GPE_TUNNEL_PREFIX;
88 * Check if a TerminationPoint is a tunnel port that meets
89 * requirements for the Service Function Chaining with NSH
90 * encapsulation. The tunnel port must support setting the
91 * VNID, destination Tunnel IP address, NSI, NSP, and all
92 * four NSHC fields from flow-mods, and use VXLAN encapsulation.
94 * @param tpAugmentation the {@link OvsdbTerminationPointAugmentation}
95 * @return true if it can be an SFC NSH tunnel port, false if not
98 public boolean isValidTunnelPort(OvsdbTerminationPointAugmentation tpAugmentation) {
99 if (hasTunnelOptions(tpAugmentation, optsMap)
100 && InterfaceTypeVxlan.class.equals(tpAugmentation.getInterfaceType())
101 && getDestPort(tpAugmentation).equals(VXLAN_GPE_PORT_NUMBER.toString())) {