Fix checkstyle whitespace issues - WHITESPACE ONLY
Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/ArpCache.java b/src/main/java/net/onrc/onos/apps/proxyarp/ArpCache.java
index f2e2891..f8c1589 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/ArpCache.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/ArpCache.java
@@ -43,6 +43,7 @@
/**
* Class constructor, specifying the MAC address for the entry.
+ *
* @param macAddress MAC address for the entry
*/
public ArpCacheEntry(MACAddress macAddress) {
@@ -52,6 +53,7 @@
/**
* Returns the MAC address this entry represents.
+ *
* @return this entry's MAC address
*/
public MACAddress getMacAddress() {
@@ -60,6 +62,7 @@
/**
* Update the timestamp for this entry.
+ *
* @param time the new timestamp to update the entry with
*/
public void setTimeLastSeen(long time) {
@@ -68,6 +71,7 @@
/**
* Returns whether the entry has timed out or not.
+ *
* @return true if the entry has timed out.
*/
public boolean isExpired() {
@@ -84,6 +88,7 @@
/**
* Get the MAC address that is mapped to an IP address in the ARP cache.
+ *
* @param ipAddress the IP address to look up
* @return the MAC address if found in the cache, null if not
*/
@@ -110,7 +115,8 @@
* Update an entry in the ARP cache. If the IP to MAC mapping is already
* in the cache, its timestamp will be updated. If not, the entry will
* be added with a new timestamp of the current time.
- * @param ipAddress the IP address that will be mapped in the cache
+ *
+ * @param ipAddress the IP address that will be mapped in the cache
* @param macAddress the MAC address that maps to {@code ipAddress}
*/
synchronized void update(InetAddress ipAddress, MACAddress macAddress) {
@@ -125,8 +131,8 @@
/**
* Retrieve a list of all mappings in the ARP cache.
- * @return list of all ARP mappings, formatted as a human-readable string
*
+ * @return list of all ARP mappings, formatted as a human-readable string
*/
synchronized List<String> getMappings() {
List<String> result = new ArrayList<String>(arpCache.size());
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/ArpCacheResource.java b/src/main/java/net/onrc/onos/apps/proxyarp/ArpCacheResource.java
index 7bf2a5a..70818c9 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/ArpCacheResource.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/ArpCacheResource.java
@@ -7,12 +7,12 @@
/**
* REST resource to view the IP to MAC mappings in the ARP cache.
- *
*/
public class ArpCacheResource extends ServerResource {
/**
* Handler for a REST call to retrieve the ARP cache.
+ *
* @return list of mappings formatted as a human-readable string.
*/
@Get("json")
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/ArpReplyNotification.java b/src/main/java/net/onrc/onos/apps/proxyarp/ArpReplyNotification.java
index bde2734..9866359 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/ArpReplyNotification.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/ArpReplyNotification.java
@@ -15,20 +15,24 @@
private int targetAddress;
private MACAddress targetMacAddress;
- protected ArpReplyNotification() {}
+ protected ArpReplyNotification() {
+ }
+
/**
* Class constructor.
- * @param targetAddress IP address received from the ARP reply
+ *
+ * @param targetAddress IP address received from the ARP reply
* @param targetMacAddress MAC address received from the ARP reply
*/
public ArpReplyNotification(int targetAddress,
- MACAddress targetMacAddress) {
+ MACAddress targetMacAddress) {
this.targetAddress = targetAddress;
this.targetMacAddress = targetMacAddress;
}
/**
* Returns the IP address of the ARP reply.
+ *
* @return the IP address
*/
public int getTargetAddress() {
@@ -37,6 +41,7 @@
/**
* Returns the MAC address of the ARP reply.
+ *
* @return the MAC address
*/
public MACAddress getTargetMacAddress() {
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/BroadcastPacketOutNotification.java b/src/main/java/net/onrc/onos/apps/proxyarp/BroadcastPacketOutNotification.java
index c2097f2..5f70cf1 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/BroadcastPacketOutNotification.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/BroadcastPacketOutNotification.java
@@ -1,16 +1,15 @@
package net.onrc.onos.apps.proxyarp;
-
// TODO This class is too generic to be handled by ProxyArpService.
// TODO The generic broadcast packet shouldn't contain an IP address which is
// only for ARP packets.
+
/**
* Notification to all ONOS instances to broadcast this packet out the edge of
* the network. The edge is defined as any port that doesn't have a link to
* another switch. The one exception is the port that the packet was received
* on.
- *
*/
public class BroadcastPacketOutNotification extends PacketOutNotification {
@@ -21,32 +20,29 @@
private final short inPort;
protected BroadcastPacketOutNotification() {
- super();
+ super();
this.address = -1;
this.inSwitch = -1;
this.inPort = -1;
}
+
/**
* Class constructor.
*
- * @param packet
- * packet data to send in the packet-out
- * @param address
- * target IP address if the packet is an ARP packet
- * @param inSwitch
- * dpid of the switch the packet was received on
- * @param inPort
- * port number of the receiving port
+ * @param packet packet data to send in the packet-out
+ * @param address target IP address if the packet is an ARP packet
+ * @param inSwitch dpid of the switch the packet was received on
+ * @param inPort port number of the receiving port
*/
public BroadcastPacketOutNotification(byte[] packet, int address,
- long inSwitch, short inPort) {
+ long inSwitch, short inPort) {
super(packet);
this.address = address;
this.inSwitch = inSwitch;
this.inPort = inPort;
}
-
+
/**
* Get the dpid of the switch the packet was received on.
*
@@ -69,7 +65,7 @@
* Get the target IP address if the packet is an ARP packet.
*
* @return the target IP address for ARP packets, or null if the packet is
- * not an ARP packet
+ * not an ARP packet
*/
public int getTargetAddress() {
return address;
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/IArpRequester.java b/src/main/java/net/onrc/onos/apps/proxyarp/IArpRequester.java
index ddc0ab4..ec83b28 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/IArpRequester.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/IArpRequester.java
@@ -7,7 +7,6 @@
/**
* Callback interface for modules using the {@link IProxyArpService} to send ARP
* requests.
- *
*/
public interface IArpRequester {
/**
@@ -15,10 +14,8 @@
* it receives a reply for a request previously submitted by this
* {@code IArpRequester}.
*
- * @param ipAddress
- * The IP address than an ARP request was sent for
- * @param macAddress
- * The MAC address mapped to the requested IP address
+ * @param ipAddress The IP address than an ARP request was sent for
+ * @param macAddress The MAC address mapped to the requested IP address
*/
public void arpResponse(InetAddress ipAddress, MACAddress macAddress);
}
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/IProxyArpService.java b/src/main/java/net/onrc/onos/apps/proxyarp/IProxyArpService.java
index 1cdf18c..7093d3b 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/IProxyArpService.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/IProxyArpService.java
@@ -7,6 +7,7 @@
import net.floodlightcontroller.util.MACAddress;
// Extends IFloodlightService so we can access it from REST API resources
+
/**
* Provides ARP services to other modules.
*/
@@ -17,7 +18,7 @@
*
* @param ipAddress the IP address to request the ARP mapping for
* @return the MACAddress that maps to the specified IP address, or null if
- * no mapping is found
+ * no mapping is found
*/
public MACAddress getMacAddress(InetAddress ipAddress);
@@ -28,10 +29,10 @@
* @param ipAddress the IP address to send an ARP request for
* @param requester the {@link IArpRequester} object that will be called if
* a reply is received
- * @param retry whether to keep sending requests until the MAC is learnt
+ * @param retry whether to keep sending requests until the MAC is learnt
*/
public void sendArpRequest(InetAddress ipAddress, IArpRequester requester,
- boolean retry);
+ boolean retry);
/**
* Returns a snapshot of the entire ARP cache.
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/PacketOutNotification.java b/src/main/java/net/onrc/onos/apps/proxyarp/PacketOutNotification.java
index bd64e59..c0b56a7 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/PacketOutNotification.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/PacketOutNotification.java
@@ -8,20 +8,21 @@
* abstract base class that will be subclassed by specific types of
* notifications.
*/
-public abstract class PacketOutNotification implements Serializable{
+public abstract class PacketOutNotification implements Serializable {
private static final long serialVersionUID = 1L;
protected final byte[] packet;
-
+
/**
* Class constructor.
+ *
* @param packet the packet data to send in the packet-out
*/
public PacketOutNotification() {
- packet = null;
+ packet = null;
}
-
+
public PacketOutNotification(byte[] packet) {
this.packet = packet;
}
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java b/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
index f876310..805e657 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
@@ -55,7 +55,7 @@
import com.google.common.collect.SetMultimap;
public class ProxyArpManager implements IProxyArpService, IOFMessageListener,
- IFloodlightModule {
+ IFloodlightModule {
private static final Logger log = LoggerFactory
.getLogger(ProxyArpManager.class);
@@ -72,16 +72,16 @@
private static final String BROADCAST_PACKET_OUT_CHANNEL_NAME = "onos.broadcast_packet_out";
private static final String SINGLE_PACKET_OUT_CHANNEL_NAME = "onos.single_packet_out";
private ArpReplyEventHandler arpReplyEventHandler = new ArpReplyEventHandler();
- private BroadcastPacketOutEventHandler broadcastPacketOutEventHandler = new BroadcastPacketOutEventHandler();
+ private BroadcastPacketOutEventHandler broadcastPacketOutEventHandler = new BroadcastPacketOutEventHandler();
private SinglePacketOutEventHandler singlePacketOutEventHandler = new SinglePacketOutEventHandler();
private IConfigInfoService configService;
private IRestApiService restApi;
private IFlowPusherService flowPusher;
-
- private INetworkGraphService networkGraphService;
- private NetworkGraph networkGraph;
- private IOnosDeviceService onosDeviceService;
+
+ private INetworkGraphService networkGraphService;
+ private NetworkGraph networkGraph;
+ private IOnosDeviceService onosDeviceService;
private short vlan;
private static final short NO_VLAN = 0;
@@ -89,123 +89,123 @@
private SetMultimap<InetAddress, ArpRequest> arpRequests;
private class BroadcastPacketOutEventHandler implements
- IEventChannelListener<Long, BroadcastPacketOutNotification> {
+ IEventChannelListener<Long, BroadcastPacketOutNotification> {
- @Override
- public void entryAdded(BroadcastPacketOutNotification value) {
- if(log.isTraceEnabled()) {
- log.trace("entryAdded ip{}, sw {}, port {}, packet {}", value.getTargetAddress(), value.getInSwitch(), value.getInPort(), value.packet.length);
- }
- BroadcastPacketOutNotification notification = (BroadcastPacketOutNotification) value;
- broadcastArpRequestOutMyEdge(notification.packet,
- notification.getInSwitch(),
- notification.getInPort());
-
- // set timestamp
- ByteBuffer buffer = ByteBuffer.allocate(4);
- buffer.putInt(notification.getTargetAddress());
- InetAddress addr = null;
- try {
- addr = InetAddress.getByAddress(buffer.array());
- } catch (UnknownHostException e) {
- log.error("Exception:", e);
- }
-
- if (addr != null) {
- for (ArpRequest request : arpRequests.get(addr)) {
- request.setRequestTime();
- }
- }
- }
-
- @Override
- public void entryUpdated(BroadcastPacketOutNotification value) {
- log.debug("entryUpdated");
- // TODO: For now, entryUpdated() is processed as entryAdded()
- entryAdded(value);
- }
-
- @Override
- public void entryRemoved(BroadcastPacketOutNotification value) {
- log.debug("entryRemoved");
- // TODO: Not implemented. Revisit when this module is refactored
- }
+ @Override
+ public void entryAdded(BroadcastPacketOutNotification value) {
+ if (log.isTraceEnabled()) {
+ log.trace("entryAdded ip{}, sw {}, port {}, packet {}", value.getTargetAddress(), value.getInSwitch(), value.getInPort(), value.packet.length);
+ }
+ BroadcastPacketOutNotification notification = (BroadcastPacketOutNotification) value;
+ broadcastArpRequestOutMyEdge(notification.packet,
+ notification.getInSwitch(),
+ notification.getInPort());
+
+ // set timestamp
+ ByteBuffer buffer = ByteBuffer.allocate(4);
+ buffer.putInt(notification.getTargetAddress());
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getByAddress(buffer.array());
+ } catch (UnknownHostException e) {
+ log.error("Exception:", e);
+ }
+
+ if (addr != null) {
+ for (ArpRequest request : arpRequests.get(addr)) {
+ request.setRequestTime();
+ }
+ }
+ }
+
+ @Override
+ public void entryUpdated(BroadcastPacketOutNotification value) {
+ log.debug("entryUpdated");
+ // TODO: For now, entryUpdated() is processed as entryAdded()
+ entryAdded(value);
+ }
+
+ @Override
+ public void entryRemoved(BroadcastPacketOutNotification value) {
+ log.debug("entryRemoved");
+ // TODO: Not implemented. Revisit when this module is refactored
+ }
}
-
+
private class SinglePacketOutEventHandler implements
- IEventChannelListener<Long, SinglePacketOutNotification> {
- @Override
- public void entryAdded(SinglePacketOutNotification packetOutNotification) {
- log.debug("entryAdded");
- SinglePacketOutNotification notification =
- (SinglePacketOutNotification) packetOutNotification;
- sendArpRequestOutPort(notification.packet,
- notification.getOutSwitch(),
- notification.getOutPort());
-
- // set timestamp
- ByteBuffer buffer = ByteBuffer.allocate(4);
- buffer.putInt(notification.getTargetAddress());
- InetAddress addr = null;
- try {
- addr = InetAddress.getByAddress(buffer.array());
- } catch (UnknownHostException e) {
- log.error("Exception:", e);
- }
-
- if (addr != null) {
- for (ArpRequest request : arpRequests.get(addr)) {
- request.setRequestTime();
- }
- }
- }
-
- @Override
- public void entryUpdated(SinglePacketOutNotification packetOutNotification) {
- log.debug("entryUpdated");
- // TODO: For now, entryUpdated() is processed as entryAdded()
- entryAdded(packetOutNotification);
- }
-
- @Override
- public void entryRemoved(SinglePacketOutNotification packetOutNotification) {
- log.debug("entryRemoved");
- // TODO: Not implemented. Revisit when this module is refactored
- }
+ IEventChannelListener<Long, SinglePacketOutNotification> {
+ @Override
+ public void entryAdded(SinglePacketOutNotification packetOutNotification) {
+ log.debug("entryAdded");
+ SinglePacketOutNotification notification =
+ (SinglePacketOutNotification) packetOutNotification;
+ sendArpRequestOutPort(notification.packet,
+ notification.getOutSwitch(),
+ notification.getOutPort());
+
+ // set timestamp
+ ByteBuffer buffer = ByteBuffer.allocate(4);
+ buffer.putInt(notification.getTargetAddress());
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getByAddress(buffer.array());
+ } catch (UnknownHostException e) {
+ log.error("Exception:", e);
+ }
+
+ if (addr != null) {
+ for (ArpRequest request : arpRequests.get(addr)) {
+ request.setRequestTime();
+ }
+ }
+ }
+
+ @Override
+ public void entryUpdated(SinglePacketOutNotification packetOutNotification) {
+ log.debug("entryUpdated");
+ // TODO: For now, entryUpdated() is processed as entryAdded()
+ entryAdded(packetOutNotification);
+ }
+
+ @Override
+ public void entryRemoved(SinglePacketOutNotification packetOutNotification) {
+ log.debug("entryRemoved");
+ // TODO: Not implemented. Revisit when this module is refactored
+ }
}
private class ArpReplyEventHandler implements
- IEventChannelListener<Long, ArpReplyNotification> {
-
- @Override
- public void entryAdded(ArpReplyNotification arpReply) {
- log.debug("Received ARP reply notification for ip {}, mac {}",
- arpReply.getTargetAddress(), arpReply.getTargetMacAddress());
- ByteBuffer buffer = ByteBuffer.allocate(4);
- buffer.putInt(arpReply.getTargetAddress());
- InetAddress addr = null;
- try {
- addr = InetAddress.getByAddress(buffer.array());
- } catch (UnknownHostException e) {
- log.error("Exception:", e);
- }
-
- if(addr != null) {
- sendArpReplyToWaitingRequesters(addr,
- arpReply.getTargetMacAddress());
- }
- }
+ IEventChannelListener<Long, ArpReplyNotification> {
- @Override
- public void entryUpdated(ArpReplyNotification arpReply) {
- // TODO: For now, entryUpdated() is processed as entryAdded()
- entryAdded(arpReply);
- }
+ @Override
+ public void entryAdded(ArpReplyNotification arpReply) {
+ log.debug("Received ARP reply notification for ip {}, mac {}",
+ arpReply.getTargetAddress(), arpReply.getTargetMacAddress());
+ ByteBuffer buffer = ByteBuffer.allocate(4);
+ buffer.putInt(arpReply.getTargetAddress());
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getByAddress(buffer.array());
+ } catch (UnknownHostException e) {
+ log.error("Exception:", e);
+ }
- @Override
- public void entryRemoved(ArpReplyNotification arpReply) {
- // TODO: Not implemented. Revisit when this module is refactored
- }
+ if (addr != null) {
+ sendArpReplyToWaitingRequesters(addr,
+ arpReply.getTargetMacAddress());
+ }
+ }
+
+ @Override
+ public void entryUpdated(ArpReplyNotification arpReply) {
+ // TODO: For now, entryUpdated() is processed as entryAdded()
+ entryAdded(arpReply);
+ }
+
+ @Override
+ public void entryRemoved(ArpReplyNotification arpReply) {
+ // TODO: Not implemented. Revisit when this module is refactored
+ }
}
private static class ArpRequest {
@@ -234,7 +234,7 @@
}
public void dispatchReply(InetAddress ipAddress,
- MACAddress replyMacAddress) {
+ MACAddress replyMacAddress) {
requester.arpResponse(ipAddress, replyMacAddress);
}
@@ -260,10 +260,10 @@
ProxyArpManager.this.sendArpReply(arpRequest, dpid, port,
macAddress);
}
-
- public ARP getArpRequest() {
- return arpRequest;
- }
+
+ public ARP getArpRequest() {
+ return arpRequest;
+ }
}
@Override
@@ -298,7 +298,7 @@
@Override
public void init(FloodlightModuleContext context) {
- this.floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
+ this.floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
this.configService = context.getServiceImpl(IConfigInfoService.class);
this.restApi = context.getServiceImpl(IRestApiService.class);
this.datagrid = context.getServiceImpl(IDatagridService.class);
@@ -320,25 +320,25 @@
restApi.addRestletRoutable(new ArpWebRoutable());
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
- networkGraph = networkGraphService.getNetworkGraph();
-
- //
- // Event notification setup: channels and event handlers
- //
- broadcastPacketOutEventChannel = datagrid.addListener(BROADCAST_PACKET_OUT_CHANNEL_NAME,
- broadcastPacketOutEventHandler,
- Long.class,
- BroadcastPacketOutNotification.class);
-
- singlePacketOutEventChannel = datagrid.addListener(SINGLE_PACKET_OUT_CHANNEL_NAME,
- singlePacketOutEventHandler,
- Long.class,
- SinglePacketOutNotification.class);
-
- arpReplyEventChannel = datagrid.addListener(ARP_REPLY_CHANNEL_NAME,
- arpReplyEventHandler,
- Long.class,
- ArpReplyNotification.class);
+ networkGraph = networkGraphService.getNetworkGraph();
+
+ //
+ // Event notification setup: channels and event handlers
+ //
+ broadcastPacketOutEventChannel = datagrid.addListener(BROADCAST_PACKET_OUT_CHANNEL_NAME,
+ broadcastPacketOutEventHandler,
+ Long.class,
+ BroadcastPacketOutNotification.class);
+
+ singlePacketOutEventChannel = datagrid.addListener(SINGLE_PACKET_OUT_CHANNEL_NAME,
+ singlePacketOutEventHandler,
+ Long.class,
+ SinglePacketOutNotification.class);
+
+ arpReplyEventChannel = datagrid.addListener(ARP_REPLY_CHANNEL_NAME,
+ arpReplyEventHandler,
+ Long.class,
+ ArpReplyNotification.class);
Timer arpTimer = new Timer("arp-processing");
arpTimer.scheduleAtFixedRate(new TimerTask() {
@@ -373,17 +373,17 @@
log.debug("Cleaning expired ARP request for {}", entry
.getKey().getHostAddress());
- // If the ARP request is expired and then delete the device
- // TODO check whether this is OK from this thread
- HostArpRequester requester = (HostArpRequester) request.requester;
- ARP req = requester.getArpRequest();
- Device targetDev = networkGraph.getDeviceByMac(MACAddress.valueOf(req.getTargetHardwareAddress()));
- if(targetDev != null) {
- onosDeviceService.deleteOnosDeviceByMac(MACAddress.valueOf(req.getTargetHardwareAddress()));
- if (log.isDebugEnabled()) {
- log.debug("RemoveDevice: {} due to no have not recieve the ARP reply", targetDev.getMacAddress());
- }
- }
+ // If the ARP request is expired and then delete the device
+ // TODO check whether this is OK from this thread
+ HostArpRequester requester = (HostArpRequester) request.requester;
+ ARP req = requester.getArpRequest();
+ Device targetDev = networkGraph.getDeviceByMac(MACAddress.valueOf(req.getTargetHardwareAddress()));
+ if (targetDev != null) {
+ onosDeviceService.deleteOnosDeviceByMac(MACAddress.valueOf(req.getTargetHardwareAddress()));
+ if (log.isDebugEnabled()) {
+ log.debug("RemoveDevice: {} due to no have not recieve the ARP reply", targetDev.getMacAddress());
+ }
+ }
it.remove();
@@ -460,7 +460,7 @@
}
private void handleArpRequest(IOFSwitch sw, OFPacketIn pi, ARP arp,
- Ethernet eth) {
+ Ethernet eth) {
if (log.isTraceEnabled()) {
log.trace("ARP request received for {}",
inetAddressToString(arp.getTargetProtocolAddress()));
@@ -492,86 +492,84 @@
// MACAddress macAddress = arpCache.lookup(target);
- arpRequests.put(target, new ArpRequest(
- new HostArpRequester(arp, sw.getId(), pi.getInPort()), false));
-
- Device targetDevice = networkGraph.getDeviceByMac(MACAddress.valueOf(arp.getTargetHardwareAddress()));
+ arpRequests.put(target, new ArpRequest(
+ new HostArpRequester(arp, sw.getId(), pi.getInPort()), false));
- if (targetDevice == null) {
- if (log.isTraceEnabled()) {
- log.trace("No device info found for {} - broadcasting",
- target.getHostAddress());
- }
-
- // We don't know the device so broadcast the request out
- BroadcastPacketOutNotification key =
- new BroadcastPacketOutNotification(eth.serialize(),
- ByteBuffer.wrap(arp.getTargetProtocolAddress()).getInt(), sw.getId(), pi.getInPort());
- log.debug("broadcastPacketOutEventChannel mac {}, ip {}, dpid {}, port {}, paket {}", eth.getSourceMAC().toLong(),
- ByteBuffer.wrap(arp.getTargetProtocolAddress()).getInt(), sw.getId(), pi.getInPort(), eth.serialize().length);
- broadcastPacketOutEventChannel.addTransientEntry(eth.getDestinationMAC().toLong(), key);
- }
- else {
- // Even if the device exists in our database, we do not reply to
- // the request directly, but check whether the device is still valid
- MACAddress macAddress = MACAddress.valueOf(arp.getTargetHardwareAddress());
+ Device targetDevice = networkGraph.getDeviceByMac(MACAddress.valueOf(arp.getTargetHardwareAddress()));
- if (log.isTraceEnabled()) {
- log.trace("The target Device Record in DB is: {} => {} from ARP request host at {}/{}",
- new Object [] {
- inetAddressToString(arp.getTargetProtocolAddress()),
- macAddress,
- HexString.toHexString(sw.getId()), pi.getInPort()});
- }
+ if (targetDevice == null) {
+ if (log.isTraceEnabled()) {
+ log.trace("No device info found for {} - broadcasting",
+ target.getHostAddress());
+ }
- // sendArpReply(arp, sw.getId(), pi.getInPort(), macAddress);
+ // We don't know the device so broadcast the request out
+ BroadcastPacketOutNotification key =
+ new BroadcastPacketOutNotification(eth.serialize(),
+ ByteBuffer.wrap(arp.getTargetProtocolAddress()).getInt(), sw.getId(), pi.getInPort());
+ log.debug("broadcastPacketOutEventChannel mac {}, ip {}, dpid {}, port {}, paket {}", eth.getSourceMAC().toLong(),
+ ByteBuffer.wrap(arp.getTargetProtocolAddress()).getInt(), sw.getId(), pi.getInPort(), eth.serialize().length);
+ broadcastPacketOutEventChannel.addTransientEntry(eth.getDestinationMAC().toLong(), key);
+ } else {
+ // Even if the device exists in our database, we do not reply to
+ // the request directly, but check whether the device is still valid
+ MACAddress macAddress = MACAddress.valueOf(arp.getTargetHardwareAddress());
- Iterable<net.onrc.onos.core.topology.Port> outPorts = targetDevice.getAttachmentPoints();
+ if (log.isTraceEnabled()) {
+ log.trace("The target Device Record in DB is: {} => {} from ARP request host at {}/{}",
+ new Object[]{
+ inetAddressToString(arp.getTargetProtocolAddress()),
+ macAddress,
+ HexString.toHexString(sw.getId()), pi.getInPort()});
+ }
- if (!outPorts.iterator().hasNext()){
- if (log.isTraceEnabled()) {
- log.trace("Device {} exists but is not connected to any ports" +
- " - broadcasting", macAddress);
- }
-
-// BroadcastPacketOutNotification key =
-// new BroadcastPacketOutNotification(eth.serialize(),
-// target, sw.getId(), pi.getInPort());
-// broadcastPacketOutEventChannel.addTransientEntry(eth.getDestinationMAC().toLong(), key);
- }
- else {
- for (net.onrc.onos.core.topology.Port portObject : outPorts) {
- //long outSwitch = 0;
- //short outPort = 0;
+ // sendArpReply(arp, sw.getId(), pi.getInPort(), macAddress);
- if(portObject.getOutgoingLink() != null || portObject.getIncomingLink() != null) {
- continue;
- }
-
- short outPort = portObject.getNumber().shortValue();
- Switch outSwitchObject = portObject.getSwitch();
- long outSwitch = outSwitchObject.getDpid();
-
- if (log.isTraceEnabled()) {
- log.trace("Probing device {} on port {}/{}",
- new Object[] {macAddress,
- HexString.toHexString(outSwitch), outPort});
- }
-
- SinglePacketOutNotification key =
- new SinglePacketOutNotification(eth.serialize(),
- ByteBuffer.wrap(target.getAddress()).getInt(), outSwitch, outPort);
- singlePacketOutEventChannel.addTransientEntry(eth.getDestinationMAC().toLong(), key);
- }
- }
- }
+ Iterable<net.onrc.onos.core.topology.Port> outPorts = targetDevice.getAttachmentPoints();
+
+ if (!outPorts.iterator().hasNext()) {
+ if (log.isTraceEnabled()) {
+ log.trace("Device {} exists but is not connected to any ports" +
+ " - broadcasting", macAddress);
+ }
+
+// BroadcastPacketOutNotification key =
+// new BroadcastPacketOutNotification(eth.serialize(),
+// target, sw.getId(), pi.getInPort());
+// broadcastPacketOutEventChannel.addTransientEntry(eth.getDestinationMAC().toLong(), key);
+ } else {
+ for (net.onrc.onos.core.topology.Port portObject : outPorts) {
+ //long outSwitch = 0;
+ //short outPort = 0;
+
+ if (portObject.getOutgoingLink() != null || portObject.getIncomingLink() != null) {
+ continue;
+ }
+
+ short outPort = portObject.getNumber().shortValue();
+ Switch outSwitchObject = portObject.getSwitch();
+ long outSwitch = outSwitchObject.getDpid();
+
+ if (log.isTraceEnabled()) {
+ log.trace("Probing device {} on port {}/{}",
+ new Object[]{macAddress,
+ HexString.toHexString(outSwitch), outPort});
+ }
+
+ SinglePacketOutNotification key =
+ new SinglePacketOutNotification(eth.serialize(),
+ ByteBuffer.wrap(target.getAddress()).getInt(), outSwitch, outPort);
+ singlePacketOutEventChannel.addTransientEntry(eth.getDestinationMAC().toLong(), key);
+ }
+ }
+ }
}
// Not used because device manager currently updates the database
// for ARP replies. May be useful in the future.
private void handleArpReply(IOFSwitch sw, OFPacketIn pi, ARP arp) {
if (log.isTraceEnabled()) {
- log.trace("ARP reply recieved: {} => {}, on {}/{}", new Object[] {
+ log.trace("ARP reply recieved: {} => {}, on {}/{}", new Object[]{
inetAddressToString(arp.getSenderProtocolAddress()),
HexString.toHexString(arp.getSenderHardwareAddress()),
HexString.toHexString(sw.getId()), pi.getInPort()});
@@ -660,19 +658,19 @@
}
// sendArpRequestToSwitches(ipAddress, eth.serialize());
- SinglePacketOutNotification key =
- new SinglePacketOutNotification(eth.serialize(), ByteBuffer.wrap(ipAddress.getAddress()).getInt(),
- intf.getDpid(), intf.getPort());
- singlePacketOutEventChannel.addTransientEntry(MACAddress.valueOf(senderMacAddress).toLong(), key);
+ SinglePacketOutNotification key =
+ new SinglePacketOutNotification(eth.serialize(), ByteBuffer.wrap(ipAddress.getAddress()).getInt(),
+ intf.getDpid(), intf.getPort());
+ singlePacketOutEventChannel.addTransientEntry(MACAddress.valueOf(senderMacAddress).toLong(), key);
}
-
+
private void sendArpRequestToSwitches(InetAddress dstAddress, byte[] arpRequest) {
- sendArpRequestToSwitches(dstAddress, arpRequest, 0,
- OFPort.OFPP_NONE.getValue());
+ sendArpRequestToSwitches(dstAddress, arpRequest, 0,
+ OFPort.OFPP_NONE.getValue());
}
private void sendArpRequestToSwitches(InetAddress dstAddress,
- byte[] arpRequest, long inSwitch, short inPort) {
+ byte[] arpRequest, long inSwitch, short inPort) {
if (configService.hasLayer3Configuration()) {
Interface intf = configService.getOutgoingInterface(dstAddress);
@@ -718,14 +716,14 @@
MACAddress mac = new MACAddress(arp.getSenderHardwareAddress());
- ArpReplyNotification key =
- new ArpReplyNotification(ByteBuffer.wrap(targetAddress.getAddress()).getInt(), mac);
- log.debug("ArpReplyNotification ip {}, mac{}", ByteBuffer.wrap(targetAddress.getAddress()).getInt(), mac);
- arpReplyEventChannel.addTransientEntry(mac.toLong(), key);
+ ArpReplyNotification key =
+ new ArpReplyNotification(ByteBuffer.wrap(targetAddress.getAddress()).getInt(), mac);
+ log.debug("ArpReplyNotification ip {}, mac{}", ByteBuffer.wrap(targetAddress.getAddress()).getInt(), mac);
+ arpReplyEventChannel.addTransientEntry(mac.toLong(), key);
}
private void broadcastArpRequestOutMyEdge(byte[] arpRequest, long inSwitch,
- short inPort) {
+ short inPort) {
List<SwitchPort> switchPorts = new ArrayList<SwitchPort>();
for (IOFSwitch sw : floodlightProvider.getSwitches().values()) {
@@ -736,27 +734,27 @@
List<OFAction> actions = new ArrayList<OFAction>();
- Switch graphSw = networkGraph.getSwitch(sw.getId());
- Collection<net.onrc.onos.core.topology.Port> ports = graphSw.getPorts();
-
- if (ports == null) {
- continue;
- }
-
- for (net.onrc.onos.core.topology.Port portObject : ports) {
- if (portObject.getOutgoingLink() == null && portObject.getNumber() > 0) {
- Long portNumber = portObject.getNumber();
-
- if (sw.getId() == inSwitch && portNumber.shortValue() == inPort) {
- // This is the port that the ARP message came in,
- // so don't broadcast out this port
- continue;
- }
- switchPorts.add(new SwitchPort(new Dpid(sw.getId()),
- new net.onrc.onos.core.util.Port(portNumber.shortValue())));
- actions.add(new OFActionOutput(portNumber.shortValue()));
- }
- }
+ Switch graphSw = networkGraph.getSwitch(sw.getId());
+ Collection<net.onrc.onos.core.topology.Port> ports = graphSw.getPorts();
+
+ if (ports == null) {
+ continue;
+ }
+
+ for (net.onrc.onos.core.topology.Port portObject : ports) {
+ if (portObject.getOutgoingLink() == null && portObject.getNumber() > 0) {
+ Long portNumber = portObject.getNumber();
+
+ if (sw.getId() == inSwitch && portNumber.shortValue() == inPort) {
+ // This is the port that the ARP message came in,
+ // so don't broadcast out this port
+ continue;
+ }
+ switchPorts.add(new SwitchPort(new Dpid(sw.getId()),
+ new net.onrc.onos.core.util.Port(portNumber.shortValue())));
+ actions.add(new OFActionOutput(portNumber.shortValue()));
+ }
+ }
po.setActions(actions);
short actionsLength = (short) (actions.size() * OFActionOutput.MINIMUM_LENGTH);
@@ -801,11 +799,11 @@
}
private void sendArpReply(ARP arpRequest, long dpid, short port,
- MACAddress targetMac) {
+ MACAddress targetMac) {
if (log.isTraceEnabled()) {
log.trace(
"Sending reply {} => {} to {}",
- new Object[] {
+ new Object[]{
inetAddressToString(arpRequest
.getTargetProtocolAddress()),
targetMac,
@@ -883,7 +881,7 @@
@Override
public void sendArpRequest(InetAddress ipAddress, IArpRequester requester,
- boolean retry) {
+ boolean retry) {
arpRequests.put(ipAddress, new ArpRequest(requester, retry));
// Sanity check to make sure we don't send a request for our own address
@@ -898,7 +896,7 @@
}
private void sendArpReplyToWaitingRequesters(InetAddress address,
- MACAddress mac) {
+ MACAddress mac) {
log.debug("Sending ARP reply for {} to requesters",
address.getHostAddress());
@@ -920,16 +918,16 @@
//TODO here, comment outed from long time ago. I will check if we need it later.
/*IDeviceObject deviceObject = deviceStorage.getDeviceByIP(
- InetAddresses.coerceToInteger(address));
+ InetAddresses.coerceToInteger(address));
MACAddress mac = MACAddress.valueOf(deviceObject.getMACAddress());
log.debug("Found {} at {} in network map",
- address.getHostAddress(), mac);*/
+ address.getHostAddress(), mac);*/
// Don't hold an ARP lock while dispatching requests
for (ArpRequest request : requestsToSend) {
request.dispatchReply(address, mac);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/SinglePacketOutNotification.java b/src/main/java/net/onrc/onos/apps/proxyarp/SinglePacketOutNotification.java
index 8ee255b..ff5ab87 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/SinglePacketOutNotification.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/SinglePacketOutNotification.java
@@ -1,8 +1,8 @@
package net.onrc.onos.apps.proxyarp;
-
// TODO This class is too generic to be handled by ProxyArpService.
+
/**
* Notification to another ONOS instance to send a packet out a single port.
*/
@@ -16,13 +16,14 @@
/**
* Class constructor.
- * @param packet the packet data to send in the packet-out
- * @param address target IP address if the packet is an ARP packet
+ *
+ * @param packet the packet data to send in the packet-out
+ * @param address target IP address if the packet is an ARP packet
* @param outSwitch the dpid of the switch to send the packet on
- * @param outPort the port number of the port to send the packet out
+ * @param outPort the port number of the port to send the packet out
*/
public SinglePacketOutNotification(byte[] packet, int address,
- long outSwitch, short outPort) {
+ long outSwitch, short outPort) {
super(packet);
this.address = address;
@@ -32,6 +33,7 @@
/**
* Get the dpid of the switch the packet will be sent out.
+ *
* @return the switch's dpid
*/
public long getOutSwitch() {
@@ -40,6 +42,7 @@
/**
* Get the port number of the port the packet will be sent out.
+ *
* @return the port number
*/
public short getOutPort() {
@@ -48,8 +51,9 @@
/**
* Get the target IP address if the packet is an ARP packet.
+ *
* @return the target IP address for ARP packets, or null if the packet is
- * not an ARP packet
+ * not an ARP packet
*/
public int getTargetAddress() {
return address;