blob: aef37bb0e7e446dcb69bd489928b17a5c620c628 [file] [log] [blame]
Jonathan Hart06e89082016-08-08 17:21:01 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Jonathan Hart06e89082016-08-08 17:21:01 -07003 *
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 Milkeyb65d7842017-08-03 16:28:24 -070017package org.onosproject.net.neighbour;
Jonathan Hart06e89082016-08-08 17:21:01 -070018
19import com.google.common.annotations.Beta;
20import org.onlab.packet.Ethernet;
21import org.onlab.packet.IpAddress;
22import org.onlab.packet.MacAddress;
23import org.onlab.packet.VlanId;
Ray Milkeyfacf2862017-08-03 11:58:29 -070024import org.onosproject.net.intf.Interface;
Jonathan Hart06e89082016-08-08 17:21:01 -070025import org.onosproject.net.ConnectPoint;
26
Jonathan Hart06e89082016-08-08 17:21:01 -070027/**
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 Hart9bdaaec2016-08-22 13:33:45 -070035public interface NeighbourMessageContext {
Jonathan Hart06e89082016-08-08 17:21:01 -070036 /**
37 * Gets the port where the packet came in to the network.
38 *
39 * @return connect point
40 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070041 ConnectPoint inPort();
Jonathan Hart06e89082016-08-08 17:21:01 -070042
43 /**
44 * Gets the full parsed representation of the packet.
45 *
46 * @return ethernet header
47 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070048 Ethernet packet();
Jonathan Hart06e89082016-08-08 17:21:01 -070049
50 /**
51 * Gets the protocol of the packet.
52 *
53 * @return protocol
54 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070055 NeighbourProtocol protocol();
Jonathan Hart06e89082016-08-08 17:21:01 -070056
57 /**
58 * Gets the message type of the packet.
59 *
60 * @return message type
61 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070062 NeighbourMessageType type();
Jonathan Hart06e89082016-08-08 17:21:01 -070063
64 /**
65 * Gets the vlan of the packet, if any.
66 *
67 * @return vlan
68 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070069 VlanId vlan();
Jonathan Hart06e89082016-08-08 17:21:01 -070070
71 /**
72 * Gets the source MAC address of the message.
73 *
74 * @return source MAC address
75 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070076 MacAddress srcMac();
Jonathan Hart06e89082016-08-08 17:21:01 -070077
78 /**
Jonathan Hartc4f681c2016-09-09 07:14:25 -070079 * 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 Hart06e89082016-08-08 17:21:01 -070089 * Gets the target IP address of the message.
90 *
91 * @return target IP address
92 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070093 IpAddress target();
Jonathan Hart06e89082016-08-08 17:21:01 -070094
95 /**
96 * Gets the source IP address of the message.
97 *
98 * @return source IP address
99 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -0700100 IpAddress sender();
Jonathan Hart06e89082016-08-08 17:21:01 -0700101
102 /**
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700103 * Forwards the message to a given output port.
Jonathan Hart06e89082016-08-08 17:21:01 -0700104 *
105 * @param outPort output port
106 */
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700107 void forward(ConnectPoint outPort);
Jonathan Hart06e89082016-08-08 17:21:01 -0700108
109 /**
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700110 * 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 Hart06e89082016-08-08 17:21:01 -0700116 * @param outIntf output interface
117 */
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700118 void forward(Interface outIntf);
Jonathan Hart06e89082016-08-08 17:21:01 -0700119
120 /**
121 * Replies to the request message with a given MAC address.
122 *
123 * @param targetMac target MAC address
124 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -0700125 void reply(MacAddress targetMac);
Jonathan Hart06e89082016-08-08 17:21:01 -0700126
127 /**
128 * Floods the incoming message out all ports except the input port.
129 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -0700130 void flood();
Jonathan Hart06e89082016-08-08 17:21:01 -0700131
132 /**
133 * Drops the incoming message.
134 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -0700135 void drop();
Jonathan Hart06e89082016-08-08 17:21:01 -0700136}