1 /*
2 Copyright (c) 2013-2018, 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 %lu %lu %lu %lu"
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 /* wan iface */
93 class IPACM_Wan : public IPACM_Iface
94 {
95 
96 public:
97 
98 	static bool wan_up;
99 	static bool wan_up_v6;
100 	static uint8_t xlat_mux_id;
101 	/* IPACM interface name */
102 	static char wan_up_dev_name[IF_NAME_LEN];
103 	static uint32_t curr_wan_ip;
104 	IPACM_Wan(int, ipacm_wan_iface_type, uint8_t *);
105 	virtual ~IPACM_Wan();
106 
isWanUP(int ipa_if_num_tether)107 	static bool isWanUP(int ipa_if_num_tether)
108 	{
109 #ifdef FEATURE_IPA_ANDROID
110 #ifdef FEATURE_IPACM_HAL
111 		/*To avoid -Wall -Werror error */
112 		IPACMDBG_H("ipa_if_num_tether: %d\n",ipa_if_num_tether);
113 		return wan_up;
114 #else
115 		uint32_t i;
116 		for (i=0; i < ipa_if_num_tether_v4_total;i++)
117 		{
118 			if (ipa_if_num_tether_v4[i] == ipa_if_num_tether)
119 			{
120 				IPACMDBG_H("support ipv4 tether_iface(%s)\n",
121 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
122 				return wan_up;
123 				break;
124 			}
125 		}
126 		return false;
127 #endif
128 #else
129 		return wan_up;
130 #endif
131 	}
132 
isWanUP_V6(int ipa_if_num_tether)133 	static bool isWanUP_V6(int ipa_if_num_tether)
134 	{
135 #ifdef FEATURE_IPA_ANDROID
136 #ifdef FEATURE_IPACM_HAL
137 		/*To avoid -Wall -Werror error */
138 		IPACMDBG_H("ipa_if_num_tether: %d\n",ipa_if_num_tether);
139 		return wan_up_v6;
140 #else
141 		uint32_t i;
142 		for (i=0; i < ipa_if_num_tether_v6_total;i++)
143 		{
144 			if (ipa_if_num_tether_v6[i] == ipa_if_num_tether)
145 			{
146 				IPACMDBG_H("support ipv6 tether_iface(%s)\n",
147 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
148 				return wan_up_v6;
149 				break;
150 			}
151 		}
152 		return false;
153 #endif
154 #else
155 		return wan_up_v6;
156 #endif
157 	}
158 
159 #ifdef FEATURE_IPA_ANDROID
delete_tether_iface(ipa_ip_type iptype,int ipa_if_num_tether)160 	static int delete_tether_iface(ipa_ip_type iptype, int ipa_if_num_tether)
161 	{
162 		uint32_t i, j;
163 
164 		if (iptype == IPA_IP_v4)
165 		{
166 			/* delete support tether ifaces to its array*/
167 			for (i=0; i < IPACM_Wan::ipa_if_num_tether_v4_total; i++)
168 			{
169 				if(IPACM_Wan::ipa_if_num_tether_v4[i] == ipa_if_num_tether)
170 				{
171 					IPACMDBG_H("Found tether client at position %d name(%s)\n", i,
172 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
173 					break;
174 				}
175 			}
176 			if(i == IPACM_Wan::ipa_if_num_tether_v4_total)
177 			{
178 				IPACMDBG_H("Not finding the tethered ipv4 client.\n");
179 				return IPACM_FAILURE;
180 			}
181 			for(j = i+1; j < IPACM_Wan::ipa_if_num_tether_v4_total; j++)
182 			{
183 				IPACM_Wan::ipa_if_num_tether_v4[j-1] = IPACM_Wan::ipa_if_num_tether_v4[j];
184 			}
185 			IPACM_Wan::ipa_if_num_tether_v4_total--;
186 			IPACMDBG_H("Now the total num of ipa_if_num_tether_v4_total is %d\n",
187 				IPACM_Wan::ipa_if_num_tether_v4_total);
188 		}
189 		else
190 		{
191 			/* delete support tether ifaces to its array*/
192 			for (i=0; i < IPACM_Wan::ipa_if_num_tether_v6_total; i++)
193 			{
194 				if(IPACM_Wan::ipa_if_num_tether_v6[i] == ipa_if_num_tether)
195 				{
196 					IPACMDBG_H("Found tether client at position %d name(%s)\n", i,
197 					IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
198 					break;
199 				}
200 			}
201 			if(i == IPACM_Wan::ipa_if_num_tether_v6_total)
202 			{
203 				IPACMDBG_H("Not finding the tethered ipv6 client.\n");
204 				return IPACM_FAILURE;
205 			}
206 			for(j = i+1; j < IPACM_Wan::ipa_if_num_tether_v6_total; j++)
207 			{
208 				IPACM_Wan::ipa_if_num_tether_v6[j-1] = IPACM_Wan::ipa_if_num_tether_v6[j];
209 			}
210 			IPACM_Wan::ipa_if_num_tether_v6_total--;
211 			IPACMDBG_H("Now the total num of ipa_if_num_tether_v6_total is %d\n",
212 				IPACM_Wan::ipa_if_num_tether_v6_total);
213 		}
214 		return IPACM_SUCCESS;
215 	}
216 #endif
217 
getWANIP()218 	static uint32_t getWANIP()
219 	{
220 		return curr_wan_ip;
221 	}
222 
getXlat_Mux_Id()223 	static bool getXlat_Mux_Id()
224 	{
225 		return xlat_mux_id;
226 	}
227 
228 	void event_callback(ipa_cm_event_id event,
229 											void *data);
230 
231 	static struct ipa_flt_rule_add flt_rule_v4[IPA_MAX_FLT_RULE];
232 	static struct ipa_flt_rule_add flt_rule_v6[IPA_MAX_FLT_RULE];
233 
234 	static int num_v4_flt_rule;
235 	static int num_v6_flt_rule;
236 
237 	ipacm_wan_iface_type m_is_sta_mode;
238 	static bool backhaul_is_sta_mode;
239 	static bool is_ext_prop_set;
240 	static uint32_t backhaul_ipv6_prefix[2];
241 
242 	static bool embms_is_on;
243 	static bool backhaul_is_wan_bridge;
244 
isWan_Bridge_Mode()245 	static bool isWan_Bridge_Mode()
246 	{
247 		return backhaul_is_wan_bridge;
248 	}
249 #ifdef FEATURE_IPA_ANDROID
250 	/* IPACM interface id */
251 	static uint32_t ipa_if_num_tether_v4_total;
252 	static int ipa_if_num_tether_v4[IPA_MAX_IFACE_ENTRIES];
253 	static uint32_t ipa_if_num_tether_v6_total;
254 	static int ipa_if_num_tether_v6[IPA_MAX_IFACE_ENTRIES];
255 #endif
256 
257 private:
258 
259 	bool is_ipv6_frag_firewall_flt_rule_installed;
260 	uint32_t ipv6_frag_firewall_flt_rule_hdl;
261 	uint32_t *wan_route_rule_v4_hdl;
262 	uint32_t *wan_route_rule_v6_hdl;
263 	uint32_t *wan_route_rule_v6_hdl_a5;
264 	uint32_t hdr_hdl_sta_v4;
265 	uint32_t hdr_hdl_sta_v6;
266 	uint32_t firewall_hdl_v4[IPACM_MAX_FIREWALL_ENTRIES];
267 	uint32_t firewall_hdl_v6[IPACM_MAX_FIREWALL_ENTRIES];
268 	uint32_t dft_wan_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
269 	uint32_t ipv6_dest_flt_rule_hdl[MAX_DEFAULT_v6_ROUTE_RULES];
270 	int num_ipv6_dest_flt_rule;
271 	uint32_t ODU_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
272 	int num_firewall_v4,num_firewall_v6;
273 	uint32_t wan_v4_addr;
274 	uint32_t wan_v4_addr_gw;
275 	uint32_t wan_v6_addr_gw[4];
276 	bool wan_v4_addr_set;
277 	bool wan_v4_addr_gw_set;
278 	bool wan_v6_addr_gw_set;
279 	bool active_v4;
280 	bool active_v6;
281 	bool header_set_v4;
282 	bool header_set_v6;
283 	bool header_partial_default_wan_v4;
284 	bool header_partial_default_wan_v6;
285 	uint8_t ext_router_mac_addr[IPA_MAC_ADDR_SIZE];
286 	uint8_t netdev_mac[IPA_MAC_ADDR_SIZE];
287 
288 	static int num_ipv4_modem_pdn;
289 
290 	static int num_ipv6_modem_pdn;
291 
292 	int modem_ipv4_pdn_index;
293 
294 	int modem_ipv6_pdn_index;
295 
296 	bool is_default_gateway;
297 
298 	uint32_t ipv6_prefix[2];
299 
300 	/* IPACM firewall Configuration file*/
301 	IPACM_firewall_conf_t firewall_config;
302 
303 	/* STA mode wan-client*/
304 	int wan_client_len;
305 	ipa_wan_client *wan_client;
306 	int header_name_count;
307 	uint32_t num_wan_client;
308 	uint8_t invalid_mac[IPA_MAC_ADDR_SIZE];
309 	bool is_xlat;
310 
311 	/* update network stats for CNE */
312 	int ipa_network_stats_fd;
313 	uint32_t hdr_hdl_dummy_v6;
314 	uint32_t hdr_proc_hdl_dummy_v6;
315 
get_client_memptr(ipa_wan_client * param,int cnt)316 	inline ipa_wan_client* get_client_memptr(ipa_wan_client *param, int cnt)
317 	{
318 	    char *ret = ((char *)param) + (wan_client_len * cnt);
319 		return (ipa_wan_client *)ret;
320 	}
321 
get_wan_client_index(uint8_t * mac_addr)322 	inline int get_wan_client_index(uint8_t *mac_addr)
323 	{
324 		int cnt;
325 		int num_wan_client_tmp = num_wan_client;
326 
327 		IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
328 						 mac_addr[0], mac_addr[1], mac_addr[2],
329 						 mac_addr[3], mac_addr[4], mac_addr[5]);
330 
331 		for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
332 		{
333 			IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
334 							 get_client_memptr(wan_client, cnt)->mac[0],
335 							 get_client_memptr(wan_client, cnt)->mac[1],
336 							 get_client_memptr(wan_client, cnt)->mac[2],
337 							 get_client_memptr(wan_client, cnt)->mac[3],
338 							 get_client_memptr(wan_client, cnt)->mac[4],
339 							 get_client_memptr(wan_client, cnt)->mac[5]);
340 
341 			if(memcmp(get_client_memptr(wan_client, cnt)->mac,
342 								mac_addr,
343 								sizeof(get_client_memptr(wan_client, cnt)->mac)) == 0)
344 			{
345 				IPACMDBG_H("Matched client index: %d\n", cnt);
346 				return cnt;
347 			}
348 		}
349 
350 		return IPACM_INVALID_INDEX;
351 	}
352 
get_wan_client_index_ipv4(uint32_t ipv4_addr)353 	inline int get_wan_client_index_ipv4(uint32_t ipv4_addr)
354 	{
355 		int cnt;
356 		int num_wan_client_tmp = num_wan_client;
357 
358 		IPACMDBG_H("Passed IPv4 %x\n", ipv4_addr);
359 
360 		for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
361 		{
362 			if (get_client_memptr(wan_client, cnt)->ipv4_set)
363 			{
364 				IPACMDBG_H("stored IPv4 %x\n", get_client_memptr(wan_client, cnt)->v4_addr);
365 
366 				if(ipv4_addr == get_client_memptr(wan_client, cnt)->v4_addr)
367 				{
368 					IPACMDBG_H("Matched client index: %d\n", cnt);
369 					IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
370 							get_client_memptr(wan_client, cnt)->mac[0],
371 							get_client_memptr(wan_client, cnt)->mac[1],
372 							get_client_memptr(wan_client, cnt)->mac[2],
373 							get_client_memptr(wan_client, cnt)->mac[3],
374 							get_client_memptr(wan_client, cnt)->mac[4],
375 							get_client_memptr(wan_client, cnt)->mac[5]);
376 					IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
377 							get_client_memptr(wan_client, cnt)->ipv4_header_set,
378 							get_client_memptr(wan_client, cnt)->ipv6_header_set);
379 					return cnt;
380 				}
381 			}
382 		}
383 		return IPACM_INVALID_INDEX;
384 	}
385 
get_wan_client_index_ipv6(uint32_t * ipv6_addr)386 	inline int get_wan_client_index_ipv6(uint32_t* ipv6_addr)
387 	{
388 		int cnt, v6_num;
389 		int num_wan_client_tmp = num_wan_client;
390 
391 		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]);
392 
393 		for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
394 		{
395 			if (get_client_memptr(wan_client, cnt)->ipv6_set)
396 			{
397 			    for(v6_num=0;v6_num < get_client_memptr(wan_client, cnt)->ipv6_set;v6_num++)
398 	            {
399 
400 					IPACMDBG_H("stored IPv6 0x%08x.0x%08x.0x%08x.0x%08x\n", get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0],
401 						get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1],
402 						get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2],
403 						get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3]);
404 
405 					if(ipv6_addr[0] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0] &&
406 					   ipv6_addr[1] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1] &&
407 					   ipv6_addr[2]== get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2] &&
408 					   ipv6_addr[3] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3])
409 					{
410 						IPACMDBG_H("Matched client index: %d\n", cnt);
411 						IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
412 								get_client_memptr(wan_client, cnt)->mac[0],
413 								get_client_memptr(wan_client, cnt)->mac[1],
414 								get_client_memptr(wan_client, cnt)->mac[2],
415 								get_client_memptr(wan_client, cnt)->mac[3],
416 								get_client_memptr(wan_client, cnt)->mac[4],
417 								get_client_memptr(wan_client, cnt)->mac[5]);
418 						IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
419 								get_client_memptr(wan_client, cnt)->ipv4_header_set,
420 								get_client_memptr(wan_client, cnt)->ipv6_header_set);
421 						return cnt;
422 					}
423 				}
424 			}
425 		}
426 		return IPACM_INVALID_INDEX;
427 	}
428 
delete_wan_rtrules(int clt_indx,ipa_ip_type iptype)429 	inline int delete_wan_rtrules(int clt_indx, ipa_ip_type iptype)
430 	{
431 		uint32_t tx_index;
432 		uint32_t rt_hdl;
433 		int num_v6;
434 
435 		if(iptype == IPA_IP_v4)
436 		{
437 		     for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
438 		     {
439 		        if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
440 			{
441 				IPACMDBG_H("Delete client index %d ipv4 Qos rules for tx:%d \n",clt_indx,tx_index);
442 				rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v4;
443 
444 				if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
445 				{
446 					return IPACM_FAILURE;
447 				}
448 			}
449 		     } /* end of for loop */
450 
451 		     /* clean the 4 Qos ipv4 RT rules for client:clt_indx */
452 		     if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
453 		     {
454 				get_client_memptr(wan_client, clt_indx)->route_rule_set_v4 = false;
455 		     }
456 		}
457 
458 		if(iptype == IPA_IP_v6)
459 		{
460 		    for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
461 		    {
462 
463 				if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
464 				{
465 					for(num_v6 =0;num_v6 < get_client_memptr(wan_client, clt_indx)->route_rule_set_v6;num_v6++)
466 					{
467 						IPACMDBG_H("Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
468 						rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[num_v6];
469 						if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
470 						{
471 							return IPACM_FAILURE;
472 						}
473 
474 						rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6_wan[num_v6];
475 						if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
476 						{
477 							return IPACM_FAILURE;
478 						}
479 					}
480 
481 				}
482 			} /* end of for loop */
483 
484 		    /* clean the 4 Qos ipv6 RT rules for client:clt_indx */
485 		    if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
486 		    {
487 		                 get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 = 0;
488                     }
489 		}
490 
491 		return IPACM_SUCCESS;
492 	}
493 
494 	int handle_wan_hdr_init(uint8_t *mac_addr);
495 	int handle_wan_client_ipaddr(ipacm_event_data_all *data);
496 	int handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
497 
498 	/* handle new_address event */
499 	int handle_addr_evt(ipacm_event_data_addr *data);
500 
501 	/* wan default route/filter rule configuration */
502 	int handle_route_add_evt(ipa_ip_type iptype);
503 
504 	/* construct complete STA ethernet header */
505 	int handle_sta_header_add_evt();
506 
507 	bool check_dft_firewall_rules_attr_mask(IPACM_firewall_conf_t *firewall_config);
508 
509 #ifdef FEATURE_IPA_ANDROID
510 	/* wan posting supported tether_iface */
511 	int post_wan_up_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
512 
513 	int post_wan_down_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
514 #endif
515 	int config_dft_firewall_rules(ipa_ip_type iptype);
516 
517 	/* configure the initial firewall filter rules */
518 	int config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, ipa_ioc_add_flt_rule *pFilteringTable_v6);
519 
520 	int handle_route_del_evt(ipa_ip_type iptype);
521 
522 	int del_dft_firewall_rules(ipa_ip_type iptype);
523 
524 	int handle_down_evt();
525 
526 	/*handle wan-iface down event */
527 	int handle_down_evt_ex();
528 
529 	/* wan default route/filter rule delete */
530 	int handle_route_del_evt_ex(ipa_ip_type iptype);
531 
532 	/* configure the initial firewall filter rules */
533 	int config_dft_firewall_rules_ex(struct ipa_flt_rule_add* rules, int rule_offset,
534 		ipa_ip_type iptype);
535 
536 	/* init filtering rule in wan dl filtering table */
537 	int init_fl_rule_ex(ipa_ip_type iptype);
538 
539 	/* add ICMP and ALG rules in wan dl filtering table */
540 	int add_icmp_alg_rules(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
541 
542 	/* query extended property */
543 	int query_ext_prop();
544 
545 	ipa_ioc_query_intf_ext_props *ext_prop;
546 
547 	int config_wan_firewall_rule(ipa_ip_type iptype);
548 
549 	int del_wan_firewall_rule(ipa_ip_type iptype);
550 
551 	int add_dft_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
552 
553 	int add_tcpv6_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset);
554 
555 	int install_wan_filtering_rule(bool is_sw_routing);
556 
557 	void change_to_network_order(ipa_ip_type iptype, ipa_rule_attrib* attrib);
558 
559 	bool is_global_ipv6_addr(uint32_t* ipv6_addr);
560 
561 	void handle_wlan_SCC_MCC_switch(bool, ipa_ip_type);
562 
563 	void handle_wan_client_SCC_MCC_switch(bool, ipa_ip_type);
564 
565 	int handle_network_stats_evt();
566 
567 	int m_fd_ipa;
568 
569 	int handle_network_stats_update(ipa_get_apn_data_stats_resp_msg_v01 *data);
570 
571 	/* construct dummy ethernet header */
572 	int add_dummy_rx_hdr();
573 };
574 
575 #endif /* IPACM_WAN_H */
576