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