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