• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
7     * Redistributions of source code must retain the above copyright
8       notice, this list of conditions and the following disclaimer.
9     * Redistributions in binary form must reproduce the above
10       copyright notice, this list of conditions and the following
11       disclaimer in the documentation and/or other materials provided
12       with the distribution.
13     * Neither the name of The Linux Foundation nor the names of its
14       contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29 /*!
30 	@file
31 	IPACM_Wan.cpp
32 
33 	@brief
34 	This file implements the WAN iface functionality.
35 
36 	@Author
37 	Skylar Chang
38 
39 */
40 #ifndef IPACM_WAN_H
41 #define IPACM_WAN_H
42 
43 #include <stdio.h>
44 #include <IPACM_CmdQueue.h>
45 #include <linux/msm_ipa.h>
46 #include "IPACM_Routing.h"
47 #include "IPACM_Filtering.h"
48 #include <IPACM_Iface.h>
49 #include <IPACM_Defs.h>
50 #include <IPACM_Xml.h>
51 
52 #define IPA_NUM_DEFAULT_WAN_FILTER_RULES 3 /*1 for v4, 2 for v6*/
53 #define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4 2
54 
55 #ifdef FEATURE_IPA_ANDROID
56 #define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 7
57 #define IPA_V2_NUM_TCP_WAN_FILTER_RULE_IPV6 3
58 #define IPA_V2_NUM_MULTICAST_WAN_FILTER_RULE_IPV6 3
59 #define IPA_V2_NUM_FRAG_WAN_FILTER_RULE_IPV6 1
60 #else
61 #define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 3
62 #endif
63 
64 #define NETWORK_STATS "%s %llu %llu %llu %llu"
65 #define IPA_NETWORK_STATS_FILE_NAME "/data/misc/ipa/network_stats"
66 
67 typedef struct _wan_client_rt_hdl
68 {
69 	uint32_t wan_rt_rule_hdl_v4;
70 	uint32_t wan_rt_rule_hdl_v6[IPV6_NUM_ADDR];
71 	uint32_t wan_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];
72 }wan_client_rt_hdl;
73 
74 typedef struct _ipa_wan_client
75 {
76 	ipacm_event_data_wlan_ex* p_hdr_info;
77 	uint8_t mac[IPA_MAC_ADDR_SIZE];
78 	uint32_t v4_addr;
79 	uint32_t v6_addr[IPV6_NUM_ADDR][4];
80 	uint32_t hdr_hdl_v4;
81 	uint32_t hdr_hdl_v6;
82 	bool route_rule_set_v4;
83 	int route_rule_set_v6;
84 	bool ipv4_set;
85 	int ipv6_set;
86 	bool ipv4_header_set;
87 	bool ipv6_header_set;
88 	bool power_save_set;
89 	wan_client_rt_hdl wan_rt_hdl[0]; /* depends on number of tx properties */
90 }ipa_wan_client;
91 
92 typedef struct
93 {
94 	bool coalesce_tcp_enable;
95 	bool coalesce_udp_enable;
96 }ipacm_coalesce;
97 
98 /* wan iface */
99 class IPACM_Wan : public IPACM_Iface
100 {
101 
102 public:
103 	/* IPACM pm_depency q6 check*/
104 	static int ipa_pm_q6_check;
105 	static bool wan_up;
106 	static bool wan_up_v6;
107 	static uint8_t xlat_mux_id;
108 	static uint16_t mtu_default_wan;
109 	uint16_t mtu_size;
110 	/* IPACM interface name */
111 	static char wan_up_dev_name[IF_NAME_LEN];
112 	static uint32_t curr_wan_ip;
113 	IPACM_Wan(int, ipacm_wan_iface_type, uint8_t *);
114 	virtual ~IPACM_Wan();
115 
isWanUP(int ipa_if_num_tether)116 	static bool isWanUP(int ipa_if_num_tether)
117 	{
118 #ifdef FEATURE_IPA_ANDROID
119 #ifdef FEATURE_IPACM_HAL
120 		/*To avoid -Wall -Werror error */
121 		IPACMDBG_H("ipa_if_num_tether: %d\n",ipa_if_num_tether);
122 		return wan_up;
123 #else
124 		uint32_t i;
125 		for (i=0; i < ipa_if_num_tether_v4_total;i++)
126 		{
127 			if (ipa_if_num_tether_v4[i] == ipa_if_num_tether)
128 			{
129 				IPACMDBG_H("support ipv4 tether_iface(%s)\n",
130 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
131 				return wan_up;
132 				break;
133 			}
134 		}
135 		return false;
136 #endif
137 #else
138 		return wan_up;
139 #endif
140 	}
141 
queryMTU(int ipa_if_num_tether,enum ipa_ip_type iptype)142 	static uint16_t queryMTU(int ipa_if_num_tether, enum ipa_ip_type iptype)
143 	{
144 		if (iptype == IPA_IP_v4)
145 		{
146 			if (isWanUP(ipa_if_num_tether))
147 			{
148 				return mtu_default_wan;
149 			}
150 		}
151 		else if (iptype == IPA_IP_v6)
152 		{
153 			if (isWanUP_V6(ipa_if_num_tether))
154 			{
155 				return mtu_default_wan;
156 
157 			}
158 		}
159 		return DEFAULT_MTU_SIZE;
160 	}
161 
isWanUP_V6(int ipa_if_num_tether)162 	static bool isWanUP_V6(int ipa_if_num_tether)
163 	{
164 #ifdef FEATURE_IPA_ANDROID
165 #ifdef FEATURE_IPACM_HAL
166 		/*To avoid -Wall -Werror error */
167 		IPACMDBG_H("ipa_if_num_tether: %d\n",ipa_if_num_tether);
168 		return wan_up_v6;
169 #else
170 		uint32_t i;
171 		for (i=0; i < ipa_if_num_tether_v6_total;i++)
172 		{
173 			if (ipa_if_num_tether_v6[i] == ipa_if_num_tether)
174 			{
175 				IPACMDBG_H("support ipv6 tether_iface(%s)\n",
176 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
177 				return wan_up_v6;
178 				break;
179 			}
180 		}
181 		return false;
182 #endif
183 #else
184 		return wan_up_v6;
185 #endif
186 	}
187 
188 #ifdef FEATURE_IPA_ANDROID
delete_tether_iface(ipa_ip_type iptype,int ipa_if_num_tether)189 	static int delete_tether_iface(ipa_ip_type iptype, int ipa_if_num_tether)
190 	{
191 		uint32_t i, j;
192 
193 		if (iptype == IPA_IP_v4)
194 		{
195 			/* delete support tether ifaces to its array*/
196 			for (i=0; i < IPACM_Wan::ipa_if_num_tether_v4_total; i++)
197 			{
198 				if(IPACM_Wan::ipa_if_num_tether_v4[i] == ipa_if_num_tether)
199 				{
200 					IPACMDBG_H("Found tether client at position %d name(%s)\n", i,
201 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
202 					break;
203 				}
204 			}
205 			if(i == IPACM_Wan::ipa_if_num_tether_v4_total)
206 			{
207 				IPACMDBG_H("Not finding the tethered ipv4 client.\n");
208 				return IPACM_FAILURE;
209 			}
210 			for(j = i+1; j < IPACM_Wan::ipa_if_num_tether_v4_total; j++)
211 			{
212 				IPACM_Wan::ipa_if_num_tether_v4[j-1] = IPACM_Wan::ipa_if_num_tether_v4[j];
213 			}
214 			IPACM_Wan::ipa_if_num_tether_v4_total--;
215 			IPACMDBG_H("Now the total num of ipa_if_num_tether_v4_total is %d\n",
216 				IPACM_Wan::ipa_if_num_tether_v4_total);
217 		}
218 		else
219 		{
220 			/* delete support tether ifaces to its array*/
221 			for (i=0; i < IPACM_Wan::ipa_if_num_tether_v6_total; i++)
222 			{
223 				if(IPACM_Wan::ipa_if_num_tether_v6[i] == ipa_if_num_tether)
224 				{
225 					IPACMDBG_H("Found tether client at position %d name(%s)\n", i,
226 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
227 					break;
228 				}
229 			}
230 			if(i == IPACM_Wan::ipa_if_num_tether_v6_total)
231 			{
232 				IPACMDBG_H("Not finding the tethered ipv6 client.\n");
233 				return IPACM_FAILURE;
234 			}
235 			for(j = i+1; j < IPACM_Wan::ipa_if_num_tether_v6_total; j++)
236 			{
237 				IPACM_Wan::ipa_if_num_tether_v6[j-1] = IPACM_Wan::ipa_if_num_tether_v6[j];
238 			}
239 			IPACM_Wan::ipa_if_num_tether_v6_total--;
240 			IPACMDBG_H("Now the total num of ipa_if_num_tether_v6_total is %d\n",
241 				IPACM_Wan::ipa_if_num_tether_v6_total);
242 		}
243 		return IPACM_SUCCESS;
244 	}
245 #endif
coalesce_config(uint8_t qmap_id,bool tcp_enable,bool udp_enable)246 	static void coalesce_config(uint8_t qmap_id, bool tcp_enable, bool udp_enable)
247 	{
248 		if (qmap_id >= IPA_MAX_NUM_SW_PDNS)
249 		{
250 			IPACMERR("qmap_id (%d) beyond the Max range (%d), abort\n",
251 				qmap_id, IPA_MAX_NUM_SW_PDNS);
252 			return ;
253 		}
254 
255 		IPACM_Wan::coalesce_enable_info[qmap_id].coalesce_tcp_enable = tcp_enable;
256 		IPACM_Wan::coalesce_enable_info[qmap_id].coalesce_udp_enable = udp_enable;
257 		IPACMDBG_H(" Updated qmap(%d) coalesce enable TCP:%d UDP:%d\n",
258 				qmap_id,
259 				IPACM_Wan::coalesce_enable_info[qmap_id].coalesce_tcp_enable,
260 				IPACM_Wan::coalesce_enable_info[qmap_id].coalesce_udp_enable);
261 		return ;
262 	}
263 
coalesce_config_reset()264 	static void coalesce_config_reset()
265 	{
266 		int i;
267 		/* reset coalesce settings on all modem interfaces */
268 		for (i = 0; i < IPA_MAX_NUM_SW_PDNS; i++)
269 			IPACM_Wan::coalesce_config(i, false, false);
270 		return ;
271 	}
272 
getWANIP()273 	static uint32_t getWANIP()
274 	{
275 		return curr_wan_ip;
276 	}
277 
getXlat_Mux_Id()278 	static int getXlat_Mux_Id()
279 	{
280 		if (is_xlat)
281 		{
282 			IPACMDBG_H("xlat_mux_id: %d\n", xlat_mux_id);
283 			return xlat_mux_id;
284 		} else {
285 			IPACMDBG_H("no xlat return invalid mux-id: 0\n");
286 			return 0;
287 		}
288 	}
289 
clearExtProp()290 	static void clearExtProp()
291 	{
292 		IPACM_Wan::is_ext_prop_set = false;
293 		IPACM_Iface::ipacmcfg->DelExtProp(IPA_IP_v4);
294 		IPACM_Iface::ipacmcfg->DelExtProp(IPA_IP_v6);
295 	}
296 
297 	void event_callback(ipa_cm_event_id event,
298 											void *data);
299 
300 	static struct ipa_flt_rule_add flt_rule_v4[IPA_MAX_FLT_RULE];
301 	static struct ipa_flt_rule_add flt_rule_v6[IPA_MAX_FLT_RULE];
302 
303 	static int num_v4_flt_rule;
304 	static int num_v6_flt_rule;
305 
306 	ipacm_wan_iface_type m_is_sta_mode;
307 	static ipacm_wan_iface_type backhaul_mode;
308 	static bool is_ext_prop_set;
309 	static uint32_t backhaul_ipv6_prefix[2];
310 
311 	static bool embms_is_on;
312 	static bool backhaul_is_wan_bridge;
313 	static bool is_xlat;
314 
isWan_Bridge_Mode()315 	static bool isWan_Bridge_Mode()
316 	{
317 		return backhaul_is_wan_bridge;
318 	}
319 #ifdef FEATURE_IPA_ANDROID
320 	/* IPACM interface id */
321 	static uint32_t ipa_if_num_tether_v4_total;
322 	static int ipa_if_num_tether_v4[IPA_MAX_IFACE_ENTRIES];
323 	static uint32_t ipa_if_num_tether_v6_total;
324 	static int ipa_if_num_tether_v6[IPA_MAX_IFACE_ENTRIES];
325 
isXlat()326 	static bool isXlat()
327 	{
328 		return is_xlat;
329 	}
330 #endif
331 
332 	/* indicate coalesce support on tcp or udp*/
333 	static ipacm_coalesce coalesce_enable_info[IPA_MAX_NUM_SW_PDNS];
334 
335 private:
336 
337 	bool is_ipv6_frag_firewall_flt_rule_installed;
338 	uint32_t ipv6_frag_firewall_flt_rule_hdl;
339 	uint32_t *wan_route_rule_v4_hdl;
340 	uint32_t *wan_route_rule_v6_hdl;
341 	uint32_t *wan_route_rule_v6_hdl_a5;
342 	uint32_t hdr_hdl_sta_v4;
343 	uint32_t hdr_hdl_sta_v6;
344 	uint32_t firewall_hdl_v4[IPACM_MAX_FIREWALL_ENTRIES];
345 	uint32_t firewall_hdl_v6[IPACM_MAX_FIREWALL_ENTRIES];
346 	uint32_t dft_wan_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
347 	uint32_t ipv6_dest_flt_rule_hdl[MAX_DEFAULT_v6_ROUTE_RULES];
348 	int num_ipv6_dest_flt_rule;
349 	uint32_t ODU_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
350 	int num_firewall_v4,num_firewall_v6;
351 	uint32_t wan_v4_addr;
352 	uint32_t wan_v4_addr_gw;
353 	uint32_t wan_v6_addr_gw[4];
354 	bool wan_v4_addr_set;
355 	bool wan_v4_addr_gw_set;
356 	bool wan_v6_addr_gw_set;
357 	bool active_v4;
358 	bool active_v6;
359 	bool header_set_v4;
360 	bool header_set_v6;
361 	bool header_partial_default_wan_v4;
362 	bool header_partial_default_wan_v6;
363 	uint8_t ext_router_mac_addr[IPA_MAC_ADDR_SIZE];
364 	uint8_t netdev_mac[IPA_MAC_ADDR_SIZE];
365 	/* create additional set of v4 Coalesce RT-rules: tcp udp */
366 	uint32_t dft_coalesce_rt_rule_hdl[2*MAX_DEFAULT_v4_ROUTE_RULES+ 2*MAX_DEFAULT_v6_ROUTE_RULES];
367 
368 	static int num_ipv4_modem_pdn;
369 
370 	static int num_ipv6_modem_pdn;
371 
372 	int modem_ipv4_pdn_index;
373 
374 	int modem_ipv6_pdn_index;
375 
376 	bool is_default_gateway;
377 
378 	uint32_t ipv6_prefix[2];
379 
380 	/* IPACM firewall Configuration file*/
381 	IPACM_firewall_conf_t firewall_config;
382 
383 	/* STA mode wan-client*/
384 	int wan_client_len;
385 	ipa_wan_client *wan_client;
386 	int header_name_count;
387 	uint32_t num_wan_client;
388 	uint8_t invalid_mac[IPA_MAC_ADDR_SIZE];
389 	bool is_xlat_local;
390 
391 	/* update network stats for CNE */
392 	int ipa_network_stats_fd;
393 	uint32_t hdr_hdl_dummy_v6;
394 	uint32_t hdr_proc_hdl_dummy_v6;
395 
396 	/* handle for UDP mhi frag rule */
397 	uint32_t mhi_dl_v4_frag_hdl;
398 
399 	/* handle for icmpv6 exception rule */
400 	uint32_t icmpv6_exception_hdl;
401 
402 	/* handle for TCP FIN rule */
403 	uint32_t tcp_fin_hdl;
404 
405 	/* handle for TCP RST rule */
406 	uint32_t tcp_rst_hdl;
407 
get_client_memptr(ipa_wan_client * param,int cnt)408 	inline ipa_wan_client* get_client_memptr(ipa_wan_client *param, int cnt)
409 	{
410 	    char *ret = ((char *)param) + (wan_client_len * cnt);
411 		return (ipa_wan_client *)ret;
412 	}
413 
get_wan_client_index(uint8_t * mac_addr)414 	inline int get_wan_client_index(uint8_t *mac_addr)
415 	{
416 		int cnt;
417 		int num_wan_client_tmp = num_wan_client;
418 
419 		IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
420 						 mac_addr[0], mac_addr[1], mac_addr[2],
421 						 mac_addr[3], mac_addr[4], mac_addr[5]);
422 
423 		for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
424 		{
425 			IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
426 							 get_client_memptr(wan_client, cnt)->mac[0],
427 							 get_client_memptr(wan_client, cnt)->mac[1],
428 							 get_client_memptr(wan_client, cnt)->mac[2],
429 							 get_client_memptr(wan_client, cnt)->mac[3],
430 							 get_client_memptr(wan_client, cnt)->mac[4],
431 							 get_client_memptr(wan_client, cnt)->mac[5]);
432 
433 			if(memcmp(get_client_memptr(wan_client, cnt)->mac,
434 								mac_addr,
435 								sizeof(get_client_memptr(wan_client, cnt)->mac)) == 0)
436 			{
437 				IPACMDBG_H("Matched client index: %d\n", cnt);
438 				return cnt;
439 			}
440 		}
441 
442 		return IPACM_INVALID_INDEX;
443 	}
444 
get_wan_client_index_ipv4(uint32_t ipv4_addr)445 	inline int get_wan_client_index_ipv4(uint32_t ipv4_addr)
446 	{
447 		int cnt;
448 		int num_wan_client_tmp = num_wan_client;
449 
450 		IPACMDBG_H("Passed IPv4 %x\n", ipv4_addr);
451 
452 		for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
453 		{
454 			if (get_client_memptr(wan_client, cnt)->ipv4_set)
455 			{
456 				IPACMDBG_H("stored IPv4 %x\n", get_client_memptr(wan_client, cnt)->v4_addr);
457 
458 				if(ipv4_addr == get_client_memptr(wan_client, cnt)->v4_addr)
459 				{
460 					IPACMDBG_H("Matched client index: %d\n", cnt);
461 					IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
462 							get_client_memptr(wan_client, cnt)->mac[0],
463 							get_client_memptr(wan_client, cnt)->mac[1],
464 							get_client_memptr(wan_client, cnt)->mac[2],
465 							get_client_memptr(wan_client, cnt)->mac[3],
466 							get_client_memptr(wan_client, cnt)->mac[4],
467 							get_client_memptr(wan_client, cnt)->mac[5]);
468 					IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
469 							get_client_memptr(wan_client, cnt)->ipv4_header_set,
470 							get_client_memptr(wan_client, cnt)->ipv6_header_set);
471 					return cnt;
472 				}
473 			}
474 		}
475 		return IPACM_INVALID_INDEX;
476 	}
477 
get_wan_client_index_ipv6(uint32_t * ipv6_addr)478 	inline int get_wan_client_index_ipv6(uint32_t* ipv6_addr)
479 	{
480 		int cnt, v6_num;
481 		int num_wan_client_tmp = num_wan_client;
482 
483 		IPACMDBG_H("Get ipv6 address 0x%08x.0x%08x.0x%08x.0x%08x\n", ipv6_addr[0], ipv6_addr[1], ipv6_addr[2], ipv6_addr[3]);
484 
485 		for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
486 		{
487 			if (get_client_memptr(wan_client, cnt)->ipv6_set)
488 			{
489 			    for(v6_num=0;v6_num < get_client_memptr(wan_client, cnt)->ipv6_set;v6_num++)
490 	            {
491 
492 					IPACMDBG_H("stored IPv6 0x%08x.0x%08x.0x%08x.0x%08x\n", get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0],
493 						get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1],
494 						get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2],
495 						get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3]);
496 
497 					if(ipv6_addr[0] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0] &&
498 					   ipv6_addr[1] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1] &&
499 					   ipv6_addr[2]== get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2] &&
500 					   ipv6_addr[3] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3])
501 					{
502 						IPACMDBG_H("Matched client index: %d\n", cnt);
503 						IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
504 								get_client_memptr(wan_client, cnt)->mac[0],
505 								get_client_memptr(wan_client, cnt)->mac[1],
506 								get_client_memptr(wan_client, cnt)->mac[2],
507 								get_client_memptr(wan_client, cnt)->mac[3],
508 								get_client_memptr(wan_client, cnt)->mac[4],
509 								get_client_memptr(wan_client, cnt)->mac[5]);
510 						IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
511 								get_client_memptr(wan_client, cnt)->ipv4_header_set,
512 								get_client_memptr(wan_client, cnt)->ipv6_header_set);
513 						return cnt;
514 					}
515 				}
516 			}
517 		}
518 		return IPACM_INVALID_INDEX;
519 	}
520 
delete_wan_rtrules(int clt_indx,ipa_ip_type iptype)521 	inline int delete_wan_rtrules(int clt_indx, ipa_ip_type iptype)
522 	{
523 		uint32_t tx_index;
524 		uint32_t rt_hdl;
525 		int num_v6;
526 
527 		if(iptype == IPA_IP_v4)
528 		{
529 		     for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
530 		     {
531 		        if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
532 			{
533 				IPACMDBG_H("Delete client index %d ipv4 Qos rules for tx:%d \n",clt_indx,tx_index);
534 				rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v4;
535 
536 				if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
537 				{
538 					return IPACM_FAILURE;
539 				}
540 			}
541 		     } /* end of for loop */
542 
543 		     /* clean the 4 Qos ipv4 RT rules for client:clt_indx */
544 		     if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
545 		     {
546 				get_client_memptr(wan_client, clt_indx)->route_rule_set_v4 = false;
547 		     }
548 		}
549 
550 		if(iptype == IPA_IP_v6)
551 		{
552 		    for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
553 		    {
554 
555 				if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
556 				{
557 					for(num_v6 =0;num_v6 < get_client_memptr(wan_client, clt_indx)->route_rule_set_v6;num_v6++)
558 					{
559 						IPACMDBG_H("Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
560 						rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[num_v6];
561 						if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
562 						{
563 							return IPACM_FAILURE;
564 						}
565 
566 						rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6_wan[num_v6];
567 						if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
568 						{
569 							return IPACM_FAILURE;
570 						}
571 					}
572 
573 				}
574 			} /* end of for loop */
575 
576 		    /* clean the 4 Qos ipv6 RT rules for client:clt_indx */
577 		    if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
578 		    {
579 		                 get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 = 0;
580                     }
581 		}
582 
583 		return IPACM_SUCCESS;
584 	}
585 
586 	int handle_wan_hdr_init(uint8_t *mac_addr);
587 	int handle_wan_client_ipaddr(ipacm_event_data_all *data);
588 	int handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
589 
590 	/* handle new_address event */
591 	int handle_addr_evt(ipacm_event_data_addr *data);
592 
593 	/* handle new_address event for q6_mhi */
594 	int handle_addr_evt_mhi_q6(ipacm_event_data_addr *data);
595 
596 	/* wan default route/filter rule configuration */
597 	int handle_route_add_evt(ipa_ip_type iptype);
598 
599 	/* construct complete STA ethernet header */
600 	int handle_sta_header_add_evt();
601 
602 	bool check_dft_firewall_rules_attr_mask(IPACM_firewall_conf_t *firewall_config);
603 
604 #ifdef FEATURE_IPA_ANDROID
605 	/* wan posting supported tether_iface */
606 	int post_wan_up_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
607 
608 	int post_wan_down_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
609 #endif
610 	int config_dft_firewall_rules(ipa_ip_type iptype);
611 
612 	/* configure the initial firewall filter rules */
613 	int config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, ipa_ioc_add_flt_rule *pFilteringTable_v6);
614 
615 	int handle_route_del_evt(ipa_ip_type iptype);
616 
617 	int del_dft_firewall_rules(ipa_ip_type iptype);
618 
619 	int handle_down_evt();
620 
621 	/*handle wan-iface down event */
622 	int handle_down_evt_ex();
623 
624 	/* wan default route/filter rule delete */
625 	int handle_route_del_evt_ex(ipa_ip_type iptype);
626 
627 	/* configure the initial firewall filter rules */
628 	int config_dft_firewall_rules_ex(struct ipa_flt_rule_add* rules, int rule_offset,
629 		ipa_ip_type iptype);
630 
631 	/* init filtering rule in wan dl filtering table */
632 	int init_fl_rule_ex(ipa_ip_type iptype);
633 
634 	/* add ICMP and ALG rules in wan dl filtering table */
635 	int add_icmp_alg_rules(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
636 
637 	/* query extended property */
638 	int query_ext_prop();
639 
640 	ipa_ioc_query_intf_ext_props *ext_prop;
641 
642 	int config_wan_firewall_rule(ipa_ip_type iptype);
643 
644 	int del_wan_firewall_rule(ipa_ip_type iptype);
645 
646 	int add_dft_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
647 
648 	int add_tcpv6_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset);
649 
650 	int install_wan_filtering_rule(bool is_sw_routing);
651 
652 	void handle_wlan_SCC_MCC_switch(bool, ipa_ip_type);
653 
654 	void handle_wan_client_SCC_MCC_switch(bool, ipa_ip_type);
655 
656 	int handle_network_stats_evt();
657 
658 	int m_fd_ipa;
659 
660 	int handle_network_stats_update(ipa_get_apn_data_stats_resp_msg_v01 *data);
661 
662 	/* construct dummy ethernet header */
663 	int add_dummy_rx_hdr();
664 
665 	int handle_coalesce_evt();
666 
667 	int add_offload_frag_rule();
668 
669 	int delete_offload_frag_rule();
670 
671 	int add_icmpv6_exception_rule();
672 
673 	int delete_icmpv6_exception_rule();
674 
675 	int add_tcp_fin_rst_exception_rule();
676 
677 	int delete_tcp_fin_rst_exception_rule();
678 
679 	/* Query mtu size */
680 	int query_mtu_size();
681 };
682 
683 #endif /* IPACM_WAN_H */
684