Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.packet; |
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import net.floodlightcontroller.core.module.IFloodlightService; |
| 6 | import net.onrc.onos.core.packet.Ethernet; |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame^] | 7 | import net.onrc.onos.core.util.SwitchPort; |
Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 8 | |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame^] | 9 | /** |
| 10 | * Provides packet services to ONOS applications. This includes both the |
| 11 | * ability to receive packets from the network, and to send packets out |
| 12 | * ports in the network. The packet service provides a global context for |
| 13 | * packet operations; an application can send/receive packets to/from any |
| 14 | * port in the network. |
| 15 | * <p/> |
| 16 | * NOTE: Global packet-ins are currently not implemented. An application can |
| 17 | * subscribe to local packet-ins only at the moment. |
| 18 | */ |
Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 19 | public interface IPacketService extends IFloodlightService { |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame^] | 20 | /** |
| 21 | * Register to listen for packet-in events. |
| 22 | * |
| 23 | * @param listener the function to call when a packet-in event is received |
| 24 | */ |
Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 25 | public void registerPacketListener(IPacketListener listener); |
| 26 | |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame^] | 27 | // TODO investigate using Port objects again when Ports can be safely |
| 28 | // passed around. |
| 29 | /** |
| 30 | * Send a packet out a specific port in the network. |
| 31 | * |
| 32 | * @param switchPort the port to send the packet out |
| 33 | * @param eth the packet to send |
| 34 | */ |
| 35 | public void sendPacket(SwitchPort switchPort, Ethernet eth); |
Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 36 | |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame^] | 37 | /** |
| 38 | * Send a packet out multiple ports in the network. |
| 39 | * |
| 40 | * @param switchPorts a list of ports to send the packet out |
| 41 | * @param eth the packet to send |
| 42 | */ |
| 43 | public void sendPacket(List<SwitchPort> switchPorts, Ethernet eth); |
Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 44 | |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame^] | 45 | /** |
| 46 | * Broadcast the packet out all edge ports in the network. An edge port is |
| 47 | * defined as any port that doesn't have a link to another switch. |
| 48 | * |
| 49 | * @param eth the packet to broadcast |
| 50 | */ |
Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 51 | public void broadcastPacket(Ethernet eth); |
| 52 | |
Jonathan Hart | e6e6373 | 2014-04-16 14:29:49 -0700 | [diff] [blame^] | 53 | /** |
| 54 | * Broadcast the packet out all edge ports in the network, except for the |
| 55 | * specified excluded port. An edge port is defined as any port that |
| 56 | * doesn't have a link to another switch. |
| 57 | * <p/> |
| 58 | * This is useful for packets that are received from a host in the |
| 59 | * dataplane, where we want to broadcast the packet to everyone apart from |
| 60 | * the host that sent it. |
| 61 | * |
| 62 | * @param eth the packet to broadcast |
| 63 | * @param inSwitchPort the exception port that the packet is not |
| 64 | * broadcast out |
| 65 | */ |
| 66 | public void broadcastPacket(Ethernet eth, SwitchPort inSwitchPort); |
Jonathan Hart | 1f75cae | 2014-04-09 17:24:09 -0700 | [diff] [blame] | 67 | } |