Jian Li | 672ebda | 2017-02-06 20:21:04 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-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 | |
| 18 | import io.netty.buffer.ByteBuf; |
| 19 | import org.onosproject.lisp.msg.exceptions.LispWriterException; |
| 20 | import org.onosproject.lisp.msg.types.LispAfiAddress; |
| 21 | |
| 22 | /** |
| 23 | * Generic LISP record interface. |
| 24 | */ |
| 25 | public interface LispRecord { |
| 26 | |
| 27 | /** |
| 28 | * Obtains record TTL value. |
| 29 | * |
| 30 | * @return record TTL value |
| 31 | */ |
| 32 | int getRecordTtl(); |
| 33 | |
| 34 | /** |
| 35 | * Obtains address mask length. |
| 36 | * |
| 37 | * @return mask length |
| 38 | */ |
| 39 | byte getMaskLength(); |
| 40 | |
| 41 | /** |
| 42 | * Obtains LispMapReplyAction enum code. |
| 43 | * |
| 44 | * @return LispMapReplyAction enum code |
| 45 | */ |
| 46 | LispMapReplyAction getAction(); |
| 47 | |
| 48 | /** |
| 49 | * Obtains authoritative flag. |
| 50 | * |
| 51 | * @return authoritative flag |
| 52 | */ |
| 53 | boolean isAuthoritative(); |
| 54 | |
| 55 | /** |
| 56 | * Obtains map version number. |
| 57 | * |
| 58 | * @return map version number |
| 59 | */ |
| 60 | short getMapVersionNumber(); |
| 61 | |
| 62 | /** |
| 63 | * Obtains EID prefix. |
| 64 | * |
| 65 | * @return EID prefix |
| 66 | */ |
| 67 | LispAfiAddress getEidPrefixAfi(); |
| 68 | |
| 69 | /** |
| 70 | * Writes LISP message object into communication channel. |
| 71 | * |
| 72 | * @param byteBuf byte buffer |
| 73 | * @throws LispWriterException on error |
| 74 | */ |
| 75 | void writeTo(ByteBuf byteBuf) throws LispWriterException; |
| 76 | |
| 77 | /** |
| 78 | * A builder for LISP record. |
| 79 | * |
| 80 | * @param <T> sub-builder type |
| 81 | */ |
| 82 | interface RecordBuilder<T> { |
| 83 | |
| 84 | /** |
| 85 | * Sets record TTL value. |
| 86 | * |
| 87 | * @param recordTtl record TTL |
| 88 | * @return parameterized object |
| 89 | */ |
| 90 | T withRecordTtl(int recordTtl); |
| 91 | |
| 92 | /** |
| 93 | * Sets mask length. |
| 94 | * |
| 95 | * @param maskLength mask length |
| 96 | * @return parameterized object |
| 97 | */ |
| 98 | T withMaskLength(byte maskLength); |
| 99 | |
| 100 | /** |
| 101 | * Sets LISP map reply action enum. |
| 102 | * |
| 103 | * @param action map reply action |
| 104 | * @return parameterized object |
| 105 | */ |
| 106 | T withAction(LispMapReplyAction action); |
| 107 | |
| 108 | /** |
| 109 | * Sets authoritative flag. |
| 110 | * |
| 111 | * @param authoritative authoritative flag |
| 112 | * @return parameterized object |
| 113 | */ |
| 114 | T withIsAuthoritative(boolean authoritative); |
| 115 | |
| 116 | /** |
| 117 | * Sets LISP map version number. |
| 118 | * |
| 119 | * @param mapVersionNumber map version number |
| 120 | * @return parameterized object |
| 121 | */ |
| 122 | T withMapVersionNumber(short mapVersionNumber); |
| 123 | |
| 124 | /** |
| 125 | * Sets EID prefix. |
| 126 | * |
| 127 | * @param prefix EID prefix |
| 128 | * @return parameterized object |
| 129 | */ |
| 130 | T withEidPrefixAfi(LispAfiAddress prefix); |
| 131 | } |
| 132 | } |