blob: 65042c6b8eb600444a41634039be83b7291f86a1 [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
Jonathan Hart06e89082016-08-08 17:21:01 -070019import org.onlab.packet.Ethernet;
20import org.onlab.packet.IpAddress;
21import org.onlab.packet.MacAddress;
22import org.onlab.packet.VlanId;
Ray Milkeyfacf2862017-08-03 11:58:29 -070023import org.onosproject.net.intf.Interface;
Jonathan Hart06e89082016-08-08 17:21:01 -070024import org.onosproject.net.ConnectPoint;
25
Jonathan Hart06e89082016-08-08 17:21:01 -070026/**
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 Hart9bdaaec2016-08-22 13:33:45 -070033public interface NeighbourMessageContext {
Jonathan Hart06e89082016-08-08 17:21:01 -070034 /**
35 * Gets the port where the packet came in to the network.
36 *
37 * @return connect point
38 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070039 ConnectPoint inPort();
Jonathan Hart06e89082016-08-08 17:21:01 -070040
41 /**
42 * Gets the full parsed representation of the packet.
43 *
44 * @return ethernet header
45 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070046 Ethernet packet();
Jonathan Hart06e89082016-08-08 17:21:01 -070047
48 /**
49 * Gets the protocol of the packet.
50 *
51 * @return protocol
52 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070053 NeighbourProtocol protocol();
Jonathan Hart06e89082016-08-08 17:21:01 -070054
55 /**
56 * Gets the message type of the packet.
57 *
58 * @return message type
59 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070060 NeighbourMessageType type();
Jonathan Hart06e89082016-08-08 17:21:01 -070061
62 /**
63 * Gets the vlan of the packet, if any.
64 *
65 * @return vlan
66 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070067 VlanId vlan();
Jonathan Hart06e89082016-08-08 17:21:01 -070068
69 /**
70 * Gets the source MAC address of the message.
71 *
72 * @return source MAC address
73 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070074 MacAddress srcMac();
Jonathan Hart06e89082016-08-08 17:21:01 -070075
76 /**
Jonathan Hartc4f681c2016-09-09 07:14:25 -070077 * 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 Hart06e89082016-08-08 17:21:01 -070087 * Gets the target IP address of the message.
88 *
89 * @return target IP address
90 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070091 IpAddress target();
Jonathan Hart06e89082016-08-08 17:21:01 -070092
93 /**
94 * Gets the source IP address of the message.
95 *
96 * @return source IP address
97 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -070098 IpAddress sender();
Jonathan Hart06e89082016-08-08 17:21:01 -070099
100 /**
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700101 * Forwards the message to a given output port.
Jonathan Hart06e89082016-08-08 17:21:01 -0700102 *
103 * @param outPort output port
104 */
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700105 void forward(ConnectPoint outPort);
Jonathan Hart06e89082016-08-08 17:21:01 -0700106
107 /**
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700108 * 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 Hart06e89082016-08-08 17:21:01 -0700114 * @param outIntf output interface
115 */
Jonathan Hart2efe0c22016-09-21 12:04:45 -0700116 void forward(Interface outIntf);
Jonathan Hart06e89082016-08-08 17:21:01 -0700117
118 /**
119 * Replies to the request message with a given MAC address.
120 *
121 * @param targetMac target MAC address
122 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -0700123 void reply(MacAddress targetMac);
Jonathan Hart06e89082016-08-08 17:21:01 -0700124
125 /**
126 * Floods the incoming message out all ports except the input port.
127 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -0700128 void flood();
Jonathan Hart06e89082016-08-08 17:21:01 -0700129
130 /**
131 * Drops the incoming message.
132 */
Jonathan Hart9bdaaec2016-08-22 13:33:45 -0700133 void drop();
Jonathan Hart06e89082016-08-08 17:21:01 -0700134}