Jonathan Hart | 313fdf0 | 2014-04-10 14:09:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.packetservice; |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 2 | |
Jonathan Hart | 8ed69c5 | 2014-04-09 13:29:16 -0700 | [diff] [blame] | 3 | import java.util.Arrays; |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 4 | |
Yuta HIGUCHI | d92b10c | 2014-08-25 09:30:28 -0700 | [diff] [blame] | 5 | import net.onrc.onos.core.topology.MutableTopology; |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 6 | |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame] | 7 | import com.google.common.collect.Multimap; |
| 8 | |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 9 | /** |
| 10 | * A PacketOutNotification contains data sent between ONOS instances that |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 11 | * directs other instances to send a packet out a set of ports. This is an |
| 12 | * abstract base class that will be subclassed by specific types of |
| 13 | * notifications. |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 14 | */ |
pingping-lin | 0426dee | 2014-08-27 15:03:17 -0700 | [diff] [blame^] | 15 | public abstract class PacketOutNotification { |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 16 | |
Jonathan Hart | 313fdf0 | 2014-04-10 14:09:46 -0700 | [diff] [blame] | 17 | private final byte[] packet; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 18 | |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 19 | /** |
Jonathan Hart | 51dc5e1 | 2014-04-22 11:03:59 -0700 | [diff] [blame] | 20 | * Default constructor, used for deserialization. |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame] | 21 | */ |
| 22 | protected PacketOutNotification() { |
| 23 | packet = null; |
| 24 | } |
| 25 | |
| 26 | /** |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 27 | * Class constructor. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 28 | * |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 29 | * @param packet the packet data to send in the packet-out |
| 30 | */ |
| 31 | public PacketOutNotification(byte[] packet) { |
Jonathan Hart | 8ed69c5 | 2014-04-09 13:29:16 -0700 | [diff] [blame] | 32 | this.packet = Arrays.copyOf(packet, packet.length); |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 33 | } |
Jonathan Hart | 313fdf0 | 2014-04-10 14:09:46 -0700 | [diff] [blame] | 34 | |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Gets the packet that needs to be sent into the network. |
| 37 | * |
| 38 | * @return the packet data as a serialized byte array |
| 39 | */ |
Jonathan Hart | 313fdf0 | 2014-04-10 14:09:46 -0700 | [diff] [blame] | 40 | public byte[] getPacketData() { |
| 41 | return Arrays.copyOf(packet, packet.length); |
| 42 | } |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Calculate a list of local ports that the packet should be sent out. |
| 46 | * <p/> |
| 47 | * A {@link PacketOutNotification} contains a high-level description of the |
| 48 | * where to send the packet. The receiver of the notification needs to know |
| 49 | * an explicit list of ports to send the packet out. This function will |
| 50 | * calculate that list, given the list of edge ports controlled by this |
| 51 | * instance. |
| 52 | * |
Jonathan Hart | f5bd258 | 2014-04-09 17:43:41 -0700 | [diff] [blame] | 53 | * @param localPorts the map of locally-controlled ports |
Yuta HIGUCHI | d92b10c | 2014-08-25 09:30:28 -0700 | [diff] [blame] | 54 | * @param mutableTopology an instance of the global topology |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame] | 55 | * @return a multimap of ports that the packet should be sent out, |
| 56 | * in the form |
| 57 | * {@code {dpid1 => {portnum1, portnum2, ...}, dpid2 => {portnum1}, ...}} |
| 58 | */ |
| 59 | public abstract Multimap<Long, Short> calculateOutPorts( |
Yuta HIGUCHI | d92b10c | 2014-08-25 09:30:28 -0700 | [diff] [blame] | 60 | Multimap<Long, Short> localPorts, MutableTopology mutableTopology); |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 61 | } |