blob: bf44a0ed5c04556796a3042458de57fd8a091ca4 [file] [log] [blame]
Carmelo Cascone2ea177b2016-02-25 18:38:42 -08001/*
Carmelo Casconeaa8b6292016-04-13 14:27:06 -07002 * Copyright 2016-present Open Networking Laboratory
Carmelo Cascone2ea177b2016-02-25 18:38:42 -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
Carmelo Casconeaa8b6292016-04-13 14:27:06 -070017package org.onosproject.bmv2.api.runtime;
Carmelo Cascone2ea177b2016-02-25 18:38:42 -080018
19import org.onlab.util.KryoNamespace;
20import org.onosproject.net.flow.AbstractExtension;
21import org.onosproject.net.flow.criteria.ExtensionSelector;
22import org.onosproject.net.flow.criteria.ExtensionSelectorType;
23
Carmelo Casconeaa8b6292016-04-13 14:27:06 -070024/**
25 * Extension selector for Bmv2 used as a wrapper for a {@link Bmv2MatchKey}.
26 */
Carmelo Cascone2ea177b2016-02-25 18:38:42 -080027public class Bmv2ExtensionSelector extends AbstractExtension implements ExtensionSelector {
28
29 private final KryoNamespace appKryo = new KryoNamespace.Builder().build();
30 private Bmv2MatchKey matchKey;
31
32 public Bmv2ExtensionSelector(Bmv2MatchKey matchKey) {
33 this.matchKey = matchKey;
34 }
35
36 public Bmv2MatchKey matchKey() {
37 return matchKey;
38 }
39
40 @Override
41 public ExtensionSelectorType type() {
42 return ExtensionSelectorType.ExtensionSelectorTypes.P4_BMV2_MATCH_KEY.type();
43 }
44
45 @Override
46 public byte[] serialize() {
47 return appKryo.serialize(matchKey);
48 }
49
50 @Override
51 public void deserialize(byte[] data) {
52 matchKey = appKryo.deserialize(data);
53 }
54}