• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright (c) 2013-2016, 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_iface.h
32 
33 		@brief
34 		This file implements the basis Iface definitions.
35 
36 		@Author
37 		Skylar Chang
38 
39 */
40 #ifndef IPACM_IFACE_H
41 #define IPACM_IFACE_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_Header.h"
49 #include "IPACM_EvtDispatcher.h"
50 #include "IPACM_Xml.h"
51 #include "IPACM_Log.h"
52 #include "IPACM_Config.h"
53 #include "IPACM_Defs.h"
54 #include <string.h>
55 
56 /* current support 2 ipv6-address*/
57 #define MAX_DEFAULT_v4_ROUTE_RULES  1
58 #define MAX_DEFAULT_v6_ROUTE_RULES  2
59 #define IPV4_DEFAULT_FILTERTING_RULES 3
60 
61 #ifdef FEATURE_IPA_ANDROID
62 #define IPV6_DEFAULT_FILTERTING_RULES 6
63 #else
64 #define IPV6_DEFAULT_FILTERTING_RULES 3
65 #endif
66 
67 #define IPV6_DEFAULT_LAN_FILTERTING_RULES 1
68 #define IPV6_NUM_ADDR 3
69 #define MAX_SOFTWAREROUTING_FILTERTING_RULES 2
70 #define INVALID_IFACE -1
71 
72 /* iface */
73 class IPACM_Iface :public IPACM_Listener
74 {
75 public:
76 
77 	/* Static class for reading IPACM configuration from XML file*/
78 	static IPACM_Config *ipacmcfg;
79 
80 	/* IPACM interface id */
81 	int ipa_if_num;
82 
83 	/* IPACM interface category */
84 	ipacm_iface_type ipa_if_cate;
85 
86 	/* IPACM interface name */
87 	char dev_name[IF_NAME_LEN];
88 
89 	/* IPACM interface iptype v4, v6 or both */
90 	ipa_ip_type ip_type;
91 
92 	/* IPACM interface v6 ip-address*/
93 	uint32_t ipv6_addr[MAX_DEFAULT_v6_ROUTE_RULES][4];
94 
95 	uint32_t software_routing_fl_rule_hdl[MAX_SOFTWAREROUTING_FILTERTING_RULES];
96 
97 	bool softwarerouting_act;
98 
99 	/* IPACM number of default route rules for ipv6*/
100 	uint32_t num_dft_rt_v6;
101 
102 	uint32_t dft_v4fl_rule_hdl[IPV4_DEFAULT_FILTERTING_RULES];
103 	uint32_t dft_v6fl_rule_hdl[IPV6_DEFAULT_FILTERTING_RULES + IPV6_DEFAULT_LAN_FILTERTING_RULES];
104 	/* create additional set of v6 RT-rules in Wanv6RT table*/
105 	uint32_t dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+2*MAX_DEFAULT_v6_ROUTE_RULES];
106 
107 	ipa_ioc_query_intf *iface_query;
108 	ipa_ioc_query_intf_tx_props *tx_prop;
109 	ipa_ioc_query_intf_rx_props *rx_prop;
110 
111 	virtual int handle_down_evt() = 0;
112 
113 	virtual int handle_addr_evt(ipacm_event_data_addr *data) = 0;
114 
115 	IPACM_Iface(int iface_index);
116 
117 	virtual void event_callback(ipa_cm_event_id event,
118 															void *data) = 0;
119 
120 	/* Query ipa_interface_index by given linux interface_index */
121 	static int iface_ipa_index_query(int interface_index);
122 
123 	/* Query ipa_interface ipv4_addr by given linux interface_index */
124 	static void iface_addr_query(int interface_index);
125 
126 	/*Query the IPA endpoint property */
127 	int query_iface_property(void);
128 
129 	/*Configure the initial filter rules */
130 	virtual int init_fl_rule(ipa_ip_type iptype);
131 
132 	/* Change IP Type.*/
133 	void config_ip_type(ipa_ip_type iptype);
134 
135 	/* Get interface index */
136 	virtual int ipa_get_if_index(char * if_name, int * if_index);
137 
138 	static IPACM_Routing m_routing;
139 	static IPACM_Filtering m_filtering;
140 	static IPACM_Header m_header;
141 
142 	/* software routing enable */
143 	virtual int handle_software_routing_enable(void);
144 
145 	/* software routing disable */
146 	virtual int handle_software_routing_disable(void);
147 
148 private:
149 
150 	static const char *DEVICE_NAME;
151 };
152 
153 #endif /* IPACM_IFACE_H */
154