blob: 5f70cf1e815cda124ea1fe0a8a7bc66f6512d5d2 [file] [log] [blame]
Jonathan Hart0961fe82014-04-03 09:56:25 -07001package net.onrc.onos.apps.proxyarp;
Jonathan Hart7804bea2014-01-07 10:50:52 -08002
TeruU7feef8a2014-04-03 00:15:49 -07003
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -07004// TODO This class is too generic to be handled by ProxyArpService.
5// TODO The generic broadcast packet shouldn't contain an IP address which is
6// only for ARP packets.
Ray Milkey269ffb92014-04-03 14:43:30 -07007
Jonathan Hart7804bea2014-01-07 10:50:52 -08008/**
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.
Jonathan Hart7804bea2014-01-07 10:50:52 -080013 */
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070014public class BroadcastPacketOutNotification extends PacketOutNotification {
Jonathan Hart7804bea2014-01-07 10:50:52 -080015
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070016 private static final long serialVersionUID = 1L;
Jonathan Hart7804bea2014-01-07 10:50:52 -080017
TeruU7feef8a2014-04-03 00:15:49 -070018 private final int address;
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070019 private final long inSwitch;
20 private final short inPort;
Jonathan Hart7804bea2014-01-07 10:50:52 -080021
TeruU7feef8a2014-04-03 00:15:49 -070022 protected BroadcastPacketOutNotification() {
Ray Milkey269ffb92014-04-03 14:43:30 -070023 super();
TeruU7feef8a2014-04-03 00:15:49 -070024 this.address = -1;
25 this.inSwitch = -1;
26 this.inPort = -1;
27 }
Ray Milkey269ffb92014-04-03 14:43:30 -070028
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070029 /**
30 * Class constructor.
31 *
Ray Milkey269ffb92014-04-03 14:43:30 -070032 * @param packet packet data to send in the packet-out
33 * @param address target IP address if the packet is an ARP packet
34 * @param inSwitch dpid of the switch the packet was received on
35 * @param inPort port number of the receiving port
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070036 */
TeruU7feef8a2014-04-03 00:15:49 -070037 public BroadcastPacketOutNotification(byte[] packet, int address,
Ray Milkey269ffb92014-04-03 14:43:30 -070038 long inSwitch, short inPort) {
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070039 super(packet);
Jonathan Hart7804bea2014-01-07 10:50:52 -080040
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070041 this.address = address;
42 this.inSwitch = inSwitch;
43 this.inPort = inPort;
44 }
Ray Milkey269ffb92014-04-03 14:43:30 -070045
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070046 /**
47 * Get the dpid of the switch the packet was received on.
48 *
49 * @return receiving switch dpid
50 */
51 public long getInSwitch() {
52 return inSwitch;
53 }
54
55 /**
56 * Get the port number of the port the packet was received on.
57 *
58 * @return receiving port number
59 */
60 public short getInPort() {
61 return inPort;
62 }
63
64 /**
65 * Get the target IP address if the packet is an ARP packet.
66 *
67 * @return the target IP address for ARP packets, or null if the packet is
Ray Milkey269ffb92014-04-03 14:43:30 -070068 * not an ARP packet
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070069 */
TeruU7feef8a2014-04-03 00:15:49 -070070 public int getTargetAddress() {
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070071 return address;
72 }
Jonathan Hart7804bea2014-01-07 10:50:52 -080073}