Jonathan Hart | 0961fe8 | 2014-04-03 09:56:25 -0700 | [diff] [blame] | 1 | package net.onrc.onos.apps.proxyarp; |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 2 | |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 3 | |
Naoki Shiota | 78e403c | 2014-02-20 17:13:36 -0800 | [diff] [blame] | 4 | |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 5 | // TODO This class is too generic to be handled by ProxyArpService. |
| 6 | // TODO The generic broadcast packet shouldn't contain an IP address which is |
| 7 | // only for ARP packets. |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 8 | /** |
| 9 | * Notification to all ONOS instances to broadcast this packet out the edge of |
| 10 | * the network. The edge is defined as any port that doesn't have a link to |
| 11 | * another switch. The one exception is the port that the packet was received |
| 12 | * on. |
| 13 | * |
| 14 | */ |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 15 | public class BroadcastPacketOutNotification extends PacketOutNotification { |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 16 | |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 17 | private static final long serialVersionUID = 1L; |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 18 | |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 19 | private final int address; |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 20 | private final long inSwitch; |
| 21 | private final short inPort; |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 22 | |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 23 | protected BroadcastPacketOutNotification() { |
| 24 | super(); |
| 25 | this.address = -1; |
| 26 | this.inSwitch = -1; |
| 27 | this.inPort = -1; |
| 28 | } |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Class constructor. |
| 31 | * |
| 32 | * @param packet |
| 33 | * packet data to send in the packet-out |
| 34 | * @param address |
| 35 | * target IP address if the packet is an ARP packet |
| 36 | * @param inSwitch |
| 37 | * dpid of the switch the packet was received on |
| 38 | * @param inPort |
| 39 | * port number of the receiving port |
| 40 | */ |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 41 | public BroadcastPacketOutNotification(byte[] packet, int address, |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 42 | long inSwitch, short inPort) { |
| 43 | super(packet); |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 44 | |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 45 | this.address = address; |
| 46 | this.inSwitch = inSwitch; |
| 47 | this.inPort = inPort; |
| 48 | } |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 49 | |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 50 | /** |
| 51 | * Get the dpid of the switch the packet was received on. |
| 52 | * |
| 53 | * @return receiving switch dpid |
| 54 | */ |
| 55 | public long getInSwitch() { |
| 56 | return inSwitch; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get the port number of the port the packet was received on. |
| 61 | * |
| 62 | * @return receiving port number |
| 63 | */ |
| 64 | public short getInPort() { |
| 65 | return inPort; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get the target IP address if the packet is an ARP packet. |
| 70 | * |
| 71 | * @return the target IP address for ARP packets, or null if the packet is |
| 72 | * not an ARP packet |
| 73 | */ |
TeruU | 7feef8a | 2014-04-03 00:15:49 -0700 | [diff] [blame] | 74 | public int getTargetAddress() { |
Jonathan Hart | 7c9a2fb | 2014-03-27 09:51:41 -0700 | [diff] [blame] | 75 | return address; |
| 76 | } |
Jonathan Hart | 7804bea | 2014-01-07 10:50:52 -0800 | [diff] [blame] | 77 | } |