blob: de159484b1d7cfcde7b307095a9529b236cc734a [file] [log] [blame]
Phaneendra Manda8db7d092016-06-04 00:17:24 +05301/*
2 * Copyright 2016-present 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 java.util.Objects;
20
21import org.onlab.util.KryoNamespace;
22import org.onosproject.net.flow.AbstractExtension;
23import org.onosproject.net.flow.instructions.ExtensionTreatment;
24import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
25
26import com.google.common.base.MoreObjects;
27
28/**
29 * Nicira tunnel gpe next protocol extension instruction to tunGpeNp value.
30 */
31public class NiciraTunGpeNp extends AbstractExtension implements ExtensionTreatment {
32
33 private byte tunGpeNp;
34
35 private final KryoNamespace appKryo = new KryoNamespace.Builder().build();
36
37 /**
38 * Creates a new NiciraTunGpeNp instruction.
39 */
40 NiciraTunGpeNp() {
41 tunGpeNp = (byte) 0;
42 }
43
44 /**
45 * Creates a new NiciraTunGpeNp instruction with given value.
46 *
47 * @param tunGpeNp tunnel gpe next protocol value
48 */
49 public NiciraTunGpeNp(byte tunGpeNp) {
50 this.tunGpeNp = tunGpeNp;
51 }
52
53 /**
54 * Gets the tunGpeNp.
55 *
56 * @return tunGpeNp
57 */
58 public byte tunGpeNp() {
59 return tunGpeNp;
60 }
61
62 @Override
63 public ExtensionTreatmentType type() {
64 return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_TUN_GPE_NP.type();
65 }
66
67 @Override
68 public void deserialize(byte[] data) {
69 tunGpeNp = (byte) (appKryo.deserialize(data));
70 }
71
72 @Override
73 public byte[] serialize() {
74 return appKryo.serialize(tunGpeNp);
75 }
76
77 @Override
78 public int hashCode() {
79 return Objects.hash(tunGpeNp);
80 }
81
82 @Override
83 public boolean equals(Object obj) {
84 if (this == obj) {
85 return true;
86 }
87 if (obj instanceof NiciraTunGpeNp) {
88 NiciraTunGpeNp that = (NiciraTunGpeNp) obj;
89 return Objects.equals(tunGpeNp, that.tunGpeNp);
90
91 }
92 return false;
93 }
94
95 @Override
96 public String toString() {
97 return MoreObjects.toStringHelper(getClass()).add("tunGpeNp", tunGpeNp).toString();
98 }
99}