blob: ae7cb599ee6c96109da278ea6247ce6c7e872ba1 [file] [log] [blame]
Jian Li10a09062016-07-26 23:58:50 +09001/*
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 */
16package org.onosproject.lisp.msg.protocols;
17
Jian Li47671902016-08-11 01:18:18 +090018import io.netty.buffer.ByteBuf;
Yoonseon Hanca814bf2016-09-12 11:37:48 -070019import org.onosproject.lisp.msg.exceptions.LispWriterException;
Jian Li10a09062016-07-26 23:58:50 +090020import org.onosproject.lisp.msg.types.LispAfiAddress;
21
Jian Li47671902016-08-11 01:18:18 +090022import java.util.List;
23
Jian Li10a09062016-07-26 23:58:50 +090024/**
25 * LISP record section which is part of LISP map register message.
26 */
27public interface LispMapRecord {
28
29 /**
30 * Obtains record TTL value.
31 *
32 * @return record TTL value
33 */
34 int getRecordTtl();
35
36 /**
37 * Obtains locator count value.
38 *
39 * @return locator count value
40 */
41 int getLocatorCount();
42
43 /**
44 * Obtains address mask length.
45 *
46 * @return mask length
47 */
48 byte getMaskLength();
49
50 /**
51 * Obtains LispMapReplyAction enum code.
52 *
53 * @return LispMapReplyAction enum code
54 */
55 LispMapReplyAction getAction();
56
57 /**
58 * Obtains authoritative flag.
59 *
60 * @return authoritative flag
61 */
62 boolean isAuthoritative();
63
64 /**
65 * Obtains map version number.
66 *
67 * @return map version number
68 */
69 short getMapVersionNumber();
70
71 /**
72 * Obtains EID prefix.
73 *
74 * @return EID prefix
75 */
76 LispAfiAddress getEidPrefixAfi();
77
78 /**
Jian Li47671902016-08-11 01:18:18 +090079 * Obtains a collection of locator records.
80 *
81 * @return a collection of locator records
82 */
83 List<LispLocatorRecord> getLocators();
84
85 /**
86 * Writes LISP message object into communication channel.
87 *
88 * @param byteBuf byte buffer
Ray Milkey0bb1e102016-11-10 14:51:27 -080089 * @throws LispWriterException on error
Jian Li47671902016-08-11 01:18:18 +090090 */
Yoonseon Hanca814bf2016-09-12 11:37:48 -070091 void writeTo(ByteBuf byteBuf) throws LispWriterException;
Jian Li47671902016-08-11 01:18:18 +090092
93 /**
Jian Li10a09062016-07-26 23:58:50 +090094 * A builder of LISP map record.
95 */
96 interface MapRecordBuilder {
97
98 /**
99 * Sets record TTL value.
100 *
101 * @param recordTtl record TTL
102 * @return MapRecordBuilder object
103 */
104 MapRecordBuilder withRecordTtl(int recordTtl);
105
106 /**
Jian Li10a09062016-07-26 23:58:50 +0900107 * Sets mask length.
108 *
109 * @param maskLength mask length
110 * @return MapRecordBuilder object
111 */
112 MapRecordBuilder withMaskLength(byte maskLength);
113
114 /**
115 * Sets LISP map reply action enum.
116 *
117 * @param action map reply action
118 * @return MapRecordBuilder object
119 */
120 MapRecordBuilder withAction(LispMapReplyAction action);
121
122 /**
123 * Sets authoritative flag.
124 *
125 * @param authoritative authoritative flag
126 * @return MapRecordBuilder object
127 */
128 MapRecordBuilder withAuthoritative(boolean authoritative);
129
130 /**
131 * Sets LISP map version number.
132 *
133 * @param mapVersionNumber map version number
134 * @return MapRecordBuilder object
135 */
136 MapRecordBuilder withMapVersionNumber(short mapVersionNumber);
137
138 /**
139 * Sets EID prefix.
140 *
141 * @param prefix EID prefix
142 * @return MapRecordBuilder object
143 */
144 MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix);
Jian Li631e62a2016-08-03 22:42:00 +0900145
146 /**
Jian Li47671902016-08-11 01:18:18 +0900147 * Sets a collection of locator records.
148 *
149 * @param records a collection of locator records
150 * @return MapRecordBuilder object
151 */
152 MapRecordBuilder withLocators(List<LispLocatorRecord> records);
153
154 /**
Jian Li631e62a2016-08-03 22:42:00 +0900155 * Builds map record.
156 *
157 * @return map record instance
158 */
159 LispMapRecord build();
Jian Li10a09062016-07-26 23:58:50 +0900160 }
161}