blob: 9f302991d6c10e9f192e79df783ce08fb7d4e790 [file] [log] [blame]
Jonathan Hart26a8d952015-12-02 15:16:35 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.driver.extensions;
18
19import org.onosproject.net.behaviour.ExtensionSelectorResolver;
20import org.onosproject.net.driver.AbstractHandlerBehaviour;
21import org.onosproject.net.flow.criteria.ExtensionSelector;
22import org.onosproject.net.flow.criteria.ExtensionSelectorType;
23import org.onosproject.openflow.controller.ExtensionSelectorInterpreter;
24import org.projectfloodlight.openflow.protocol.OFFactory;
25import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
26
27/**
28 * Interpreter for Nicira OpenFlow selector extensions.
29 */
30public class NiciraExtensionSelectorInterpreter
31 extends AbstractHandlerBehaviour
32 implements ExtensionSelectorInterpreter, ExtensionSelectorResolver {
33
34 @Override
35 public boolean supported(ExtensionSelectorType extensionSelectorType) {
Phaneendra Mandaefb38752015-12-04 00:43:38 +053036 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
37 return true;
38 }
39 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
40 return true;
41 }
42 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) {
43 return true;
44 }
45 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) {
46 return true;
47 }
48 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) {
49 return true;
50 }
51 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
52 return true;
53 }
Jonathan Hart26a8d952015-12-02 15:16:35 -080054 return false;
55 }
56
57 @Override
58 public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
Phaneendra Mandaefb38752015-12-04 00:43:38 +053059 ExtensionSelectorType type = extensionSelector.type();
60 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
61 // TODO
62 }
63 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
64 // TODO
65 }
66 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) {
67 // TODO
68 }
69 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) {
70 // TODO
71 }
72 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) {
73 // TODO
74 }
75 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
76 // TODO
77 }
Jonathan Hart26a8d952015-12-02 15:16:35 -080078 return null;
79 }
80
81 @Override
82 public ExtensionSelector mapOxm(OFOxm<?> oxm) {
83 return null;
84 }
85
86 @Override
87 public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) {
Phaneendra Mandaefb38752015-12-04 00:43:38 +053088 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
89 return new NiciraMatchNshSpi();
90 }
91 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
92 return new NiciraMatchNshSi();
93 }
94 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())
95 || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())
96 || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())
97 || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
98 return new NiciraMatchNshContextHeader(type);
99 }
Jonathan Hart26a8d952015-12-02 15:16:35 -0800100 return null;
101 }
102}