blob: d710ebc4f67fe69e5549d0a9f1160f00f221063a [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
89 */
Yoonseon Hanca814bf2016-09-12 11:37:48 -070090 void writeTo(ByteBuf byteBuf) throws LispWriterException;
Jian Li47671902016-08-11 01:18:18 +090091
92 /**
Jian Li10a09062016-07-26 23:58:50 +090093 * A builder of LISP map record.
94 */
95 interface MapRecordBuilder {
96
97 /**
98 * Sets record TTL value.
99 *
100 * @param recordTtl record TTL
101 * @return MapRecordBuilder object
102 */
103 MapRecordBuilder withRecordTtl(int recordTtl);
104
105 /**
Jian Li10a09062016-07-26 23:58:50 +0900106 * Sets mask length.
107 *
108 * @param maskLength mask length
109 * @return MapRecordBuilder object
110 */
111 MapRecordBuilder withMaskLength(byte maskLength);
112
113 /**
114 * Sets LISP map reply action enum.
115 *
116 * @param action map reply action
117 * @return MapRecordBuilder object
118 */
119 MapRecordBuilder withAction(LispMapReplyAction action);
120
121 /**
122 * Sets authoritative flag.
123 *
124 * @param authoritative authoritative flag
125 * @return MapRecordBuilder object
126 */
127 MapRecordBuilder withAuthoritative(boolean authoritative);
128
129 /**
130 * Sets LISP map version number.
131 *
132 * @param mapVersionNumber map version number
133 * @return MapRecordBuilder object
134 */
135 MapRecordBuilder withMapVersionNumber(short mapVersionNumber);
136
137 /**
138 * Sets EID prefix.
139 *
140 * @param prefix EID prefix
141 * @return MapRecordBuilder object
142 */
143 MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix);
Jian Li631e62a2016-08-03 22:42:00 +0900144
145 /**
Jian Li47671902016-08-11 01:18:18 +0900146 * Sets a collection of locator records.
147 *
148 * @param records a collection of locator records
149 * @return MapRecordBuilder object
150 */
151 MapRecordBuilder withLocators(List<LispLocatorRecord> records);
152
153 /**
Jian Li631e62a2016-08-03 22:42:00 +0900154 * Builds map record.
155 *
156 * @return map record instance
157 */
158 LispMapRecord build();
Jian Li10a09062016-07-26 23:58:50 +0900159 }
160}