blob: 57f0a6703392cf187dd546eeaac246884b5e9a21 [file] [log] [blame]
Jonathan Hart26a8d952015-12-02 15:16:35 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jonathan Hart26a8d952015-12-02 15:16:35 -08003 *
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
Jian Lidab72562016-04-12 14:10:32 -070019import com.fasterxml.jackson.databind.node.ObjectNode;
20import org.onosproject.codec.CodecContext;
Jonathan Hart26a8d952015-12-02 15:16:35 -080021import org.onosproject.net.behaviour.ExtensionSelectorResolver;
22import org.onosproject.net.driver.AbstractHandlerBehaviour;
23import org.onosproject.net.flow.criteria.ExtensionSelector;
24import org.onosproject.net.flow.criteria.ExtensionSelectorType;
25import org.onosproject.openflow.controller.ExtensionSelectorInterpreter;
26import org.projectfloodlight.openflow.protocol.OFFactory;
27import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
28
29/**
30 * Interpreter for Nicira OpenFlow selector extensions.
31 */
32public class NiciraExtensionSelectorInterpreter
33 extends AbstractHandlerBehaviour
34 implements ExtensionSelectorInterpreter, ExtensionSelectorResolver {
35
36 @Override
37 public boolean supported(ExtensionSelectorType extensionSelectorType) {
Phaneendra Mandaefb38752015-12-04 00:43:38 +053038 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
39 return true;
40 }
41 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
42 return true;
43 }
44 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) {
45 return true;
46 }
47 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) {
48 return true;
49 }
50 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) {
51 return true;
52 }
53 if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
54 return true;
55 }
Jonathan Hart26a8d952015-12-02 15:16:35 -080056 return false;
57 }
58
59 @Override
60 public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) {
Phaneendra Mandaefb38752015-12-04 00:43:38 +053061 ExtensionSelectorType type = extensionSelector.type();
62 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
63 // TODO
64 }
65 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
66 // TODO
67 }
68 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) {
69 // TODO
70 }
71 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) {
72 // TODO
73 }
74 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) {
75 // TODO
76 }
77 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
78 // TODO
79 }
Jonathan Hart26a8d952015-12-02 15:16:35 -080080 return null;
81 }
82
83 @Override
84 public ExtensionSelector mapOxm(OFOxm<?> oxm) {
85 return null;
86 }
87
88 @Override
89 public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) {
Phaneendra Mandaefb38752015-12-04 00:43:38 +053090 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) {
91 return new NiciraMatchNshSpi();
92 }
93 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) {
94 return new NiciraMatchNshSi();
95 }
96 if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())
97 || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())
98 || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())
99 || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) {
100 return new NiciraMatchNshContextHeader(type);
101 }
Jonathan Hart26a8d952015-12-02 15:16:35 -0800102 return null;
103 }
Jian Lidab72562016-04-12 14:10:32 -0700104
105 @Override
106 public ObjectNode encode(ExtensionSelector extensionSelector, CodecContext context) {
107 // TODO
108 return null;
109 }
110
111 @Override
112 public ExtensionSelector decode(ObjectNode json, CodecContext context) {
113 // TODO
114 return null;
115 }
Jonathan Hart26a8d952015-12-02 15:16:35 -0800116}