blob: 49ff541c83e800253681ec694d563fd77cbcb63d [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;
Jian Li10a09062016-07-26 23:58:50 +090019import org.onosproject.lisp.msg.types.LispAfiAddress;
20
Jian Li47671902016-08-11 01:18:18 +090021import java.util.List;
22
Jian Li10a09062016-07-26 23:58:50 +090023/**
24 * LISP record section which is part of LISP map register message.
25 */
26public interface LispMapRecord {
27
28 /**
29 * Obtains record TTL value.
30 *
31 * @return record TTL value
32 */
33 int getRecordTtl();
34
35 /**
36 * Obtains locator count value.
37 *
38 * @return locator count value
39 */
40 int getLocatorCount();
41
42 /**
43 * Obtains address mask length.
44 *
45 * @return mask length
46 */
47 byte getMaskLength();
48
49 /**
50 * Obtains LispMapReplyAction enum code.
51 *
52 * @return LispMapReplyAction enum code
53 */
54 LispMapReplyAction getAction();
55
56 /**
57 * Obtains authoritative flag.
58 *
59 * @return authoritative flag
60 */
61 boolean isAuthoritative();
62
63 /**
64 * Obtains map version number.
65 *
66 * @return map version number
67 */
68 short getMapVersionNumber();
69
70 /**
71 * Obtains EID prefix.
72 *
73 * @return EID prefix
74 */
75 LispAfiAddress getEidPrefixAfi();
76
77 /**
Jian Li47671902016-08-11 01:18:18 +090078 * Obtains a collection of locator records.
79 *
80 * @return a collection of locator records
81 */
82 List<LispLocatorRecord> getLocators();
83
84 /**
85 * Writes LISP message object into communication channel.
86 *
87 * @param byteBuf byte buffer
88 */
89 void writeTo(ByteBuf byteBuf);
90
91 /**
Jian Li10a09062016-07-26 23:58:50 +090092 * A builder of LISP map record.
93 */
94 interface MapRecordBuilder {
95
96 /**
97 * Sets record TTL value.
98 *
99 * @param recordTtl record TTL
100 * @return MapRecordBuilder object
101 */
102 MapRecordBuilder withRecordTtl(int recordTtl);
103
104 /**
105 * Sets locator count.
106 *
107 * @param locatorCount locator count
108 * @return MapRecordBuilder object
109 */
110 MapRecordBuilder withLocatorCount(int locatorCount);
111
112 /**
113 * Sets mask length.
114 *
115 * @param maskLength mask length
116 * @return MapRecordBuilder object
117 */
118 MapRecordBuilder withMaskLength(byte maskLength);
119
120 /**
121 * Sets LISP map reply action enum.
122 *
123 * @param action map reply action
124 * @return MapRecordBuilder object
125 */
126 MapRecordBuilder withAction(LispMapReplyAction action);
127
128 /**
129 * Sets authoritative flag.
130 *
131 * @param authoritative authoritative flag
132 * @return MapRecordBuilder object
133 */
134 MapRecordBuilder withAuthoritative(boolean authoritative);
135
136 /**
137 * Sets LISP map version number.
138 *
139 * @param mapVersionNumber map version number
140 * @return MapRecordBuilder object
141 */
142 MapRecordBuilder withMapVersionNumber(short mapVersionNumber);
143
144 /**
145 * Sets EID prefix.
146 *
147 * @param prefix EID prefix
148 * @return MapRecordBuilder object
149 */
150 MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix);
Jian Li631e62a2016-08-03 22:42:00 +0900151
152 /**
Jian Li47671902016-08-11 01:18:18 +0900153 * Sets a collection of locator records.
154 *
155 * @param records a collection of locator records
156 * @return MapRecordBuilder object
157 */
158 MapRecordBuilder withLocators(List<LispLocatorRecord> records);
159
160 /**
Jian Li631e62a2016-08-03 22:42:00 +0900161 * Builds map record.
162 *
163 * @return map record instance
164 */
165 LispMapRecord build();
Jian Li10a09062016-07-26 23:58:50 +0900166 }
167}