Merge "IPACM: Warn messages seen on Apps processor and follows the Data stall"
diff --git a/ipacm/src/IPACM_Conntrack_NATApp.cpp b/ipacm/src/IPACM_Conntrack_NATApp.cpp
index 2424248..d6bbc19 100644
--- a/ipacm/src/IPACM_Conntrack_NATApp.cpp
+++ b/ipacm/src/IPACM_Conntrack_NATApp.cpp
@@ -1,4 +1,4 @@
-/* 
+/*
 Copyright (c) 2013, The Linux Foundation. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -179,7 +179,7 @@
 	int cnt = 0;
 	IPACMDBG("%s() %d\n", __FUNCTION__, __LINE__);
 
-	for(; cnt < curCnt; cnt++)
+	for(; cnt < max_entries; cnt++)
 	{
 		if(cache[cnt].private_ip == rule->private_ip &&
 			 cache[cnt].target_ip == rule->target_ip &&
@@ -230,16 +230,16 @@
 					return -1;
 				}
 
-				IPACMDBG("Deleted Nat entry Successfully\n");
+				IPACMDBG("Deleted Nat entry(%d) Successfully\n", cnt);
 			}
 			else
 			{
-				IPACMDBG("Deleted Nat entry only from cache\n");
+				IPACMDBG("Deleted Nat entry(%d) only from cache\n", cnt);
 			}
-			
+
 			memset(&cache[cnt], 0, sizeof(cache[cnt]));
 			curCnt--;
-			break; 
+			break;
 		}
 	}
 
@@ -306,7 +306,7 @@
 			nat_rule.private_port = rule->private_port;
 			nat_rule.public_port = rule->public_port;
 			nat_rule.protocol = rule->protocol;
-			
+
 			if(isPwrSaveIf(rule->private_ip) ||
 				 isPwrSaveIf(rule->target_ip))
 			{
@@ -346,8 +346,12 @@
 
 	if(cache[cnt].enabled == true)
 	{
-		IPACMDBG("Added rule successfully\n");
+		IPACMDBG("Added rule(%d) successfully\n", cnt);
 	}
+  else
+  {
+    IPACMDBG("Cached rule(%d) successfully\n", cnt);
+  }
 
 	return 0;
 }
@@ -379,7 +383,7 @@
 			return;
 		}
 	}
-	
+
 	nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);
 	if(rule->protocol == IPPROTO_UDP)
 	{
@@ -416,9 +420,9 @@
 	iptodot("Source IP:", nfct_get_attr_u32(ct, ATTR_IPV4_SRC));
 	iptodot("Destination IP:",  nfct_get_attr_u32(ct, ATTR_IPV4_DST));
 	IPACMDBG("Source Port: %d, Destination Port: %d\n",
-					 nfct_get_attr_u16(ct, ATTR_PORT_SRC), nfct_get_attr_u16(ct, ATTR_PORT_DST)); 
-	
-	IPACMDBG("updating %d connection with time: %d\n", 
+					 nfct_get_attr_u16(ct, ATTR_PORT_SRC), nfct_get_attr_u16(ct, ATTR_PORT_DST));
+
+	IPACMDBG("updating %d connection with time: %d\n",
 					 rule->protocol, nfct_get_attr_u32(ct, ATTR_TIMEOUT));
 
 	ret = nfct_query(ct_hdl, NFCT_Q_UPDATE, ct);
@@ -440,7 +444,7 @@
 	int cnt;
 	uint32_t ts;
 
-	for(cnt = 0; cnt < curCnt; cnt++)
+	for(cnt = 0; cnt < max_entries; cnt++)
 	{
 		ts = 0;
 		if(cache[cnt].enabled == true)
@@ -458,7 +462,7 @@
 								                  cache[cnt].timestamp, ts);
 				continue;
 			}
-			
+
 			UpdateCTUdpTs(&cache[cnt], ts);
 		} /* end of outer if */
 
@@ -500,7 +504,7 @@
 int NatApp::UpdatePwrSaveIf(uint32_t client_lan_ip)
 {
 	int cnt;
-	IPACMDBG("\n");
+	IPACMDBG("Received IP address: 0x%x\n", client_lan_ip);
 
 	if(client_lan_ip == INVALID_IP_ADDR)
 	{
@@ -529,7 +533,7 @@
 		}
 	}
 
-	for(cnt = 0; cnt < curCnt; cnt++)
+	for(cnt = 0; cnt < max_entries; cnt++)
 	{
 		if(cache[cnt].private_ip == client_lan_ip &&
 			 cache[cnt].enabled == true)
@@ -553,7 +557,7 @@
 	int cnt;
 	ipa_nat_ipv4_rule nat_rule;
 
-	IPACMDBG("\n");
+	IPACMDBG("Received ip address: 0x%x\n", client_lan_ip);
 
 	if(client_lan_ip == INVALID_IP_ADDR)
 	{
@@ -570,7 +574,7 @@
 		}
 	}
 
-	for(cnt = 0; cnt < curCnt; cnt++)
+	for(cnt = 0; cnt < max_entries; cnt++)
 	{
 		if(cache[cnt].private_ip == client_lan_ip &&
 			 cache[cnt].enabled == false)
@@ -582,7 +586,7 @@
 			nat_rule.private_port = cache[cnt].private_port;
 			nat_rule.public_port = cache[cnt].public_port;
 			nat_rule.protocol = cache[cnt].protocol;
-			
+
 			if(ipa_nat_add_ipv4_rule(nat_table_hdl, &nat_rule, &cache[cnt].rule_hdl) < 0)
 			{
 				IPACMERR("unable to add the rule delete from cache\n");