Jian Li | 7ccc3a8 | 2016-12-09 01:30:56 +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.ctl; |
| 17 | |
| 18 | import io.netty.channel.Channel; |
| 19 | import org.onlab.packet.IpAddress; |
Jian Li | b86d8ad | 2017-05-03 02:53:44 +0900 | [diff] [blame^] | 20 | import org.onosproject.lisp.msg.protocols.LispEidRecord; |
Jian Li | 7ccc3a8 | 2016-12-09 01:30:56 +0900 | [diff] [blame] | 21 | import org.onosproject.lisp.msg.protocols.LispMessage; |
| 22 | import org.onosproject.net.Device; |
| 23 | |
Jian Li | b86d8ad | 2017-05-03 02:53:44 +0900 | [diff] [blame^] | 24 | import java.util.List; |
| 25 | |
Jian Li | 7ccc3a8 | 2016-12-09 01:30:56 +0900 | [diff] [blame] | 26 | /** |
| 27 | * Represents to provider facing side of a router. |
| 28 | */ |
| 29 | public interface LispRouter { |
| 30 | |
| 31 | /** |
| 32 | * Writes the LISP control message to the channel. |
| 33 | * |
| 34 | * @param msg the message to be written |
| 35 | */ |
| 36 | void sendMessage(LispMessage msg); |
| 37 | |
| 38 | /** |
| 39 | * Handles the LISP control message from the channel. |
| 40 | * |
| 41 | * @param msg the message to be handled |
| 42 | */ |
| 43 | void handleMessage(LispMessage msg); |
| 44 | |
| 45 | /** |
| 46 | * Returns the router device type. |
| 47 | * |
| 48 | * @return device type |
| 49 | */ |
| 50 | Device.Type deviceType(); |
| 51 | |
| 52 | /** |
| 53 | * Identifies the channel used to communicate with the router. |
| 54 | * |
| 55 | * @return string representation of the connection to the device |
| 56 | */ |
| 57 | String channelId(); |
| 58 | |
| 59 | /** |
| 60 | * Sets the associated Netty channel for this router. |
| 61 | * |
| 62 | * @param channel the Netty channel |
| 63 | */ |
| 64 | void setChannel(Channel channel); |
| 65 | |
| 66 | /** |
| 67 | * Obtains a string version of the ID for this router. |
| 68 | * |
| 69 | * @return string representation of the device identifier |
| 70 | */ |
| 71 | String stringId(); |
| 72 | |
| 73 | /** |
| 74 | * Obtains an IpAddress version of the ID for this router. |
| 75 | * |
| 76 | * @return raw IP address of the device identifier |
| 77 | */ |
| 78 | IpAddress routerId(); |
| 79 | |
| 80 | /** |
| 81 | * Checks if the router is connected. |
| 82 | * |
| 83 | * @return whether the router is connected |
| 84 | */ |
| 85 | boolean isConnected(); |
Jian Li | 834ff72 | 2016-12-13 19:43:02 +0900 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Sets whether the router is connected. |
| 89 | * |
| 90 | * @param connected whether the router is connected |
| 91 | */ |
| 92 | void setConnected(boolean connected); |
| 93 | |
| 94 | /** |
| 95 | * Checks if the router is subscribed. |
| 96 | * As long as a router sends Map-Request message, |
| 97 | * we treat the router is subscribed. |
| 98 | * |
| 99 | * @return whether the router is subscribed |
| 100 | */ |
| 101 | boolean isSubscribed(); |
| 102 | |
| 103 | /** |
| 104 | * Sets whether the router is subscribed. |
| 105 | * |
| 106 | * @param subscribed whether the router is subscribed |
| 107 | */ |
| 108 | void setSubscribed(boolean subscribed); |
| 109 | |
| 110 | /** |
Jian Li | b86d8ad | 2017-05-03 02:53:44 +0900 | [diff] [blame^] | 111 | * Obtains a collection of EID records that associated with this router. |
| 112 | * |
| 113 | * @return a collection EID records that associated with this router |
| 114 | */ |
| 115 | List<LispEidRecord> getEidRecords(); |
| 116 | |
| 117 | /** |
| 118 | * Associates the EID records to this router. |
| 119 | * |
| 120 | * @param records a collection of EID records |
| 121 | */ |
| 122 | void setEidRecords(List<LispEidRecord> records); |
| 123 | |
| 124 | /** |
Jian Li | 834ff72 | 2016-12-13 19:43:02 +0900 | [diff] [blame] | 125 | * Sets the LISP agent to be used. This method can only be invoked once. |
| 126 | * |
| 127 | * @param agent the agent to set |
| 128 | */ |
| 129 | void setAgent(LispRouterAgent agent); |
| 130 | |
| 131 | /** |
| 132 | * Announces to the LISP agent that this router has connected. |
| 133 | * |
| 134 | * @return true if successful, false if duplicate router |
| 135 | */ |
| 136 | boolean connectRouter(); |
| 137 | |
| 138 | /** |
| 139 | * Disconnects the router by closing UDP connection. |
| 140 | * Results in a call to the channel handler's close method for cleanup. |
| 141 | */ |
| 142 | void disconnectRouter(); |
Jian Li | 7ccc3a8 | 2016-12-09 01:30:56 +0900 | [diff] [blame] | 143 | } |