ipacm: Fix TOS_MASKED firewall rule programming

TOS_MASKED cannot be implemented using the
attribute TOS as it does not accept mask.

CRs-Fixed: 2280281
Change-Id: I515139d55beae4261f65d7126c6f7bf200837f98
Signed-off-by: Ghanim Fodi <gfodi@codeaurora.org>
diff --git a/ipacm/src/IPACM_Xml.cpp b/ipacm/src/IPACM_Xml.cpp
index b81856a..4451906 100644
--- a/ipacm/src/IPACM_Xml.cpp
+++ b/ipacm/src/IPACM_Xml.cpp
@@ -665,6 +665,9 @@
 						memcpy(content_buf, (void *)content, str_size);
 						config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos
 							 = atoi(content_buf);
+						// Here we do not know if it is TOS with mask or not, so we put at both places
+						config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.tos_value
+							= atoi(content_buf);
 						IPACMDBG_H("\n IPV4 TOS val is %d \n",
 										 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos);
 					}
@@ -674,13 +677,25 @@
 					content = IPACM_read_content_element(xml_node);
 					if (content)
 					{
+						uint8_t mask;
+
 						str_size = strlen(content);
 						memset(content_buf, 0, sizeof(content_buf));
 						memcpy(content_buf, (void *)content, str_size);
-						config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos
-							 &= atoi(content_buf);
-						IPACMDBG_H("\n IPv4 TOS mask is %d \n",
-								config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos);
+						mask = atoi(content_buf);
+						IPACMDBG_H("\n IPv4 TOS mask is %u \n", mask);
+						if (mask != 0xFF) {
+							// TOS attribute cannot be used
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos = 0;
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.tos_mask = mask;
+
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |=
+								IPA_FLT_TOS_MASKED;
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask &=
+								~IPA_FLT_TOS;
+						} else {
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.tos_value = 0;
+						}
 					}
 				}
 				else if (0 == IPACM_util_icmp_string((char*)xml_node->name, IPV4NextHeaderProtocol_TAG))