Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 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 | |
Ray Milkey | b65d784 | 2017-08-03 16:28:24 -0700 | [diff] [blame] | 17 | package org.onosproject.net.neighbour; |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 18 | |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 19 | import org.onlab.packet.Ethernet; |
| 20 | import org.onlab.packet.IpAddress; |
| 21 | import org.onlab.packet.MacAddress; |
| 22 | import org.onlab.packet.VlanId; |
Ray Milkey | facf286 | 2017-08-03 11:58:29 -0700 | [diff] [blame] | 23 | import org.onosproject.net.intf.Interface; |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 24 | import org.onosproject.net.ConnectPoint; |
| 25 | |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Context of an incoming neighbor message (e.g. ARP, NDP). |
| 28 | * |
| 29 | * <p>This includes information about the message accessible through a |
| 30 | * protocol-agnostic interface, as well as mechanisms to perform an action in |
| 31 | * response to the incoming message.</p> |
| 32 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 33 | public interface NeighbourMessageContext { |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 34 | /** |
| 35 | * Gets the port where the packet came in to the network. |
| 36 | * |
| 37 | * @return connect point |
| 38 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 39 | ConnectPoint inPort(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Gets the full parsed representation of the packet. |
| 43 | * |
| 44 | * @return ethernet header |
| 45 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 46 | Ethernet packet(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Gets the protocol of the packet. |
| 50 | * |
| 51 | * @return protocol |
| 52 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 53 | NeighbourProtocol protocol(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * Gets the message type of the packet. |
| 57 | * |
| 58 | * @return message type |
| 59 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 60 | NeighbourMessageType type(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Gets the vlan of the packet, if any. |
| 64 | * |
| 65 | * @return vlan |
| 66 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 67 | VlanId vlan(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Gets the source MAC address of the message. |
| 71 | * |
| 72 | * @return source MAC address |
| 73 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 74 | MacAddress srcMac(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
Jonathan Hart | c4f681c | 2016-09-09 07:14:25 -0700 | [diff] [blame] | 77 | * Gets the destination MAC address of the message. |
| 78 | * <p> |
| 79 | * Only valid for reply packets, will be null for request packets. |
| 80 | * </p> |
| 81 | * |
| 82 | * @return target MAC address |
| 83 | */ |
| 84 | MacAddress dstMac(); |
| 85 | |
| 86 | /** |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 87 | * Gets the target IP address of the message. |
| 88 | * |
| 89 | * @return target IP address |
| 90 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 91 | IpAddress target(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * Gets the source IP address of the message. |
| 95 | * |
| 96 | * @return source IP address |
| 97 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 98 | IpAddress sender(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
Jonathan Hart | 2efe0c2 | 2016-09-21 12:04:45 -0700 | [diff] [blame] | 101 | * Forwards the message to a given output port. |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 102 | * |
| 103 | * @param outPort output port |
| 104 | */ |
Jonathan Hart | 2efe0c2 | 2016-09-21 12:04:45 -0700 | [diff] [blame] | 105 | void forward(ConnectPoint outPort); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
Jonathan Hart | 2efe0c2 | 2016-09-21 12:04:45 -0700 | [diff] [blame] | 108 | * Forwards the message to a given interface. |
| 109 | * <p> |
| 110 | * The message will be modified to fit the parameters of the outgoing |
| 111 | * interface. For example, if the interface has a VLAN configured, the |
| 112 | * outgoing packet will have that VLAN tag added. |
| 113 | * </p> |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 114 | * @param outIntf output interface |
| 115 | */ |
Jonathan Hart | 2efe0c2 | 2016-09-21 12:04:45 -0700 | [diff] [blame] | 116 | void forward(Interface outIntf); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Replies to the request message with a given MAC address. |
| 120 | * |
| 121 | * @param targetMac target MAC address |
| 122 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 123 | void reply(MacAddress targetMac); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Floods the incoming message out all ports except the input port. |
| 127 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 128 | void flood(); |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * Drops the incoming message. |
| 132 | */ |
Jonathan Hart | 9bdaaec | 2016-08-22 13:33:45 -0700 | [diff] [blame] | 133 | void drop(); |
Charles Chan | eded688 | 2018-06-29 14:28:39 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * Gets whether this neighbour message context involves a router. |
| 137 | * |
| 138 | * @return true if this neighbour message context involves a router |
| 139 | */ |
| 140 | default boolean isRouter() { |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Sets whether this neighbour message context involves a router. |
| 146 | * |
| 147 | * @param isRouter true if this neighbour message context involves a router |
| 148 | */ |
| 149 | default void setIsRouter(boolean isRouter) { |
| 150 | } |
Jonathan Hart | 06e8908 | 2016-08-08 17:21:01 -0700 | [diff] [blame] | 151 | } |