aboutsummaryrefslogtreecommitdiff
path: root/data-ipa-cfg-mgr/ipacm/inc
diff options
context:
space:
mode:
authorFedor917 <cryscript@gmail.com>2016-10-26 00:02:15 +0700
committerFedor917 <cryscript@gmail.com>2016-10-26 00:02:15 +0700
commit4a6f194ca90f6975820d22008fd93af691957cef (patch)
treea88ccfadec9c524a6f5404a2a9ad52dd42c9f563 /data-ipa-cfg-mgr/ipacm/inc
parent514fff9c46d0e960ce1f57d6d38de6a15f6501f4 (diff)
Initial commit
Diffstat (limited to 'data-ipa-cfg-mgr/ipacm/inc')
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h107
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h356
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h104
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h105
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h133
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h362
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h76
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h75
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h70
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h158
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h91
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h518
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h175
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h54
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h100
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h81
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h223
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h77
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h488
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h329
-rw-r--r--data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h299
21 files changed, 3981 insertions, 0 deletions
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h
new file mode 100644
index 0000000..2f7709a
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h
@@ -0,0 +1,107 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_CmdQueue.h
+
+ @brief
+ This file implements the IPAM Comment Queue definitions
+
+ @Author
+
+*/
+#ifndef IPA_CONNTRACK_MESSAGE_H
+#define IPA_CONNTRACK_MESSAGE_H
+
+#include <pthread.h>
+#include "IPACM_Defs.h"
+
+
+
+/*---------------------------------------------------------------------------
+ Event data required by IPA_CM
+---------------------------------------------------------------------------*/
+
+
+typedef struct _ipacm_cmd_q_data {
+ ipa_cm_event_id event;
+ void *evt_data;
+}ipacm_cmd_q_data;
+
+typedef struct cmd_s
+{
+ void (*callback_ptr)(ipacm_cmd_q_data *);
+ ipacm_cmd_q_data data;
+}cmd_t;
+
+class Message
+{
+private:
+ Message *m_next;
+
+public:
+ cmd_t evt;
+
+ Message()
+ {
+ m_next = NULL;
+ evt.callback_ptr = NULL;
+ }
+ ~Message() { }
+ void setnext(Message *item) { m_next = item; }
+ Message* getnext() { return m_next; }
+};
+
+class MessageQueue
+{
+
+private:
+ Message *Head;
+ Message *Tail;
+ Message* dequeue(void);
+ static MessageQueue *inst;
+
+ MessageQueue()
+ {
+ Head = NULL;
+ Tail = NULL;
+ }
+
+public:
+
+ ~MessageQueue() { }
+ void enqueue(Message *item);
+
+ static void* Process(void *);
+ static MessageQueue* getInstance();
+
+};
+
+#endif /* IPA_CONNTRACK_MESSAGE_H */
+
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h
new file mode 100644
index 0000000..665b844
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h
@@ -0,0 +1,356 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Config.h
+
+ @brief
+ This file implements the IPACM Configuration from XML file
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_CONFIG_H
+#define IPACM_CONFIG_H
+
+#include "IPACM_Defs.h"
+#include "IPACM_Xml.h"
+#include "IPACM_EvtDispatcher.h"
+
+typedef struct
+{
+ char iface_name[IPA_IFACE_NAME_LEN];
+}NatIfaces;
+
+/* for IPACM rm dependency use*/
+typedef struct _ipa_rm_client
+{
+ ipa_rm_resource_name producer_rm1;
+ ipa_rm_resource_name consumer_rm1;
+ ipa_rm_resource_name producer_rm2;
+ ipa_rm_resource_name consumer_rm2;
+ bool producer1_up; /* only monitor producer_rm1, not monitor producer_rm2 */
+ bool consumer1_up; /* only monitor consumer_rm1, not monitor consumer_rm2 */
+ bool rm_set; /* once producer1_up and consumer1_up, will add bi-directional dependency */
+ bool rx_bypass_ipa; /* support WLAN may not register RX-property, should not add dependency */
+}ipa_rm_client;
+
+#define MAX_NUM_EXT_PROPS 15
+
+/* used to hold extended properties */
+typedef struct
+{
+ uint8_t num_ext_props;
+ ipa_ioc_ext_intf_prop prop[MAX_NUM_EXT_PROPS];
+} ipacm_ext_prop;
+
+/* iface */
+class IPACM_Config
+{
+public:
+
+ /* IPACM ipa_client map to rm_resource*/
+ ipa_rm_resource_name ipa_client_rm_map_tbl[IPA_CLIENT_MAX];
+
+ /* IPACM monitored rm_depency table */
+ ipa_rm_client ipa_rm_tbl[IPA_MAX_RM_ENTRY];
+
+ /* IPACM rm_depency a2 endpoint check*/
+ int ipa_rm_a2_check;
+
+ /* Store interested interface and their configuration from XML file */
+ ipa_ifi_dev_name_t *iface_table;
+
+ /* Store interested ALG port from XML file */
+ ipacm_alg *alg_table;
+
+ /* Store private subnet configuration from XML file */
+ ipa_private_subnet private_subnet_table[IPA_MAX_PRIVATE_SUBNET_ENTRIES];
+
+ /* Store the non nat iface names */
+ NatIfaces *pNatIfaces;
+
+ /* Store the bridge iface names */
+ char ipa_virtual_iface_name[IPA_IFACE_NAME_LEN];
+
+ /* Store the number of interface IPACM read from XML file */
+ int ipa_num_ipa_interfaces;
+
+ int ipa_num_private_subnet;
+
+ int ipa_num_alg_ports;
+
+ int ipa_nat_max_entries;
+
+ bool ipacm_odu_router_mode;
+
+ bool ipacm_odu_enable;
+
+ bool ipacm_odu_embms_enable;
+
+ int ipa_nat_iface_entries;
+
+ /* Store the total number of wlan guest ap configured */
+ int ipa_num_wlan_guest_ap;
+
+ /* Max valid rm entry */
+ int ipa_max_valid_rm_entry;
+
+ /* Store SW-enable or not */
+ bool ipa_sw_rt_enable;
+
+ /* Store bridge mode or not */
+ bool ipa_bridge_enable;
+
+ /* Store bridge netdev mac */
+ uint8_t bridge_mac[IPA_MAC_ADDR_SIZE];
+
+ /* Store the flt rule count for each producer client*/
+ int flt_rule_count_v4[IPA_CLIENT_CONS - IPA_CLIENT_PROD];
+ int flt_rule_count_v6[IPA_CLIENT_CONS - IPA_CLIENT_PROD];
+
+ /* IPACM routing table name for v4/v6 */
+ struct ipa_ioc_get_rt_tbl rt_tbl_lan_v4, rt_tbl_wan_v4, rt_tbl_default_v4, rt_tbl_v6, rt_tbl_wan_v6;
+ struct ipa_ioc_get_rt_tbl rt_tbl_wan_dl;
+ struct ipa_ioc_get_rt_tbl rt_tbl_lan2lan_v4, rt_tbl_lan2lan_v6;
+ struct ipa_ioc_get_rt_tbl rt_tbl_odu_v4, rt_tbl_odu_v6;
+ struct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_lan_lan_v4, rt_tbl_eth_bridge_lan_wlan_v4, rt_tbl_eth_bridge_wlan_wlan_v4;
+ struct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_lan_lan_v6, rt_tbl_eth_bridge_lan_wlan_v6, rt_tbl_eth_bridge_wlan_wlan_v6;
+
+ bool isMCC_Mode;
+
+ /* To return the instance */
+ static IPACM_Config* GetInstance();
+
+ inline void increaseFltRuleCount(int index, ipa_ip_type iptype, int increment)
+ {
+ if((index >= IPA_CLIENT_CONS - IPA_CLIENT_PROD) || (index < 0))
+ {
+ IPACMERR("Index is out of range: %d.\n", index);
+ return;
+ }
+ if(iptype == IPA_IP_v4)
+ {
+ flt_rule_count_v4[index] += increment;
+ IPACMDBG_H("Now num of v4 flt rules on client %d is %d.\n", index, flt_rule_count_v4[index]);
+ }
+ else
+ {
+ flt_rule_count_v6[index] += increment;
+ IPACMDBG_H("Now num of v6 flt rules on client %d is %d.\n", index, flt_rule_count_v6[index]);
+ }
+ return;
+ }
+
+ inline void decreaseFltRuleCount(int index, ipa_ip_type iptype, int decrement)
+ {
+ if((index >= IPA_CLIENT_CONS - IPA_CLIENT_PROD) || (index < 0))
+ {
+ IPACMERR("Index is out of range: %d.\n", index);
+ return;
+ }
+ if(iptype == IPA_IP_v4)
+ {
+ flt_rule_count_v4[index] -= decrement;
+ IPACMDBG_H("Now num of v4 flt rules on client %d is %d.\n", index, flt_rule_count_v4[index]);
+ }
+ else
+ {
+ flt_rule_count_v6[index] -= decrement;
+ IPACMDBG_H("Now num of v6 flt rules on client %d is %d.\n", index, flt_rule_count_v6[index]);
+ }
+ return;
+ }
+
+ inline int getFltRuleCount(int index, ipa_ip_type iptype)
+ {
+ if((index >= IPA_CLIENT_CONS - IPA_CLIENT_PROD) || (index < 0))
+ {
+ IPACMERR("Index is out of range: %d.\n", index);
+ return -1;
+ }
+ if(iptype == IPA_IP_v4)
+ {
+ return flt_rule_count_v4[index];
+ }
+ else
+ {
+ return flt_rule_count_v6[index];
+ }
+ }
+
+ inline int GetAlgPortCnt()
+ {
+ return ipa_num_alg_ports;
+ }
+
+ int GetAlgPorts(int nPorts, ipacm_alg *pAlgPorts);
+
+ inline int GetNatMaxEntries(void)
+ {
+ return ipa_nat_max_entries;
+ }
+
+ inline int GetNatIfacesCnt()
+ {
+ return ipa_nat_iface_entries;
+ }
+ int GetNatIfaces(int nPorts, NatIfaces *ifaces);
+
+ /* for IPACM resource manager dependency usage */
+ void AddRmDepend(ipa_rm_resource_name rm1,bool rx_bypass_ipa);
+
+ void DelRmDepend(ipa_rm_resource_name rm1);
+
+ int AddNatIfaces(char *dev_name);
+
+ int DelNatIfaces(char *dev_name);
+
+ inline void SetQmapId(uint8_t id)
+ {
+ qmap_id = id;
+ }
+
+ inline uint8_t GetQmapId()
+ {
+ return qmap_id;
+ }
+
+ int SetExtProp(ipa_ioc_query_intf_ext_props *prop);
+
+ ipacm_ext_prop* GetExtProp(ipa_ip_type ip_type);
+
+ int DelExtProp(ipa_ip_type ip_type);
+
+ int Init(void);
+
+ inline bool isPrivateSubnet(uint32_t ip_addr)
+ {
+ for(int cnt=0; cnt<ipa_num_private_subnet; cnt++)
+ {
+ if(private_subnet_table[cnt].subnet_addr ==
+ (private_subnet_table[cnt].subnet_mask & ip_addr))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+#ifdef FEATURE_IPA_ANDROID
+ inline bool AddPrivateSubnet(uint32_t ip_addr, int ipa_if_index)
+ {
+ ipacm_cmd_q_data evt_data;
+ ipacm_event_data_fid *data_fid;
+ uint32_t subnet_mask = ~0;
+ for(int cnt=0; cnt<ipa_num_private_subnet; cnt++)
+ {
+ if(private_subnet_table[cnt].subnet_addr == ip_addr)
+ {
+ IPACMDBG("Already has private subnet_addr as: 0x%x in entry(%d) \n", ip_addr, cnt);
+ return true;
+ }
+ }
+
+ if(ipa_num_private_subnet < IPA_MAX_PRIVATE_SUBNET_ENTRIES)
+ {
+ IPACMDBG("Add IPACM private subnet_addr as: 0x%x in entry(%d) \n", ip_addr, ipa_num_private_subnet);
+ private_subnet_table[ipa_num_private_subnet].subnet_addr = ip_addr;
+ private_subnet_table[ipa_num_private_subnet].subnet_mask = (subnet_mask >> 8) << 8;
+ ipa_num_private_subnet++;
+
+ /* IPACM private subnet set changes */
+ data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
+ if(data_fid == NULL)
+ {
+ IPACMERR("unable to allocate memory for event data_fid\n");
+ return IPACM_FAILURE;
+ }
+ data_fid->if_index = ipa_if_index; // already ipa index, not fid index
+ evt_data.event = IPA_PRIVATE_SUBNET_CHANGE_EVENT;
+ evt_data.evt_data = data_fid;
+
+ /* Insert IPA_PRIVATE_SUBNET_CHANGE_EVENT to command queue */
+ IPACM_EvtDispatcher::PostEvt(&evt_data);
+ return true;
+ }
+ IPACMERR("IPACM private subnet_addr overflow, total entry(%d)\n", ipa_num_private_subnet);
+ return false;
+ }
+
+ inline bool DelPrivateSubnet(uint32_t ip_addr, int ipa_if_index)
+ {
+ ipacm_cmd_q_data evt_data;
+ ipacm_event_data_fid *data_fid;
+ for(int cnt=0; cnt<ipa_num_private_subnet; cnt++)
+ {
+ if(private_subnet_table[cnt].subnet_addr == ip_addr)
+ {
+ IPACMDBG("Found private subnet_addr as: 0x%x in entry(%d) \n", ip_addr, cnt);
+ for (; cnt < ipa_num_private_subnet - 1; cnt++)
+ {
+ private_subnet_table[cnt].subnet_addr = private_subnet_table[cnt+1].subnet_addr;
+ }
+ ipa_num_private_subnet = ipa_num_private_subnet - 1;
+
+ /* IPACM private subnet set changes */
+ data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
+ if(data_fid == NULL)
+ {
+ IPACMERR("unable to allocate memory for event data_fid\n");
+ return IPACM_FAILURE;
+ }
+ data_fid->if_index = ipa_if_index; // already ipa index, not fid index
+ evt_data.event = IPA_PRIVATE_SUBNET_CHANGE_EVENT;
+ evt_data.evt_data = data_fid;
+
+ /* Insert IPA_PRIVATE_SUBNET_CHANGE_EVENT to command queue */
+ IPACM_EvtDispatcher::PostEvt(&evt_data);
+ return true;
+ }
+ }
+ IPACMDBG("can't find private subnet_addr as: 0x%x \n", ip_addr);
+ return false;
+ }
+#endif /* defined(FEATURE_IPA_ANDROID)*/
+
+ static const char *DEVICE_NAME_ODU;
+
+private:
+ static IPACM_Config *pInstance;
+ static const char *DEVICE_NAME;
+ IPACM_Config(void);
+ int m_fd; /* File descriptor of the IPA device node /dev/ipa */
+ uint8_t qmap_id;
+ ipacm_ext_prop ext_prop_v4;
+ ipacm_ext_prop ext_prop_v6;
+};
+
+#endif /* IPACM_CONFIG */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h
new file mode 100644
index 0000000..a6076cf
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h
@@ -0,0 +1,104 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IPACM_CONNTRACK_FILTER_H
+#define IPACM_CONNTRACK_FILTER_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <errno.h>
+
+#include "IPACM_ConntrackClient.h"
+#include "IPACM_CmdQueue.h"
+#include "IPACM_Conntrack_NATApp.h"
+#include "IPACM_EvtDispatcher.h"
+#include "IPACM_Defs.h"
+
+#ifndef IPACM_DEBUG
+#define IPACM_DEBUG
+#endif
+
+extern "C"
+{
+#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
+#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
+#include <sys/inotify.h>
+}
+
+using namespace std;
+
+#define UDP_TIMEOUT_UPDATE 20
+#define BROADCAST_IPV4_ADDR 0xFFFFFFFF
+
+class IPACM_ConntrackClient
+{
+
+private:
+ static IPACM_ConntrackClient *pInstance;
+
+ struct nfct_handle *tcp_hdl;
+ struct nfct_handle *udp_hdl;
+ struct nfct_filter *tcp_filter;
+ struct nfct_filter *udp_filter;
+ static int IPA_Conntrack_Filters_Ignore_Local_Addrs(struct nfct_filter *filter);
+ static int IPA_Conntrack_Filters_Ignore_Bridge_Addrs(struct nfct_filter *filter);
+ static int IPA_Conntrack_Filters_Ignore_Local_Iface(struct nfct_filter *, ipacm_event_iface_up *);
+ IPACM_ConntrackClient();
+
+public:
+ static int IPAConntrackEventCB(enum nf_conntrack_msg_type type,
+ struct nf_conntrack *ct,
+ void *data);
+
+ static int IPA_Conntrack_UDP_Filter_Init(void);
+ static int IPA_Conntrack_TCP_Filter_Init(void);
+ static void* TCPRegisterWithConnTrack(void *);
+ static void* UDPRegisterWithConnTrack(void *);
+ static void* UDPConnTimeoutUpdate(void *);
+
+ static void UpdateUDPFilters(void *, bool);
+ static void UpdateTCPFilters(void *, bool);
+ static void Read_TcpUdp_Timeout(char *in, int len);
+
+ static IPACM_ConntrackClient* GetInstance();
+
+#ifdef IPACM_DEBUG
+#define iptodot(X,Y) \
+ IPACMLOG(" %s(0x%x): %d.%d.%d.%d\n", X, Y, ((Y>>24) & 0xFF), ((Y>>16) & 0xFF), ((Y>>8) & 0xFF), (Y & 0xFF));
+#endif
+
+#define log_nat(A,B,C,D,E,F) \
+ IPACMDBG_H("protocol %d Private IP: %d.%d.%d.%d\t Target IP: %d.%d.%d.%d\t private port: %d public port: %d %s",A,((B>>24) & 0xFF), ((B>>16) & 0xFF), ((B>>8) & 0xFF), (B & 0xFF), ((C>>24) & 0xFF), ((C>>16) & 0xFF),((C>>8) & 0xFF),(C & 0xFF),D,E,F);
+
+};
+
+#endif /* IPACM_CONNTRACK_FILTER_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h
new file mode 100644
index 0000000..db83598
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h
@@ -0,0 +1,105 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef IPACM_CONNTRACK_LISTENER
+#define IPACM_CONNTRACK_LISTENER
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <errno.h>
+
+#include "IPACM_CmdQueue.h"
+#include "IPACM_Conntrack_NATApp.h"
+#include "IPACM_Listener.h"
+#ifdef CT_OPT
+#include "IPACM_LanToLan.h"
+#endif
+
+#define MAX_NAT_IFACES 50
+#define MAX_STA_CLNT_IFACES 10
+
+using namespace std;
+
+class IPACM_ConntrackListener : public IPACM_Listener
+{
+
+private:
+ bool isCTReg;
+ bool isNatThreadStart;
+ bool WanUp;
+ NatApp *nat_inst;
+
+ int NatIfaceCnt;
+ int StaClntCnt;
+ NatIfaces *pNatIfaces;
+ uint32_t nat_iface_ipv4_addr[MAX_NAT_IFACES];
+ uint32_t nonnat_iface_ipv4_addr[MAX_NAT_IFACES];
+ uint32_t sta_clnt_ipv4_addr[MAX_STA_CLNT_IFACES];
+ IPACM_Config *pConfig;
+#ifdef CT_OPT
+ IPACM_LanToLan *p_lan2lan;
+#endif
+
+ void ProcessCTMessage(void *);
+ void ProcessTCPorUDPMsg(struct nf_conntrack *,
+ enum nf_conntrack_msg_type, u_int8_t);
+ void TriggerWANUp(void *);
+ void TriggerWANDown(uint32_t);
+ int CreateNatThreads(void);
+ int CreateConnTrackThreads(void);
+
+#ifdef CT_OPT
+ void ProcessCTV6Message(void *);
+#endif
+
+public:
+ char wan_ifname[IPA_IFACE_NAME_LEN];
+ uint32_t wan_ipaddr;
+ bool isStaMode;
+ IPACM_ConntrackListener();
+ void event_callback(ipa_cm_event_id, void *data);
+ inline bool isWanUp()
+ {
+ return WanUp;
+ }
+
+ void HandleNeighIpAddrAddEvt(ipacm_event_data_all *);
+ void HandleNeighIpAddrDelEvt(uint32_t);
+ void HandleSTAClientAddEvt(uint32_t);
+ void HandleSTAClientDelEvt(uint32_t);
+};
+
+extern IPACM_ConntrackListener *CtList;
+
+#endif /* IPACM_CONNTRACK_LISTENER */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h
new file mode 100644
index 0000000..e6c27af
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h
@@ -0,0 +1,133 @@
+/*
+Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef IPACM_CONNTRACK_NATAPP_H
+#define IPACM_CONNTRACK_NATAPP_H
+
+#include <string.h> /* for stderror */
+#include <stdlib.h>
+#include <cstdio> /* for perror */
+
+#include "IPACM_Config.h"
+#include "IPACM_Xml.h"
+
+extern "C"
+{
+#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
+#include <ipa_nat_drv.h>
+}
+
+#define MAX_TEMP_ENTRIES 25
+
+#define IPACM_TCP_FULL_FILE_NAME "/proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established"
+#define IPACM_UDP_FULL_FILE_NAME "/proc/sys/net/ipv4/netfilter/ip_conntrack_udp_timeout_stream"
+
+typedef struct _nat_table_entry
+{
+ uint32_t private_ip;
+ uint16_t private_port;
+
+ uint32_t target_ip;
+ uint16_t target_port;
+
+ uint32_t public_ip;
+ uint16_t public_port;
+
+ u_int8_t protocol;
+ uint32_t timestamp;
+
+ bool dst_nat;
+ bool enabled;
+ uint32_t rule_hdl;
+
+}nat_table_entry;
+
+#define CHK_TBL_HDL() if(nat_table_hdl == 0){ return -1; }
+
+class NatApp
+{
+private:
+
+ static NatApp *pInstance;
+
+ nat_table_entry *cache;
+ nat_table_entry temp[MAX_TEMP_ENTRIES];
+ uint32_t pub_ip_addr;
+ uint32_t pub_ip_addr_pre;
+ uint32_t nat_table_hdl;
+
+ int curCnt, max_entries;
+
+ ipacm_alg *pALGPorts;
+ uint16_t nALGPort;
+
+ uint32_t tcp_timeout;
+ uint32_t udp_timeout;
+
+ uint32_t PwrSaveIfs[IPA_MAX_NUM_WIFI_CLIENTS];
+
+ struct nf_conntrack *ct;
+ struct nfct_handle *ct_hdl;
+
+ NatApp();
+ int Init();
+
+ void UpdateCTUdpTs(nat_table_entry *, uint32_t);
+ bool ChkForDup(const nat_table_entry *);
+ bool isAlgPort(uint8_t, uint16_t);
+ void Reset();
+ bool isPwrSaveIf(uint32_t);
+
+public:
+ static NatApp* GetInstance();
+
+ int AddTable(uint32_t);
+ uint32_t GetTableHdl(uint32_t);
+ int DeleteTable(uint32_t);
+
+ int AddEntry(const nat_table_entry *);
+ int DeleteEntry(const nat_table_entry *);
+
+ void UpdateUDPTimeStamp();
+
+ int UpdatePwrSaveIf(uint32_t);
+ int ResetPwrSaveIf(uint32_t);
+ int DelEntriesOnClntDiscon(uint32_t);
+ int DelEntriesOnSTAClntDiscon(uint32_t);
+
+ void Read_TcpUdp_Timeout(void);
+
+ void AddTempEntry(const nat_table_entry *);
+ void CacheEntry(const nat_table_entry *);
+ void DeleteTempEntry(const nat_table_entry *);
+ void FlushTempEntries(uint32_t, bool);
+};
+
+
+
+#endif /* IPACM_CONNTRACK_NATAPP_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h
new file mode 100644
index 0000000..677b122
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h
@@ -0,0 +1,362 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Defs.h
+
+ @brief
+ This file implements the common definitions amon all ifaces.
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPA_CM_DEFS_H
+#define IPA_CM_DEFS_H
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <linux/msm_ipa.h>
+#include "IPACM_Log.h"
+
+extern "C"
+{
+#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
+#include <libnetfilter_conntrack/libnetfilter_conntrack_tcp.h>
+}
+
+#define IF_NAME_LEN 16
+#define IPA_MAX_FILE_LEN 64
+#define IPA_IFACE_NAME_LEN 16
+#define IPA_ALG_PROTOCOL_NAME_LEN 10
+
+#define IPA_WLAN_PARTIAL_HDR_OFFSET 0 // dst mac first then src mac
+//#define IPA_ETH_PARTIAL_HDR_OFFSET 8 // dst mac first then src mac
+#define IPA_ODU_PARTIAL_HDR_OFFSET 8 // dst mac first then src mac
+#define IPA_WLAN_PARTIAL_HDR_NAME_v4 "IEEE802_3_v4"
+#define IPA_WLAN_PARTIAL_HDR_NAME_v6 "IEEE802_3_v6"
+#define IPA_WAN_PARTIAL_HDR_NAME_v4 "IEEE802_3_STA_v4"
+#define IPA_WAN_PARTIAL_HDR_NAME_v6 "IEEE802_3_STA_v6"
+#define IPA_ETH_HDR_NAME_v4 "IPACM_ETH_v4"
+#define IPA_ETH_HDR_NAME_v6 "IPACM_ETH_v6"
+#define IPA_ODU_HDR_NAME_v4 "IPACM_ODU_v4"
+#define IPA_ODU_HDR_NAME_v6 "IPACM_ODU_v6"
+
+
+#define IPA_MAX_IFACE_ENTRIES 15
+#define IPA_MAX_PRIVATE_SUBNET_ENTRIES 3
+#define IPA_MAX_ALG_ENTRIES 20
+#define IPA_MAX_RM_ENTRY 6
+
+#define IPV4_ADDR_LINKLOCAL 0xA9FE0000
+#define IPV4_ADDR_LINKLOCAL_MASK 0xFFFF0000
+
+#define V4_DEFAULT_ROUTE_TABLE_NAME "ipa_dflt_rt"
+#define V4_LAN_ROUTE_TABLE_NAME "COMRTBLLANv4"
+#define V4_WAN_ROUTE_TABLE_NAME "WANRTBLv4"
+#define WAN_DL_ROUTE_TABLE_NAME "ipa_dflt_wan_rt"
+#define V6_COMMON_ROUTE_TABLE_NAME "COMRTBLv6"
+#define V6_WAN_ROUTE_TABLE_NAME "WANRTBLv6"
+#define V4_LAN_TO_LAN_ROUTE_TABLE_NAME "LANTOLANRTBLv4"
+#define V6_LAN_TO_LAN_ROUTE_TABLE_NAME "LANTOLANRTBLv6"
+#define V4_ODU_ROUTE_TABLE_NAME "ODURTBLv4"
+#define V6_ODU_ROUTE_TABLE_NAME "ODURTBLv6"
+
+#define ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_LAN_LAN_RTBLv4"
+#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_LAN_WLAN_RTBLv4"
+#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_WLAN_WLAN_RTBLv4"
+#define ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_LAN_LAN_RTBLv6"
+#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_LAN_WLAN_RTBLv6"
+#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_WLAN_WLAN_RTBLv6"
+
+#define WWAN_QMI_IOCTL_DEVICE_NAME "/dev/wwan_ioctl"
+#define IPA_DEVICE_NAME "/dev/ipa"
+#define IPA_MAX_FLT_RULE 50
+
+#define MAX_OFFLOAD_PAIR 3
+#define MAX_NUM_PROP 8
+#define IPA_LAN_TO_LAN_USB_HDR_NAME_V4 "Lan2Lan_USB_v4"
+#define IPA_LAN_TO_LAN_USB_HDR_NAME_V6 "Lan2Lan_USB_v6"
+#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V4 "Lan2Lan_Wlan_v4"
+#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V6 "Lan2Lan_Wlan_v6"
+#define IPA_LAN_TO_LAN_MAX_WLAN_CLIENT 16
+#define IPA_LAN_TO_LAN_MAX_USB_CLIENT 1
+#define IPA_LAN_TO_LAN_MAX_CPE_CLIENT 15
+#define IPA_LAN_TO_LAN_MAX_LAN_CLIENT (IPA_LAN_TO_LAN_MAX_USB_CLIENT + IPA_LAN_TO_LAN_MAX_CPE_CLIENT)
+#define TCP_FIN_SHIFT 16
+#define TCP_SYN_SHIFT 17
+#define TCP_RST_SHIFT 18
+#define NUM_TCP_CTL_FLT_RULE 3
+#define NUM_IPV6_PREFIX_FLT_RULE 1
+
+/*---------------------------------------------------------------------------
+ Return values indicating error status
+---------------------------------------------------------------------------*/
+
+#define IPACM_SUCCESS 0 /* Successful operation */
+#define IPACM_FAILURE -1 /* Unsuccessful operation */
+
+#define IPACM_IP_NULL (ipa_ip_type)0xFF
+#define IPACM_INVALID_INDEX (ipa_ip_type)0xFF
+
+#define IPA_MAX_NUM_WIFI_CLIENTS 32
+#define IPA_MAX_NUM_WAN_CLIENTS 10
+#define IPA_MAX_NUM_ETH_CLIENTS 15
+#define IPA_MAX_NUM_AMPDU_RULE 15
+#define IPA_MAC_ADDR_SIZE 6
+
+/*===========================================================================
+ GLOBAL DEFINITIONS AND DECLARATIONS
+===========================================================================*/
+typedef enum
+{
+ IPA_CFG_CHANGE_EVENT = 1, /* 1 NULL */
+ IPA_LINK_UP_EVENT, /* 2 ipacm_event_data_fid */
+ IPA_LINK_DOWN_EVENT, /* 3 ipacm_event_data_fid */
+ IPA_ADDR_ADD_EVENT, /* 4 ipacm_event_data_addr */
+ IPA_ADDR_DEL_EVENT, /* 5 no use */
+ IPA_ROUTE_ADD_EVENT, /* 6 ipacm_event_data_addr */
+ IPA_ROUTE_DEL_EVENT, /* 7 ipacm_event_data_addr */
+ IPA_FIREWALL_CHANGE_EVENT, /* 8 NULL */
+ IPA_WLAN_AP_LINK_UP_EVENT, /* 9 ipacm_event_data_mac */
+ IPA_WLAN_STA_LINK_UP_EVENT, /* 10 ipacm_event_data_mac */
+ IPA_WLAN_CLIENT_ADD_EVENT, /* 11 ipacm_event_data_mac */
+ IPA_WLAN_CLIENT_DEL_EVENT, /* 12 ipacm_event_data_mac */
+ IPA_WLAN_CLIENT_POWER_SAVE_EVENT, /* 13 ipacm_event_data_mac */
+ IPA_WLAN_CLIENT_RECOVER_EVENT, /* 14 ipacm_event_data_mac */
+ IPA_NEW_NEIGH_EVENT, /* 15 ipacm_event_data_all */
+ IPA_DEL_NEIGH_EVENT, /* 16 ipacm_event_data_all */
+ IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, /* 17 ipacm_event_data_all */
+ IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, /* 18 ipacm_event_data_all */
+ IPA_SW_ROUTING_ENABLE, /* 19 NULL */
+ IPA_SW_ROUTING_DISABLE, /* 20 NULL */
+ IPA_PROCESS_CT_MESSAGE, /* 21 ipacm_ct_evt_data */
+ IPA_HANDLE_WAN_UP, /* 22 ipacm_event_iface_up */
+ IPA_HANDLE_WAN_DOWN, /* 23 ipacm_event_iface_up */
+ IPA_HANDLE_WLAN_UP, /* 24 ipacm_event_iface_up */
+ IPA_HANDLE_LAN_UP, /* 25 ipacm_event_iface_up */
+ IPA_WLAN_CLIENT_ADD_EVENT_EX, /* 26 ipacm_event_data_wlan_ex */
+ IPA_HANDLE_WAN_UP_V6, /* 27 NULL */
+ IPA_HANDLE_WAN_DOWN_V6, /* 28 NULL */
+ IPA_LAN_CLIENT_ACTIVE, /* 29 ipacm_event_lan_client*/
+ IPA_LAN_CLIENT_INACTIVE, /* 30 ipacm_event_lan_client*/
+ IPA_LAN_CLIENT_DISCONNECT, /* 31 ipacm_event_lan_client*/
+ IPA_LAN_CLIENT_POWER_SAVE, /* 32 ipacm_event_lan_client*/
+ IPA_LAN_CLIENT_POWER_RECOVER, /* 33 ipacm_event_lan_client*/
+ IPA_LAN_TO_LAN_NEW_CONNECTION, /* 34 ipacm_event_connection */
+ IPA_LAN_TO_LAN_DEL_CONNECTION, /* 35 ipacm_event_connection */
+ IPA_LAN_DELETE_SELF, /* 36 ipacm_event_data_fid */
+ IPA_WLAN_LINK_DOWN_EVENT, /* 37 ipacm_event_data_mac */
+ IPA_USB_LINK_UP_EVENT, /* 38 ipacm_event_data_fid */
+ IPA_PROCESS_CT_MESSAGE_V6, /* 39 ipacm_ct_evt_data */
+ IPA_PRIVATE_SUBNET_CHANGE_EVENT, /* 40 ipacm_event_data_fid */
+ IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT, /* 41 ipacm_event_data_fid */
+ IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, /* 42 ipacm_event_data_fid */
+ IPA_WAN_EMBMS_LINK_UP_EVENT, /* 43 ipacm_event_data_mac */
+ IPA_ETH_BRIDGE_LAN_CLIENT_ADD_EVENT, /* 44 ipacm_event_data_mac */
+ IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT, /* 45 ipacm_event_data_mac */
+ IPA_ETH_BRIDGE_LAN_CLIENT_DEL_EVENT, /* 46 ipacm_event_data_mac */
+ IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT, /* 47 ipacm_event_data_mac */
+ IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT, /* 48 ipacm_event_data_if_cat */
+ IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT, /* 49 ipacm_event_data_if_cat */
+ IPA_WLAN_SWITCH_TO_SCC, /* 50 No Data */
+ IPA_WLAN_SWITCH_TO_MCC, /* 51 No Data */
+ IPA_CRADLE_WAN_MODE_SWITCH, /* 52 ipacm_event_cradle_wan_mode */
+ IPA_WAN_XLAT_CONNECT_EVENT, /* 53 ipacm_event_data_fid */
+ IPA_TETHERING_STATS_UPDATE_EVENT, /* 54 ipacm_event_data_fid */
+ IPA_NETWORK_STATS_UPDATE_EVENT, /* 55 ipacm_event_data_fid */
+ IPA_HANDLE_WAN_UP_TETHER, /* 56 ipacm_event_iface_up_tehter */
+ IPA_HANDLE_WAN_DOWN_TETHER, /* 57 ipacm_event_iface_up_tehter */
+ IPA_HANDLE_WAN_UP_V6_TETHER, /* 58 ipacm_event_iface_up_tehter */
+ IPA_HANDLE_WAN_DOWN_V6_TETHER, /* 59 ipacm_event_iface_up_tehter */
+ IPA_BRIDGE_LINK_UP_EVENT, /* 60 ipacm_event_data_all */
+ IPACM_EVENT_MAX
+} ipa_cm_event_id;
+
+typedef struct
+{
+ uint8_t num_rule;
+ uint32_t rule_hdl[MAX_NUM_PROP];
+} lan_to_lan_rt_rule_hdl;
+
+typedef enum
+{
+ LAN_IF = 0,
+ WLAN_IF,
+ WAN_IF,
+ VIRTUAL_IF,
+ ETH_IF,
+ EMBMS_IF,
+ ODU_IF,
+ UNKNOWN_IF
+} ipacm_iface_type;
+
+typedef enum
+{
+ ROUTER = 0,
+ BRIDGE
+} ipacm_cradle_iface_mode;
+
+typedef enum
+{
+ FULL,
+ INTERNET
+} ipacm_wlan_access_mode;
+
+typedef struct
+{
+ struct nf_conntrack *ct;
+ enum nf_conntrack_msg_type type;
+}ipacm_ct_evt_data;
+
+typedef struct
+{
+ char iface_name[IPA_IFACE_NAME_LEN];
+ ipacm_iface_type if_cat;
+ ipacm_cradle_iface_mode if_mode;
+ ipacm_wlan_access_mode wlan_mode;
+ int netlink_interface_index;
+} ipa_ifi_dev_name_t;
+
+typedef struct
+{
+ uint32_t subnet_addr;
+ uint32_t subnet_mask;
+} ipa_private_subnet;
+
+
+typedef struct _ipacm_event_data_all
+{
+ enum ipa_ip_type iptype;
+ int if_index;
+ uint32_t ipv4_addr;
+ uint32_t ipv6_addr[4];
+ uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
+} ipacm_event_data_all;
+
+class IPACM_Lan;
+
+typedef struct
+{
+ ipacm_cradle_iface_mode cradle_wan_mode;
+} ipacm_event_cradle_wan_mode;
+
+typedef struct
+{
+ enum ipa_ip_type iptype;
+ uint32_t ipv4_addr;
+ uint32_t ipv6_addr[4];
+ uint8_t mac_addr[6];
+ IPACM_Lan* p_iface;
+} ipacm_event_lan_client;
+
+typedef struct
+{
+ enum ipa_ip_type iptype;
+ uint32_t src_ipv4_addr;
+ uint32_t dst_ipv4_addr;
+ uint32_t src_ipv6_addr[4];
+ uint32_t dst_ipv6_addr[4];
+} ipacm_event_connection;
+
+typedef struct _ipacm_event_data_fid
+{
+ int if_index;
+} ipacm_event_data_fid;
+
+typedef struct
+{
+ ipacm_iface_type if_cat;
+} ipacm_event_data_if_cat;
+
+typedef struct _ipacm_event_data_iptype
+{
+ int if_index;
+ int if_index_tether;
+ enum ipa_ip_type iptype;
+} ipacm_event_data_iptype;
+
+
+typedef struct _ipacm_event_data_addr
+{
+ enum ipa_ip_type iptype;
+ int if_index;
+ uint32_t ipv4_addr_gw;
+ uint32_t ipv4_addr;
+ uint32_t ipv4_addr_mask;
+ uint32_t ipv6_addr[4];
+ uint32_t ipv6_addr_mask[4];
+ uint32_t ipv6_addr_gw[4];
+} ipacm_event_data_addr;
+
+typedef struct _ipacm_event_data_mac
+{
+ int if_index;
+ uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
+} ipacm_event_data_mac;
+
+typedef struct
+{
+ int if_index;
+ uint8_t num_of_attribs;
+ struct ipa_wlan_hdr_attrib_val attribs[0];
+} ipacm_event_data_wlan_ex;
+
+typedef struct _ipacm_event_iface_up
+{
+ char ifname[IPA_IFACE_NAME_LEN];
+ uint32_t ipv4_addr;
+ uint32_t addr_mask;
+ uint32_t ipv6_prefix[2];
+ bool is_sta;
+ uint8_t xlat_mux_id;
+}ipacm_event_iface_up;
+
+typedef struct _ipacm_event_iface_up_tether
+{
+ uint32_t if_index_tether;
+ uint32_t ipv6_prefix[2];
+ bool is_sta;
+}ipacm_event_iface_up_tehter;
+
+typedef enum
+{
+ Q6_WAN = 0,
+ WLAN_WAN,
+ ECM_WAN
+} ipacm_wan_iface_type;
+
+typedef struct _ipacm_ifacemgr_data
+{
+ int if_index;
+ ipacm_wan_iface_type if_type;
+ uint8_t mac_addr[IPA_MAC_ADDR_SIZE];
+}ipacm_ifacemgr_data;
+
+#endif /* IPA_CM_DEFS_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h
new file mode 100644
index 0000000..550f4d4
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h
@@ -0,0 +1,76 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*!
+ @file
+ IPACM_EvtDispatcher.h
+
+ @brief
+ This file implements the IPAM event dispatcher definitions
+
+ @Author
+
+*/
+#ifndef IPACM_EvtDispatcher_H
+#define IPACM_EvtDispatcher_H
+
+#include <stdio.h>
+#include <IPACM_CmdQueue.h>
+#include "IPACM_Defs.h"
+#include "IPACM_Listener.h"
+
+/* queue */
+typedef struct _cmd_evts
+{
+ ipa_cm_event_id event;
+ IPACM_Listener *obj;
+ //int ipa_interface_index;
+ _cmd_evts *next;
+} cmd_evts;
+
+
+
+class IPACM_EvtDispatcher
+{
+public:
+
+ /* api for all iface instances to register events */
+ static int registr(ipa_cm_event_id event, IPACM_Listener *obj);
+
+ /* api for all iface instances to de-register events */
+ static int deregistr(IPACM_Listener *obj);
+
+ static int PostEvt(ipacm_cmd_q_data *);
+ static void ProcessEvt(ipacm_cmd_q_data *);
+
+private:
+ static cmd_evts *head;
+};
+
+#endif /* IPACM_EvtDispatcher_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h
new file mode 100644
index 0000000..7554ba9
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h
@@ -0,0 +1,75 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*!
+ @file
+ IPACM_Filtering.h
+
+ @brief
+ This file implements the IPACM filtering definitions
+
+ @Author
+ Skylar Chang
+
+*/
+
+#ifndef IPACM_FILTERING_H
+#define IPACM_FILTERING_H
+
+#include <stdint.h>
+#include <linux/msm_ipa.h>
+#include <IPACM_Defs.h>
+#include <linux/rmnet_ipa_fd_ioctl.h>
+
+class IPACM_Filtering
+{
+public:
+ IPACM_Filtering();
+ ~IPACM_Filtering();
+ bool AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTable);
+ bool DeleteFilteringRule(struct ipa_ioc_del_flt_rule *ruleTable);
+ bool Commit(enum ipa_ip_type ip);
+ bool Reset(enum ipa_ip_type ip);
+ bool DeviceNodeIsOpened();
+ bool DeleteFilteringHdls(uint32_t *flt_rule_hdls,
+ ipa_ip_type ip,
+ uint8_t num_rules);
+
+ bool AddWanDLFilteringRule(struct ipa_ioc_add_flt_rule const *rule_table_v4, struct ipa_ioc_add_flt_rule const * rule_table_v6, uint8_t mux_id);
+ bool SendFilteringRuleIndex(struct ipa_fltr_installed_notif_req_msg_v01* table);
+ bool ModifyFilteringRule(struct ipa_ioc_mdfy_flt_rule* ruleTable);
+ ipa_filter_action_enum_v01 GetQmiFilterAction(ipa_flt_action action);
+
+private:
+ static const char *DEVICE_NAME;
+ int fd; /* File descriptor of the IPA device node /dev/ipa */
+};
+
+#endif //IPACM_FILTERING_H
+
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h
new file mode 100644
index 0000000..027c8ff
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h
@@ -0,0 +1,70 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ * IPACM_Header.h
+ *
+ * Created on: Jun 20, 2012
+ * Author: tatias
+ */
+
+//////////////////////////////////////////////////////////////////////////////////
+
+#ifndef IPACM_HEADER_H
+#define IPACM_HEADER_H
+
+#include <stdint.h>
+#include "linux/msm_ipa.h"
+
+//////////////////////////////////////////////////////////////////////////////////
+
+class IPACM_Header
+{
+private:
+ int m_fd;
+public:
+ bool AddHeader(struct ipa_ioc_add_hdr *pHeaderTable);
+ bool DeleteHeader(struct ipa_ioc_del_hdr *pHeaderTable);
+ bool GetHeaderHandle(struct ipa_ioc_get_hdr *pHeaderStruct);
+ bool CopyHeader(struct ipa_ioc_copy_hdr *pCopyHeaderStruct);
+ bool Commit();
+ bool Reset();
+ bool DeleteHeaderHdl(uint32_t hdr_hdl);
+ bool AddHeaderProcCtx(struct ipa_ioc_add_hdr_proc_ctx* pHeader);
+ bool DeleteHeaderProcCtx(uint32_t hdl);
+
+ IPACM_Header();
+ ~IPACM_Header();
+ bool DeviceNodeIsOpened();
+};
+
+
+#endif
+
+
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h
new file mode 100644
index 0000000..efcaa63
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h
@@ -0,0 +1,158 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_iface.h
+
+ @brief
+ This file implements the basis Iface definitions.
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_IFACE_H
+#define IPACM_IFACE_H
+
+#include <stdio.h>
+#include <IPACM_CmdQueue.h>
+#include <linux/msm_ipa.h>
+#include "IPACM_Routing.h"
+#include "IPACM_Filtering.h"
+#include "IPACM_Header.h"
+#include "IPACM_EvtDispatcher.h"
+#include "IPACM_Xml.h"
+#include "IPACM_Log.h"
+#include "IPACM_Config.h"
+#include "IPACM_Defs.h"
+#include <string.h>
+
+/* current support 2 ipv6-address*/
+#define MAX_DEFAULT_v4_ROUTE_RULES 1
+#define MAX_DEFAULT_v6_ROUTE_RULES 2
+#define IPV4_DEFAULT_FILTERTING_RULES 3
+
+#ifdef FEATURE_IPA_ANDROID
+#define IPV6_DEFAULT_FILTERTING_RULES 6
+#else
+#define IPV6_DEFAULT_FILTERTING_RULES 3
+#endif
+
+#define IPV6_DEFAULT_LAN_FILTERTING_RULES 1
+#define IPV6_NUM_ADDR 3
+#define MAX_SOFTWAREROUTING_FILTERTING_RULES 2
+#define INVALID_IFACE -1
+
+/* iface */
+class IPACM_Iface :public IPACM_Listener
+{
+public:
+
+ /* Static class for reading IPACM configuration from XML file*/
+ static IPACM_Config *ipacmcfg;
+
+ /* IPACM interface id */
+ int ipa_if_num;
+
+ /* IPACM interface category */
+ int ipa_if_cate;
+
+ /* IPACM interface name */
+ char dev_name[IF_NAME_LEN];
+
+ /* IPACM interface iptype v4, v6 or both */
+ ipa_ip_type ip_type;
+
+ /* IPACM interface v6 ip-address*/
+ uint32_t ipv6_addr[MAX_DEFAULT_v6_ROUTE_RULES][4];
+
+ uint32_t header_hdl;
+
+ uint32_t software_routing_fl_rule_hdl[MAX_SOFTWAREROUTING_FILTERTING_RULES];
+
+ bool softwarerouting_act;
+
+ /* IPACM number of default route rules for ipv6*/
+ int num_dft_rt_v6;
+
+ uint32_t dft_v4fl_rule_hdl[IPV4_DEFAULT_FILTERTING_RULES];
+ uint32_t dft_v6fl_rule_hdl[IPV6_DEFAULT_FILTERTING_RULES + IPV6_DEFAULT_LAN_FILTERTING_RULES];
+ /* create additional set of v6 RT-rules in Wanv6RT table*/
+ uint32_t dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+2*MAX_DEFAULT_v6_ROUTE_RULES];
+
+ ipa_ioc_query_intf *iface_query;
+ ipa_ioc_query_intf_tx_props *tx_prop;
+ ipa_ioc_query_intf_rx_props *rx_prop;
+
+ virtual int handle_down_evt() = 0;
+
+ virtual int handle_addr_evt(ipacm_event_data_addr *data) = 0;
+
+ IPACM_Iface(int iface_index);
+
+ virtual void event_callback(ipa_cm_event_id event,
+ void *data) = 0;
+
+ /* Query ipa_interface_index by given linux interface_index */
+ static int iface_ipa_index_query(int interface_index);
+
+ /* Query ipa_interface ipv4_addr by given linux interface_index */
+ static void iface_addr_query(int interface_index);
+
+ /*Query the IPA endpoint property */
+ int query_iface_property(void);
+
+ /*implement IPACM strlcpy */
+ size_t strlcpy(char *dest, const char *src, size_t size);
+
+ /*implement IPACM strlcat */
+ size_t strlcat(char *dest, const char *src, size_t n);
+
+ /*Configure the initial filter rules */
+ virtual int init_fl_rule(ipa_ip_type iptype);
+
+ /* Get interface index */
+ virtual int ipa_get_if_index(char * if_name, int * if_index);
+
+ 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 disable */
+ virtual int handle_software_routing_disable(void);
+
+private:
+
+ static const char *DEVICE_NAME;
+};
+
+#endif /* IPACM_IFACE_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h
new file mode 100644
index 0000000..e65c5d5
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h
@@ -0,0 +1,91 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_IfaceManager.h
+
+ @brief
+ This file implements the IPAM iface_manager definitions
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_IFACEMANAGER_H
+#define IPACM_IFACEMANAGER_H
+
+#include <stdio.h>
+#include <IPACM_CmdQueue.h>
+
+#include "IPACM_Routing.h"
+#include "IPACM_Filtering.h"
+#include "IPACM_Listener.h"
+#include "IPACM_Iface.h"
+
+#define IPA_MAX_NUM_NEIGHBOR_CLIENTS 17
+#define IPA_INSTANCE_NOT_FOUND 0
+#define IPA_INSTANCE_FOUND 1
+
+/* queue */
+typedef struct _iface_instances
+{
+ /* Linux interface id */
+ int ipa_if_index;
+ IPACM_Listener *obj;
+ _iface_instances *next;
+} iface_instances;
+
+
+class IPACM_IfaceManager : public IPACM_Listener
+{
+
+public:
+
+ IPACM_IfaceManager();
+
+ void event_callback(ipa_cm_event_id event,
+ void *data);
+
+ /* api for all iface instances to de-register instances */
+ static int deregistr(IPACM_Listener *param);
+
+
+private:
+ int create_iface_instance(ipacm_ifacemgr_data *);
+
+ /* api to register instances */
+ int registr(int ipa_if_index, IPACM_Listener *obj);
+
+ int SearchInstance(int ipa_if_index);
+
+ static iface_instances *head;
+
+};
+
+#endif /* IPACM_IFACEMANAGER_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h
new file mode 100644
index 0000000..a210255
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h
@@ -0,0 +1,518 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Lan.h
+
+ @brief
+ This file implements the LAN iface definitions
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_LAN_H
+#define IPACM_LAN_H
+
+#include <stdio.h>
+#include <linux/msm_ipa.h>
+
+#include "IPACM_CmdQueue.h"
+#include "IPACM_Iface.h"
+#include "IPACM_Routing.h"
+#include "IPACM_Filtering.h"
+#include "IPACM_Config.h"
+#include "IPACM_Conntrack_NATApp.h"
+
+#define IPA_WAN_DEFAULT_FILTER_RULE_HANDLES 1
+#define IPA_PRIV_SUBNET_FILTER_RULE_HANDLES 3
+#define IPA_NUM_ODU_ROUTE_RULES 2
+#define MAX_WAN_UL_FILTER_RULES MAX_NUM_EXT_PROPS
+#define NUM_IPV4_ICMP_FLT_RULE 1
+#define NUM_IPV6_ICMP_FLT_RULE 1
+
+/* ndc bandwidth ipatetherstats <ifaceIn> <ifaceOut> */
+/* <in->out_bytes> <in->out_pkts> <out->in_bytes> <out->in_pkts */
+
+#define PIPE_STATS "%s %s %lu %lu %lu %lu"
+#define IPA_PIPE_STATS_FILE_NAME "/data/misc/ipa/tether_stats"
+
+/* store each lan-iface unicast routing rule and its handler*/
+struct ipa_lan_rt_rule
+{
+ ipa_ip_type ip;
+ uint32_t v4_addr;
+ uint32_t v4_addr_mask;
+ uint32_t v6_addr[4];
+ uint32_t rt_rule_hdl[0];
+};
+
+typedef enum
+{
+ SRC_WLAN,
+ SRC_LAN
+} eth_bridge_src_iface;
+
+typedef enum
+{
+ DST_WLAN,
+ DST_LAN
+} eth_bridge_dst_iface;
+
+/* Support multiple eth client */
+typedef struct _eth_client_rt_hdl
+{
+ uint32_t eth_rt_rule_hdl_v4;
+ uint32_t eth_rt_rule_hdl_v6[IPV6_NUM_ADDR];
+ uint32_t eth_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];
+}eth_client_rt_hdl;
+
+typedef struct _ipa_eth_client
+{
+ uint8_t mac[IPA_MAC_ADDR_SIZE];
+ uint32_t v4_addr;
+ uint32_t v6_addr[IPV6_NUM_ADDR][4];
+ uint32_t hdr_hdl_v4;
+ uint32_t hdr_hdl_v6;
+ bool route_rule_set_v4;
+ int route_rule_set_v6;
+ bool ipv4_set;
+ int ipv6_set;
+ bool ipv4_header_set;
+ bool ipv6_header_set;
+ eth_client_rt_hdl eth_rt_hdl[0]; /* depends on number of tx properties */
+}ipa_eth_client;
+
+struct lan2lan_flt_rule_hdl
+{
+ uint32_t rule_hdl;
+ bool valid;
+};
+
+struct lan2lan_hdr_hdl
+{
+ uint32_t hdr_hdl;
+ bool valid;
+};
+
+struct eth_bridge_client_flt_info
+{
+ uint8_t mac[IPA_MAC_ADDR_SIZE];
+ uint32_t flt_rule_hdl_v4;
+ bool flt_rule_set_v4;
+ uint32_t flt_rule_hdl_v6;
+ bool flt_rule_set_v6;
+};
+
+struct eth_bridge_client_rt_info
+{
+ uint8_t mac[IPA_MAC_ADDR_SIZE];
+ uint32_t rt_rule_hdl[0];
+};
+
+struct hdr_proc_ctx_info
+{
+ uint32_t proc_ctx_hdl;
+ bool valid;
+};
+
+struct eth_bridge_subnet_client_info
+{
+ uint8_t mac[IPA_MAC_ADDR_SIZE];
+ int ipa_if_num;
+};
+
+/* lan iface */
+class IPACM_Lan : public IPACM_Iface
+{
+public:
+
+ IPACM_Lan(int iface_index);
+ ~IPACM_Lan();
+
+ /* store lan's wan-up filter rule handlers */
+ uint32_t lan_wan_fl_rule_hdl[IPA_WAN_DEFAULT_FILTER_RULE_HANDLES];
+
+ /* store private-subnet filter rule handlers */
+ uint32_t private_fl_rule_hdl[IPA_MAX_PRIVATE_SUBNET_ENTRIES];
+
+ /* LAN-iface's callback function */
+ void event_callback(ipa_cm_event_id event, void *data);
+
+ virtual int handle_wan_up(ipa_ip_type ip_type);
+
+ /* configure filter rule for wan_up event*/
+ virtual int handle_wan_up_ex(ipacm_ext_prop* ext_prop, ipa_ip_type iptype, uint8_t xlat_mux_id);
+
+ /* delete filter rule for wan_down event*/
+ virtual int handle_wan_down(bool is_sta_mode);
+
+ /* delete filter rule for wan_down event*/
+ virtual int handle_wan_down_v6(bool is_sta_mode);
+
+ /* configure private subnet filter rules*/
+ virtual int handle_private_subnet(ipa_ip_type iptype);
+
+ /* handle new_address event*/
+ int handle_addr_evt(ipacm_event_data_addr *data);
+
+ int handle_addr_evt_odu_bridge(ipacm_event_data_addr* data);
+
+ int handle_del_ipv6_addr(ipacm_event_data_all *data);
+
+ static bool odu_up;
+
+ /* install UL filter rule from Q6 */
+ virtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype, uint8_t xlat_mux_id);
+
+ int add_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr, uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t* rule_hdl);
+
+ int del_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);
+
+ virtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl);
+
+ int add_lan2lan_rt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr,
+ uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t hdr_hdl, lan_to_lan_rt_rule_hdl* rule_hdl);
+
+ int del_lan2lan_rt_rule(ipa_ip_type iptype, lan_to_lan_rt_rule_hdl);
+
+ int del_lan2lan_hdr(ipa_ip_type iptype, uint32_t hdr_hdl);
+
+ int handle_cradle_wan_mode_switch(bool is_wan_bridge_mode);
+
+ int install_ipv4_icmp_flt_rule();
+
+ static ipa_hdr_l2_type lan_hdr_type;
+ static ipa_hdr_l2_type wlan_hdr_type;
+
+ static uint32_t usb_hdr_template_hdl;
+ static uint32_t wlan_hdr_template_hdl;
+ static uint32_t cpe_hdr_template_hdl;
+
+ static hdr_proc_ctx_info lan_to_wlan_hdr_proc_ctx, wlan_to_usb_hdr_proc_ctx, wlan_to_cpe_hdr_proc_ctx;
+ static hdr_proc_ctx_info wlan_to_wlan_hdr_proc_ctx;
+ static hdr_proc_ctx_info cpe_to_usb_hdr_proc_ctx, usb_to_cpe_hdr_proc_ctx;
+
+ static eth_bridge_subnet_client_info eth_bridge_wlan_client[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
+ static eth_bridge_subnet_client_info eth_bridge_lan_client[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
+
+ static int num_wlan_client;
+ static int num_lan_client;
+
+ static bool is_usb_up;
+ static bool is_cpe_up;
+
+protected:
+
+ lan2lan_flt_rule_hdl wlan_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
+ lan2lan_flt_rule_hdl wlan_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
+ lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
+ lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
+
+ eth_bridge_client_flt_info eth_bridge_wlan_client_flt_info[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
+ eth_bridge_client_flt_info eth_bridge_lan_client_flt_info[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
+
+ int wlan_client_flt_info_count;
+ int lan_client_flt_info_count;
+
+ int client_rt_info_size_v4;
+ int client_rt_info_size_v6;
+
+ eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_lan_info_v4;
+ int lan_client_rt_from_lan_info_count_v4;
+ eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_lan_info_v6;
+ int lan_client_rt_from_lan_info_count_v6;
+ eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_wlan_info_v4;
+ int lan_client_rt_from_wlan_info_count_v4;
+ eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_wlan_info_v6;
+ int lan_client_rt_from_wlan_info_count_v6;
+
+ int each_client_rt_rule_count_v4;
+ int each_client_rt_rule_count_v6;
+
+ virtual int eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype);
+
+ virtual int eth_bridge_handle_dummy_lan_client_flt_rule(ipa_ip_type iptype);
+
+ int eth_bridge_add_lan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype);
+
+ int eth_bridge_del_lan_client_flt_rule(uint8_t* mac);
+
+ int eth_bridge_add_wlan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype);
+
+ int eth_bridge_del_wlan_client_flt_rule(uint8_t* mac);
+
+ int eth_bridge_post_lan_client_event(uint8_t* mac_addr, ipa_cm_event_id evt);
+
+ int add_hdr_proc_ctx();
+
+ int del_hdr_proc_ctx();
+
+ ipa_hdr_proc_type get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2);
+
+ virtual int eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype);
+
+ virtual int eth_bridge_install_cache_lan_client_flt_rule(ipa_ip_type iptype);
+
+ int eth_bridge_add_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype);
+
+ int eth_bridge_del_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src);
+
+ eth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype);
+
+ void eth_bridge_add_lan_client(uint8_t* mac);
+
+ void eth_bridge_del_lan_client(uint8_t* mac);
+
+ int eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl);
+
+
+
+ virtual int add_dummy_lan2lan_flt_rule(ipa_ip_type iptype);
+
+ virtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype);
+
+ int handle_private_subnet_android(ipa_ip_type iptype);
+
+ int reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);
+
+ /*handle lan2lan client active*/
+ int handle_lan2lan_client_active(ipacm_event_data_all *data, ipa_cm_event_id event);
+
+ virtual int install_ipv6_prefix_flt_rule(uint32_t* prefix);
+
+ virtual void delete_ipv6_prefix_flt_rule();
+
+ int install_ipv6_icmp_flt_rule();
+
+ void post_del_self_evt();
+
+ /* handle tethering stats */
+ int handle_tethering_stats_event(ipa_get_data_stats_resp_msg_v01 *data);
+
+ /* handle tethering client */
+ int handle_tethering_client(bool reset, ipacm_client_enum ipa_client);
+
+ lan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v4[MAX_OFFLOAD_PAIR];
+ lan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v6[MAX_OFFLOAD_PAIR];
+
+ uint8_t num_lan2lan_flt_rule_v4;
+ uint8_t num_lan2lan_flt_rule_v6;
+
+ lan2lan_hdr_hdl lan2lan_hdr_hdl_v4[MAX_OFFLOAD_PAIR];
+ lan2lan_hdr_hdl lan2lan_hdr_hdl_v6[MAX_OFFLOAD_PAIR];
+
+ /* store ipv4 UL filter rule handlers from Q6*/
+ uint32_t wan_ul_fl_rule_hdl_v4[MAX_WAN_UL_FILTER_RULES];
+
+ /* store ipv6 UL filter rule handlers from Q6*/
+ uint32_t wan_ul_fl_rule_hdl_v6[MAX_WAN_UL_FILTER_RULES];
+
+ virtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype);
+
+ uint32_t ipv4_icmp_flt_rule_hdl[NUM_IPV4_ICMP_FLT_RULE];
+ uint32_t tcp_ctl_flt_rule_hdl_v4[NUM_TCP_CTL_FLT_RULE];
+ uint32_t tcp_ctl_flt_rule_hdl_v6[NUM_TCP_CTL_FLT_RULE];
+
+ uint32_t ipv6_prefix_flt_rule_hdl[NUM_IPV6_PREFIX_FLT_RULE];
+ uint32_t ipv6_icmp_flt_rule_hdl[NUM_IPV6_ICMP_FLT_RULE];
+
+ int num_wan_ul_fl_rule_v4;
+ int num_wan_ul_fl_rule_v6;
+
+ bool is_active;
+ bool modem_ul_v4_set;
+ bool modem_ul_v6_set;
+
+ uint32_t if_ipv4_subnet;
+
+ /* expected modem UL rules starting index */
+ int exp_index_v4;
+ int exp_index_v6;
+
+private:
+
+ /* dynamically allocate lan iface's unicast routing rule structure */
+
+ bool is_mode_switch; /* indicate mode switch, need post internal up event */
+
+ int eth_client_len;
+
+ ipa_eth_client *eth_client;
+
+ int header_name_count;
+
+ int num_eth_client;
+
+ NatApp *Nat_App;
+
+ int ipv6_set;
+
+ uint32_t ODU_hdr_hdl_v4, ODU_hdr_hdl_v6;
+
+ uint32_t *odu_route_rule_v4_hdl;
+
+ uint32_t *odu_route_rule_v6_hdl;
+
+ bool ipv4_header_set;
+
+ bool ipv6_header_set;
+
+ inline ipa_eth_client* get_client_memptr(ipa_eth_client *param, int cnt)
+ {
+ char *ret = ((char *)param) + (eth_client_len * cnt);
+ return (ipa_eth_client *)ret;
+ }
+
+ inline int get_eth_client_index(uint8_t *mac_addr)
+ {
+ int cnt;
+ int num_eth_client_tmp = num_eth_client;
+
+ IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ mac_addr[0], mac_addr[1], mac_addr[2],
+ mac_addr[3], mac_addr[4], mac_addr[5]);
+
+ for(cnt = 0; cnt < num_eth_client_tmp; cnt++)
+ {
+ IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(eth_client, cnt)->mac[0],
+ get_client_memptr(eth_client, cnt)->mac[1],
+ get_client_memptr(eth_client, cnt)->mac[2],
+ get_client_memptr(eth_client, cnt)->mac[3],
+ get_client_memptr(eth_client, cnt)->mac[4],
+ get_client_memptr(eth_client, cnt)->mac[5]);
+
+ if(memcmp(get_client_memptr(eth_client, cnt)->mac,
+ mac_addr,
+ sizeof(get_client_memptr(eth_client, cnt)->mac)) == 0)
+ {
+ IPACMDBG_H("Matched client index: %d\n", cnt);
+ return cnt;
+ }
+ }
+
+ return IPACM_INVALID_INDEX;
+ }
+
+ inline int delete_eth_rtrules(int clt_indx, ipa_ip_type iptype)
+ {
+ uint32_t tx_index;
+ uint32_t rt_hdl;
+ int num_v6;
+
+ if(iptype == IPA_IP_v4)
+ {
+ for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
+ {
+ if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(eth_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
+ {
+ IPACMDBG_H("Delete client index %d ipv4 RT-rules for tx:%d\n",clt_indx,tx_index);
+ rt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v4;
+
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
+ {
+ return IPACM_FAILURE;
+ }
+ }
+ } /* end of for loop */
+
+ /* clean the ipv4 RT rules for eth-client:clt_indx */
+ if(get_client_memptr(eth_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
+ {
+ get_client_memptr(eth_client, clt_indx)->route_rule_set_v4 = false;
+ }
+ }
+
+ if(iptype == IPA_IP_v6)
+ {
+ for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
+ {
+ if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
+ {
+ for(num_v6 =0;num_v6 < get_client_memptr(eth_client, clt_indx)->route_rule_set_v6;num_v6++)
+ {
+ IPACMDBG_H("Delete client index %d ipv6 RT-rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
+ rt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6[num_v6];
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
+ {
+ return IPACM_FAILURE;
+ }
+
+ rt_hdl = get_client_memptr(eth_client, clt_indx)->eth_rt_hdl[tx_index].eth_rt_rule_hdl_v6_wan[num_v6];
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
+ {
+ return IPACM_FAILURE;
+ }
+ }
+ }
+ } /* end of for loop */
+
+ /* clean the ipv6 RT rules for eth-client:clt_indx */
+ if(get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
+ {
+ get_client_memptr(eth_client, clt_indx)->route_rule_set_v6 = 0;
+ }
+ }
+
+ return IPACM_SUCCESS;
+ }
+
+ /* handle eth client initial, construct full headers (tx property) */
+ int handle_eth_hdr_init(uint8_t *mac_addr);
+
+ /* handle eth client ip-address */
+ int handle_eth_client_ipaddr(ipacm_event_data_all *data);
+
+ /* handle eth client routing rule*/
+ int handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
+
+ /*handle eth client del mode*/
+ int handle_eth_client_down_evt(uint8_t *mac_addr);
+
+ /* handle odu client initial, construct full headers (tx property) */
+ int handle_odu_hdr_init(uint8_t *mac_addr);
+
+ /* handle odu default route rule configuration */
+ int handle_odu_route_add();
+
+ /* handle odu default route rule deletion */
+ int handle_odu_route_del();
+
+ /*handle lan iface down event*/
+ int handle_down_evt();
+
+ /*handle lan2lan internal mesg posting*/
+ int post_lan2lan_client_disconnect_msg(ipa_ip_type iptype);
+
+ /*handle reset usb-client rt-rules */
+ int handle_lan_client_reset_rt(ipa_ip_type iptype);
+};
+
+#endif /* IPACM_LAN_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h
new file mode 100644
index 0000000..06d5832
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h
@@ -0,0 +1,175 @@
+/*
+Copyright (c) 2014, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ * IPACM_LanToLan.h
+ *
+ * Created on: Mar 4th, 2014
+ * Author: Shihuan Liu
+ */
+
+#ifndef IPACM_LANTOLAN_H
+#define IPACM_LANTOLAN_H
+
+#include <stdint.h>
+#include "linux/msm_ipa.h"
+#include "IPACM_Iface.h"
+#include "IPACM_Defs.h"
+#include "IPACM_Lan.h"
+#include <unordered_map>
+
+#ifdef FEATURE_IPA_ANDROID
+#include <libxml/list.h>
+#else/* defined(FEATURE_IPA_ANDROID) */
+#include <list>
+#endif /* ndefined(FEATURE_IPA_ANDROID)*/
+
+struct client_info;
+
+struct peer_info
+{
+ struct client_info* peer_pointer;
+ int num_connection;
+};
+
+//used to store rule handles for offload link (one direction)
+struct offload_link_info
+{
+ struct client_info* peer_pointer;
+ uint32_t flt_rule_hdl;
+ lan_to_lan_rt_rule_hdl rt_rule_hdl;
+ uint32_t hdr_hdl;
+};
+
+typedef list<peer_info> peer_info_list;
+typedef list<offload_link_info> offload_link_info_list;
+typedef list<ipacm_event_connection> connection_list;
+
+struct client_info
+{
+ union
+ {
+ uint32_t ipv4_addr;
+ uint32_t ipv6_addr[4];
+ } ip;
+ uint8_t mac_addr[6];
+ bool is_active;
+ bool is_powersave;
+ IPACM_Lan* p_iface;
+ peer_info_list peer;
+ offload_link_info_list link;
+};
+
+struct v6_addr
+{
+ uint32_t ipv6_addr[4];
+};
+
+typedef unordered_map<uint32_t, client_info> client_table_v4;
+typedef unordered_map<uint64_t, client_info> client_table_v6;
+
+
+class IPACM_LanToLan : public IPACM_Listener
+{
+
+public:
+
+ IPACM_LanToLan();
+ ~IPACM_LanToLan();
+
+ void handle_new_connection(ipacm_event_connection* new_conn);
+ void handle_del_connection(ipacm_event_connection* del_conn);
+
+ static IPACM_LanToLan* getLan2LanInstance();
+
+private:
+
+ uint8_t num_offload_pair_v4_;
+ uint8_t num_offload_pair_v6_;
+ client_table_v4 client_info_v4_;
+ client_table_v6 client_info_v6_;
+
+ connection_list connection_v4_;
+ connection_list connection_v6_;
+
+ static IPACM_LanToLan* p_instance;
+
+ void event_callback(ipa_cm_event_id event, void* param);
+
+ void handle_client_active(ipacm_event_lan_client* data);
+
+ void check_potential_link(ipa_ip_type iptype, client_info* client);
+
+ int add_offload_link(ipa_ip_type iptype, client_info* client, client_info* peer);
+
+ void handle_client_inactive(ipacm_event_lan_client* data);
+
+ int turnoff_offload_links(ipa_ip_type iptype, client_info* client);
+
+ int del_offload_link(ipa_ip_type iptype, IPACM_Lan* client, IPACM_Lan* peer, offload_link_info* link);
+
+ void handle_client_disconnect(ipacm_event_lan_client* data);
+
+ int clear_peer_list(client_info* client);
+
+ void handle_client_power_save(ipacm_event_lan_client* data);
+
+ void handle_client_power_recover(ipacm_event_lan_client* data);
+
+ int remove_flt_rules(ipa_ip_type iptype, client_info* client);
+
+ int add_flt_rules(ipa_ip_type iptype, client_info* client);
+
+//the following are for connections
+
+ void handle_new_lan2lan_connection(ipacm_event_connection* data);
+
+ bool add_connection(client_info* src_client, client_info* dst_client);
+
+ void handle_del_lan2lan_connection(ipacm_event_connection* data);
+
+ bool remove_connection(client_info* src_client, client_info* dst_client);
+
+ void erase_offload_link(ipa_ip_type iptype, client_info* src_client, client_info* dst_client);
+
+ void generate_new_connection(ipa_ip_type iptype, client_info* client);
+
+ bool is_lan2lan_connection(ipacm_event_connection* data);
+
+ bool is_potential_lan2lan_connection(ipacm_event_connection* new_conn);
+
+ void cache_new_connection(ipacm_event_connection* new_conn);
+
+ void remove_cache_connection(ipacm_event_connection* del_conn);
+
+ void check_cache_connection(ipa_ip_type iptype, client_info* client);
+
+};
+
+#endif
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h
new file mode 100644
index 0000000..9d774fe
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h
@@ -0,0 +1,54 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Listener.h
+
+ @brief
+ This file implements the abstract class notifier.
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_LISTENER_H
+#define IPACM_LISTENER_H
+
+#include "IPACM_Defs.h"
+#include "IPACM_CmdQueue.h"
+
+/* abstract class notifier */
+class IPACM_Listener
+{
+public:
+ virtual void event_callback(ipa_cm_event_id event, void *data) = 0;
+ virtual ~IPACM_Listener(void) {};
+};
+
+#endif /* IPACM_LISTENER_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h
new file mode 100644
index 0000000..8fce44e
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h
@@ -0,0 +1,100 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_log.h
+
+ @brief
+ This file implements the IPAM log functionality.
+
+ @Author
+ Skylar Chang
+
+*/
+
+#ifndef IPACM_LOG_H
+#define IPACM_LOG_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+
+#define MAX_BUF_LEN 256
+
+#ifdef FEATURE_IPA_ANDROID
+#define IPACMLOG_FILE "/dev/socket/ipacm_log_file"
+#else/* defined(FEATURE_IPA_ANDROID) */
+#define IPACMLOG_FILE "/etc/ipacm_log_file"
+#endif /* defined(NOT FEATURE_IPA_ANDROID)*/
+
+typedef struct ipacm_log_buffer_s {
+ char user_data[MAX_BUF_LEN];
+} ipacm_log_buffer_t;
+
+void ipacm_log_send( void * user_data);
+
+static char buffer_send[MAX_BUF_LEN];
+static char dmesg_cmd[MAX_BUF_LEN];
+
+#define IPACMDBG_DMESG(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
+ snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s: " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
+ memset(dmesg_cmd, 0, MAX_BUF_LEN);\
+ snprintf(dmesg_cmd, MAX_BUF_LEN, "echo %s > /dev/kmsg", buffer_send);\
+ system(dmesg_cmd);
+#ifdef DEBUG
+#define PERROR(fmt) memset(buffer_send, 0, MAX_BUF_LEN);\
+ snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s()", __FILE__, __LINE__, __FUNCTION__);\
+ ipacm_log_send (buffer_send); \
+ perror(fmt);
+#define IPACMERR(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
+ snprintf(buffer_send,MAX_BUF_LEN,"ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
+ ipacm_log_send (buffer_send);\
+ printf("ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#define IPACMDBG_H(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
+ snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
+ ipacm_log_send (buffer_send);\
+ printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#else
+#define PERROR(fmt) perror(fmt)
+#define IPACMERR(fmt, ...) printf("ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#define IPACMDBG_H(fmt, ...) printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#endif
+#define IPACMDBG(fmt, ...) printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
+#define IPACMLOG(fmt, ...) printf(fmt, ##__VA_ARGS__);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IPACM_LOG_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h
new file mode 100644
index 0000000..14e86e5
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h
@@ -0,0 +1,81 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Neighbor.h
+
+ @brief
+ This file implements the functionality of handling IPACM Neighbor events.
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_NEIGHBOR_H
+#define IPACM_NEIGHBOR_H
+
+#include <stdio.h>
+#include <IPACM_CmdQueue.h>
+#include <linux/msm_ipa.h>
+#include "IPACM_Routing.h"
+#include "IPACM_Filtering.h"
+#include "IPACM_Listener.h"
+#include "IPACM_Iface.h"
+
+#define IPA_MAX_NUM_NEIGHBOR_CLIENTS 100
+
+struct ipa_neighbor_client
+{
+ uint8_t mac_addr[6];
+ int iface_index;
+ uint32_t v4_addr;
+ int ipa_if_num;
+};
+
+class IPACM_Neighbor : public IPACM_Listener
+{
+
+public:
+
+ IPACM_Neighbor();
+
+ void event_callback(ipa_cm_event_id event,
+ void *data);
+
+private:
+
+ int num_neighbor_client;
+
+ int circular_index;
+
+ ipa_neighbor_client neighbor_client[IPA_MAX_NUM_NEIGHBOR_CLIENTS];
+
+};
+
+#endif /* IPACM_NEIGHBOR_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h
new file mode 100644
index 0000000..b0bdeb8
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h
@@ -0,0 +1,223 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPA_Netlink.h
+
+ @brief
+ IPACM Netlink Messaging Implementation File
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_NETLINK_H
+#define IPACM_NETLINK_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/if_addr.h>
+#include <linux/rtnetlink.h>
+#include <linux/netlink.h>
+#include <netinet/in.h>
+#include "IPACM_Defs.h"
+
+#define MAX_NUM_OF_FD 10
+#define IPA_NL_MSG_MAX_LEN (2048)
+
+/*---------------------------------------------------------------------------
+ Type representing enumeration of NetLink event indication messages
+---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+ Types representing parsed NetLink message
+---------------------------------------------------------------------------*/
+#define IPA_NLA_PARAM_NONE (0x0000)
+#define IPA_NLA_PARAM_PREFIXADDR (0x0001)
+#define IPA_NLA_PARAM_LOCALADDR (0x0002)
+#define IPA_NLA_PARAM_LABELNAME (0x0004)
+#define IPA_NLA_PARAM_BCASTADDR (0x0008)
+#define IPA_NLA_PARAM_ACASTADDR (0x0010)
+#define IPA_NLA_PARAM_MCASTADDR (0x0020)
+#define IPA_NLA_PARAM_CACHEINFO (0x0080)
+#define IPA_NLA_PARAM_PROTOINFO (0x0100)
+#define IPA_NLA_PARAM_FLAGS (0x0200)
+
+#define IPA_RTA_PARAM_NONE (0x0000)
+#define IPA_RTA_PARAM_DST (0x0001)
+#define IPA_RTA_PARAM_SRC (0x0002)
+#define IPA_RTA_PARAM_GATEWAY (0x0004)
+#define IPA_RTA_PARAM_IIF (0x0008)
+#define IPA_RTA_PARAM_OIF (0x0010)
+#define IPA_RTA_PARAM_CACHEINFO (0x0020)
+#define IPA_RTA_PARAM_PRIORITY (0x0080)
+#define IPA_RTA_PARAM_METRICS (0x0100)
+
+
+/*---------------------------------------------------------------------------
+ Type representing function callback registered with a socket listener
+ thread for reading from a socket on receipt of an incoming message
+---------------------------------------------------------------------------*/
+typedef int (*ipa_sock_thrd_fd_read_f)(int fd);
+
+typedef enum
+{
+ IPA_INIT = 0,
+ IPA_LINK_UP_WAIT,
+ IPA_LINK_UP,
+ IPA_LINK_DOWN_WAIT,
+ IPA_LINK_DOWN
+} ipa_nl_state_e;
+
+typedef struct
+{
+ int sk_fd;
+ ipa_sock_thrd_fd_read_f read_func;
+} ipa_nl_sk_fd_map_info_t;
+
+typedef struct
+{
+ ipa_nl_sk_fd_map_info_t sk_fds[MAX_NUM_OF_FD];
+ fd_set fdset;
+ int num_fd;
+ int max_fd;
+} ipa_nl_sk_fd_set_info_t;
+
+typedef struct
+{
+ int sk_fd; /* socket descriptor */
+ struct sockaddr_nl sk_addr_loc; /* local address of socket */
+} ipa_nl_sk_info_t;
+
+typedef struct ipa_nl_addr_s {
+ struct sockaddr_storage ip_addr;
+ unsigned int mask;
+} ipa_nl_addr_t;
+
+typedef struct ipa_nl_proto_info_s {
+ unsigned int param_mask;
+ unsigned int flags;
+ struct ifla_cacheinfo cache_info;
+} ipa_nl_proto_info_t;
+
+typedef struct
+{
+ struct ifinfomsg metainfo; /* from header */
+} ipa_nl_link_info_t;
+
+
+
+typedef struct ipa_nl_addr_info_s {
+ struct ifaddrmsg metainfo; /* from header */
+ struct /* attributes */
+ {
+ unsigned int param_mask;
+ unsigned char label_name[IF_NAME_LEN];
+ struct sockaddr_storage prefix_addr;
+ struct sockaddr_storage local_addr;
+ struct sockaddr_storage bcast_addr;
+ struct sockaddr_storage acast_addr;
+ struct sockaddr_storage mcast_addr;
+ } attr_info;
+} ipa_nl_addr_info_t;
+
+
+typedef struct ipa_nl_neigh_info_s {
+ struct ndmsg metainfo; /* from header */
+ struct /* attributes */
+ {
+ unsigned int param_mask;
+ struct sockaddr_storage local_addr;
+ struct sockaddr lladdr_hwaddr;
+ } attr_info;
+} ipa_nl_neigh_info_t;
+
+
+
+typedef struct ipa_nl_route_info_s {
+ struct rtmsg metainfo; /* from header */
+ struct /* attributes */
+ {
+ unsigned int param_mask;
+ struct sockaddr_storage dst_addr;
+ struct sockaddr_storage src_addr;
+ struct sockaddr_storage gateway_addr;
+ struct sockaddr_storage mark_addr;
+ struct rta_cacheinfo cache_info;
+ __u32 iif_index; /* Link index */
+ __u32 oif_index; /* Link index */
+ __u32 priority;
+ __u32 metrics;
+ ipa_nl_proto_info_t proto_info;
+ } attr_info;
+} ipa_nl_route_info_t;
+
+#define IPA_FLOW_TYPE_INVALID (-1)
+
+typedef struct
+{
+ unsigned int type;
+ bool link_event;
+ /* Optional parameters */
+ ipa_nl_link_info_t nl_link_info;
+ ipa_nl_addr_info_t nl_addr_info;
+ ipa_nl_neigh_info_t nl_neigh_info;
+ ipa_nl_route_info_t nl_route_info;
+} ipa_nl_msg_t;
+
+/* Initialization routine for listener on NetLink sockets interface */
+int ipa_nl_listener_init
+(
+ unsigned int nl_type,
+ unsigned int nl_groups,
+ ipa_nl_sk_fd_set_info_t *sk_fdset,
+ ipa_sock_thrd_fd_read_f read_f
+ );
+
+/* Virtual function registered to receive incoming messages over the NETLINK routing socket*/
+int ipa_nl_recv_msg(int fd);
+
+/* map mask value for ipv6 */
+int mask_v6(int index, uint32_t *mask);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IPACM_NETLINK_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h
new file mode 100644
index 0000000..4f5488f
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h
@@ -0,0 +1,77 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Routing.cpp
+
+ @brief
+ This file implements the IPACM routing functionality.
+
+ @Author
+ Skylar Chang
+
+*/
+
+
+#ifndef IPACM_ROUTING_H
+#define IPACM_ROUTING_H
+
+#include <stdint.h>
+#include <linux/msm_ipa.h>
+#include <IPACM_Defs.h>
+
+using namespace std;
+
+class IPACM_Routing
+{
+public:
+ IPACM_Routing();
+ ~IPACM_Routing();
+
+ bool AddRoutingRule(struct ipa_ioc_add_rt_rule *ruleTable);
+ bool DeleteRoutingRule(struct ipa_ioc_del_rt_rule *ruleTable);
+
+ bool Commit(enum ipa_ip_type ip);
+ bool Reset(enum ipa_ip_type ip);
+
+ bool GetRoutingTable(struct ipa_ioc_get_rt_tbl *routingTable);
+ bool PutRoutingTable(uint32_t routingTableHandle);
+
+ bool DeviceNodeIsOpened();
+ bool DeleteRoutingHdl(uint32_t rt_rule_hdl, ipa_ip_type ip);
+
+ bool ModifyRoutingRule(struct ipa_ioc_mdfy_rt_rule *);
+
+private:
+ static const char *DEVICE_NAME;
+ int m_fd; /* File descriptor of the IPA device node /dev/ipa */
+};
+
+#endif //IPACM_ROUTING_H
+
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h
new file mode 100644
index 0000000..711f276
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h
@@ -0,0 +1,488 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Wan.cpp
+
+ @brief
+ This file implements the WAN iface functionality.
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_WAN_H
+#define IPACM_WAN_H
+
+#include <stdio.h>
+#include <IPACM_CmdQueue.h>
+#include <linux/msm_ipa.h>
+#include "IPACM_Routing.h"
+#include "IPACM_Filtering.h"
+#include <IPACM_Iface.h>
+#include <IPACM_Defs.h>
+#include <IPACM_Xml.h>
+
+#define IPA_NUM_DEFAULT_WAN_FILTER_RULES 3 /*1 for v4, 2 for v6*/
+#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV4 2
+
+#ifdef FEATURE_IPA_ANDROID
+#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 6
+#else
+#define IPA_V2_NUM_DEFAULT_WAN_FILTER_RULE_IPV6 3
+#endif
+
+#define NETWORK_STATS "%s %lu %lu %lu %lu"
+#define IPA_NETWORK_STATS_FILE_NAME "/data/misc/ipa/network_stats"
+
+typedef struct _wan_client_rt_hdl
+{
+ uint32_t wan_rt_rule_hdl_v4;
+ uint32_t wan_rt_rule_hdl_v6[IPV6_NUM_ADDR];
+ uint32_t wan_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];
+}wan_client_rt_hdl;
+
+typedef struct _ipa_wan_client
+{
+ ipacm_event_data_wlan_ex* p_hdr_info;
+ uint8_t mac[IPA_MAC_ADDR_SIZE];
+ uint32_t v4_addr;
+ uint32_t v6_addr[IPV6_NUM_ADDR][4];
+ uint32_t hdr_hdl_v4;
+ uint32_t hdr_hdl_v6;
+ bool route_rule_set_v4;
+ int route_rule_set_v6;
+ bool ipv4_set;
+ int ipv6_set;
+ bool ipv4_header_set;
+ bool ipv6_header_set;
+ bool power_save_set;
+ wan_client_rt_hdl wan_rt_hdl[0]; /* depends on number of tx properties */
+}ipa_wan_client;
+
+/* wan iface */
+class IPACM_Wan : public IPACM_Iface
+{
+
+public:
+
+ static bool wan_up;
+ static bool wan_up_v6;
+ static uint8_t xlat_mux_id;
+ /* IPACM interface name */
+ static char wan_up_dev_name[IF_NAME_LEN];
+ IPACM_Wan(int, ipacm_wan_iface_type, uint8_t *);
+ virtual ~IPACM_Wan();
+
+ static bool isWanUP(int ipa_if_num_tether)
+ {
+#ifdef FEATURE_IPA_ANDROID
+ int i;
+ for (i=0; i < ipa_if_num_tether_v4_total;i++)
+ {
+ if (ipa_if_num_tether_v4[i] == ipa_if_num_tether)
+ {
+ IPACMDBG_H("support ipv4 tether_iface(%s)\n",
+ IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
+ return wan_up;
+ break;
+ }
+ }
+ return false;
+#else
+ return wan_up;
+#endif
+ }
+
+ static bool isWanUP_V6(int ipa_if_num_tether)
+ {
+#ifdef FEATURE_IPA_ANDROID
+ int i;
+ for (i=0; i < ipa_if_num_tether_v6_total;i++)
+ {
+ if (ipa_if_num_tether_v6[i] == ipa_if_num_tether)
+ {
+ IPACMDBG_H("support ipv6 tether_iface(%s)\n",
+ IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether].iface_name);
+ return wan_up_v6;
+ break;
+ }
+ }
+ return false;
+#else
+ return wan_up_v6;
+#endif
+ }
+
+ static bool getXlat_Mux_Id()
+ {
+ return xlat_mux_id;
+ }
+
+ void event_callback(ipa_cm_event_id event,
+ void *data);
+
+ static struct ipa_flt_rule_add flt_rule_v4[IPA_MAX_FLT_RULE];
+ static struct ipa_flt_rule_add flt_rule_v6[IPA_MAX_FLT_RULE];
+
+ static int num_v4_flt_rule;
+ static int num_v6_flt_rule;
+
+ ipacm_wan_iface_type m_is_sta_mode;
+ static bool backhaul_is_sta_mode;
+ static bool is_ext_prop_set;
+ static uint32_t backhaul_ipv6_prefix[2];
+
+ static bool embms_is_on;
+ static bool backhaul_is_wan_bridge;
+
+ static bool isWan_Bridge_Mode()
+ {
+ return backhaul_is_wan_bridge;
+ }
+#ifdef FEATURE_IPA_ANDROID
+ /* IPACM interface id */
+ static int ipa_if_num_tether_v4_total;
+ static int ipa_if_num_tether_v4[IPA_MAX_IFACE_ENTRIES];
+ static int ipa_if_num_tether_v6_total;
+ static int ipa_if_num_tether_v6[IPA_MAX_IFACE_ENTRIES];
+#endif
+
+private:
+
+ uint32_t ipv6_frag_firewall_flt_rule_hdl;
+ uint32_t *wan_route_rule_v4_hdl;
+ uint32_t *wan_route_rule_v6_hdl;
+ uint32_t *wan_route_rule_v6_hdl_a5;
+ uint32_t hdr_hdl_sta_v4;
+ uint32_t hdr_hdl_sta_v6;
+ uint32_t firewall_hdl_v4[IPACM_MAX_FIREWALL_ENTRIES];
+ uint32_t firewall_hdl_v6[IPACM_MAX_FIREWALL_ENTRIES];
+ uint32_t dft_wan_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
+ uint32_t ipv6_dest_flt_rule_hdl[MAX_DEFAULT_v6_ROUTE_RULES];
+ int num_ipv6_dest_flt_rule;
+ uint32_t ODU_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
+ int num_firewall_v4,num_firewall_v6;
+ uint32_t wan_v4_addr;
+ uint32_t wan_v4_addr_gw;
+ uint32_t wan_v6_addr_gw[4];
+ bool wan_v4_addr_set;
+ bool wan_v4_addr_gw_set;
+ bool wan_v6_addr_gw_set;
+ bool active_v4;
+ bool active_v6;
+ bool header_set_v4;
+ bool header_set_v6;
+ bool header_partial_default_wan_v4;
+ bool header_partial_default_wan_v6;
+ uint8_t ext_router_mac_addr[IPA_MAC_ADDR_SIZE];
+
+ static int num_ipv4_modem_pdn;
+
+ static int num_ipv6_modem_pdn;
+
+ int modem_ipv4_pdn_index;
+
+ int modem_ipv6_pdn_index;
+
+ bool is_default_gateway;
+
+ uint32_t ipv6_prefix[2];
+
+ /* IPACM firewall Configuration file*/
+ IPACM_firewall_conf_t firewall_config;
+
+ /* STA mode wan-client*/
+ int wan_client_len;
+ ipa_wan_client *wan_client;
+ int header_name_count;
+ int num_wan_client;
+ uint8_t invalid_mac[IPA_MAC_ADDR_SIZE];
+ bool is_xlat;
+
+ /* update network stats for CNE */
+ int ipa_network_stats_fd;
+
+ inline ipa_wan_client* get_client_memptr(ipa_wan_client *param, int cnt)
+ {
+ char *ret = ((char *)param) + (wan_client_len * cnt);
+ return (ipa_wan_client *)ret;
+ }
+
+ inline int get_wan_client_index(uint8_t *mac_addr)
+ {
+ int cnt;
+ int num_wan_client_tmp = num_wan_client;
+
+ IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ mac_addr[0], mac_addr[1], mac_addr[2],
+ mac_addr[3], mac_addr[4], mac_addr[5]);
+
+ for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
+ {
+ IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(wan_client, cnt)->mac[0],
+ get_client_memptr(wan_client, cnt)->mac[1],
+ get_client_memptr(wan_client, cnt)->mac[2],
+ get_client_memptr(wan_client, cnt)->mac[3],
+ get_client_memptr(wan_client, cnt)->mac[4],
+ get_client_memptr(wan_client, cnt)->mac[5]);
+
+ if(memcmp(get_client_memptr(wan_client, cnt)->mac,
+ mac_addr,
+ sizeof(get_client_memptr(wan_client, cnt)->mac)) == 0)
+ {
+ IPACMDBG_H("Matched client index: %d\n", cnt);
+ return cnt;
+ }
+ }
+
+ return IPACM_INVALID_INDEX;
+ }
+
+ inline int get_wan_client_index_ipv4(uint32_t ipv4_addr)
+ {
+ int cnt;
+ int num_wan_client_tmp = num_wan_client;
+
+ IPACMDBG_H("Passed IPv4 %x\n", ipv4_addr);
+
+ for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
+ {
+ if (get_client_memptr(wan_client, cnt)->ipv4_set)
+ {
+ IPACMDBG_H("stored IPv4 %x\n", get_client_memptr(wan_client, cnt)->v4_addr);
+
+ if(ipv4_addr == get_client_memptr(wan_client, cnt)->v4_addr)
+ {
+ IPACMDBG_H("Matched client index: %d\n", cnt);
+ IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(wan_client, cnt)->mac[0],
+ get_client_memptr(wan_client, cnt)->mac[1],
+ get_client_memptr(wan_client, cnt)->mac[2],
+ get_client_memptr(wan_client, cnt)->mac[3],
+ get_client_memptr(wan_client, cnt)->mac[4],
+ get_client_memptr(wan_client, cnt)->mac[5]);
+ IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
+ get_client_memptr(wan_client, cnt)->ipv4_header_set,
+ get_client_memptr(wan_client, cnt)->ipv6_header_set);
+ return cnt;
+ }
+ }
+ }
+ return IPACM_INVALID_INDEX;
+ }
+
+ inline int get_wan_client_index_ipv6(uint32_t* ipv6_addr)
+ {
+ int cnt, v6_num;
+ int num_wan_client_tmp = num_wan_client;
+
+ 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]);
+
+ for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
+ {
+ if (get_client_memptr(wan_client, cnt)->ipv6_set)
+ {
+ for(v6_num=0;v6_num < get_client_memptr(wan_client, cnt)->ipv6_set;v6_num++)
+ {
+
+ IPACMDBG_H("stored IPv6 0x%08x.0x%08x.0x%08x.0x%08x\n", get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0],
+ get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1],
+ get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2],
+ get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3]);
+
+ if(ipv6_addr[0] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][0] &&
+ ipv6_addr[1] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][1] &&
+ ipv6_addr[2]== get_client_memptr(wan_client, cnt)->v6_addr[v6_num][2] &&
+ ipv6_addr[3] == get_client_memptr(wan_client, cnt)->v6_addr[v6_num][3])
+ {
+ IPACMDBG_H("Matched client index: %d\n", cnt);
+ IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(wan_client, cnt)->mac[0],
+ get_client_memptr(wan_client, cnt)->mac[1],
+ get_client_memptr(wan_client, cnt)->mac[2],
+ get_client_memptr(wan_client, cnt)->mac[3],
+ get_client_memptr(wan_client, cnt)->mac[4],
+ get_client_memptr(wan_client, cnt)->mac[5]);
+ IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
+ get_client_memptr(wan_client, cnt)->ipv4_header_set,
+ get_client_memptr(wan_client, cnt)->ipv6_header_set);
+ return cnt;
+ }
+ }
+ }
+ }
+ return IPACM_INVALID_INDEX;
+ }
+
+ inline int delete_wan_rtrules(int clt_indx, ipa_ip_type iptype)
+ {
+ uint32_t tx_index;
+ uint32_t rt_hdl;
+ int num_v6;
+
+ if(iptype == IPA_IP_v4)
+ {
+ for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
+ {
+ if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
+ {
+ IPACMDBG_H("Delete client index %d ipv4 Qos rules for tx:%d \n",clt_indx,tx_index);
+ rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v4;
+
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
+ {
+ return IPACM_FAILURE;
+ }
+ }
+ } /* end of for loop */
+
+ /* clean the 4 Qos ipv4 RT rules for client:clt_indx */
+ if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
+ {
+ get_client_memptr(wan_client, clt_indx)->route_rule_set_v4 = false;
+ }
+ }
+
+ if(iptype == IPA_IP_v6)
+ {
+ for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
+ {
+
+ if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
+ {
+ for(num_v6 =0;num_v6 < get_client_memptr(wan_client, clt_indx)->route_rule_set_v6;num_v6++)
+ {
+ IPACMDBG_H("Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
+ rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6[num_v6];
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
+ {
+ return IPACM_FAILURE;
+ }
+
+ rt_hdl = get_client_memptr(wan_client, clt_indx)->wan_rt_hdl[tx_index].wan_rt_rule_hdl_v6_wan[num_v6];
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
+ {
+ return IPACM_FAILURE;
+ }
+ }
+
+ }
+ } /* end of for loop */
+
+ /* clean the 4 Qos ipv6 RT rules for client:clt_indx */
+ if(get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
+ {
+ get_client_memptr(wan_client, clt_indx)->route_rule_set_v6 = 0;
+ }
+ }
+
+ return IPACM_SUCCESS;
+ }
+
+ int handle_wan_hdr_init(uint8_t *mac_addr);
+ int handle_wan_client_ipaddr(ipacm_event_data_all *data);
+ int handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
+
+ /* handle new_address event */
+ int handle_addr_evt(ipacm_event_data_addr *data);
+
+ /* wan default route/filter rule configuration */
+ int handle_route_add_evt(ipa_ip_type iptype);
+
+ /* construct complete STA ethernet header */
+ int handle_sta_header_add_evt();
+
+ bool check_dft_firewall_rules_attr_mask(IPACM_firewall_conf_t *firewall_config);
+
+#ifdef FEATURE_IPA_ANDROID
+ /* wan posting supported tether_iface */
+ int post_wan_up_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
+
+ int post_wan_down_tether_evt(ipa_ip_type iptype, int ipa_if_num_tether);
+#endif
+ int config_dft_firewall_rules(ipa_ip_type iptype);
+
+ /* configure the initial firewall filter rules */
+ int config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, ipa_ioc_add_flt_rule *pFilteringTable_v6);
+
+ int handle_route_del_evt(ipa_ip_type iptype);
+
+ int del_dft_firewall_rules(ipa_ip_type iptype);
+
+ int handle_down_evt();
+
+ /*handle wan-iface down event */
+ int handle_down_evt_ex();
+
+ /* wan default route/filter rule delete */
+ int handle_route_del_evt_ex(ipa_ip_type iptype);
+
+ /* configure the initial firewall filter rules */
+ int config_dft_firewall_rules_ex(struct ipa_flt_rule_add* rules, int rule_offset,
+ ipa_ip_type iptype);
+
+ /* Change IP Type.*/
+ void config_ip_type(ipa_ip_type iptype);
+
+ /* init filtering rule in wan dl filtering table */
+ int init_fl_rule_ex(ipa_ip_type iptype);
+
+ /* add ICMP and ALG rules in wan dl filtering table */
+ int add_icmp_alg_rules(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
+
+ /* query extended property */
+ int query_ext_prop();
+
+ ipa_ioc_query_intf_ext_props *ext_prop;
+
+ int config_wan_firewall_rule(ipa_ip_type iptype);
+
+ int del_wan_firewall_rule(ipa_ip_type iptype);
+
+ int add_dft_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
+
+ int install_wan_filtering_rule(bool is_sw_routing);
+
+ void change_to_network_order(ipa_ip_type iptype, ipa_rule_attrib* attrib);
+
+ bool is_global_ipv6_addr(uint32_t* ipv6_addr);
+
+ void handle_wlan_SCC_MCC_switch(bool, ipa_ip_type);
+ void handle_wan_client_SCC_MCC_switch(bool, ipa_ip_type);
+
+ int handle_network_stats_evt();
+
+ int m_fd_ipa;
+
+ int handle_network_stats_update(ipa_get_apn_data_stats_resp_msg_v01 *data);
+};
+
+#endif /* IPACM_WAN_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h
new file mode 100644
index 0000000..6a2d53a
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h
@@ -0,0 +1,329 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Wlan.h
+
+ @brief
+ This file implements the WLAN iface functionality.
+
+ @Author
+ Skylar Chang
+
+*/
+#ifndef IPACM_WLAN_H
+#define IPACM_WLAN_H
+
+#include <stdio.h>
+#include <IPACM_CmdQueue.h>
+#include <linux/msm_ipa.h>
+#include "IPACM_Routing.h"
+#include "IPACM_Filtering.h"
+#include "IPACM_Lan.h"
+#include "IPACM_Iface.h"
+#include "IPACM_Conntrack_NATApp.h"
+
+typedef struct _wlan_client_rt_hdl
+{
+ uint32_t wifi_rt_rule_hdl_v4;
+ uint32_t wifi_rt_rule_hdl_v6[IPV6_NUM_ADDR];
+ uint32_t wifi_rt_rule_hdl_v6_wan[IPV6_NUM_ADDR];
+}wlan_client_rt_hdl;
+
+typedef struct _ipa_wlan_client
+{
+ ipacm_event_data_wlan_ex* p_hdr_info;
+ uint8_t mac[IPA_MAC_ADDR_SIZE];
+ uint32_t v4_addr;
+ uint32_t v6_addr[IPV6_NUM_ADDR][4];
+ uint32_t hdr_hdl_v4;
+ uint32_t hdr_hdl_v6;
+ bool route_rule_set_v4;
+ int route_rule_set_v6;
+ bool ipv4_set;
+ int ipv6_set;
+ bool ipv4_header_set;
+ bool ipv6_header_set;
+ bool power_save_set;
+ wlan_client_rt_hdl wifi_rt_hdl[0]; /* depends on number of tx properties */
+}ipa_wlan_client;
+
+/* wlan iface */
+class IPACM_Wlan : public IPACM_Lan
+{
+
+public:
+
+ IPACM_Wlan(int iface_index);
+ virtual ~IPACM_Wlan(void);
+
+ static int total_num_wifi_clients;
+
+ void event_callback(ipa_cm_event_id event,
+ void *data);
+
+ virtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl);
+
+private:
+
+ eth_bridge_client_flt_info eth_bridge_lan_client_flt_info[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
+ int lan_client_flt_info_count;
+
+ static lan2lan_flt_rule_hdl self_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
+ static lan2lan_flt_rule_hdl self_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
+
+ static lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
+ static lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
+
+ bool is_guest_ap;
+
+ eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_lan_info_v4;
+ int wlan_client_rt_from_lan_info_count_v4;
+ eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_lan_info_v6;
+ int wlan_client_rt_from_lan_info_count_v6;
+
+ eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v4;
+ int wlan_client_rt_from_wlan_info_count_v4;
+ eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v6;
+ int wlan_client_rt_from_wlan_info_count_v6;
+
+ int eth_bridge_install_wlan_guest_ap_ipv6_flt_rule();
+
+ virtual int eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype);
+
+ virtual int eth_bridge_handle_dummy_lan_client_flt_rule(ipa_ip_type iptype);
+
+ int eth_bridge_add_lan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype);
+
+ int eth_bridge_del_lan_client_flt_rule(uint8_t* mac);
+
+ int eth_bridge_add_self_client_flt_rule(uint8_t* mac, ipa_ip_type iptype);
+
+ int eth_bridge_del_self_client_flt_rule(uint8_t* mac);
+
+ virtual int eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype);
+
+ virtual int eth_bridge_install_cache_lan_client_flt_rule(ipa_ip_type iptype);
+
+ int eth_bridge_add_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype);
+
+ int eth_bridge_del_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src);
+
+ eth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype);
+
+ void eth_bridge_add_wlan_client(uint8_t* mac, int if_num);
+
+ void eth_bridge_del_wlan_client(uint8_t* mac);
+
+
+ int wlan_client_len;
+ ipa_wlan_client *wlan_client;
+
+ int header_name_count;
+ int num_wifi_client;
+
+ int wlan_ap_index;
+
+ static uint32_t* dummy_flt_rule_hdl_v4;
+ static uint32_t* dummy_flt_rule_hdl_v6;
+
+ static int num_wlan_ap_iface;
+
+ NatApp *Nat_App;
+
+ inline ipa_wlan_client* get_client_memptr(ipa_wlan_client *param, int cnt)
+ {
+ char *ret = ((char *)param) + (wlan_client_len * cnt);
+ return (ipa_wlan_client *)ret;
+ }
+
+ inline int get_wlan_client_index(uint8_t *mac_addr)
+ {
+ int cnt;
+ int num_wifi_client_tmp = num_wifi_client;
+
+ IPACMDBG_H("Passed MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ mac_addr[0], mac_addr[1], mac_addr[2],
+ mac_addr[3], mac_addr[4], mac_addr[5]);
+
+ for(cnt = 0; cnt < num_wifi_client_tmp; cnt++)
+ {
+ IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(wlan_client, cnt)->mac[0],
+ get_client_memptr(wlan_client, cnt)->mac[1],
+ get_client_memptr(wlan_client, cnt)->mac[2],
+ get_client_memptr(wlan_client, cnt)->mac[3],
+ get_client_memptr(wlan_client, cnt)->mac[4],
+ get_client_memptr(wlan_client, cnt)->mac[5]);
+
+ if(memcmp(get_client_memptr(wlan_client, cnt)->mac,
+ mac_addr,
+ sizeof(get_client_memptr(wlan_client, cnt)->mac)) == 0)
+ {
+ IPACMDBG_H("Matched client index: %d\n", cnt);
+ return cnt;
+ }
+ }
+
+ return IPACM_INVALID_INDEX;
+ }
+
+ inline int delete_default_qos_rtrules(int clt_indx, ipa_ip_type iptype)
+ {
+ uint32_t tx_index;
+ uint32_t rt_hdl;
+ int num_v6;
+
+ if(iptype == IPA_IP_v4)
+ {
+ for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
+ {
+ if((tx_prop->tx[tx_index].ip == IPA_IP_v4) && (get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4==true)) /* for ipv4 */
+ {
+ IPACMDBG_H("Delete client index %d ipv4 Qos rules for tx:%d \n",clt_indx,tx_index);
+ rt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v4;
+
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v4) == false)
+ {
+ return IPACM_FAILURE;
+ }
+ }
+ } /* end of for loop */
+
+ /* clean the 4 Qos ipv4 RT rules for client:clt_indx */
+ if(get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4==true) /* for ipv4 */
+ {
+ get_client_memptr(wlan_client, clt_indx)->route_rule_set_v4 = false;
+ }
+ }
+
+ if(iptype == IPA_IP_v6)
+ {
+ for(tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
+ {
+
+ if((tx_prop->tx[tx_index].ip == IPA_IP_v6) && (get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 != 0)) /* for ipv6 */
+ {
+ for(num_v6 =0;num_v6 < get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6;num_v6++)
+ {
+ IPACMDBG_H("Delete client index %d ipv6 Qos rules for %d-st ipv6 for tx:%d\n", clt_indx,num_v6,tx_index);
+ rt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6[num_v6];
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
+ {
+ return IPACM_FAILURE;
+ }
+
+ rt_hdl = get_client_memptr(wlan_client, clt_indx)->wifi_rt_hdl[tx_index].wifi_rt_rule_hdl_v6_wan[num_v6];
+ if(m_routing.DeleteRoutingHdl(rt_hdl, IPA_IP_v6) == false)
+ {
+ return IPACM_FAILURE;
+ }
+ }
+
+ }
+ } /* end of for loop */
+
+ /* clean the 4 Qos ipv6 RT rules for client:clt_indx */
+ if(get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 != 0) /* for ipv6 */
+ {
+ get_client_memptr(wlan_client, clt_indx)->route_rule_set_v6 = 0;
+ }
+ }
+
+ return IPACM_SUCCESS;
+ }
+
+ /* for handle wifi client initial,copy all partial headers (tx property) */
+ int handle_wlan_client_init_ex(ipacm_event_data_wlan_ex *data);
+
+ /*handle lan2lan internal mesg posting*/
+ int handle_lan2lan_msg_post(uint8_t *mac_addr, ipa_cm_event_id event, ipa_ip_type iptype);
+
+ /*handle wifi client */
+ int handle_wlan_client_ipaddr(ipacm_event_data_all *data);
+
+ /*handle wifi client routing rule*/
+ int handle_wlan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
+
+ /*handle wifi client power-save mode*/
+ int handle_wlan_client_pwrsave(uint8_t *mac_addr);
+
+ /*handle wifi client del mode*/
+ int handle_wlan_client_down_evt(uint8_t *mac_addr);
+
+ /*handle wlan iface down event*/
+ int handle_down_evt();
+
+ /* add dummy filtering rules for WLAN AP-AP mode support */
+ void add_dummy_flt_rule();
+
+ /* install dummy filtering rules for WLAN AP-AP mode support */
+ int install_dummy_flt_rule(ipa_ip_type iptype, int num_rule);
+
+ /* delete dummy flt rule for WLAN AP-AP mode support*/
+ void del_dummy_flt_rule();
+
+ /*Configure the initial filter rules */
+ virtual int init_fl_rule(ipa_ip_type iptype);
+
+ virtual int add_dummy_lan2lan_flt_rule(ipa_ip_type iptype);
+
+ virtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype);
+
+ /*configure private subnet filter rules*/
+ virtual int handle_private_subnet(ipa_ip_type iptype);
+
+ /* install UL filter rule from Q6 */
+ virtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype, uint8_t xlat_mux_id);
+
+ /* install TCP control filter rules */
+ virtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype);
+
+ /*handle reset wifi-client rt-rules */
+ int handle_wlan_client_reset_rt(ipa_ip_type iptype);
+
+ void handle_SCC_MCC_switch(ipa_ip_type);
+
+ void eth_bridge_handle_wlan_SCC_MCC_switch(ipa_ip_type iptype);
+
+ int eth_bridge_modify_wlan_client_flt_rule(uint8_t* mac, eth_bridge_dst_iface dst_iface, ipa_ip_type iptype);
+
+ int eth_bridge_modify_wlan_rt_rule(uint8_t* mac, eth_bridge_src_iface src_iface, ipa_ip_type iptyp);
+
+ /*handle wlan access mode switch */
+ void eth_bridge_handle_wlan_mode_switch();
+
+ virtual int install_ipv6_prefix_flt_rule(uint32_t* prefix);
+
+ virtual void delete_ipv6_prefix_flt_rule();
+
+};
+
+
+#endif /* IPACM_WLAN_H */
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h
new file mode 100644
index 0000000..f645ae1
--- /dev/null
+++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h
@@ -0,0 +1,299 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*!
+ @file
+ IPACM_Xml.h
+
+ @brief
+ This file implements the XML specific parsing functionality.
+
+ @Author
+ Skylar Chang/Shihuan Liu
+
+*/
+#ifndef IPACM_XML_H
+#define IPACM_XML_H
+
+#include <linux/msm_ipa.h>
+#include "IPACM_Defs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <stdint.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define IPACM_ASSERT(a) \
+if (!(a)) { \
+ fprintf(stderr, "%s, %d: assertion (a) failed!", \
+ __FILE__, \
+ __LINE__); \
+ abort(); \
+}
+
+/* Max allowed size of the XML file (2 MB) */
+#define IPACM_XML_MAX_FILESIZE (2 << 20)
+#define IPACM_MAX_FIREWALL_ENTRIES 50
+#define IPACM_IPV6_ADDR_LEN 16
+
+/* Defines for clipping space or space & quotes (single, double) */
+#define IPACM_XML_CLIP_SPACE " "
+#define IPACM_XML_CLIP_SPACE_QUOTES " '\""
+
+#define MAX_XML_STR_LEN 120
+
+/* IPA Config Entries */
+#define system_TAG "system"
+#define ODU_TAG "ODUCFG"
+#define ODUMODE_TAG "OduMode"
+#define ODUEMBMS_OFFLOAD_TAG "eMBMS_offload"
+#define ODU_ROUTER_TAG "router"
+#define ODU_BRIDGE_TAG "bridge"
+#define IPACMCFG_TAG "IPACM"
+#define IPACMIFACECFG_TAG "IPACMIface"
+#define IFACE_TAG "Iface"
+#define NAME_TAG "Name"
+#define CATEGORY_TAG "Category"
+#define MODE_TAG "Mode"
+#define IPACMPRIVATESUBNETCFG_TAG "IPACMPrivateSubnet"
+#define SUBNET_TAG "Subnet"
+#define SUBNETADDRESS_TAG "SubnetAddress"
+#define SUBNETMASK_TAG "SubnetMask"
+#define WANIF_TAG "WAN"
+#define LANIF_TAG "LAN"
+#define WLANIF_TAG "WLAN"
+#define WLAN_FULL_MODE_TAG "full"
+#define WLAN_INTERNET_MODE_TAG "internet"
+#define WLAN_MODE_TAG "WlanMode"
+#define VIRTUALIF_TAG "VIRTUAL"
+#define UNKNOWNIF_TAG "UNKNOWN"
+#define ODUIF_TAG "ODU"
+#define EMBMSIF_TAG "EMBMS"
+#define ETHIF_TAG "ETH"
+#define IFACE_ROUTER_MODE_TAG "ROUTER"
+#define IFACE_BRIDGE_MODE_TAG "BRIDGE"
+#define IPACMALG_TAG "IPACMALG"
+#define ALG_TAG "ALG"
+#define Protocol_TAG "Protocol"
+#define Port_TAG "Port"
+#define TCP_PROTOCOL_TAG "TCP"
+#define UDP_PROTOCOL_TAG "UDP"
+
+/* FIREWALL Config Entries */
+#define Firewall_TAG "Firewall"
+#define MobileAPFirewallCfg_TAG "MobileAPFirewallCfg"
+#define FirewallEnabled_TAG "FirewallEnabled"
+#define FirewallPktsAllowed_TAG "FirewallPktsAllowed"
+
+#define IPFamily_TAG "IPFamily"
+#define IPV4SourceAddress_TAG "IPV4SourceAddress"
+#define IPV4SourceIPAddress_TAG "IPV4SourceIPAddress"
+#define IPV4SourceSubnetMask_TAG "IPV4SourceSubnetMask"
+
+#define IPV4DestinationAddress_TAG "IPV4DestinationAddress"
+#define IPV4DestinationIPAddress_TAG "IPV4DestinationIPAddress"
+#define IPV4DestinationSubnetMask_TAG "IPV4DestinationSubnetMask"
+
+#define IPV4TypeOfService_TAG "IPV4TypeOfService"
+#define TOSValue_TAG "TOSValue"
+#define TOSMask_TAG "TOSMask"
+
+#define IPV4NextHeaderProtocol_TAG "IPV4NextHeaderProtocol"
+
+#define IPV6SourceAddress_TAG "IPV6SourceAddress"
+#define IPV6SourceIPAddress_TAG "IPV6SourceIPAddress"
+#define IPV6SourcePrefix_TAG "IPV6SourcePrefix"
+
+#define IPV6DestinationAddress_TAG "IPV6DestinationAddress"
+#define IPV6DestinationIPAddress_TAG "IPV6DestinationIPAddress"
+#define IPV6DestinationPrefix_TAG "IPV6DestinationPrefix"
+
+#define IPV6TrafficClass_TAG "IPV6TrafficClass"
+#define TrfClsValue_TAG "TrfClsValue"
+#define TrfClsMask_TAG "TrfClsMask"
+
+#define IPV6NextHeaderProtocol_TAG "IPV6NextHeaderProtocol"
+
+#define TCPSource_TAG "TCPSource"
+#define TCPSourcePort_TAG "TCPSourcePort"
+#define TCPSourceRange_TAG "TCPSourceRange"
+
+#define TCPDestination_TAG "TCPDestination"
+#define TCPDestinationPort_TAG "TCPDestinationPort"
+#define TCPDestinationRange_TAG "TCPDestinationRange"
+
+#define UDPSource_TAG "UDPSource"
+#define UDPSourcePort_TAG "UDPSourcePort"
+#define UDPSourceRange_TAG "UDPSourceRange"
+
+#define UDPDestination_TAG "UDPDestination"
+#define UDPDestinationPort_TAG "UDPDestinationPort"
+#define UDPDestinationRange_TAG "UDPDestinationRange"
+
+#define ICMPType_TAG "ICMPType"
+#define ICMPCode_TAG "ICMPCode"
+
+#define ESP_TAG "ESP"
+#define ESPSPI_TAG "ESPSPI"
+
+#define TCP_UDPSource_TAG "TCP_UDPSource"
+#define TCP_UDPSourcePort_TAG "TCP_UDPSourcePort"
+#define TCP_UDPSourceRange_TAG "TCP_UDPSourceRange"
+
+#define TCP_UDPDestination_TAG "TCP_UDPDestination"
+#define TCP_UDPDestinationPort_TAG "TCP_UDPDestinationPort"
+#define TCP_UDPDestinationRange_TAG "TCP_UDPDestinationRange"
+
+#define IPACMNat_TAG "IPACMNAT"
+#define NAT_MaxEntries_TAG "MaxNatEntries"
+
+/*---------------------------------------------------------------------------
+ IP protocol numbers - use in dss_socket() to identify protocols.
+ Also contains the extension header types for IPv6.
+---------------------------------------------------------------------------*/
+typedef enum
+{
+ IPACM_FIREWALL_IPV6_BASE_HDR = 4, /* IPv6 Base Header */
+ IPACM_FIREWALL_IPPROTO_HOP_BY_HOP_OPT_HDR = 0, /* Hop-by-hop Option Header */
+ IPACM_FIREWALL_IPPROTO_ICMP = 1, /* ICMP protocol */
+ IPACM_FIREWALL_IPPROTO_IGMP = 2, /* IGMP protocol */
+ IPACM_FIREWALL_IPPROTO_IP = IPACM_FIREWALL_IPV6_BASE_HDR, /* IPv4 */
+ IPACM_FIREWALL_IPPROTO_TCP = 6, /* TCP Protocol */
+ IPACM_FIREWALL_IPPROTO_UDP = 17, /* UDP Protocol */
+ IPACM_FIREWALL_IPPROTO_IPV6 = 41, /* IPv6 */
+ IPACM_FIREWALL_IPPROTO_ROUTING_HDR = 43, /* Routing Header */
+ IPACM_FIREWALL_IPPROTO_FRAG_HDR = 44, /* Fragmentation Header */
+ IPACM_FIREWALL_IPPROTO_GRE = 47, /* GRE Protocol */
+ IPACM_FIREWALL_IPPROTO_ESP = 50, /* ESP Protocol */
+ IPACM_FIREWALL_IPPROTO_AH = 51, /* Authentication Header */
+ IPACM_FIREWALL_IPPROTO_ICMP6 = 58, /* ICMPv6 */
+ IPACM_FIREWALL_NO_NEXT_HDR = 59, /* No Next Header for IPv6 */
+ IPACM_FIREWALL_IPPROTO_DEST_OPT_HDR = 60, /* Destination Options Header */
+ IPACM_FIREWALL_IPPROTO_MOBILITY_HDR = 135, /* Mobility Header */
+ IPACM_FIREWALL_IPPROTO_TCP_UDP = 253 /* Unspecified protocol used for IPACM */
+} ipacm_firewall_ip_protocol_enum_type;
+
+/* define as mobileap firewall rule format*/
+typedef enum
+{
+ IP_V4 = 4,
+ IP_V6 = 6
+} firewall_ip_version_enum;
+
+/*---------------------------------------------------------------------------
+ Extended FireWall Entry Configuration.
+---------------------------------------------------------------------------*/
+typedef struct
+{
+ struct ipa_rule_attrib attrib;
+ firewall_ip_version_enum ip_vsn;
+} IPACM_extd_firewall_entry_conf_t;
+
+
+/*---------------------------------------------------------------------------
+ Extended FireWall configuration.
+---------------------------------------------------------------------------*/
+typedef union
+{
+ IPACM_extd_firewall_entry_conf_t extd_firewall_entry;
+} IPACM_extd_firewall_conf_t;
+
+
+typedef struct
+{
+ char firewall_config_file[IPA_MAX_FILE_LEN];
+ uint8_t num_extd_firewall_entries;
+ IPACM_extd_firewall_entry_conf_t extd_firewall_entries[IPACM_MAX_FIREWALL_ENTRIES];
+ bool rule_action_accept;
+ bool firewall_enable;
+} IPACM_firewall_conf_t;
+
+
+
+typedef struct
+{
+ uint8_t num_iface_entries;
+ ipa_ifi_dev_name_t iface_entries[IPA_MAX_IFACE_ENTRIES];
+} ipacm_iface_conf_t;
+
+typedef struct
+{
+ uint8_t num_subnet_entries;
+ ipa_private_subnet private_subnet_entries[IPA_MAX_PRIVATE_SUBNET_ENTRIES];
+} ipacm_private_subnet_conf_t;
+
+typedef struct
+{
+ uint8_t protocol;
+ uint16_t port;
+} ipacm_alg;
+
+typedef struct
+{
+ uint8_t num_alg_entries;
+ ipacm_alg alg_entries[IPA_MAX_ALG_ENTRIES];
+} ipacm_alg_conf_t;
+
+
+typedef struct _IPACM_conf_t
+{
+ ipacm_iface_conf_t iface_config;
+ ipacm_private_subnet_conf_t private_subnet_config;
+ ipacm_alg_conf_t alg_config;
+ int nat_max_entries;
+ bool odu_enable;
+ bool router_mode_enable;
+ bool odu_embms_enable;
+ int num_wlan_guest_ap;
+} IPACM_conf_t;
+
+/* This function read IPACM XML configuration*/
+int ipacm_read_cfg_xml
+(
+ char *xml_file, /* Filename and path */
+ IPACM_conf_t *config /* Mobile AP config data */
+);
+
+/* This function reads QCMAP Firewall XML and store in IPACM Firewall stucture */
+int IPACM_read_firewall_xml
+(
+ char *xml_file, /* Filename and path */
+ IPACM_firewall_conf_t *config /* Mobile AP config data */
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //IPACM_XML