Jian Li | 10a0906 | 2016-07-26 23:58:50 +0900 | [diff] [blame] | 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 | |
Jian Li | 4767190 | 2016-08-11 01:18:18 +0900 | [diff] [blame] | 18 | import io.netty.buffer.ByteBuf; |
Yoonseon Han | ca814bf | 2016-09-12 11:37:48 -0700 | [diff] [blame] | 19 | import org.onosproject.lisp.msg.exceptions.LispWriterException; |
Jian Li | 10a0906 | 2016-07-26 23:58:50 +0900 | [diff] [blame] | 20 | import org.onosproject.lisp.msg.types.LispAfiAddress; |
| 21 | |
Jian Li | 4767190 | 2016-08-11 01:18:18 +0900 | [diff] [blame] | 22 | import java.util.List; |
| 23 | |
Jian Li | 10a0906 | 2016-07-26 23:58:50 +0900 | [diff] [blame] | 24 | /** |
| 25 | * LISP record section which is part of LISP map register message. |
| 26 | */ |
| 27 | public 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 Li | 4767190 | 2016-08-11 01:18:18 +0900 | [diff] [blame] | 79 | * 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 Milkey | 0bb1e10 | 2016-11-10 14:51:27 -0800 | [diff] [blame] | 89 | * @throws LispWriterException on error |
Jian Li | 4767190 | 2016-08-11 01:18:18 +0900 | [diff] [blame] | 90 | */ |
Yoonseon Han | ca814bf | 2016-09-12 11:37:48 -0700 | [diff] [blame] | 91 | void writeTo(ByteBuf byteBuf) throws LispWriterException; |
Jian Li | 4767190 | 2016-08-11 01:18:18 +0900 | [diff] [blame] | 92 | |
| 93 | /** |
Jian Li | 10a0906 | 2016-07-26 23:58:50 +0900 | [diff] [blame] | 94 | * 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 Li | 10a0906 | 2016-07-26 23:58:50 +0900 | [diff] [blame] | 107 | * 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 Li | 631e62a | 2016-08-03 22:42:00 +0900 | [diff] [blame] | 145 | |
| 146 | /** |
Jian Li | 4767190 | 2016-08-11 01:18:18 +0900 | [diff] [blame] | 147 | * 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 Li | 631e62a | 2016-08-03 22:42:00 +0900 | [diff] [blame] | 155 | * Builds map record. |
| 156 | * |
| 157 | * @return map record instance |
| 158 | */ |
| 159 | LispMapRecord build(); |
Jian Li | 10a0906 | 2016-07-26 23:58:50 +0900 | [diff] [blame] | 160 | } |
| 161 | } |