CORD-1899-AAA-handle absence in sadis data

Change-Id: I6922e115634bd586500fe2fd50359f121fa09ce1
diff --git a/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java b/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java
index 4cdf958..8973a5f 100755
--- a/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java
+++ b/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java
@@ -259,13 +259,21 @@
             aaaManager.radiusOperationalStatusService.setStatusServerReqSent(false);
             return;
         }
-        ipToSnMap.put(deviceInfo.ipAddress(), serialNo);
+
         if (radiusPacket.getIdentifier() == RadiusOperationalStatusManager.AAA_REQUEST_ID_STATUS_REQUEST ||
                 radiusPacket.getIdentifier() == RadiusOperationalStatusManager.AAA_REQUEST_ID_FAKE_ACCESS_REQUEST) {
             aaaManager.radiusOperationalStatusService.setOutTimeInMillis(radiusPacket.getIdentifier());
         } else {
             aaaManager.aaaStatisticsManager.putOutgoingIdentifierToMap(radiusPacket.getIdentifier());
         }
+
+        Ip4Address ipAddress = deviceInfo.ipAddress();
+        if (ipAddress != null) {
+            ipToSnMap.put(ipAddress, serialNo);
+        } else {
+            log.warn("Cannot Map IpAddress to SerialNo : ipAddress = {}", ipAddress);
+        }
+
         // send the message out
         sendFromRadiusServerPort(pktCustomizer.
                 customizeEthernetIPHeaders(ethReply, inPkt));
diff --git a/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java b/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java
index d8dd486..52536d1 100755
--- a/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java
+++ b/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java
@@ -20,8 +20,9 @@
 import java.nio.ByteBuffer;
 
 import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
+import org.onlab.packet.Ip4Address;
 import org.onlab.packet.MacAddress;
+import org.onlab.packet.IPv4;
 import org.onlab.packet.RADIUS;
 import org.onlab.packet.RADIUSAttribute;
 import org.onosproject.net.AnnotationKeys;
@@ -95,6 +96,14 @@
             return inPkt;
         }
         String nodeName = deviceInfo.nasId();
+        Ip4Address ipAddress = deviceInfo.ipAddress();
+        if (nasPortId == null || nodeName == null || ipAddress == null) {
+            log.warn("Insufficient data to Customize packet" +
+                    " : nasPortId = {}, nodeName = {}, ipAddress = {}",
+                    nasPortId, nodeName, ipAddress);
+            return inPkt;
+        }
+
 
         log.info("Setting nasId={} nasPortId{}", nodeName, nasPortId);
 
@@ -149,10 +158,18 @@
             return inPkt;
         }
 
-        inPkt.setSourceMACAddress(deviceInfo.hardwareIdentifier());
+        MacAddress macAddress = deviceInfo.hardwareIdentifier();
+        Ip4Address ipAddress = deviceInfo.ipAddress();
+        if (macAddress == null || ipAddress == null) {
+            log.warn("Insufficient data to Customize Ethernet IP Headers" +
+                    " : hardwareIdentifier = {}, ipAddress = {}",
+                    macAddress, ipAddress);
+            return inPkt;
+        }
+        inPkt.setSourceMACAddress(macAddress);
 
         IPv4 ipv4Packet = (IPv4) inPkt.getPayload();
-        ipv4Packet.setSourceAddress(deviceInfo.ipAddress().toString());
+        ipv4Packet.setSourceAddress(ipAddress.toString());
         inPkt.setPayload(ipv4Packet);
 
         return inPkt;