Jian Li | cb1fca2 | 2016-07-19 18:34:25 +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 | |
| 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 | cb1fca2 | 2016-07-19 18:34:25 +0900 | [diff] [blame] | 20 | |
Jian Li | afe2d3f | 2016-11-01 02:49:07 +0900 | [diff] [blame] | 21 | import java.net.InetSocketAddress; |
| 22 | |
Jian Li | cb1fca2 | 2016-07-19 18:34:25 +0900 | [diff] [blame] | 23 | /** |
| 24 | * LISP message interface. |
| 25 | */ |
| 26 | public interface LispMessage { |
| 27 | |
| 28 | /** |
| 29 | * Obtains LISP message type. |
| 30 | * |
| 31 | * @return LISP message type |
| 32 | */ |
| 33 | LispType getType(); |
| 34 | |
| 35 | /** |
Jian Li | afe2d3f | 2016-11-01 02:49:07 +0900 | [diff] [blame] | 36 | * Configures the sender's IP address with port number. |
| 37 | * Note that this information is used to make the UDP datagram packet. |
| 38 | * |
| 39 | * @param sender LISP message sender |
| 40 | */ |
| 41 | void configSender(InetSocketAddress sender); |
| 42 | |
| 43 | /** |
| 44 | * Obtains the sender's IP address with port number. |
| 45 | * Note that this information is used to make the UDP datagram packet. |
| 46 | * |
| 47 | * @return send's IP address with port number |
| 48 | */ |
| 49 | InetSocketAddress getSender(); |
| 50 | |
| 51 | /** |
Jian Li | cb1fca2 | 2016-07-19 18:34:25 +0900 | [diff] [blame] | 52 | * Writes LISP message object into communication channel. |
| 53 | * |
| 54 | * @param byteBuf byte buffer |
Yoonseon Han | ca814bf | 2016-09-12 11:37:48 -0700 | [diff] [blame] | 55 | * @throws LispWriterException if the writing request is failed due to |
| 56 | * the lisp object cannot be written to the buffer. |
Jian Li | cb1fca2 | 2016-07-19 18:34:25 +0900 | [diff] [blame] | 57 | */ |
Yoonseon Han | ca814bf | 2016-09-12 11:37:48 -0700 | [diff] [blame] | 58 | void writeTo(ByteBuf byteBuf) throws LispWriterException; |
Jian Li | cb1fca2 | 2016-07-19 18:34:25 +0900 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Generates LISP message builder. |
| 62 | * |
| 63 | * @return builder object |
| 64 | */ |
| 65 | Builder createBuilder(); |
| 66 | |
| 67 | /** |
| 68 | * LISP message builder interface. |
| 69 | */ |
Jian Li | 719b3bf | 2016-07-22 00:38:29 +0900 | [diff] [blame] | 70 | interface Builder { |
Jian Li | cb1fca2 | 2016-07-19 18:34:25 +0900 | [diff] [blame] | 71 | |
| 72 | /** |
Jian Li | cb1fca2 | 2016-07-19 18:34:25 +0900 | [diff] [blame] | 73 | * Obtains LISP message type. |
| 74 | * |
| 75 | * @return LISP message type |
| 76 | */ |
| 77 | LispType getType(); |
| 78 | } |
| 79 | } |