Fix rule index notification to modem: take into account the
private subnet filtering rules

Change-Id: I7af4c8c7ac21ac279a83a7bedc0bab7fea718864
Signed-off-by: Ravi Gummadidala <rgummadi@codeaurora.org>
diff --git a/ipacm/inc/IPACM_Iface.h b/ipacm/inc/IPACM_Iface.h
index 52616e6..d0ba6cc 100644
--- a/ipacm/inc/IPACM_Iface.h
+++ b/ipacm/inc/IPACM_Iface.h
@@ -120,21 +120,23 @@
     /*Query the IPA endpoint property */
     int query_iface_property(void);
 
-		/*Configure the initial filter rules */
-		virtual int init_fl_rule(ipa_ip_type iptype);
+	/*Configure the initial filter rules */
+	virtual int init_fl_rule(ipa_ip_type iptype);
 
-		static IPACM_Routing m_routing;
-		static IPACM_Filtering m_filtering;
-		static IPACM_Header m_header;
+	static IPACM_Routing m_routing;
+	static IPACM_Filtering m_filtering;
+	static IPACM_Header m_header;
 
-		/* software routing enable */
-		virtual int handle_software_routing_enable(void);
+	/* software routing enable */
+	virtual int handle_software_routing_enable(void);
 
-		/* software routing disable */
-		virtual int handle_software_routing_disable(void);
+	/* software routing disable */
+	virtual int handle_software_routing_disable(void);
 
 	/* used to get filtering rule index in table */
-	int flt_rule_count;
+	int flt_rule_count_v4;
+	
+	int flt_rule_count_v6;
 
 
 private:
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
index ecb78d9..af31028 100644
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -76,7 +76,8 @@
 	memset(software_routing_fl_rule_hdl, 0, sizeof(software_routing_fl_rule_hdl));
 	memset(ipv6_addr, 0, sizeof(ipv6_addr));
 
-	flt_rule_count = 0;
+	flt_rule_count_v4 = 0;
+	flt_rule_count_v6 = 0;
 	query_iface_property();
 	IPACMDBG(" create iface-index(%d) constructor\n", ipa_if_num);
 	return;
@@ -666,7 +667,7 @@
 		}
 		else
 		{
-			flt_rule_count += IPV4_DEFAULT_FILTERTING_RULES;
+			flt_rule_count_v4 += IPV4_DEFAULT_FILTERTING_RULES;
 			/* copy filter hdls */
 			for (int i = 0; i < IPV4_DEFAULT_FILTERTING_RULES; i++)
 			{
@@ -754,7 +755,7 @@
 		}
 		else
 		{
-			flt_rule_count += IPV6_DEFAULT_FILTERTING_RULES;
+			flt_rule_count_v6 += IPV6_DEFAULT_FILTERTING_RULES;
 			/* copy filter hdls */
 			for (int i = 0;
 					 i < IPV6_DEFAULT_FILTERTING_RULES;
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index 9e189d5..8824d99 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -870,6 +870,8 @@
 		return IPACM_FAILURE;
 	}
 
+	flt_rule_count_v4 = IPV4_DEFAULT_FILTERTING_RULES + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
+	
 	if(is_sta_mode == false)
 	{
 		if (m_filtering.DeleteFilteringHdls(wan_ul_fl_rule_hdl_v4, 
@@ -1145,10 +1147,11 @@
 			return IPACM_FAILURE;
 		}
 
+		flt_rule_count_v4 += IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
+		
 		/* copy filter rule hdls */
 		for (i = 0; i < IPACM_Iface::ipacmcfg->ipa_num_private_subnet; i++)
 		{
-
 			private_fl_rule_hdl[i] = m_pFilteringTable->rules[i].flt_rule_hdl;
 		}
 		free(m_pFilteringTable);
@@ -1581,12 +1584,19 @@
 		flt_rule_entry.rule.rt_tbl_idx = prop->prop[cnt].rt_tbl_idx;
 		memcpy(&pFilteringTable->rules[cnt], &flt_rule_entry, sizeof(flt_rule_entry));
 
-		flt_index.filter_index_list[cnt].filter_index = flt_rule_count;
+		if(iptype == IPA_IP_v4)
+		{
+			IPACMDBG("Filtering rule %d has index %d\n", cnt, flt_rule_count_v4);
+			flt_index.filter_index_list[cnt].filter_index = flt_rule_count_v4;
+			flt_rule_count_v4++;
+		}
+		if(iptype == IPA_IP_v6)
+		{
+			IPACMDBG("Filtering rule %d has index %d\n", cnt, flt_rule_count_v6);
+			flt_index.filter_index_list[cnt].filter_index = flt_rule_count_v6;
+			flt_rule_count_v6++;
+		}
 		flt_index.filter_index_list[cnt].filter_handle = prop->prop[cnt].filter_hdl;
-		
-		IPACMDBG("Filtering rule %d, index %d\n", cnt, flt_index.filter_index_list[cnt].filter_index);
-
-		flt_rule_count++;
 	}
 
 	if(false == m_filtering.SendFilteringRuleIndex(&flt_index))
@@ -1645,6 +1655,8 @@
 		return IPACM_FAILURE;
 	}
 
+	flt_rule_count_v6 = IPV6_DEFAULT_FILTERTING_RULES;
+	
 	if(is_sta_mode == false)
 	{
 		if (m_filtering.DeleteFilteringHdls(wan_ul_fl_rule_hdl_v6,