code adjustment according to reviewer's suggestion: MAC final type, indentation, exception handler
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;
- }
}