Phaneendra Manda
Committed by Gerrit Code Review

[ONOS-3284]Types added Spi, SI and context header

Change-Id: Ib29d90d401c390d4ff5ac06e17507f2ffbb70f12
...@@ -16,13 +16,15 @@ ...@@ -16,13 +16,15 @@
16 16
17 package org.onosproject.driver.extensions; 17 package org.onosproject.driver.extensions;
18 18
19 -import com.google.common.base.MoreObjects; 19 +import java.util.Objects;
20 +
20 import org.onlab.util.KryoNamespace; 21 import org.onlab.util.KryoNamespace;
22 +import org.onosproject.net.NshContextHeader;
21 import org.onosproject.net.flow.AbstractExtension; 23 import org.onosproject.net.flow.AbstractExtension;
22 import org.onosproject.net.flow.instructions.ExtensionTreatment; 24 import org.onosproject.net.flow.instructions.ExtensionTreatment;
23 import org.onosproject.net.flow.instructions.ExtensionTreatmentType; 25 import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
24 26
25 -import java.util.Objects; 27 +import com.google.common.base.MoreObjects;
26 28
27 /** 29 /**
28 * Nicira set NSH Context header extension instruction. 30 * Nicira set NSH Context header extension instruction.
...@@ -30,7 +32,7 @@ import java.util.Objects; ...@@ -30,7 +32,7 @@ import java.util.Objects;
30 public class NiciraSetNshContextHeader extends AbstractExtension implements 32 public class NiciraSetNshContextHeader extends AbstractExtension implements
31 ExtensionTreatment { 33 ExtensionTreatment {
32 34
33 - private int nshCh; 35 + private NshContextHeader nshCh;
34 private ExtensionTreatmentType type; 36 private ExtensionTreatmentType type;
35 37
36 private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); 38 private final KryoNamespace appKryo = new KryoNamespace.Builder().build();
...@@ -41,7 +43,7 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements ...@@ -41,7 +43,7 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements
41 * @param type extension treatment type 43 * @param type extension treatment type
42 */ 44 */
43 NiciraSetNshContextHeader(ExtensionTreatmentType type) { 45 NiciraSetNshContextHeader(ExtensionTreatmentType type) {
44 - this.nshCh = 0; 46 + this.nshCh = NshContextHeader.of(0);
45 this.type = type; 47 this.type = type;
46 } 48 }
47 49
...@@ -51,7 +53,7 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements ...@@ -51,7 +53,7 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements
51 * @param nshCh nsh context header 53 * @param nshCh nsh context header
52 * @param type extension treatment type 54 * @param type extension treatment type
53 */ 55 */
54 - NiciraSetNshContextHeader(int nshCh, ExtensionTreatmentType type) { 56 + NiciraSetNshContextHeader(NshContextHeader nshCh, ExtensionTreatmentType type) {
55 this.nshCh = nshCh; 57 this.nshCh = nshCh;
56 this.type = type; 58 this.type = type;
57 } 59 }
...@@ -61,7 +63,7 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements ...@@ -61,7 +63,7 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements
61 * 63 *
62 * @return nsh context header 64 * @return nsh context header
63 */ 65 */
64 - public int nshCh() { 66 + public NshContextHeader nshCh() {
65 return nshCh; 67 return nshCh;
66 } 68 }
67 69
...@@ -72,12 +74,12 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements ...@@ -72,12 +74,12 @@ public class NiciraSetNshContextHeader extends AbstractExtension implements
72 74
73 @Override 75 @Override
74 public void deserialize(byte[] data) { 76 public void deserialize(byte[] data) {
75 - nshCh = appKryo.deserialize(data); 77 + nshCh = NshContextHeader.of(appKryo.deserialize(data));
76 } 78 }
77 79
78 @Override 80 @Override
79 public byte[] serialize() { 81 public byte[] serialize() {
80 - return appKryo.serialize(nshCh); 82 + return appKryo.serialize(nshCh.nshContextHeader());
81 } 83 }
82 84
83 @Override 85 @Override
......
...@@ -16,13 +16,15 @@ ...@@ -16,13 +16,15 @@
16 16
17 package org.onosproject.driver.extensions; 17 package org.onosproject.driver.extensions;
18 18
19 -import com.google.common.base.MoreObjects; 19 +import java.util.Objects;
20 +
20 import org.onlab.util.KryoNamespace; 21 import org.onlab.util.KryoNamespace;
22 +import org.onosproject.net.NshServiceIndex;
21 import org.onosproject.net.flow.AbstractExtension; 23 import org.onosproject.net.flow.AbstractExtension;
22 import org.onosproject.net.flow.instructions.ExtensionTreatment; 24 import org.onosproject.net.flow.instructions.ExtensionTreatment;
23 import org.onosproject.net.flow.instructions.ExtensionTreatmentType; 25 import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
24 26
25 -import java.util.Objects; 27 +import com.google.common.base.MoreObjects;
26 28
27 /** 29 /**
28 * Nicira set NSH SI extension instruction. 30 * Nicira set NSH SI extension instruction.
...@@ -30,7 +32,7 @@ import java.util.Objects; ...@@ -30,7 +32,7 @@ import java.util.Objects;
30 public class NiciraSetNshSi extends AbstractExtension implements 32 public class NiciraSetNshSi extends AbstractExtension implements
31 ExtensionTreatment { 33 ExtensionTreatment {
32 34
33 - private byte nshSi; 35 + private NshServiceIndex nshSi;
34 36
35 private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); 37 private final KryoNamespace appKryo = new KryoNamespace.Builder().build();
36 38
...@@ -38,7 +40,7 @@ public class NiciraSetNshSi extends AbstractExtension implements ...@@ -38,7 +40,7 @@ public class NiciraSetNshSi extends AbstractExtension implements
38 * Creates a new set nsh si instruction. 40 * Creates a new set nsh si instruction.
39 */ 41 */
40 NiciraSetNshSi() { 42 NiciraSetNshSi() {
41 - nshSi = 0; 43 + nshSi = NshServiceIndex.of((short) 0);
42 } 44 }
43 45
44 /** 46 /**
...@@ -46,7 +48,7 @@ public class NiciraSetNshSi extends AbstractExtension implements ...@@ -46,7 +48,7 @@ public class NiciraSetNshSi extends AbstractExtension implements
46 * 48 *
47 * @param nshSi nsh service index 49 * @param nshSi nsh service index
48 */ 50 */
49 - NiciraSetNshSi(byte nshSi) { 51 + NiciraSetNshSi(NshServiceIndex nshSi) {
50 this.nshSi = nshSi; 52 this.nshSi = nshSi;
51 } 53 }
52 54
...@@ -55,7 +57,7 @@ public class NiciraSetNshSi extends AbstractExtension implements ...@@ -55,7 +57,7 @@ public class NiciraSetNshSi extends AbstractExtension implements
55 * 57 *
56 * @return nsh service index 58 * @return nsh service index
57 */ 59 */
58 - public byte nshSi() { 60 + public NshServiceIndex nshSi() {
59 return nshSi; 61 return nshSi;
60 } 62 }
61 63
...@@ -66,12 +68,12 @@ public class NiciraSetNshSi extends AbstractExtension implements ...@@ -66,12 +68,12 @@ public class NiciraSetNshSi extends AbstractExtension implements
66 68
67 @Override 69 @Override
68 public void deserialize(byte[] data) { 70 public void deserialize(byte[] data) {
69 - nshSi = appKryo.deserialize(data); 71 + nshSi = NshServiceIndex.of(appKryo.deserialize(data));
70 } 72 }
71 73
72 @Override 74 @Override
73 public byte[] serialize() { 75 public byte[] serialize() {
74 - return appKryo.serialize(nshSi); 76 + return appKryo.serialize(nshSi.serviceIndex());
75 } 77 }
76 78
77 @Override 79 @Override
......
...@@ -16,13 +16,15 @@ ...@@ -16,13 +16,15 @@
16 16
17 package org.onosproject.driver.extensions; 17 package org.onosproject.driver.extensions;
18 18
19 -import com.google.common.base.MoreObjects; 19 +import java.util.Objects;
20 +
20 import org.onlab.util.KryoNamespace; 21 import org.onlab.util.KryoNamespace;
22 +import org.onosproject.net.NshServicePathId;
21 import org.onosproject.net.flow.AbstractExtension; 23 import org.onosproject.net.flow.AbstractExtension;
22 import org.onosproject.net.flow.instructions.ExtensionTreatment; 24 import org.onosproject.net.flow.instructions.ExtensionTreatment;
23 import org.onosproject.net.flow.instructions.ExtensionTreatmentType; 25 import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
24 26
25 -import java.util.Objects; 27 +import com.google.common.base.MoreObjects;
26 28
27 /** 29 /**
28 * Nicira set NSH SPI extension instruction. 30 * Nicira set NSH SPI extension instruction.
...@@ -30,7 +32,7 @@ import java.util.Objects; ...@@ -30,7 +32,7 @@ import java.util.Objects;
30 public class NiciraSetNshSpi extends AbstractExtension implements 32 public class NiciraSetNshSpi extends AbstractExtension implements
31 ExtensionTreatment { 33 ExtensionTreatment {
32 34
33 - private int nshSpi; 35 + private NshServicePathId nshSpi;
34 36
35 private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); 37 private final KryoNamespace appKryo = new KryoNamespace.Builder().build();
36 38
...@@ -38,24 +40,24 @@ public class NiciraSetNshSpi extends AbstractExtension implements ...@@ -38,24 +40,24 @@ public class NiciraSetNshSpi extends AbstractExtension implements
38 * Creates a new set nsh spi instruction. 40 * Creates a new set nsh spi instruction.
39 */ 41 */
40 NiciraSetNshSpi() { 42 NiciraSetNshSpi() {
41 - nshSpi = 0; 43 + nshSpi = NshServicePathId.of(0);
42 } 44 }
43 45
44 /** 46 /**
45 * Creates a new set nsh spi instruction with given spi. 47 * Creates a new set nsh spi instruction with given spi.
46 * 48 *
47 - * @param nshSpi nsh service path index 49 + * @param nshSpi nsh service path id
48 */ 50 */
49 - NiciraSetNshSpi(int nshSpi) { 51 + NiciraSetNshSpi(NshServicePathId nshSpi) {
50 this.nshSpi = nshSpi; 52 this.nshSpi = nshSpi;
51 } 53 }
52 54
53 /** 55 /**
54 - * Gets the nsh service path index. 56 + * Gets the nsh service path id.
55 * 57 *
56 - * @return nsh service path index 58 + * @return nsh service path id
57 */ 59 */
58 - public int nshSpi() { 60 + public NshServicePathId nshSpi() {
59 return nshSpi; 61 return nshSpi;
60 } 62 }
61 63
...@@ -66,12 +68,12 @@ public class NiciraSetNshSpi extends AbstractExtension implements ...@@ -66,12 +68,12 @@ public class NiciraSetNshSpi extends AbstractExtension implements
66 68
67 @Override 69 @Override
68 public void deserialize(byte[] data) { 70 public void deserialize(byte[] data) {
69 - nshSpi = appKryo.deserialize(data); 71 + nshSpi = NshServicePathId.of(appKryo.deserialize(data));
70 } 72 }
71 73
72 @Override 74 @Override
73 public byte[] serialize() { 75 public byte[] serialize() {
74 - return appKryo.serialize(nshSpi); 76 + return appKryo.serialize(nshSpi.servicePathId());
75 } 77 }
76 78
77 @Override 79 @Override
...@@ -95,7 +97,7 @@ public class NiciraSetNshSpi extends AbstractExtension implements ...@@ -95,7 +97,7 @@ public class NiciraSetNshSpi extends AbstractExtension implements
95 @Override 97 @Override
96 public String toString() { 98 public String toString() {
97 return MoreObjects.toStringHelper(getClass()) 99 return MoreObjects.toStringHelper(getClass())
98 - .add("nshSpi", nshSpi) 100 + .add("nshSpi", nshSpi.toString())
99 .toString(); 101 .toString();
100 } 102 }
101 } 103 }
......
...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is; ...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is;
20 import static org.hamcrest.Matchers.notNullValue; 20 import static org.hamcrest.Matchers.notNullValue;
21 21
22 import org.junit.Test; 22 import org.junit.Test;
23 +import org.onosproject.net.NshContextHeader;
23 import org.onosproject.net.flow.instructions.ExtensionTreatmentType; 24 import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
24 25
25 import com.google.common.testing.EqualsTester; 26 import com.google.common.testing.EqualsTester;
...@@ -29,15 +30,15 @@ import com.google.common.testing.EqualsTester; ...@@ -29,15 +30,15 @@ import com.google.common.testing.EqualsTester;
29 */ 30 */
30 public class NiciraSetNshContextHeaderTest { 31 public class NiciraSetNshContextHeaderTest {
31 32
32 - final NiciraSetNshContextHeader nshCh1 = new NiciraSetNshContextHeader(10, 33 + final NiciraSetNshContextHeader nshCh1 = new NiciraSetNshContextHeader(NshContextHeader.of(10),
33 ExtensionTreatmentType. 34 ExtensionTreatmentType.
34 ExtensionTreatmentTypes. 35 ExtensionTreatmentTypes.
35 NICIRA_SET_NSH_CH1.type()); 36 NICIRA_SET_NSH_CH1.type());
36 - final NiciraSetNshContextHeader sameAsNshCh1 = new NiciraSetNshContextHeader(10, 37 + final NiciraSetNshContextHeader sameAsNshCh1 = new NiciraSetNshContextHeader(NshContextHeader.of(10),
37 ExtensionTreatmentType. 38 ExtensionTreatmentType.
38 ExtensionTreatmentTypes. 39 ExtensionTreatmentTypes.
39 NICIRA_SET_NSH_CH1.type()); 40 NICIRA_SET_NSH_CH1.type());
40 - final NiciraSetNshContextHeader nshCh2 = new NiciraSetNshContextHeader(20, 41 + final NiciraSetNshContextHeader nshCh2 = new NiciraSetNshContextHeader(NshContextHeader.of(20),
41 ExtensionTreatmentType. 42 ExtensionTreatmentType.
42 ExtensionTreatmentTypes. 43 ExtensionTreatmentTypes.
43 NICIRA_SET_NSH_CH1.type()); 44 NICIRA_SET_NSH_CH1.type());
...@@ -55,12 +56,12 @@ public class NiciraSetNshContextHeaderTest { ...@@ -55,12 +56,12 @@ public class NiciraSetNshContextHeaderTest {
55 */ 56 */
56 @Test 57 @Test
57 public void testConstruction() { 58 public void testConstruction() {
58 - final NiciraSetNshContextHeader niciraSetNshCh = new NiciraSetNshContextHeader(10, 59 + final NiciraSetNshContextHeader niciraSetNshCh = new NiciraSetNshContextHeader(NshContextHeader.of(10),
59 ExtensionTreatmentType. 60 ExtensionTreatmentType.
60 ExtensionTreatmentTypes. 61 ExtensionTreatmentTypes.
61 NICIRA_SET_NSH_CH1.type()); 62 NICIRA_SET_NSH_CH1.type());
62 assertThat(niciraSetNshCh, is(notNullValue())); 63 assertThat(niciraSetNshCh, is(notNullValue()));
63 - assertThat(niciraSetNshCh.nshCh(), is(10)); 64 + assertThat(niciraSetNshCh.nshCh().nshContextHeader(), is(10));
64 assertThat(niciraSetNshCh.type(), is(ExtensionTreatmentType. 65 assertThat(niciraSetNshCh.type(), is(ExtensionTreatmentType.
65 ExtensionTreatmentTypes. 66 ExtensionTreatmentTypes.
66 NICIRA_SET_NSH_CH1.type())); 67 NICIRA_SET_NSH_CH1.type()));
......
...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is; ...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is;
20 import static org.hamcrest.Matchers.notNullValue; 20 import static org.hamcrest.Matchers.notNullValue;
21 21
22 import org.junit.Test; 22 import org.junit.Test;
23 +import org.onosproject.net.NshServiceIndex;
23 24
24 import com.google.common.testing.EqualsTester; 25 import com.google.common.testing.EqualsTester;
25 26
...@@ -28,9 +29,9 @@ import com.google.common.testing.EqualsTester; ...@@ -28,9 +29,9 @@ import com.google.common.testing.EqualsTester;
28 */ 29 */
29 public class NiciraSetNshSiTest { 30 public class NiciraSetNshSiTest {
30 31
31 - final NiciraSetNshSi nshSi1 = new NiciraSetNshSi((byte) 10); 32 + final NiciraSetNshSi nshSi1 = new NiciraSetNshSi(NshServiceIndex.of((short) 10));
32 - final NiciraSetNshSi sameAsNshSi1 = new NiciraSetNshSi((byte) 10); 33 + final NiciraSetNshSi sameAsNshSi1 = new NiciraSetNshSi(NshServiceIndex.of((short) 10));
33 - final NiciraSetNshSi nshSi2 = new NiciraSetNshSi((byte) 20); 34 + final NiciraSetNshSi nshSi2 = new NiciraSetNshSi(NshServiceIndex.of((short) 20));
34 35
35 /** 36 /**
36 * Checks the operation of equals() methods. 37 * Checks the operation of equals() methods.
...@@ -45,8 +46,8 @@ public class NiciraSetNshSiTest { ...@@ -45,8 +46,8 @@ public class NiciraSetNshSiTest {
45 */ 46 */
46 @Test 47 @Test
47 public void testConstruction() { 48 public void testConstruction() {
48 - final NiciraSetNshSi niciraSetNshSi = new NiciraSetNshSi((byte) 15); 49 + final NiciraSetNshSi niciraSetNshSi = new NiciraSetNshSi(NshServiceIndex.of((short) 15));
49 assertThat(niciraSetNshSi, is(notNullValue())); 50 assertThat(niciraSetNshSi, is(notNullValue()));
50 - assertThat(niciraSetNshSi.nshSi(), is((byte) 15)); 51 + assertThat(niciraSetNshSi.nshSi().serviceIndex(), is((short) 15));
51 } 52 }
52 } 53 }
......
...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is; ...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.is;
20 import static org.hamcrest.Matchers.notNullValue; 20 import static org.hamcrest.Matchers.notNullValue;
21 21
22 import org.junit.Test; 22 import org.junit.Test;
23 +import org.onosproject.net.NshServicePathId;
23 24
24 import com.google.common.testing.EqualsTester; 25 import com.google.common.testing.EqualsTester;
25 26
...@@ -28,9 +29,9 @@ import com.google.common.testing.EqualsTester; ...@@ -28,9 +29,9 @@ import com.google.common.testing.EqualsTester;
28 */ 29 */
29 public class NiciraSetNshSpiTest { 30 public class NiciraSetNshSpiTest {
30 31
31 - final NiciraSetNshSpi nshSpi1 = new NiciraSetNshSpi(10); 32 + final NiciraSetNshSpi nshSpi1 = new NiciraSetNshSpi(NshServicePathId.of(10));
32 - final NiciraSetNshSpi sameAsNshSpi1 = new NiciraSetNshSpi(10); 33 + final NiciraSetNshSpi sameAsNshSpi1 = new NiciraSetNshSpi(NshServicePathId.of(10));
33 - final NiciraSetNshSpi nshSpi2 = new NiciraSetNshSpi(20); 34 + final NiciraSetNshSpi nshSpi2 = new NiciraSetNshSpi(NshServicePathId.of(20));
34 35
35 /** 36 /**
36 * Checks the operation of equals() methods. 37 * Checks the operation of equals() methods.
...@@ -45,8 +46,8 @@ public class NiciraSetNshSpiTest { ...@@ -45,8 +46,8 @@ public class NiciraSetNshSpiTest {
45 */ 46 */
46 @Test 47 @Test
47 public void testConstruction() { 48 public void testConstruction() {
48 - final NiciraSetNshSpi niciraSetNshSpi = new NiciraSetNshSpi(10); 49 + final NiciraSetNshSpi niciraSetNshSpi = new NiciraSetNshSpi(NshServicePathId.of(10));
49 assertThat(niciraSetNshSpi, is(notNullValue())); 50 assertThat(niciraSetNshSpi, is(notNullValue()));
50 - assertThat(niciraSetNshSpi.nshSpi(), is(10)); 51 + assertThat(niciraSetNshSpi.nshSpi().servicePathId(), is(10));
51 } 52 }
52 } 53 }
......