blob: c2097f22006bb2504bc51cf5fd7c405b77af8ab2 [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
Naoki Shiota78e403c2014-02-20 17:13:36 -08004
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -07005// 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 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.
13 *
14 */
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070015public class BroadcastPacketOutNotification extends PacketOutNotification {
Jonathan Hart7804bea2014-01-07 10:50:52 -080016
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070017 private static final long serialVersionUID = 1L;
Jonathan Hart7804bea2014-01-07 10:50:52 -080018
TeruU7feef8a2014-04-03 00:15:49 -070019 private final int address;
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070020 private final long inSwitch;
21 private final short inPort;
Jonathan Hart7804bea2014-01-07 10:50:52 -080022
TeruU7feef8a2014-04-03 00:15:49 -070023 protected BroadcastPacketOutNotification() {
24 super();
25 this.address = -1;
26 this.inSwitch = -1;
27 this.inPort = -1;
28 }
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070029 /**
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 */
TeruU7feef8a2014-04-03 00:15:49 -070041 public BroadcastPacketOutNotification(byte[] packet, int address,
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070042 long inSwitch, short inPort) {
43 super(packet);
Jonathan Hart7804bea2014-01-07 10:50:52 -080044
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070045 this.address = address;
46 this.inSwitch = inSwitch;
47 this.inPort = inPort;
48 }
TeruU7feef8a2014-04-03 00:15:49 -070049
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070050 /**
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 */
TeruU7feef8a2014-04-03 00:15:49 -070074 public int getTargetAddress() {
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070075 return address;
76 }
Jonathan Hart7804bea2014-01-07 10:50:52 -080077}