blob: 12ab1e33bb1d0b403e549a56ff84a27f5179a195 [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.instructions.ExtensionTreatment;
22import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
23
Carmelo Casconeaa8b6292016-04-13 14:27:06 -070024/**
25 * Extension treatment for Bmv2 used as a wrapper for a {@link Bmv2Action}.
26 */
Carmelo Cascone2ea177b2016-02-25 18:38:42 -080027public class Bmv2ExtensionTreatment extends AbstractExtension implements ExtensionTreatment {
28
29 private final KryoNamespace appKryo = new KryoNamespace.Builder().build();
30 private Bmv2Action action;
31
32 public Bmv2ExtensionTreatment(Bmv2Action action) {
33 this.action = action;
34 }
35
36 public Bmv2Action getAction() {
37 return action;
38 }
39
40 @Override
41 public ExtensionTreatmentType type() {
42 return ExtensionTreatmentType.ExtensionTreatmentTypes.P4_BMV2_ACTION.type();
43 }
44
45 @Override
46 public byte[] serialize() {
47 return appKryo.serialize(action);
48 }
49
50 @Override
51 public void deserialize(byte[] data) {
52 action = appKryo.deserialize(data);
53 }
54}