code adjustment according to reviewer's suggestion: MAC final type, indentation, exception handler
diff --git a/pingping.r b/pingping.r
deleted file mode 100644
index e69de29..0000000
--- a/pingping.r
+++ /dev/null
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
index da19ba1..49ffd4e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjects.java
@@ -1,7 +1,6 @@
package net.onrc.onos.ofcontroller.core;
import net.onrc.onos.ofcontroller.flowmanager.web.DatapathSummarySerializer;
-import net.onrc.onos.ofcontroller.util.SwitchPort;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ArpMessage.java b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ArpMessage.java
index dd159fe..6ce5ade 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ArpMessage.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ArpMessage.java
@@ -20,10 +20,10 @@
private final byte[] packetData;
//ARP reply message needs MAC info
- private MACAddress mac;
- //only send the ARP request message to the device attachment needs the attachement swith and port.
- private long outSwitch=-1;
- private short outPort=-1;
+ private final MACAddress mac;
+ //only send the ARP request message to the device attachment needs the attachment switch and port.
+ private final long outSwitch;
+ private final short outPort;
private final List<SwitchPort> switchPorts = new ArrayList<SwitchPort>();
@@ -38,19 +38,28 @@
this.type = type;
this.forAddress = address;
this.packetData = eth;
+ this.mac = null;
+ this.outSwitch = -1;
+ this.outPort = -1;
}
private ArpMessage(Type type, InetAddress address) {
this.type = type;
this.forAddress = address;
this.packetData = null;
+ this.mac = null;
+ this.outSwitch = -1;
+ this.outPort = -1;
+
}
// the ARP reply message with MAC
private ArpMessage(Type type, InetAddress address, MACAddress mac) {
this.type = type;
this.forAddress = address;
this.packetData = null;
- this.mac=mac;
+ this.mac = mac;
+ this.outSwitch = -1;
+ this.outPort = -1;
}
// construct ARP request message with attachment switch and port
@@ -58,9 +67,10 @@
long outSwitch, short outPort) {
this.type = type;
this.forAddress = address;
- this.packetData = arpRequest;
- this.setOutSwitch(outSwitch);
- this.setOutPort(outPort);
+ this.packetData = arpRequest;
+ this.mac = null;
+ this.outSwitch = outSwitch;
+ this.outPort = outPort;
}
public static ArpMessage newRequest(InetAddress forAddress, byte[] arpRequest) {
@@ -73,12 +83,12 @@
//ARP reply message with MAC
public static ArpMessage newReply(InetAddress forAddress, MACAddress mac) {
return new ArpMessage(Type.REPLY, forAddress, mac);
-
+
}
//ARP reqsuest message with attachment switch and port
public static ArpMessage newRequest(InetAddress forAddress, byte[] arpRequest, long outSwitch, short outPort ) {
return new ArpMessage(Type.REQUEST, forAddress, arpRequest, outSwitch, outPort);
-
+
}
public Type getType() {
@@ -100,15 +110,8 @@
return outSwitch;
}
- public void setOutSwitch(long outSwitch) {
- this.outSwitch = outSwitch;
- }
-
public short getOutPort() {
return outPort;
}
- public void setOutPort(short outPort) {
- this.outPort = outPort;
- }
}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
index a0aaf2a..b2b3c48 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/proxyarp/ProxyArpManager.java
@@ -314,7 +314,7 @@
InetAddress target;
try {
- target = InetAddress.getByAddress(arp.getTargetProtocolAddress());
+ target = InetAddress.getByAddress(arp.getTargetProtocolAddress());
} catch (UnknownHostException e) {
log.debug("Invalid address in ARP request", e);
return;
@@ -326,11 +326,11 @@
if (configService.isInterfaceAddress(target)) {
log.trace("ARP request for our interface. Sending reply {} => {}",
target.getHostAddress(), configService.getRouterMacAddress());
-
+
sendArpReply(arp, sw.getId(), pi.getInPort(),
configService.getRouterMacAddress());
}
-
+
return;
}
@@ -339,62 +339,57 @@
IDeviceObject targetDevice =
deviceStorage.getDeviceByIP(InetAddresses.coerceToInteger(target));
log.debug("targetDevice: {}", targetDevice);
-
- arpRequests.put(target, new ArpRequest(
- new HostArpRequester(arp, sw.getId(), pi.getInPort()), false));
-
+
+ arpRequests.put(target, new ArpRequest(
+ new HostArpRequester(arp, sw.getId(), pi.getInPort()), false));
+
if (targetDevice != null) {
- // Even the device in our database is not null, we do not reply to the request directly, but to check whether the device is still valid
+ // Even the device in our database is not null, we do not reply to the request directly, but to check whether the device is still valid
MACAddress macAddress = MACAddress.valueOf(targetDevice.getMACAddress());
-
+
if (log.isTraceEnabled()) {
- log.trace("The target Device Record in DB is: {} => {} from ARP request host at {}/{}", new Object [] {
- inetAddressToString(arp.getTargetProtocolAddress()),
- macAddress.toString(),
- HexString.toHexString(sw.getId()), pi.getInPort()});
+ log.trace("The target Device Record in DB is: {} => {} from ARP request host at {}/{}", new Object [] {
+ inetAddressToString(arp.getTargetProtocolAddress()),
+ macAddress.toString(),
+ HexString.toHexString(sw.getId()), pi.getInPort()});
}
-
- // sendArpReply(arp, sw.getId(), pi.getInPort(), macAddress);
- try {
- log.trace("Checking the device info from DB is still valid or not");
- Iterable<IPortObject> outPorts=targetDevice.getAttachedPorts();
-
- if(!outPorts.iterator().hasNext())
- {
- log.debug("outPort : null");
- sendToOtherNodes(eth, pi);
- }
- else{
-
- for (IPortObject portObject : outPorts) {
- long outSwitch=0;
- short outPort=0;
-
-
- if (!portObject.getLinkedPorts().iterator().hasNext()) {
- outPort=portObject.getNumber();
- log.debug("outPort:{} ", outPort);
- }
-
- Iterable<ISwitchObject> outSwitches= targetDevice.getSwitch();
-
- for (ISwitchObject outswitch : outSwitches) {
-
- outSwitch= HexString.toLong(outswitch.getDPID());
- log.debug("outSwitch.DPID:{}; outPort: {}", outswitch.getDPID(), outPort );
- sendToOtherNodes( eth, pi, outSwitch, outPort);
- }
-
- }
- }
- }catch (Exception e) {
- log.error("Get attach outSwitche and outPort exception", e);
+
+ // sendArpReply(arp, sw.getId(), pi.getInPort(), macAddress);
+
+ log.trace("Checking the device info from DB is still valid or not");
+ Iterable<IPortObject> outPorts=targetDevice.getAttachedPorts();
+
+ if(!outPorts.iterator().hasNext()){
+ log.debug("outPort : null");
+ sendToOtherNodes(eth, pi);
+ }else{
+
+ for (IPortObject portObject : outPorts) {
+ long outSwitch=0;
+ short outPort=0;
+
+
+ if (!portObject.getLinkedPorts().iterator().hasNext()) {
+ outPort=portObject.getNumber();
+ log.debug("outPort:{} ", outPort);
+ }
+
+ Iterable<ISwitchObject> outSwitches= targetDevice.getSwitch();
+
+ for (ISwitchObject outswitch : outSwitches) {
+
+ outSwitch= HexString.toLong(outswitch.getDPID());
+ log.debug("outSwitch.DPID:{}; outPort: {}", outswitch.getDPID(), outPort );
+ sendToOtherNodes( eth, pi, outSwitch, outPort);
+ }
+ }
}
- } else {
- log.debug("The Device info in DB is {} for IP {}", targetDevice, inetAddressToString(arp.getTargetProtocolAddress()));
-
- // We don't know the device so broadcast the request out
- sendToOtherNodes(eth, pi);
+
+ }else {
+ log.debug("The Device info in DB is {} for IP {}", targetDevice, inetAddressToString(arp.getTargetProtocolAddress()));
+
+ // We don't know the device so broadcast the request out
+ sendToOtherNodes(eth, pi);
}
}
@@ -813,24 +808,15 @@
@Override
public void arpRequestNotification(ArpMessage arpMessage) {
log.debug("Received ARP notification from other instances");
-
+
switch (arpMessage.getType()){
case REQUEST:
- if (arpMessage.getOutSwitch()==-1)
- { log.debug("OutSwitch in ARP request Message is null");
- }
- if (arpMessage.getOutPort()==-1)
- { log.debug("OutPort in ARP request Message is null");
- }
-
- if(arpMessage.getOutSwitch() ==-1 || arpMessage.getOutPort()==-1){
- broadcastArpRequestOutMyEdge(arpMessage.getPacket());
- }else if (arpMessage.getOutSwitch() >0 && arpMessage.getOutPort()>0 ){
- log.debug("OutSwitch in ARP request message is: {}; OutPort in ARP request message is: {}",arpMessage.getOutSwitch(),arpMessage.getOutPort());
- sendArpRequestOutPort(arpMessage.getPacket(),arpMessage.getOutSwitch(),arpMessage.getOutPort());
-
- }else{
- broadcastArpRequestOutMyEdge(arpMessage.getPacket());}
+ if(arpMessage.getOutSwitch() == -1 || arpMessage.getOutPort() == -1){
+ broadcastArpRequestOutMyEdge(arpMessage.getPacket());
+ }else{
+ sendArpRequestOutPort(arpMessage.getPacket(),arpMessage.getOutSwitch(),arpMessage.getOutPort());
+ log.debug("OutSwitch in ARP request message is: {}; OutPort in ARP request message is: {}",arpMessage.getOutSwitch(),arpMessage.getOutPort());
+ }
break;
case REPLY:
log.debug("Received ARP reply notification for {}",