Jian Li
Committed by Gerrit Code Review

[ONOS-4718] Implement LISP control message classes

Change-Id: I26ab3b8da383d8967c08e14b4f11f03e0663de73
...@@ -15,23 +15,50 @@ ...@@ -15,23 +15,50 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import com.google.common.collect.ImmutableList;
19 +import com.google.common.collect.Lists;
18 import io.netty.buffer.ByteBuf; 20 import io.netty.buffer.ByteBuf;
21 +import org.onlab.util.ImmutableByteSequence;
19 22
20 import java.util.List; 23 import java.util.List;
21 24
22 /** 25 /**
23 * Default LISP map notify message class. 26 * Default LISP map notify message class.
24 */ 27 */
25 -public class DefaultLispMapNotify implements LispMapNotify { 28 +public final class DefaultLispMapNotify implements LispMapNotify {
29 +
30 + private final long nonce;
31 + private final short keyId;
32 + private final byte[] authenticationData;
33 + private final byte recordCount;
34 + private final List<LispMapRecord> mapRecords;
35 +
36 + /**
37 + * A private constructor that protects object instantiation from external.
38 + *
39 + * @param nonce nonce
40 + * @param keyId key identifier
41 + * @param authenticationData authentication data
42 + * @param recordCount record count number
43 + * @param mapRecords a collection of map records
44 + */
45 + private DefaultLispMapNotify(long nonce, short keyId, byte[] authenticationData,
46 + byte recordCount, List<LispMapRecord> mapRecords) {
47 + this.nonce = nonce;
48 + this.keyId = keyId;
49 + this.authenticationData = authenticationData;
50 + this.recordCount = recordCount;
51 + this.mapRecords = mapRecords;
52 + }
26 53
27 @Override 54 @Override
28 public LispType getType() { 55 public LispType getType() {
29 - return null; 56 + return LispType.LISP_MAP_NOTIFY;
30 } 57 }
31 58
32 @Override 59 @Override
33 public void writeTo(ByteBuf byteBuf) { 60 public void writeTo(ByteBuf byteBuf) {
34 - 61 + // TODO: serialize LispMapRegister message
35 } 62 }
36 63
37 @Override 64 @Override
...@@ -41,64 +68,76 @@ public class DefaultLispMapNotify implements LispMapNotify { ...@@ -41,64 +68,76 @@ public class DefaultLispMapNotify implements LispMapNotify {
41 68
42 @Override 69 @Override
43 public long getNonce() { 70 public long getNonce() {
44 - return 0; 71 + return this.nonce;
45 } 72 }
46 73
47 @Override 74 @Override
48 public byte getRecordCount() { 75 public byte getRecordCount() {
49 - return 0; 76 + return this.recordCount;
50 } 77 }
51 78
52 @Override 79 @Override
53 public short getKeyId() { 80 public short getKeyId() {
54 - return 0; 81 + return this.keyId;
55 } 82 }
56 83
57 @Override 84 @Override
58 public byte[] getAuthenticationData() { 85 public byte[] getAuthenticationData() {
59 - return new byte[0]; 86 + return ImmutableByteSequence.copyFrom(this.authenticationData).asArray();
60 } 87 }
61 88
62 @Override 89 @Override
63 public List<LispMapRecord> getLispRecords() { 90 public List<LispMapRecord> getLispRecords() {
64 - return null; 91 + return ImmutableList.copyOf(mapRecords);
65 } 92 }
66 93
67 public static final class DefaultNotifyBuilder implements NotifyBuilder { 94 public static final class DefaultNotifyBuilder implements NotifyBuilder {
68 95
69 - @Override 96 + private long nonce;
70 - public LispMessage build() { 97 + private short keyId;
71 - return null; 98 + private byte[] authenticationData;
72 - } 99 + private byte recordCount;
100 + private List<LispMapRecord> mapRecords = Lists.newArrayList();
73 101
74 @Override 102 @Override
75 public LispType getType() { 103 public LispType getType() {
76 - return null; 104 + return LispType.LISP_MAP_NOTIFY;
77 } 105 }
78 106
79 @Override 107 @Override
80 public NotifyBuilder withNonce(long nonce) { 108 public NotifyBuilder withNonce(long nonce) {
81 - return null; 109 + this.nonce = nonce;
110 + return this;
82 } 111 }
83 112
84 @Override 113 @Override
85 public NotifyBuilder withRecordCount(byte recordCount) { 114 public NotifyBuilder withRecordCount(byte recordCount) {
86 - return null; 115 + this.recordCount = recordCount;
116 + return this;
87 } 117 }
88 118
89 @Override 119 @Override
90 public NotifyBuilder withKeyId(short keyId) { 120 public NotifyBuilder withKeyId(short keyId) {
91 - return null; 121 + this.keyId = keyId;
122 + return this;
92 } 123 }
93 124
94 @Override 125 @Override
95 public NotifyBuilder withAuthenticationData(byte[] authenticationData) { 126 public NotifyBuilder withAuthenticationData(byte[] authenticationData) {
96 - return null; 127 + this.authenticationData = authenticationData;
128 + return this;
97 } 129 }
98 130
99 @Override 131 @Override
100 public NotifyBuilder addRecord(LispMapRecord record) { 132 public NotifyBuilder addRecord(LispMapRecord record) {
101 - return null; 133 + this.mapRecords.add(record);
134 + return this;
135 + }
136 +
137 + @Override
138 + public LispMessage build() {
139 + return new DefaultLispMapNotify(nonce, keyId, authenticationData,
140 + recordCount, mapRecords);
102 } 141 }
103 } 142 }
104 } 143 }
......
...@@ -15,22 +15,58 @@ ...@@ -15,22 +15,58 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import com.google.common.collect.ImmutableList;
19 +import com.google.common.collect.Lists;
18 import io.netty.buffer.ByteBuf; 20 import io.netty.buffer.ByteBuf;
21 +import org.onlab.util.ImmutableByteSequence;
19 22
20 import java.util.List; 23 import java.util.List;
21 24
22 /** 25 /**
23 * Default LISP map register message class. 26 * Default LISP map register message class.
24 */ 27 */
25 -public class DefaultLispMapRegister implements LispMapRegister { 28 +public final class DefaultLispMapRegister implements LispMapRegister {
29 +
30 + private final long nonce;
31 + private final short keyId;
32 + private final byte[] authenticationData;
33 + private final byte recordCount;
34 + private final List<LispMapRecord> mapRecords;
35 + private final boolean proxyMapReply;
36 + private final boolean wantMapNotify;
37 +
38 + /**
39 + * A private constructor that protects object instantiation from external.
40 + *
41 + * @param nonce nonce
42 + * @param keyId key identifier
43 + * @param authenticationData authentication data
44 + * @param recordCount record count number
45 + * @param mapRecords a collection of map records
46 + * @param proxyMapReply proxy map reply flag
47 + * @param wantMapNotify want map notify flag
48 + */
49 + private DefaultLispMapRegister(long nonce, short keyId,
50 + byte[] authenticationData, byte recordCount,
51 + List<LispMapRecord> mapRecords,
52 + boolean proxyMapReply, boolean wantMapNotify) {
53 + this.nonce = nonce;
54 + this.keyId = keyId;
55 + this.authenticationData = authenticationData;
56 + this.recordCount = recordCount;
57 + this.mapRecords = mapRecords;
58 + this.proxyMapReply = proxyMapReply;
59 + this.wantMapNotify = wantMapNotify;
60 + }
61 +
26 @Override 62 @Override
27 public LispType getType() { 63 public LispType getType() {
28 - return null; 64 + return LispType.LISP_MAP_REGISTER;
29 } 65 }
30 66
31 @Override 67 @Override
32 public void writeTo(ByteBuf byteBuf) { 68 public void writeTo(ByteBuf byteBuf) {
33 - 69 + // TODO: serialize LispMapRegister message
34 } 70 }
35 71
36 @Override 72 @Override
...@@ -40,84 +76,100 @@ public class DefaultLispMapRegister implements LispMapRegister { ...@@ -40,84 +76,100 @@ public class DefaultLispMapRegister implements LispMapRegister {
40 76
41 @Override 77 @Override
42 public boolean isProxyMapReply() { 78 public boolean isProxyMapReply() {
43 - return false; 79 + return proxyMapReply;
44 } 80 }
45 81
46 @Override 82 @Override
47 public boolean isWantMapNotify() { 83 public boolean isWantMapNotify() {
48 - return false; 84 + return wantMapNotify;
49 } 85 }
50 86
51 @Override 87 @Override
52 public byte getRecordCount() { 88 public byte getRecordCount() {
53 - return 0; 89 + return recordCount;
54 } 90 }
55 91
56 @Override 92 @Override
57 public long getNonce() { 93 public long getNonce() {
58 - return 0; 94 + return nonce;
59 } 95 }
60 96
61 @Override 97 @Override
62 public short getKeyId() { 98 public short getKeyId() {
63 - return 0; 99 + return keyId;
64 } 100 }
65 101
66 @Override 102 @Override
67 public byte[] getAuthenticationData() { 103 public byte[] getAuthenticationData() {
68 - return new byte[0]; 104 + return ImmutableByteSequence.copyFrom(this.authenticationData).asArray();
69 } 105 }
70 106
71 @Override 107 @Override
72 public List<LispMapRecord> getLispRecords() { 108 public List<LispMapRecord> getLispRecords() {
73 - return null; 109 + return ImmutableList.copyOf(mapRecords);
74 } 110 }
75 111
76 public static final class DefaultRegisterBuilder implements RegisterBuilder { 112 public static final class DefaultRegisterBuilder implements RegisterBuilder {
77 113
78 - @Override 114 + private long nonce;
79 - public LispMessage build() { 115 + private short keyId;
80 - return null; 116 + private byte[] authenticationData;
81 - } 117 + private byte recordCount;
118 + private final List<LispMapRecord> mapRecords = Lists.newArrayList();
119 + private boolean proxyMapReply;
120 + private boolean wantMapNotify;
82 121
83 @Override 122 @Override
84 public LispType getType() { 123 public LispType getType() {
85 - return null; 124 + return LispType.LISP_MAP_REGISTER;
86 } 125 }
87 126
88 @Override 127 @Override
89 - public RegisterBuilder withIsProxyMapReply(boolean isProxyMapReply) { 128 + public RegisterBuilder withIsProxyMapReply(boolean proxyMapReply) {
90 - return null; 129 + this.proxyMapReply = proxyMapReply;
130 + return this;
91 } 131 }
92 132
93 @Override 133 @Override
94 - public RegisterBuilder withIsWantMapNotify(boolean isWantMapNotify) { 134 + public RegisterBuilder withIsWantMapNotify(boolean wantMapNotify) {
95 - return null; 135 + this.wantMapNotify = wantMapNotify;
136 + return this;
96 } 137 }
97 138
98 @Override 139 @Override
99 public RegisterBuilder withRecordCount(byte recordCount) { 140 public RegisterBuilder withRecordCount(byte recordCount) {
100 - return null; 141 + this.recordCount = recordCount;
142 + return this;
101 } 143 }
102 144
103 @Override 145 @Override
104 public RegisterBuilder withNonce(long nonce) { 146 public RegisterBuilder withNonce(long nonce) {
105 - return null; 147 + this.nonce = nonce;
148 + return this;
106 } 149 }
107 150
108 @Override 151 @Override
109 public RegisterBuilder withKeyId(short keyId) { 152 public RegisterBuilder withKeyId(short keyId) {
110 - return null; 153 + this.keyId = keyId;
154 + return this;
111 } 155 }
112 156
113 @Override 157 @Override
114 public RegisterBuilder withAuthenticationData(byte[] authenticationData) { 158 public RegisterBuilder withAuthenticationData(byte[] authenticationData) {
115 - return null; 159 + this.authenticationData = authenticationData;
160 + return this;
116 } 161 }
117 162
118 @Override 163 @Override
119 public RegisterBuilder addRecord(LispMapRecord record) { 164 public RegisterBuilder addRecord(LispMapRecord record) {
120 - return null; 165 + this.mapRecords.add(record);
166 + return this;
167 + }
168 +
169 + @Override
170 + public LispMessage build() {
171 + return new DefaultLispMapRegister(nonce, keyId, authenticationData,
172 + recordCount, mapRecords, proxyMapReply, wantMapNotify);
121 } 173 }
122 } 174 }
123 } 175 }
......
...@@ -20,15 +20,40 @@ import io.netty.buffer.ByteBuf; ...@@ -20,15 +20,40 @@ import io.netty.buffer.ByteBuf;
20 /** 20 /**
21 * Default LISP map reply message class. 21 * Default LISP map reply message class.
22 */ 22 */
23 -public class DefaultLispMapReply implements LispMapReply { 23 +public final class DefaultLispMapReply implements LispMapReply {
24 +
25 + private final long nonce;
26 + private final byte recordCount;
27 + private final boolean probe;
28 + private final boolean etr;
29 + private final boolean security;
30 +
31 + /**
32 + * A private constructor that protects object instantiation from external.
33 + *
34 + * @param nonce nonce
35 + * @param recordCount record count number
36 + * @param probe probe flag
37 + * @param etr etr flag
38 + * @param security security flag
39 + */
40 + private DefaultLispMapReply(long nonce, byte recordCount, boolean probe,
41 + boolean etr, boolean security) {
42 + this.nonce = nonce;
43 + this.recordCount = recordCount;
44 + this.probe = probe;
45 + this.etr = etr;
46 + this.security = security;
47 + }
48 +
24 @Override 49 @Override
25 public LispType getType() { 50 public LispType getType() {
26 - return null; 51 + return LispType.LISP_MAP_REPLY;
27 } 52 }
28 53
29 @Override 54 @Override
30 public void writeTo(ByteBuf byteBuf) { 55 public void writeTo(ByteBuf byteBuf) {
31 - 56 + // TODO: serialize LispMapReply message
32 } 57 }
33 58
34 @Override 59 @Override
...@@ -38,64 +63,75 @@ public class DefaultLispMapReply implements LispMapReply { ...@@ -38,64 +63,75 @@ public class DefaultLispMapReply implements LispMapReply {
38 63
39 @Override 64 @Override
40 public boolean isProbe() { 65 public boolean isProbe() {
41 - return false; 66 + return this.probe;
42 } 67 }
43 68
44 @Override 69 @Override
45 public boolean isEtr() { 70 public boolean isEtr() {
46 - return false; 71 + return this.etr;
47 } 72 }
48 73
49 @Override 74 @Override
50 public boolean isSecurity() { 75 public boolean isSecurity() {
51 - return false; 76 + return this.security;
52 } 77 }
53 78
54 @Override 79 @Override
55 public byte getRecordCount() { 80 public byte getRecordCount() {
56 - return 0; 81 + return this.recordCount;
57 } 82 }
58 83
59 @Override 84 @Override
60 public long getNonce() { 85 public long getNonce() {
61 - return 0; 86 + return this.nonce;
62 } 87 }
63 88
64 public static final class DefaultReplyBuilder implements ReplyBuilder { 89 public static final class DefaultReplyBuilder implements ReplyBuilder {
65 90
66 - @Override 91 + private long nonce;
67 - public LispMessage build() { 92 + private byte recordCount;
68 - return null; 93 + private boolean probe;
69 - } 94 + private boolean etr;
95 + private boolean security;
70 96
71 @Override 97 @Override
72 public LispType getType() { 98 public LispType getType() {
73 - return null; 99 + return LispType.LISP_MAP_REPLY;
74 } 100 }
75 101
76 @Override 102 @Override
77 - public ReplyBuilder withIsProbe(boolean isProbe) { 103 + public ReplyBuilder withIsProbe(boolean probe) {
78 - return null; 104 + this.probe = probe;
105 + return this;
79 } 106 }
80 107
81 @Override 108 @Override
82 - public ReplyBuilder withIsEtr(boolean isEtr) { 109 + public ReplyBuilder withIsEtr(boolean etr) {
83 - return null; 110 + this.etr = etr;
111 + return this;
84 } 112 }
85 113
86 @Override 114 @Override
87 - public ReplyBuilder withIsSecurity(boolean isSecurity) { 115 + public ReplyBuilder withIsSecurity(boolean security) {
88 - return null; 116 + this.security = security;
117 + return this;
89 } 118 }
90 119
91 @Override 120 @Override
92 public ReplyBuilder withRecordCount(byte recordCount) { 121 public ReplyBuilder withRecordCount(byte recordCount) {
93 - return null; 122 + this.recordCount = recordCount;
123 + return this;
94 } 124 }
95 125
96 @Override 126 @Override
97 public ReplyBuilder withNonce(long nonce) { 127 public ReplyBuilder withNonce(long nonce) {
98 - return null; 128 + this.nonce = nonce;
129 + return this;
130 + }
131 +
132 + @Override
133 + public LispMessage build() {
134 + return new DefaultLispMapReply(nonce, recordCount, probe, etr, security);
99 } 135 }
100 } 136 }
101 } 137 }
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import com.google.common.collect.ImmutableList;
19 +import com.google.common.collect.Lists;
18 import io.netty.buffer.ByteBuf; 20 import io.netty.buffer.ByteBuf;
19 import org.onosproject.lisp.msg.types.LispAfiAddress; 21 import org.onosproject.lisp.msg.types.LispAfiAddress;
20 22
...@@ -23,15 +25,60 @@ import java.util.List; ...@@ -23,15 +25,60 @@ import java.util.List;
23 /** 25 /**
24 * Default LISP map request message class. 26 * Default LISP map request message class.
25 */ 27 */
26 -public class DefaultLispMapRequest implements LispMapRequest { 28 +public final class DefaultLispMapRequest implements LispMapRequest {
29 +
30 + private final long nonce;
31 + private final byte recordCount;
32 + private final LispAfiAddress sourceEid;
33 + private final List<LispAfiAddress> itrRlocs;
34 + private final List<LispEidRecord> eidRecords;
35 + private final boolean authoritative;
36 + private final boolean mapDataPresent;
37 + private final boolean probe;
38 + private final boolean smr;
39 + private final boolean pitr;
40 + private final boolean smrInvoked;
41 +
42 + /**
43 + * A private constructor that protects object instantiation from external.
44 + *
45 + * @param nonce nonce
46 + * @param recordCount record count number
47 + * @param sourceEid source EID address
48 + * @param itrRlocs a collection of ITR RLOCs
49 + * @param eidRecords a collection of EID records
50 + * @param authoritative authoritative flag
51 + * @param mapDataPresent map data present flag
52 + * @param probe probe flag
53 + * @param smr smr flag
54 + * @param pitr pitr flag
55 + * @param smrInvoked smrInvoked flag
56 + */
57 + private DefaultLispMapRequest(long nonce, byte recordCount, LispAfiAddress sourceEid,
58 + List<LispAfiAddress> itrRlocs, List<LispEidRecord> eidRecords,
59 + boolean authoritative, boolean mapDataPresent, boolean probe,
60 + boolean smr, boolean pitr, boolean smrInvoked) {
61 + this.nonce = nonce;
62 + this.recordCount = recordCount;
63 + this.sourceEid = sourceEid;
64 + this.itrRlocs = itrRlocs;
65 + this.eidRecords = eidRecords;
66 + this.authoritative = authoritative;
67 + this.mapDataPresent = mapDataPresent;
68 + this.probe = probe;
69 + this.smr = smr;
70 + this.pitr = pitr;
71 + this.smrInvoked = smrInvoked;
72 + }
73 +
27 @Override 74 @Override
28 public LispType getType() { 75 public LispType getType() {
29 - return null; 76 + return LispType.LISP_MAP_REQUEST;
30 } 77 }
31 78
32 @Override 79 @Override
33 public void writeTo(ByteBuf byteBuf) { 80 public void writeTo(ByteBuf byteBuf) {
34 - 81 + // TODO: serialize LispMapRequest message
35 } 82 }
36 83
37 @Override 84 @Override
...@@ -41,109 +88,149 @@ public class DefaultLispMapRequest implements LispMapRequest { ...@@ -41,109 +88,149 @@ public class DefaultLispMapRequest implements LispMapRequest {
41 88
42 @Override 89 @Override
43 public boolean isAuthoritative() { 90 public boolean isAuthoritative() {
44 - return false; 91 + return this.authoritative;
92 + }
93 +
94 + @Override
95 + public boolean isMapDataPresent() {
96 + return this.mapDataPresent;
45 } 97 }
46 98
47 @Override 99 @Override
48 public boolean isProbe() { 100 public boolean isProbe() {
49 - return false; 101 + return this.probe;
50 } 102 }
51 103
52 @Override 104 @Override
53 public boolean isSmr() { 105 public boolean isSmr() {
54 - return false; 106 + return this.smr;
55 } 107 }
56 108
57 @Override 109 @Override
58 public boolean isPitr() { 110 public boolean isPitr() {
59 - return false; 111 + return this.pitr;
60 } 112 }
61 113
62 @Override 114 @Override
63 public boolean isSmrInvoked() { 115 public boolean isSmrInvoked() {
64 - return false; 116 + return this.smrInvoked;
65 } 117 }
66 118
67 @Override 119 @Override
68 public byte getRecordCount() { 120 public byte getRecordCount() {
69 - return 0; 121 + return this.recordCount;
70 } 122 }
71 123
72 @Override 124 @Override
73 public long getNonce() { 125 public long getNonce() {
74 - return 0; 126 + return this.nonce;
75 } 127 }
76 128
77 @Override 129 @Override
78 public LispAfiAddress getSourceEid() { 130 public LispAfiAddress getSourceEid() {
79 - return null; 131 + return this.sourceEid;
80 } 132 }
81 133
82 @Override 134 @Override
83 public List<LispAfiAddress> getItrRlocs() { 135 public List<LispAfiAddress> getItrRlocs() {
84 - return null; 136 + return ImmutableList.copyOf(itrRlocs);
85 } 137 }
86 138
87 @Override 139 @Override
88 public List<LispEidRecord> getEids() { 140 public List<LispEidRecord> getEids() {
89 - return null; 141 + return ImmutableList.copyOf(eidRecords);
90 } 142 }
91 143
92 public static final class DefaultRequestBuilder implements RequestBuilder { 144 public static final class DefaultRequestBuilder implements RequestBuilder {
93 145
146 + private long nonce;
147 + private byte recordCount;
148 + private LispAfiAddress sourceEid;
149 + private List<LispAfiAddress> itrRlocs = Lists.newArrayList();
150 + private List<LispEidRecord> eidRecords = Lists.newArrayList();
151 + private boolean authoritative;
152 + private boolean mapDataPresent;
153 + private boolean probe;
154 + private boolean smr;
155 + private boolean pitr;
156 + private boolean smrInvoked;
157 +
94 @Override 158 @Override
95 - public LispMessage build() { 159 + public LispType getType() {
96 - return null; 160 + return LispType.LISP_MAP_REQUEST;
97 } 161 }
98 162
99 @Override 163 @Override
100 - public LispType getType() { 164 + public RequestBuilder withIsAuthoritative(boolean authoritative) {
101 - return null; 165 + this.authoritative = authoritative;
166 + return this;
102 } 167 }
103 168
104 @Override 169 @Override
105 - public RequestBuilder withIsAuthoritative(boolean isAuthoritative) { 170 + public RequestBuilder withIsProbe(boolean probe) {
106 - return null; 171 + this.probe = probe;
172 + return this;
107 } 173 }
108 174
109 @Override 175 @Override
110 - public RequestBuilder withIsProbe(boolean isProbe) { 176 + public RequestBuilder withIsMapDataPresent(boolean mapDataPresent) {
111 - return null; 177 + this.mapDataPresent = mapDataPresent;
178 + return this;
112 } 179 }
113 180
181 +
114 @Override 182 @Override
115 - public RequestBuilder withIsSmr(boolean isSmr) { 183 + public RequestBuilder withIsSmr(boolean smr) {
116 - return null; 184 + this.smr = smr;
185 + return this;
117 } 186 }
118 187
119 @Override 188 @Override
120 - public RequestBuilder withIsPitr(boolean isPitr) { 189 + public RequestBuilder withIsPitr(boolean pitr) {
121 - return null; 190 + this.pitr = pitr;
191 + return this;
122 } 192 }
123 193
124 @Override 194 @Override
125 - public RequestBuilder withIsSmrInvoked(boolean isSmrInvoked) { 195 + public RequestBuilder withIsSmrInvoked(boolean smrInvoked) {
126 - return null; 196 + this.smrInvoked = smrInvoked;
197 + return this;
127 } 198 }
128 199
129 @Override 200 @Override
130 public RequestBuilder withRecordCount(byte recordCount) { 201 public RequestBuilder withRecordCount(byte recordCount) {
131 - return null; 202 + this.recordCount = recordCount;
203 + return this;
132 } 204 }
133 205
134 @Override 206 @Override
135 public RequestBuilder withNonce(long nonce) { 207 public RequestBuilder withNonce(long nonce) {
136 - return null; 208 + this.nonce = nonce;
209 + return this;
137 } 210 }
138 211
139 @Override 212 @Override
140 - public RequestBuilder withItrRloc(LispAfiAddress itrRloc) { 213 + public RequestBuilder withSourceEid(LispAfiAddress sourceEid) {
141 - return null; 214 + this.sourceEid = sourceEid;
215 + return this;
216 + }
217 +
218 + @Override
219 + public RequestBuilder addItrRloc(LispAfiAddress itrRloc) {
220 + this.itrRlocs.add(itrRloc);
221 + return this;
142 } 222 }
143 223
144 @Override 224 @Override
145 public RequestBuilder addEidRecord(LispEidRecord record) { 225 public RequestBuilder addEidRecord(LispEidRecord record) {
146 - return null; 226 + this.eidRecords.add(record);
227 + return this;
228 + }
229 +
230 + @Override
231 + public LispMessage build() {
232 + return new DefaultLispMapRequest(nonce, recordCount, sourceEid, itrRlocs,
233 + eidRecords, authoritative, mapDataPresent, probe, smr, pitr, smrInvoked);
147 } 234 }
148 } 235 }
149 } 236 }
......
...@@ -91,28 +91,28 @@ public interface LispMapReply extends LispMessage { ...@@ -91,28 +91,28 @@ public interface LispMapReply extends LispMessage {
91 interface ReplyBuilder extends Builder { 91 interface ReplyBuilder extends Builder {
92 92
93 /** 93 /**
94 - * Sets isProbe flag. 94 + * Sets probe flag.
95 * 95 *
96 - * @param isProbe isProbe flag 96 + * @param probe probe flag
97 * @return ReplyBuilder object 97 * @return ReplyBuilder object
98 */ 98 */
99 - ReplyBuilder withIsProbe(boolean isProbe); 99 + ReplyBuilder withIsProbe(boolean probe);
100 100
101 /** 101 /**
102 - * Sets isEtr flag. 102 + * Sets etr flag.
103 * 103 *
104 - * @param isEtr isEtr flag 104 + * @param etr etr flag
105 * @return ReplyBuilder object 105 * @return ReplyBuilder object
106 */ 106 */
107 - ReplyBuilder withIsEtr(boolean isEtr); 107 + ReplyBuilder withIsEtr(boolean etr);
108 108
109 /** 109 /**
110 - * Sets isSecurity flag. 110 + * Sets security flag.
111 * 111 *
112 - * @param isSecurity isSecurity flag 112 + * @param security security flag
113 * @return ReplyBuilder object 113 * @return ReplyBuilder object
114 */ 114 */
115 - ReplyBuilder withIsSecurity(boolean isSecurity); 115 + ReplyBuilder withIsSecurity(boolean security);
116 116
117 /** 117 /**
118 * Sets record count. 118 * Sets record count.
......
...@@ -21,12 +21,13 @@ import java.util.List; ...@@ -21,12 +21,13 @@ import java.util.List;
21 21
22 /** 22 /**
23 * LISP map request message interface. 23 * LISP map request message interface.
24 - * 24 + * <p>
25 * LISP map request message format is defined in RFC6830. 25 * LISP map request message format is defined in RFC6830.
26 * https://tools.ietf.org/html/rfc6830#page-27 26 * https://tools.ietf.org/html/rfc6830#page-27
27 * 27 *
28 * <pre> 28 * <pre>
29 * {@literal 29 * {@literal
30 + * <p>
30 * 0 1 2 3 31 * 0 1 2 3
31 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 32 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
32 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 33 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...@@ -62,6 +63,13 @@ public interface LispMapRequest extends LispMessage { ...@@ -62,6 +63,13 @@ public interface LispMapRequest extends LispMessage {
62 boolean isAuthoritative(); 63 boolean isAuthoritative();
63 64
64 /** 65 /**
66 + * Obtains map data present flag.
67 + *
68 + * @return map data present flag
69 + */
70 + boolean isMapDataPresent();
71 +
72 + /**
65 * Obtains probe flag. 73 * Obtains probe flag.
66 * 74 *
67 * @return probe flag 75 * @return probe flag
...@@ -130,44 +138,52 @@ public interface LispMapRequest extends LispMessage { ...@@ -130,44 +138,52 @@ public interface LispMapRequest extends LispMessage {
130 interface RequestBuilder extends Builder { 138 interface RequestBuilder extends Builder {
131 139
132 /** 140 /**
133 - * Sets isAuthoritative flag. 141 + * Sets authoritative flag.
134 * 142 *
135 - * @param isAuthoritative isAuthoritative flag 143 + * @param authoritative authoritative flag
136 * @return RequestBuilder object 144 * @return RequestBuilder object
137 */ 145 */
138 - RequestBuilder withIsAuthoritative(boolean isAuthoritative); 146 + RequestBuilder withIsAuthoritative(boolean authoritative);
139 147
140 /** 148 /**
141 - * Sets isProbe flag. 149 + * Sets probe flag.
142 * 150 *
143 - * @param isProbe isProbe flag 151 + * @param probe probe flag
144 * @return RequestBuilder object 152 * @return RequestBuilder object
145 */ 153 */
146 - RequestBuilder withIsProbe(boolean isProbe); 154 + RequestBuilder withIsProbe(boolean probe);
147 155
148 /** 156 /**
149 - * Sets isSmr flag. 157 + * Sets map data resent flag.
150 * 158 *
151 - * @param isSmr isSmr flag 159 + * @param mapDataPresent map data present flag
152 * @return RequestBuilder object 160 * @return RequestBuilder object
153 */ 161 */
154 - RequestBuilder withIsSmr(boolean isSmr); 162 + RequestBuilder withIsMapDataPresent(boolean mapDataPresent);
155 163
156 /** 164 /**
157 - * Sets isPitr flag. 165 + * Sets smr flag.
158 * 166 *
159 - * @param isPitr isPitr flag 167 + * @param smr smr flag
160 * @return RequestBuilder object 168 * @return RequestBuilder object
161 */ 169 */
162 - RequestBuilder withIsPitr(boolean isPitr); 170 + RequestBuilder withIsSmr(boolean smr);
163 171
164 /** 172 /**
165 - * Sets isSmrInvoked flag. 173 + * Sets pitr flag.
166 * 174 *
167 - * @param isSmrInvoked isSmrInvoked flag 175 + * @param pitr pitr flag
168 * @return RequestBuilder object 176 * @return RequestBuilder object
169 */ 177 */
170 - RequestBuilder withIsSmrInvoked(boolean isSmrInvoked); 178 + RequestBuilder withIsPitr(boolean pitr);
179 +
180 + /**
181 + * Sets smrInvoked flag.
182 + *
183 + * @param smrInvoked smrInvoked flag
184 + * @return RequestBuilder object
185 + */
186 + RequestBuilder withIsSmrInvoked(boolean smrInvoked);
171 187
172 /** 188 /**
173 * Sets record count. 189 * Sets record count.
...@@ -186,12 +202,20 @@ public interface LispMapRequest extends LispMessage { ...@@ -186,12 +202,20 @@ public interface LispMapRequest extends LispMessage {
186 RequestBuilder withNonce(long nonce); 202 RequestBuilder withNonce(long nonce);
187 203
188 /** 204 /**
205 + * Sets source EID address.
206 + *
207 + * @param sourceEid source EID
208 + * @return RequestBuilder object
209 + */
210 + RequestBuilder withSourceEid(LispAfiAddress sourceEid);
211 +
212 + /**
189 * Adds ITR RLOC into RLOC collection. 213 * Adds ITR RLOC into RLOC collection.
190 * 214 *
191 * @param itrRloc ITR RLOC 215 * @param itrRloc ITR RLOC
192 * @return RequestBuilder object 216 * @return RequestBuilder object
193 */ 217 */
194 - RequestBuilder withItrRloc(LispAfiAddress itrRloc); 218 + RequestBuilder addItrRloc(LispAfiAddress itrRloc);
195 219
196 /** 220 /**
197 * Adds EID record into record collection. 221 * Adds EID record into record collection.
......