Jian Li
Committed by Gerrit Code Review

[ONOS-4718] Add LispMapRecord, rename EidRecord to LispEidRecord

Change-Id: Ib43ad5201787a7d9a3b18c0cd8949822d2e31e29
...@@ -60,7 +60,7 @@ public class DefaultLispMapNotify implements LispMapNotify { ...@@ -60,7 +60,7 @@ public class DefaultLispMapNotify implements LispMapNotify {
60 } 60 }
61 61
62 @Override 62 @Override
63 - public List<LispRecord> getLispRecords() { 63 + public List<LispMapRecord> getLispRecords() {
64 return null; 64 return null;
65 } 65 }
66 66
...@@ -97,7 +97,7 @@ public class DefaultLispMapNotify implements LispMapNotify { ...@@ -97,7 +97,7 @@ public class DefaultLispMapNotify implements LispMapNotify {
97 } 97 }
98 98
99 @Override 99 @Override
100 - public NotifyBuilder addRecord(LispRecord record) { 100 + public NotifyBuilder addRecord(LispMapRecord record) {
101 return null; 101 return null;
102 } 102 }
103 } 103 }
......
1 +/*
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 +package org.onosproject.lisp.msg.protocols;
17 +
18 +import org.onosproject.lisp.msg.types.LispAfiAddress;
19 +
20 +/**
21 + * Default implementation of LispMapRecord.
22 + */
23 +public class DefaultLispMapRecord implements LispMapRecord {
24 +
25 + private int recordTtl;
26 + private int locatorCount;
27 + private byte maskLength;
28 + private LispMapReplyAction action;
29 + private boolean authoritative;
30 + private short mapVersionNumber;
31 + private LispAfiAddress eidPrefixAfi;
32 +
33 + public int getRecordTtl() {
34 + return recordTtl;
35 + }
36 +
37 + public int getLocatorCount() {
38 + return locatorCount;
39 + }
40 +
41 + public byte getMaskLength() {
42 + return maskLength;
43 + }
44 +
45 + public LispMapReplyAction getAction() {
46 + return action;
47 + }
48 +
49 + public boolean isAuthoritative() {
50 + return authoritative;
51 + }
52 +
53 + public short getMapVersionNumber() {
54 + return mapVersionNumber;
55 + }
56 +
57 + public LispAfiAddress getEidPrefixAfi() {
58 + return eidPrefixAfi;
59 + }
60 +
61 + public static final class DefaultMapRecordBuilder implements MapRecordBuilder {
62 +
63 + @Override
64 + public MapRecordBuilder withRecordTtl(int recordTtl) {
65 + return null;
66 + }
67 +
68 + @Override
69 + public MapRecordBuilder withLocatorCount(int locatorCount) {
70 + return null;
71 + }
72 +
73 + @Override
74 + public MapRecordBuilder withMaskLength(byte maskLength) {
75 + return null;
76 + }
77 +
78 + @Override
79 + public MapRecordBuilder withAction(LispMapReplyAction action) {
80 + return null;
81 + }
82 +
83 + @Override
84 + public MapRecordBuilder withAuthoritative(boolean authoritative) {
85 + return null;
86 + }
87 +
88 + @Override
89 + public MapRecordBuilder withMapVersionNumber(short mapVersionNumber) {
90 + return null;
91 + }
92 +
93 + @Override
94 + public MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix) {
95 + return null;
96 + }
97 + }
98 +}
...@@ -69,7 +69,7 @@ public class DefaultLispMapRegister implements LispMapRegister { ...@@ -69,7 +69,7 @@ public class DefaultLispMapRegister implements LispMapRegister {
69 } 69 }
70 70
71 @Override 71 @Override
72 - public List<LispRecord> getLispRecords() { 72 + public List<LispMapRecord> getLispRecords() {
73 return null; 73 return null;
74 } 74 }
75 75
...@@ -116,7 +116,7 @@ public class DefaultLispMapRegister implements LispMapRegister { ...@@ -116,7 +116,7 @@ public class DefaultLispMapRegister implements LispMapRegister {
116 } 116 }
117 117
118 @Override 118 @Override
119 - public RegisterBuilder addRecord(LispRecord record) { 119 + public RegisterBuilder addRecord(LispMapRecord record) {
120 return null; 120 return null;
121 } 121 }
122 } 122 }
......
...@@ -85,7 +85,7 @@ public class DefaultLispMapRequest implements LispMapRequest { ...@@ -85,7 +85,7 @@ public class DefaultLispMapRequest implements LispMapRequest {
85 } 85 }
86 86
87 @Override 87 @Override
88 - public List<EidRecord> getEids() { 88 + public List<LispEidRecord> getEids() {
89 return null; 89 return null;
90 } 90 }
91 91
...@@ -142,7 +142,7 @@ public class DefaultLispMapRequest implements LispMapRequest { ...@@ -142,7 +142,7 @@ public class DefaultLispMapRequest implements LispMapRequest {
142 } 142 }
143 143
144 @Override 144 @Override
145 - public RequestBuilder addEidRecord(EidRecord record) { 145 + public RequestBuilder addEidRecord(LispEidRecord record) {
146 return null; 146 return null;
147 } 147 }
148 } 148 }
......
...@@ -15,8 +15,42 @@ ...@@ -15,8 +15,42 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import org.onosproject.lisp.msg.types.LispAfiAddress;
19 +
18 /** 20 /**
19 * LISP EID record section which is part of LISP map request message. 21 * LISP EID record section which is part of LISP map request message.
20 */ 22 */
21 -public class EidRecord { 23 +public class LispEidRecord {
24 +
25 + private final byte maskLength;
26 + private final LispAfiAddress prefix;
27 +
28 + /**
29 + * Initializes LispEidRecord with mask length and EID prefix.
30 + *
31 + * @param maskLength mask length
32 + * @param prefix EID prefix
33 + */
34 + public LispEidRecord(byte maskLength, LispAfiAddress prefix) {
35 + this.maskLength = maskLength;
36 + this.prefix = prefix;
37 + }
38 +
39 + /**
40 + * Obtains mask length of the EID Record.
41 + *
42 + * @return mask length of the EID Record
43 + */
44 + public byte getMaskLength() {
45 + return maskLength;
46 + }
47 +
48 + /**
49 + * Obtains EID prefix.
50 + *
51 + * @return EID prefix
52 + */
53 + public LispAfiAddress getPrefix() {
54 + return prefix;
55 + }
22 } 56 }
......
...@@ -89,7 +89,7 @@ public interface LispMapNotify extends LispMessage { ...@@ -89,7 +89,7 @@ public interface LispMapNotify extends LispMessage {
89 * 89 *
90 * @return a collection of records 90 * @return a collection of records
91 */ 91 */
92 - List<LispRecord> getLispRecords(); 92 + List<LispMapRecord> getLispRecords();
93 93
94 /** 94 /**
95 * A builder of LISP map notify message. 95 * A builder of LISP map notify message.
...@@ -134,6 +134,6 @@ public interface LispMapNotify extends LispMessage { ...@@ -134,6 +134,6 @@ public interface LispMapNotify extends LispMessage {
134 * @param record record 134 * @param record record
135 * @return NotifyBuilder object 135 * @return NotifyBuilder object
136 */ 136 */
137 - NotifyBuilder addRecord(LispRecord record); 137 + NotifyBuilder addRecord(LispMapRecord record);
138 } 138 }
139 } 139 }
......
1 +/*
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 +package org.onosproject.lisp.msg.protocols;
17 +
18 +import org.onosproject.lisp.msg.types.LispAfiAddress;
19 +
20 +/**
21 + * LISP record section which is part of LISP map register message.
22 + */
23 +public interface LispMapRecord {
24 +
25 + /**
26 + * Obtains record TTL value.
27 + *
28 + * @return record TTL value
29 + */
30 + int getRecordTtl();
31 +
32 + /**
33 + * Obtains locator count value.
34 + *
35 + * @return locator count value
36 + */
37 + int getLocatorCount();
38 +
39 + /**
40 + * Obtains address mask length.
41 + *
42 + * @return mask length
43 + */
44 + byte getMaskLength();
45 +
46 + /**
47 + * Obtains LispMapReplyAction enum code.
48 + *
49 + * @return LispMapReplyAction enum code
50 + */
51 + LispMapReplyAction getAction();
52 +
53 + /**
54 + * Obtains authoritative flag.
55 + *
56 + * @return authoritative flag
57 + */
58 + boolean isAuthoritative();
59 +
60 + /**
61 + * Obtains map version number.
62 + *
63 + * @return map version number
64 + */
65 + short getMapVersionNumber();
66 +
67 + /**
68 + * Obtains EID prefix.
69 + *
70 + * @return EID prefix
71 + */
72 + LispAfiAddress getEidPrefixAfi();
73 +
74 + /**
75 + * A builder of LISP map record.
76 + */
77 + interface MapRecordBuilder {
78 +
79 + /**
80 + * Sets record TTL value.
81 + *
82 + * @param recordTtl record TTL
83 + * @return MapRecordBuilder object
84 + */
85 + MapRecordBuilder withRecordTtl(int recordTtl);
86 +
87 + /**
88 + * Sets locator count.
89 + *
90 + * @param locatorCount locator count
91 + * @return MapRecordBuilder object
92 + */
93 + MapRecordBuilder withLocatorCount(int locatorCount);
94 +
95 + /**
96 + * Sets mask length.
97 + *
98 + * @param maskLength mask length
99 + * @return MapRecordBuilder object
100 + */
101 + MapRecordBuilder withMaskLength(byte maskLength);
102 +
103 + /**
104 + * Sets LISP map reply action enum.
105 + *
106 + * @param action map reply action
107 + * @return MapRecordBuilder object
108 + */
109 + MapRecordBuilder withAction(LispMapReplyAction action);
110 +
111 + /**
112 + * Sets authoritative flag.
113 + *
114 + * @param authoritative authoritative flag
115 + * @return MapRecordBuilder object
116 + */
117 + MapRecordBuilder withAuthoritative(boolean authoritative);
118 +
119 + /**
120 + * Sets LISP map version number.
121 + *
122 + * @param mapVersionNumber map version number
123 + * @return MapRecordBuilder object
124 + */
125 + MapRecordBuilder withMapVersionNumber(short mapVersionNumber);
126 +
127 + /**
128 + * Sets EID prefix.
129 + *
130 + * @param prefix EID prefix
131 + * @return MapRecordBuilder object
132 + */
133 + MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix);
134 + }
135 +}
...@@ -103,7 +103,7 @@ public interface LispMapRegister extends LispMessage { ...@@ -103,7 +103,7 @@ public interface LispMapRegister extends LispMessage {
103 * 103 *
104 * @return a collection of records 104 * @return a collection of records
105 */ 105 */
106 - List<LispRecord> getLispRecords(); 106 + List<LispMapRecord> getLispRecords();
107 107
108 /** 108 /**
109 * A builder of LISP map register message. 109 * A builder of LISP map register message.
...@@ -164,6 +164,6 @@ public interface LispMapRegister extends LispMessage { ...@@ -164,6 +164,6 @@ public interface LispMapRegister extends LispMessage {
164 * @param record record 164 * @param record record
165 * @return RegisterBuilder object 165 * @return RegisterBuilder object
166 */ 166 */
167 - RegisterBuilder addRecord(LispRecord record); 167 + RegisterBuilder addRecord(LispMapRecord record);
168 } 168 }
169 } 169 }
......
1 +/*
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 +package org.onosproject.lisp.msg.protocols;
17 +
18 +/**
19 + * An enumeration class that represents Map-Reply action.
20 + *
21 + * The current assigned values are:
22 + *
23 + * (0) No-Action: The map-cache is kept alive, and no packet
24 + * encapsulation occurs.
25 + *
26 + * (1) Natively-Forward: The packet is not encapsulated or dropped
27 + * but natively forwarded.
28 + *
29 + * (2) Send-Map-Request: The packet invokes sending a Map-Request.
30 + *
31 + * (3) Drop: A packet that matches this map-cache entry is dropped.
32 + * An ICMP Destination Unreachable message SHOULD be sent.
33 + */
34 +public enum LispMapReplyAction {
35 +
36 + NoAction(0), // No-Action
37 + NativelyForward(1), // Natively-Forward
38 + SendMapRequest(2), // Send-Map-Request
39 + Drop(3); // Drop
40 +
41 + private int action;
42 +
43 + LispMapReplyAction(int action) {
44 + this.action = action;
45 + }
46 +
47 + /**
48 + * Obtains MapReplyAction code.
49 + *
50 + * @return map reply action code
51 + */
52 + public int getAction() {
53 + return action;
54 + }
55 +
56 + /**
57 + * Obtains the LispMapReplyAction enum with given action code.
58 + *
59 + * @param action action code
60 + * @return an enumeration of LispMapReplyAction
61 + */
62 + public static LispMapReplyAction valueOf(int action) {
63 + for (LispMapReplyAction act : values()) {
64 + if (act.getAction() == action) {
65 + return act;
66 + }
67 + }
68 + return null;
69 + }
70 +}
...@@ -122,7 +122,7 @@ public interface LispMapRequest extends LispMessage { ...@@ -122,7 +122,7 @@ public interface LispMapRequest extends LispMessage {
122 * 122 *
123 * @return a collection of EID records 123 * @return a collection of EID records
124 */ 124 */
125 - List<EidRecord> getEids(); 125 + List<LispEidRecord> getEids();
126 126
127 /** 127 /**
128 * A builder of LISP map request message. 128 * A builder of LISP map request message.
...@@ -199,6 +199,6 @@ public interface LispMapRequest extends LispMessage { ...@@ -199,6 +199,6 @@ public interface LispMapRequest extends LispMessage {
199 * @param record EID record 199 * @param record EID record
200 * @return RequestBuilder object 200 * @return RequestBuilder object
201 */ 201 */
202 - RequestBuilder addEidRecord(EidRecord record); 202 + RequestBuilder addEidRecord(LispEidRecord record);
203 } 203 }
204 } 204 }
......
1 -/*
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 -package org.onosproject.lisp.msg.protocols;
17 -
18 -/**
19 - * LISP record section which is part of LISP map register message.
20 - */
21 -public class LispRecord {
22 -
23 -}