diff options
Diffstat (limited to 'data-ipa-cfg-mgr/ipacm/inc')
21 files changed, 0 insertions, 3817 deletions
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h deleted file mode 100644 index 27d7c8b..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -Copyright (c) 2013-2016, 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_internal; - static MessageQueue *inst_external; - - MessageQueue() - { - Head = NULL; - Tail = NULL; - } - -public: - - ~MessageQueue() { } - void enqueue(Message *item); - - static void* Process(void *); - static MessageQueue* getInstanceInternal(); - static MessageQueue* getInstanceExternal(); - -}; - -#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 deleted file mode 100644 index 5bcb4eb..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h +++ /dev/null @@ -1,357 +0,0 @@ -/* -Copyright (c) 2013-2016, 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 25 - -/* 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; - - bool ipacm_ip_passthrough_mode; - - 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_odu_v4, rt_tbl_odu_v6; - - bool isMCC_Mode; - - /* To return the instance */ - static IPACM_Config* GetInstance(); - - const char* getEventName(ipa_cm_event_id event_id); - - 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 deleted file mode 100644 index a6076cf..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackClient.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -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 deleted file mode 100644 index cdf3ef5..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright (c) 2013-2016, 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_IFACE_ADDRESS 50 -#define MAX_STA_CLNT_IFACES 10 -#define STA_CLNT_SUBNET_MASK 0xFFFFFF00 - -using namespace std; - -typedef struct _nat_entry_bundle -{ - struct nf_conntrack *ct; - enum nf_conntrack_msg_type type; - nat_table_entry *rule; - bool isTempEntry; - -}nat_entry_bundle; - -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_IFACE_ADDRESS]; - uint32_t nonnat_iface_ipv4_addr[MAX_IFACE_ADDRESS]; - 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); - bool AddIface(nat_table_entry *, bool *); - void AddORDeleteNatEntry(const nat_entry_bundle *); - void PopulateTCPorUDPEntry(struct nf_conntrack *, uint32_t, nat_table_entry *); - void CheckSTAClient(const nat_table_entry *, bool *); - int CheckNatIface(ipacm_event_data_all *, bool *); - void HandleNonNatIPAddr(void *, bool); - -#ifdef CT_OPT - void ProcessCTV6Message(void *); - void HandleLan2Lan(struct nf_conntrack *, - enum nf_conntrack_msg_type, nat_table_entry* ); -#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 deleted file mode 100644 index e50b316..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -Copyright (c) 2013-2016, 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, bool isDummy = false); -}; - - - -#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 deleted file mode 100644 index d2cc362..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h +++ /dev/null @@ -1,354 +0,0 @@ -/* -Copyright (c) 2013-2016, 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" - -#ifdef USE_GLIB -#include <glib.h> -#define strlcpy g_strlcpy -#define strlcat g_strlcat -#endif - -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_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_DUMMY_ETH_HDR_NAME_v6 "ETH_dummy_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 20 -#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_ODU_ROUTE_TABLE_NAME "ODURTBLv4" -#define V6_ODU_ROUTE_TABLE_NAME "ODURTBLv6" - -#define WWAN_QMI_IOCTL_DEVICE_NAME "/dev/wwan_ioctl" -#define IPA_DEVICE_NAME "/dev/ipa" -#define MAX_NUM_PROP 2 - -#ifndef FEATURE_IPA_V3 -#define IPA_MAX_FLT_RULE 50 -#else -#define IPA_MAX_FLT_RULE 100 -#endif - -#define TCP_FIN_SHIFT 16 -#define TCP_SYN_SHIFT 17 -#define TCP_RST_SHIFT 18 -#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, /* NULL */ - IPA_PRIVATE_SUBNET_CHANGE_EVENT, /* ipacm_event_data_fid */ - IPA_FIREWALL_CHANGE_EVENT, /* NULL */ - IPA_LINK_UP_EVENT, /* ipacm_event_data_fid */ - IPA_LINK_DOWN_EVENT, /* ipacm_event_data_fid */ - IPA_USB_LINK_UP_EVENT, /* ipacm_event_data_fid */ - IPA_BRIDGE_LINK_UP_EVENT, /* ipacm_event_data_all */ - IPA_WAN_EMBMS_LINK_UP_EVENT, /* ipacm_event_data_mac */ - IPA_ADDR_ADD_EVENT, /* ipacm_event_data_addr */ - IPA_ADDR_DEL_EVENT, /* no use */ - IPA_ROUTE_ADD_EVENT, /* ipacm_event_data_addr */ - IPA_ROUTE_DEL_EVENT, /* ipacm_event_data_addr */ - IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT, /* ipacm_event_data_fid */ - IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, /* ipacm_event_data_fid */ - IPA_WLAN_AP_LINK_UP_EVENT, /* ipacm_event_data_mac */ - IPA_WLAN_STA_LINK_UP_EVENT, /* ipacm_event_data_mac */ - IPA_WLAN_LINK_DOWN_EVENT, /* ipacm_event_data_mac */ - IPA_WLAN_CLIENT_ADD_EVENT, /* ipacm_event_data_mac */ - IPA_WLAN_CLIENT_ADD_EVENT_EX, /* ipacm_event_data_wlan_ex */ - IPA_WLAN_CLIENT_DEL_EVENT, /* ipacm_event_data_mac */ - IPA_WLAN_CLIENT_POWER_SAVE_EVENT, /* ipacm_event_data_mac */ - IPA_WLAN_CLIENT_RECOVER_EVENT, /* ipacm_event_data_mac */ - IPA_NEW_NEIGH_EVENT, /* ipacm_event_data_all */ - IPA_DEL_NEIGH_EVENT, /* ipacm_event_data_all */ - IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, /* ipacm_event_data_all */ - IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, /* ipacm_event_data_all */ - IPA_SW_ROUTING_ENABLE, /* NULL */ - IPA_SW_ROUTING_DISABLE, /* NULL */ - IPA_PROCESS_CT_MESSAGE, /* ipacm_ct_evt_data */ - IPA_PROCESS_CT_MESSAGE_V6, /* ipacm_ct_evt_data */ - IPA_LAN_TO_LAN_NEW_CONNECTION, /* ipacm_event_connection */ - IPA_LAN_TO_LAN_DEL_CONNECTION, /* ipacm_event_connection */ - IPA_WLAN_SWITCH_TO_SCC, /* No Data */ - IPA_WLAN_SWITCH_TO_MCC, /* No Data */ - IPA_CRADLE_WAN_MODE_SWITCH, /* ipacm_event_cradle_wan_mode */ - IPA_WAN_XLAT_CONNECT_EVENT, /* ipacm_event_data_fid */ - IPA_TETHERING_STATS_UPDATE_EVENT, /* ipacm_event_data_fid */ - IPA_NETWORK_STATS_UPDATE_EVENT, /* ipacm_event_data_fid */ - - IPA_EXTERNAL_EVENT_MAX, - - IPA_HANDLE_WAN_UP, /* ipacm_event_iface_up */ - IPA_HANDLE_WAN_DOWN, /* ipacm_event_iface_up */ - IPA_HANDLE_WAN_UP_V6, /* NULL */ - IPA_HANDLE_WAN_DOWN_V6, /* NULL */ - IPA_HANDLE_WAN_UP_TETHER, /* ipacm_event_iface_up_tehter */ - IPA_HANDLE_WAN_DOWN_TETHER, /* ipacm_event_iface_up_tehter */ - IPA_HANDLE_WAN_UP_V6_TETHER, /* ipacm_event_iface_up_tehter */ - IPA_HANDLE_WAN_DOWN_V6_TETHER, /* ipacm_event_iface_up_tehter */ - IPA_HANDLE_WLAN_UP, /* ipacm_event_iface_up */ - IPA_HANDLE_LAN_UP, /* ipacm_event_iface_up */ - IPA_ETH_BRIDGE_IFACE_UP, /* ipacm_event_eth_bridge*/ - IPA_ETH_BRIDGE_IFACE_DOWN, /* ipacm_event_eth_bridge*/ - IPA_ETH_BRIDGE_CLIENT_ADD, /* ipacm_event_eth_bridge */ - IPA_ETH_BRIDGE_CLIENT_DEL, /* ipacm_event_eth_bridge*/ - IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH, /* ipacm_event_eth_bridge*/ - IPA_LAN_DELETE_SELF, /* ipacm_event_data_fid */ - 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 -{ - IPACM_Lan *p_iface; - ipa_ip_type iptype; - uint8_t mac_addr[6]; -} ipacm_event_eth_bridge; - -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; -#ifdef IPA_WAN_MSG_IPv6_ADDR_GW_LEN - uint32_t ipv4_addr_gw; - uint32_t ipv6_addr_gw[4]; -#endif -} 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; - int ipa_if_cate; - 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 deleted file mode 100644 index 550f4d4..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_EvtDispatcher.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -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 deleted file mode 100644 index 9bb8247..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright (c) 2013-2016, 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 AddFilteringRuleAfter(struct ipa_ioc_add_flt_rule_after 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 deleted file mode 100644 index 027c8ff..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Header.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -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 deleted file mode 100644 index 43b0da6..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -Copyright (c) 2013-2016, 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 */ - ipacm_iface_type 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 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); - - /*Configure the initial filter rules */ - virtual int init_fl_rule(ipa_ip_type iptype); - - /* Change IP Type.*/ - void config_ip_type(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 deleted file mode 100644 index c7184f2..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright (c) 2013-2016, 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_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 deleted file mode 100644 index 6c54f5e..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h +++ /dev/null @@ -1,390 +0,0 @@ -/* -Copyright (c) 2013-2016, 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]; -}; - -/* 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; - - -/* 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 handle_cradle_wan_mode_switch(bool is_wan_bridge_mode); - - int install_ipv4_icmp_flt_rule(); - - - /* add header processing context and return handle to lan2lan controller */ - int eth_bridge_add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_hdr_type, uint32_t *hdl); - - /* add routing rule and return handle to lan2lan controller */ - int eth_bridge_add_rt_rule(uint8_t *mac, char *rt_tbl_name, uint32_t hdr_proc_ctx_hdl, - ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int *rt_rule_count); - - /* modify routing rule*/ - int eth_bridge_modify_rt_rule(uint8_t *mac, uint32_t hdr_proc_ctx_hdl, - ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int rt_rule_count); - - /* add filtering rule and return handle to lan2lan controller */ - int eth_bridge_add_flt_rule(uint8_t *mac, uint32_t rt_tbl_hdl, ipa_ip_type iptype, uint32_t *flt_rule_hdl); - - /* delete filtering rule */ - int eth_bridge_del_flt_rule(uint32_t flt_rule_hdl, ipa_ip_type iptype); - - /* delete routing rule */ - int eth_bridge_del_rt_rule(uint32_t rt_rule_hdl, ipa_ip_type iptype); - - /* delete header processing context */ - int eth_bridge_del_hdr_proc_ctx(uint32_t hdr_proc_ctx_hdl); - - - -protected: - - int each_client_rt_rule_count[IPA_IP_MAX]; - - uint32_t eth_bridge_flt_rule_offset[IPA_IP_MAX]; - - /* mac address has to be provided for client related events */ - void eth_bridge_post_event(ipa_cm_event_id evt, ipa_ip_type iptype, uint8_t *mac); - - - - 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); - - 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); - - /* 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]; - - uint32_t ipv4_icmp_flt_rule_hdl[NUM_IPV4_ICMP_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; - - uint32_t ipv6_prefix[2]; - -private: - - /* get hdr proc ctx type given source and destination l2 hdr type */ - ipa_hdr_proc_type eth_bridge_get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2); - - /* get partial header (header template of hdr proc ctx) */ - int eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl); - - - /* 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 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 deleted file mode 100644 index a28631e..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -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" - -#ifdef FEATURE_IPA_ANDROID -#include <libxml/list.h> -#else/* defined(FEATURE_IPA_ANDROID) */ -#include <list> -#endif /* ndefined(FEATURE_IPA_ANDROID)*/ - -#define MAX_NUM_CACHED_CLIENT_ADD_EVENT 10 -#define MAX_NUM_IFACE 10 -#define MAX_NUM_CLIENT 16 - -struct rt_rule_info -{ - int num_hdl[IPA_IP_MAX]; /* one client may need more than one routing rules on the same routing table depending on tx_prop */ - uint32_t rule_hdl[IPA_IP_MAX][MAX_NUM_PROP]; -}; - -struct client_info -{ - uint8_t mac_addr[6]; - rt_rule_info inter_iface_rt_rule_hdl[IPA_HDR_L2_MAX]; /* routing rule handles of inter interface communication based on source l2 header type */ - rt_rule_info intra_iface_rt_rule_hdl; /* routing rule handles of inter interface communication */ -}; - -struct flt_rule_info -{ - client_info *p_client; - uint32_t flt_rule_hdl[IPA_IP_MAX]; -}; - -struct peer_iface_info -{ - class IPACM_LanToLan_Iface *peer; - char rt_tbl_name_for_rt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX]; - char rt_tbl_name_for_flt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX]; - list<flt_rule_info> flt_rule; -}; - -class IPACM_LanToLan_Iface -{ -public: - IPACM_LanToLan_Iface(IPACM_Lan *p_iface); - ~IPACM_LanToLan_Iface(); - - void add_client_rt_rule_for_new_iface(); - - void add_all_inter_interface_client_flt_rule(ipa_ip_type iptype); - - void add_all_intra_interface_client_flt_rule(ipa_ip_type iptype); - - void handle_down_event(); - - void handle_wlan_scc_mcc_switch(); - - void handle_intra_interface_info(); - - void handle_new_iface_up(char rt_tbl_name_for_flt[][IPA_RESOURCE_NAME_MAX], char rt_tbl_name_for_rt[][IPA_RESOURCE_NAME_MAX], - IPACM_LanToLan_Iface *peer_iface); - - void handle_client_add(uint8_t *mac); - - void handle_client_del(uint8_t *mac); - - void print_data_structure_info(); - - IPACM_Lan* get_iface_pointer(); - - bool get_m_is_ip_addr_assigned(ipa_ip_type iptype); - - void set_m_is_ip_addr_assigned(ipa_ip_type iptype, bool value); - - bool get_m_support_inter_iface_offload(); - - bool get_m_support_intra_iface_offload(); - - void increment_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type); - - void decrement_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type); - -private: - - IPACM_Lan *m_p_iface; - bool m_is_ip_addr_assigned[IPA_IP_MAX]; - bool m_support_inter_iface_offload; - bool m_support_intra_iface_offload; - - int ref_cnt_peer_l2_hdr_type[IPA_HDR_L2_MAX]; /* reference count of l2 header type of peer interfaces */ - uint32_t hdr_proc_ctx_for_inter_interface[IPA_HDR_L2_MAX]; - uint32_t hdr_proc_ctx_for_intra_interface; - - list<client_info> m_client_info; /* client list */ - list<peer_iface_info> m_peer_iface_info; /* peer information list */ - - /* The following members are for intra-interface communication*/ - peer_iface_info m_intra_interface_info; - - void add_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client); - - void add_client_flt_rule(peer_iface_info *peer, client_info *client, ipa_ip_type iptype); - - void del_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client); - - void del_client_flt_rule(peer_iface_info *peer, client_info *client); - - void add_client_rt_rule(peer_iface_info *peer, client_info *client); - - void del_client_rt_rule(peer_iface_info *peer, client_info *client); - - void clear_all_flt_rule_for_one_peer_iface(peer_iface_info *peer); - - void clear_all_rt_rule_for_one_peer_iface(peer_iface_info *peer); - - void add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type); - - void del_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type); - - void print_peer_info(peer_iface_info *peer_info); - -}; - -class IPACM_LanToLan : public IPACM_Listener -{ - -public: - - IPACM_LanToLan(); - -private: - - ~IPACM_LanToLan(); - - list<class IPACM_LanToLan_Iface> m_iface; - - list<ipacm_event_eth_bridge> m_cached_client_add_event; - - void handle_iface_up(ipacm_event_eth_bridge *data); - - void handle_iface_down(ipacm_event_eth_bridge *data); - - void handle_client_add(ipacm_event_eth_bridge *data); - - void handle_client_del(ipacm_event_eth_bridge *data); - - void handle_wlan_scc_mcc_switch(ipacm_event_eth_bridge *data); - - void handle_new_iface_up(IPACM_LanToLan_Iface *new_iface, IPACM_LanToLan_Iface *exist_iface); - - void event_callback(ipa_cm_event_id event, void* param); - - void handle_cached_client_add_event(IPACM_Lan *p_iface); - - void clear_cached_client_add_event(IPACM_Lan *p_iface); - - void print_data_structure_info(); - -}; - -#endif diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h deleted file mode 100644 index 9d774fe..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Listener.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -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 deleted file mode 100644 index dab0280..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -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__);\ - ipacm_log_send (buffer_send);\ - printf("%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,"ERROR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\ - ipacm_log_send (buffer_send);\ - printf("ERROR: %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 deleted file mode 100644 index 14e86e5..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Neighbor.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -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 deleted file mode 100644 index b0bdeb8..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Netlink.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -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 deleted file mode 100644 index b5ffabc..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -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 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 */ - - bool PutRoutingTable(uint32_t routingTableHandle); -}; - -#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 deleted file mode 100644 index fe6d35e..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h +++ /dev/null @@ -1,499 +0,0 @@ -/* -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]; - static uint32_t curr_wan_ip; - 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 uint32_t getWANIP() - { - return curr_wan_ip; - } - - 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: - - bool is_ipv6_frag_firewall_flt_rule_installed; - 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]; - uint8_t netdev_mac[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; - uint32_t hdr_hdl_dummy_v6; - uint32_t hdr_proc_hdl_dummy_v6; - - 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); - - /* 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); - - /* construct dummy ethernet header */ - int add_dummy_rx_hdr(); -}; - -#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 deleted file mode 100644 index eb911ac..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h +++ /dev/null @@ -1,240 +0,0 @@ -/* -Copyright (c) 2013-2016, 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); - - bool is_guest_ap(); - -private: - - bool m_is_guest_ap; - - /* handle wlan access mode switch in ethernet bridging*/ - void eth_bridge_handle_wlan_mode_switch(); - - - int wlan_client_len; - ipa_wlan_client *wlan_client; - - int header_name_count; - int num_wifi_client; - - int wlan_ap_index; - - 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 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(); - - /*handle reset wifi-client rt-rules */ - int handle_wlan_client_reset_rt(ipa_ip_type iptype); - - void handle_SCC_MCC_switch(ipa_ip_type); - -}; - - -#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 deleted file mode 100644 index 64c00ed..0000000 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h +++ /dev/null @@ -1,303 +0,0 @@ -/* -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" - -#define IP_PassthroughFlag_TAG "IPPassthroughFlag" -#define IP_PassthroughMode_TAG "IPPassthroughMode" - -/*--------------------------------------------------------------------------- - 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; - bool ip_passthrough_mode; -} 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 |