diff options
Diffstat (limited to 'data-ipa-cfg-mgr/ipacm/inc')
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h | 8 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h | 11 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h | 26 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h | 4 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h | 158 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h | 5 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h | 12 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h | 3 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h | 188 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h | 169 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h | 10 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h | 3 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h | 13 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h | 101 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h | 4 |
15 files changed, 270 insertions, 445 deletions
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h index 2f7709a..27d7c8b 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_CmdQueue.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -85,7 +85,8 @@ private: Message *Head; Message *Tail; Message* dequeue(void); - static MessageQueue *inst; + static MessageQueue *inst_internal; + static MessageQueue *inst_external; MessageQueue() { @@ -99,7 +100,8 @@ public: void enqueue(Message *item); static void* Process(void *); - static MessageQueue* getInstance(); + static MessageQueue* getInstanceInternal(); + static MessageQueue* getInstanceExternal(); }; diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h index 665b844..5bcb4eb 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -62,7 +62,7 @@ typedef struct _ipa_rm_client bool rx_bypass_ipa; /* support WLAN may not register RX-property, should not add dependency */ }ipa_rm_client; -#define MAX_NUM_EXT_PROPS 15 +#define MAX_NUM_EXT_PROPS 25 /* used to hold extended properties */ typedef struct @@ -115,6 +115,8 @@ public: bool ipacm_odu_embms_enable; + bool ipacm_ip_passthrough_mode; + int ipa_nat_iface_entries; /* Store the total number of wlan guest ap configured */ @@ -139,16 +141,15 @@ public: /* IPACM routing table name for v4/v6 */ struct ipa_ioc_get_rt_tbl rt_tbl_lan_v4, rt_tbl_wan_v4, rt_tbl_default_v4, rt_tbl_v6, rt_tbl_wan_v6; struct ipa_ioc_get_rt_tbl rt_tbl_wan_dl; - struct ipa_ioc_get_rt_tbl rt_tbl_lan2lan_v4, rt_tbl_lan2lan_v6; struct ipa_ioc_get_rt_tbl rt_tbl_odu_v4, rt_tbl_odu_v6; - struct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_lan_lan_v4, rt_tbl_eth_bridge_lan_wlan_v4, rt_tbl_eth_bridge_wlan_wlan_v4; - struct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_lan_lan_v6, rt_tbl_eth_bridge_lan_wlan_v6, rt_tbl_eth_bridge_wlan_wlan_v6; bool isMCC_Mode; /* To return the instance */ static IPACM_Config* GetInstance(); + 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)) diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h index db83598..cdf3ef5 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -46,11 +46,21 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "IPACM_LanToLan.h" #endif -#define MAX_NAT_IFACES 50 +#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 { @@ -63,8 +73,8 @@ private: int NatIfaceCnt; int StaClntCnt; NatIfaces *pNatIfaces; - uint32_t nat_iface_ipv4_addr[MAX_NAT_IFACES]; - uint32_t nonnat_iface_ipv4_addr[MAX_NAT_IFACES]; + uint32_t 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 @@ -78,9 +88,17 @@ private: 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: diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h index e6c27af..e50b316 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Conntrack_NATApp.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. +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 @@ -125,7 +125,7 @@ public: void AddTempEntry(const nat_table_entry *); void CacheEntry(const nat_table_entry *); void DeleteTempEntry(const nat_table_entry *); - void FlushTempEntries(uint32_t, bool); + void FlushTempEntries(uint32_t, bool, bool isDummy = false); }; diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h index 677b122..a6e76d1 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -45,6 +45,12 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #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> @@ -57,10 +63,10 @@ extern "C" #define IPA_ALG_PROTOCOL_NAME_LEN 10 #define IPA_WLAN_PARTIAL_HDR_OFFSET 0 // dst mac first then src mac -//#define IPA_ETH_PARTIAL_HDR_OFFSET 8 // dst mac first then src mac #define IPA_ODU_PARTIAL_HDR_OFFSET 8 // dst mac first then src mac #define IPA_WLAN_PARTIAL_HDR_NAME_v4 "IEEE802_3_v4" #define IPA_WLAN_PARTIAL_HDR_NAME_v6 "IEEE802_3_v6" +#define IPA_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" @@ -83,36 +89,16 @@ extern "C" #define WAN_DL_ROUTE_TABLE_NAME "ipa_dflt_wan_rt" #define V6_COMMON_ROUTE_TABLE_NAME "COMRTBLv6" #define V6_WAN_ROUTE_TABLE_NAME "WANRTBLv6" -#define V4_LAN_TO_LAN_ROUTE_TABLE_NAME "LANTOLANRTBLv4" -#define V6_LAN_TO_LAN_ROUTE_TABLE_NAME "LANTOLANRTBLv6" #define V4_ODU_ROUTE_TABLE_NAME "ODURTBLv4" #define V6_ODU_ROUTE_TABLE_NAME "ODURTBLv6" -#define ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_LAN_LAN_RTBLv4" -#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_LAN_WLAN_RTBLv4" -#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_WLAN_WLAN_RTBLv4" -#define ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_LAN_LAN_RTBLv6" -#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_LAN_WLAN_RTBLv6" -#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_WLAN_WLAN_RTBLv6" - #define WWAN_QMI_IOCTL_DEVICE_NAME "/dev/wwan_ioctl" #define IPA_DEVICE_NAME "/dev/ipa" +#define MAX_NUM_PROP 2 #define IPA_MAX_FLT_RULE 50 - -#define MAX_OFFLOAD_PAIR 3 -#define MAX_NUM_PROP 8 -#define IPA_LAN_TO_LAN_USB_HDR_NAME_V4 "Lan2Lan_USB_v4" -#define IPA_LAN_TO_LAN_USB_HDR_NAME_V6 "Lan2Lan_USB_v6" -#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V4 "Lan2Lan_Wlan_v4" -#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V6 "Lan2Lan_Wlan_v6" -#define IPA_LAN_TO_LAN_MAX_WLAN_CLIENT 16 -#define IPA_LAN_TO_LAN_MAX_USB_CLIENT 1 -#define IPA_LAN_TO_LAN_MAX_CPE_CLIENT 15 -#define IPA_LAN_TO_LAN_MAX_LAN_CLIENT (IPA_LAN_TO_LAN_MAX_USB_CLIENT + IPA_LAN_TO_LAN_MAX_CPE_CLIENT) #define TCP_FIN_SHIFT 16 #define TCP_SYN_SHIFT 17 #define TCP_RST_SHIFT 18 -#define NUM_TCP_CTL_FLT_RULE 3 #define NUM_IPV6_PREFIX_FLT_RULE 1 /*--------------------------------------------------------------------------- @@ -136,66 +122,63 @@ extern "C" ===========================================================================*/ typedef enum { - IPA_CFG_CHANGE_EVENT = 1, /* 1 NULL */ - IPA_LINK_UP_EVENT, /* 2 ipacm_event_data_fid */ - IPA_LINK_DOWN_EVENT, /* 3 ipacm_event_data_fid */ - IPA_ADDR_ADD_EVENT, /* 4 ipacm_event_data_addr */ - IPA_ADDR_DEL_EVENT, /* 5 no use */ - IPA_ROUTE_ADD_EVENT, /* 6 ipacm_event_data_addr */ - IPA_ROUTE_DEL_EVENT, /* 7 ipacm_event_data_addr */ - IPA_FIREWALL_CHANGE_EVENT, /* 8 NULL */ - IPA_WLAN_AP_LINK_UP_EVENT, /* 9 ipacm_event_data_mac */ - IPA_WLAN_STA_LINK_UP_EVENT, /* 10 ipacm_event_data_mac */ - IPA_WLAN_CLIENT_ADD_EVENT, /* 11 ipacm_event_data_mac */ - IPA_WLAN_CLIENT_DEL_EVENT, /* 12 ipacm_event_data_mac */ - IPA_WLAN_CLIENT_POWER_SAVE_EVENT, /* 13 ipacm_event_data_mac */ - IPA_WLAN_CLIENT_RECOVER_EVENT, /* 14 ipacm_event_data_mac */ - IPA_NEW_NEIGH_EVENT, /* 15 ipacm_event_data_all */ - IPA_DEL_NEIGH_EVENT, /* 16 ipacm_event_data_all */ - IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, /* 17 ipacm_event_data_all */ - IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, /* 18 ipacm_event_data_all */ - IPA_SW_ROUTING_ENABLE, /* 19 NULL */ - IPA_SW_ROUTING_DISABLE, /* 20 NULL */ - IPA_PROCESS_CT_MESSAGE, /* 21 ipacm_ct_evt_data */ - IPA_HANDLE_WAN_UP, /* 22 ipacm_event_iface_up */ - IPA_HANDLE_WAN_DOWN, /* 23 ipacm_event_iface_up */ - IPA_HANDLE_WLAN_UP, /* 24 ipacm_event_iface_up */ - IPA_HANDLE_LAN_UP, /* 25 ipacm_event_iface_up */ - IPA_WLAN_CLIENT_ADD_EVENT_EX, /* 26 ipacm_event_data_wlan_ex */ - IPA_HANDLE_WAN_UP_V6, /* 27 NULL */ - IPA_HANDLE_WAN_DOWN_V6, /* 28 NULL */ - IPA_LAN_CLIENT_ACTIVE, /* 29 ipacm_event_lan_client*/ - IPA_LAN_CLIENT_INACTIVE, /* 30 ipacm_event_lan_client*/ - IPA_LAN_CLIENT_DISCONNECT, /* 31 ipacm_event_lan_client*/ - IPA_LAN_CLIENT_POWER_SAVE, /* 32 ipacm_event_lan_client*/ - IPA_LAN_CLIENT_POWER_RECOVER, /* 33 ipacm_event_lan_client*/ - IPA_LAN_TO_LAN_NEW_CONNECTION, /* 34 ipacm_event_connection */ - IPA_LAN_TO_LAN_DEL_CONNECTION, /* 35 ipacm_event_connection */ - IPA_LAN_DELETE_SELF, /* 36 ipacm_event_data_fid */ - IPA_WLAN_LINK_DOWN_EVENT, /* 37 ipacm_event_data_mac */ - IPA_USB_LINK_UP_EVENT, /* 38 ipacm_event_data_fid */ - IPA_PROCESS_CT_MESSAGE_V6, /* 39 ipacm_ct_evt_data */ - IPA_PRIVATE_SUBNET_CHANGE_EVENT, /* 40 ipacm_event_data_fid */ - IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT, /* 41 ipacm_event_data_fid */ - IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, /* 42 ipacm_event_data_fid */ - IPA_WAN_EMBMS_LINK_UP_EVENT, /* 43 ipacm_event_data_mac */ - IPA_ETH_BRIDGE_LAN_CLIENT_ADD_EVENT, /* 44 ipacm_event_data_mac */ - IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT, /* 45 ipacm_event_data_mac */ - IPA_ETH_BRIDGE_LAN_CLIENT_DEL_EVENT, /* 46 ipacm_event_data_mac */ - IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT, /* 47 ipacm_event_data_mac */ - IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT, /* 48 ipacm_event_data_if_cat */ - IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT, /* 49 ipacm_event_data_if_cat */ - IPA_WLAN_SWITCH_TO_SCC, /* 50 No Data */ - IPA_WLAN_SWITCH_TO_MCC, /* 51 No Data */ - IPA_CRADLE_WAN_MODE_SWITCH, /* 52 ipacm_event_cradle_wan_mode */ - IPA_WAN_XLAT_CONNECT_EVENT, /* 53 ipacm_event_data_fid */ - IPA_TETHERING_STATS_UPDATE_EVENT, /* 54 ipacm_event_data_fid */ - IPA_NETWORK_STATS_UPDATE_EVENT, /* 55 ipacm_event_data_fid */ - IPA_HANDLE_WAN_UP_TETHER, /* 56 ipacm_event_iface_up_tehter */ - IPA_HANDLE_WAN_DOWN_TETHER, /* 57 ipacm_event_iface_up_tehter */ - IPA_HANDLE_WAN_UP_V6_TETHER, /* 58 ipacm_event_iface_up_tehter */ - IPA_HANDLE_WAN_DOWN_V6_TETHER, /* 59 ipacm_event_iface_up_tehter */ - IPA_BRIDGE_LINK_UP_EVENT, /* 60 ipacm_event_data_all */ + 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; @@ -269,12 +252,10 @@ typedef struct typedef struct { - enum ipa_ip_type iptype; - uint32_t ipv4_addr; - uint32_t ipv6_addr[4]; + IPACM_Lan *p_iface; + ipa_ip_type iptype; uint8_t mac_addr[6]; - IPACM_Lan* p_iface; -} ipacm_event_lan_client; +} ipacm_event_eth_bridge; typedef struct { @@ -318,6 +299,7 @@ typedef struct _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; diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h index 7554ba9..9bb8247 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Filtering.h @@ -1,5 +1,5 @@ -/* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +/* +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 @@ -53,6 +53,7 @@ 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); diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h index efcaa63..89bb26f 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Iface.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -81,7 +81,7 @@ public: int ipa_if_num; /* IPACM interface category */ - int ipa_if_cate; + ipacm_iface_type ipa_if_cate; /* IPACM interface name */ char dev_name[IF_NAME_LEN]; @@ -92,8 +92,6 @@ public: /* IPACM interface v6 ip-address*/ uint32_t ipv6_addr[MAX_DEFAULT_v6_ROUTE_RULES][4]; - uint32_t header_hdl; - uint32_t software_routing_fl_rule_hdl[MAX_SOFTWAREROUTING_FILTERTING_RULES]; bool softwarerouting_act; @@ -128,12 +126,6 @@ public: /*Query the IPA endpoint property */ int query_iface_property(void); - /*implement IPACM strlcpy */ - size_t strlcpy(char *dest, const char *src, size_t size); - - /*implement IPACM strlcat */ - size_t strlcat(char *dest, const char *src, size_t n); - /*Configure the initial filter rules */ virtual int init_fl_rule(ipa_ip_type iptype); diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h index e65c5d5..c7184f2 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_IfaceManager.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -48,7 +48,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "IPACM_Listener.h" #include "IPACM_Iface.h" -#define IPA_MAX_NUM_NEIGHBOR_CLIENTS 17 #define IPA_INSTANCE_NOT_FOUND 0 #define IPA_INSTANCE_FOUND 1 diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h index a210255..6c54f5e 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Lan.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -73,18 +73,6 @@ struct ipa_lan_rt_rule uint32_t rt_rule_hdl[0]; }; -typedef enum -{ - SRC_WLAN, - SRC_LAN -} eth_bridge_src_iface; - -typedef enum -{ - DST_WLAN, - DST_LAN -} eth_bridge_dst_iface; - /* Support multiple eth client */ typedef struct _eth_client_rt_hdl { @@ -109,44 +97,6 @@ typedef struct _ipa_eth_client eth_client_rt_hdl eth_rt_hdl[0]; /* depends on number of tx properties */ }ipa_eth_client; -struct lan2lan_flt_rule_hdl -{ - uint32_t rule_hdl; - bool valid; -}; - -struct lan2lan_hdr_hdl -{ - uint32_t hdr_hdl; - bool valid; -}; - -struct eth_bridge_client_flt_info -{ - uint8_t mac[IPA_MAC_ADDR_SIZE]; - uint32_t flt_rule_hdl_v4; - bool flt_rule_set_v4; - uint32_t flt_rule_hdl_v6; - bool flt_rule_set_v6; -}; - -struct eth_bridge_client_rt_info -{ - uint8_t mac[IPA_MAC_ADDR_SIZE]; - uint32_t rt_rule_hdl[0]; -}; - -struct hdr_proc_ctx_info -{ - uint32_t proc_ctx_hdl; - bool valid; -}; - -struct eth_bridge_subnet_client_info -{ - uint8_t mac[IPA_MAC_ADDR_SIZE]; - int ipa_if_num; -}; /* lan iface */ class IPACM_Lan : public IPACM_Iface @@ -191,110 +141,46 @@ public: /* install UL filter rule from Q6 */ virtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype, uint8_t xlat_mux_id); - int add_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr, uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t* rule_hdl); - - int del_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl); - - virtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl); - - int add_lan2lan_rt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr, - uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t hdr_hdl, lan_to_lan_rt_rule_hdl* rule_hdl); - - int del_lan2lan_rt_rule(ipa_ip_type iptype, lan_to_lan_rt_rule_hdl); - - int del_lan2lan_hdr(ipa_ip_type iptype, uint32_t hdr_hdl); - int handle_cradle_wan_mode_switch(bool is_wan_bridge_mode); int install_ipv4_icmp_flt_rule(); - static ipa_hdr_l2_type lan_hdr_type; - static ipa_hdr_l2_type wlan_hdr_type; - static uint32_t usb_hdr_template_hdl; - static uint32_t wlan_hdr_template_hdl; - static uint32_t cpe_hdr_template_hdl; + /* 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); - static hdr_proc_ctx_info lan_to_wlan_hdr_proc_ctx, wlan_to_usb_hdr_proc_ctx, wlan_to_cpe_hdr_proc_ctx; - static hdr_proc_ctx_info wlan_to_wlan_hdr_proc_ctx; - static hdr_proc_ctx_info cpe_to_usb_hdr_proc_ctx, usb_to_cpe_hdr_proc_ctx; + /* 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); - static eth_bridge_subnet_client_info eth_bridge_wlan_client[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT]; - static eth_bridge_subnet_client_info eth_bridge_lan_client[IPA_LAN_TO_LAN_MAX_LAN_CLIENT]; + /* 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); - static int num_wlan_client; - static int num_lan_client; + /* 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); - static bool is_usb_up; - static bool is_cpe_up; + /* delete filtering rule */ + int eth_bridge_del_flt_rule(uint32_t flt_rule_hdl, ipa_ip_type iptype); -protected: - - lan2lan_flt_rule_hdl wlan_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT]; - lan2lan_flt_rule_hdl wlan_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT]; - lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_LAN_CLIENT]; - lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_LAN_CLIENT]; - - eth_bridge_client_flt_info eth_bridge_wlan_client_flt_info[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT]; - eth_bridge_client_flt_info eth_bridge_lan_client_flt_info[IPA_LAN_TO_LAN_MAX_LAN_CLIENT]; - - int wlan_client_flt_info_count; - int lan_client_flt_info_count; - - int client_rt_info_size_v4; - int client_rt_info_size_v6; - - eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_lan_info_v4; - int lan_client_rt_from_lan_info_count_v4; - eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_lan_info_v6; - int lan_client_rt_from_lan_info_count_v6; - eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_wlan_info_v4; - int lan_client_rt_from_wlan_info_count_v4; - eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_wlan_info_v6; - int lan_client_rt_from_wlan_info_count_v6; - - int each_client_rt_rule_count_v4; - int each_client_rt_rule_count_v6; - - virtual int eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype); - - virtual int eth_bridge_handle_dummy_lan_client_flt_rule(ipa_ip_type iptype); - - int eth_bridge_add_lan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype); - - int eth_bridge_del_lan_client_flt_rule(uint8_t* mac); - - int eth_bridge_add_wlan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype); - - int eth_bridge_del_wlan_client_flt_rule(uint8_t* mac); - - int eth_bridge_post_lan_client_event(uint8_t* mac_addr, ipa_cm_event_id evt); - - int add_hdr_proc_ctx(); - - int del_hdr_proc_ctx(); + /* delete routing rule */ + int eth_bridge_del_rt_rule(uint32_t rt_rule_hdl, ipa_ip_type iptype); - ipa_hdr_proc_type get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2); + /* delete header processing context */ + int eth_bridge_del_hdr_proc_ctx(uint32_t hdr_proc_ctx_hdl); - virtual int eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype); - virtual int eth_bridge_install_cache_lan_client_flt_rule(ipa_ip_type iptype); - int eth_bridge_add_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype); - - int eth_bridge_del_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src); - - eth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype); - - void eth_bridge_add_lan_client(uint8_t* mac); +protected: - void eth_bridge_del_lan_client(uint8_t* mac); + int each_client_rt_rule_count[IPA_IP_MAX]; - int eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl); + 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_lan2lan_flt_rule(ipa_ip_type iptype); virtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype); @@ -302,9 +188,6 @@ protected: int reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl); - /*handle lan2lan client active*/ - int handle_lan2lan_client_active(ipacm_event_data_all *data, ipa_cm_event_id event); - virtual int install_ipv6_prefix_flt_rule(uint32_t* prefix); virtual void delete_ipv6_prefix_flt_rule(); @@ -319,26 +202,13 @@ protected: /* handle tethering client */ int handle_tethering_client(bool reset, ipacm_client_enum ipa_client); - lan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v4[MAX_OFFLOAD_PAIR]; - lan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v6[MAX_OFFLOAD_PAIR]; - - uint8_t num_lan2lan_flt_rule_v4; - uint8_t num_lan2lan_flt_rule_v6; - - lan2lan_hdr_hdl lan2lan_hdr_hdl_v4[MAX_OFFLOAD_PAIR]; - lan2lan_hdr_hdl lan2lan_hdr_hdl_v6[MAX_OFFLOAD_PAIR]; - /* store ipv4 UL filter rule handlers from Q6*/ uint32_t wan_ul_fl_rule_hdl_v4[MAX_WAN_UL_FILTER_RULES]; /* store ipv6 UL filter rule handlers from Q6*/ uint32_t wan_ul_fl_rule_hdl_v6[MAX_WAN_UL_FILTER_RULES]; - virtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype); - uint32_t ipv4_icmp_flt_rule_hdl[NUM_IPV4_ICMP_FLT_RULE]; - uint32_t tcp_ctl_flt_rule_hdl_v4[NUM_TCP_CTL_FLT_RULE]; - uint32_t tcp_ctl_flt_rule_hdl_v6[NUM_TCP_CTL_FLT_RULE]; uint32_t ipv6_prefix_flt_rule_hdl[NUM_IPV6_PREFIX_FLT_RULE]; uint32_t ipv6_icmp_flt_rule_hdl[NUM_IPV6_ICMP_FLT_RULE]; @@ -352,12 +222,17 @@ protected: uint32_t if_ipv4_subnet; - /* expected modem UL rules starting index */ - int exp_index_v4; - int exp_index_v6; + 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 */ @@ -508,9 +383,6 @@ private: /*handle lan iface down event*/ int handle_down_evt(); - /*handle lan2lan internal mesg posting*/ - int post_lan2lan_client_disconnect_msg(ipa_ip_type iptype); - /*handle reset usb-client rt-rules */ int handle_lan_client_reset_rt(ipa_ip_type iptype); }; diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h index 06d5832..a28631e 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_LanToLan.h @@ -42,7 +42,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "IPACM_Iface.h" #include "IPACM_Defs.h" #include "IPACM_Lan.h" -#include <unordered_map> #ifdef FEATURE_IPA_ANDROID #include <libxml/list.h> @@ -50,125 +49,153 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <list> #endif /* ndefined(FEATURE_IPA_ANDROID)*/ -struct client_info; +#define MAX_NUM_CACHED_CLIENT_ADD_EVENT 10 +#define MAX_NUM_IFACE 10 +#define MAX_NUM_CLIENT 16 -struct peer_info +struct rt_rule_info { - struct client_info* peer_pointer; - int num_connection; + 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]; }; -//used to store rule handles for offload link (one direction) -struct offload_link_info +struct client_info { - struct client_info* peer_pointer; - uint32_t flt_rule_hdl; - lan_to_lan_rt_rule_hdl rt_rule_hdl; - uint32_t hdr_hdl; + 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 */ }; -typedef list<peer_info> peer_info_list; -typedef list<offload_link_info> offload_link_info_list; -typedef list<ipacm_event_connection> connection_list; - -struct client_info +struct flt_rule_info { - union - { - uint32_t ipv4_addr; - uint32_t ipv6_addr[4]; - } ip; - uint8_t mac_addr[6]; - bool is_active; - bool is_powersave; - IPACM_Lan* p_iface; - peer_info_list peer; - offload_link_info_list link; + client_info *p_client; + uint32_t flt_rule_hdl[IPA_IP_MAX]; }; -struct v6_addr +struct peer_iface_info { - uint32_t ipv6_addr[4]; + 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; }; -typedef unordered_map<uint32_t, client_info> client_table_v4; -typedef unordered_map<uint64_t, client_info> client_table_v6; +class IPACM_LanToLan_Iface +{ +public: + IPACM_LanToLan_Iface(IPACM_Lan *p_iface); + ~IPACM_LanToLan_Iface(); + void add_client_rt_rule_for_new_iface(); -class IPACM_LanToLan : public IPACM_Listener -{ + void add_all_inter_interface_client_flt_rule(ipa_ip_type iptype); -public: + 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); - IPACM_LanToLan(); - ~IPACM_LanToLan(); + void print_data_structure_info(); - void handle_new_connection(ipacm_event_connection* new_conn); - void handle_del_connection(ipacm_event_connection* del_conn); + IPACM_Lan* get_iface_pointer(); - static IPACM_LanToLan* getLan2LanInstance(); + 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: - uint8_t num_offload_pair_v4_; - uint8_t num_offload_pair_v6_; - client_table_v4 client_info_v4_; - client_table_v6 client_info_v6_; + 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; - connection_list connection_v4_; - connection_list connection_v6_; + list<client_info> m_client_info; /* client list */ + list<peer_iface_info> m_peer_iface_info; /* peer information list */ - static IPACM_LanToLan* p_instance; + /* The following members are for intra-interface communication*/ + peer_iface_info m_intra_interface_info; - void event_callback(ipa_cm_event_id event, void* param); + void add_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client); - void handle_client_active(ipacm_event_lan_client* data); + void add_client_flt_rule(peer_iface_info *peer, client_info *client, ipa_ip_type iptype); - void check_potential_link(ipa_ip_type iptype, client_info* client); + void del_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client); - int add_offload_link(ipa_ip_type iptype, client_info* client, client_info* peer); + void del_client_flt_rule(peer_iface_info *peer, client_info *client); - void handle_client_inactive(ipacm_event_lan_client* data); + void add_client_rt_rule(peer_iface_info *peer, client_info *client); - int turnoff_offload_links(ipa_ip_type iptype, client_info* client); + void del_client_rt_rule(peer_iface_info *peer, client_info *client); - int del_offload_link(ipa_ip_type iptype, IPACM_Lan* client, IPACM_Lan* peer, offload_link_info* link); + void clear_all_flt_rule_for_one_peer_iface(peer_iface_info *peer); - void handle_client_disconnect(ipacm_event_lan_client* data); + void clear_all_rt_rule_for_one_peer_iface(peer_iface_info *peer); - int clear_peer_list(client_info* client); + void add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type); - void handle_client_power_save(ipacm_event_lan_client* data); + void del_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type); - void handle_client_power_recover(ipacm_event_lan_client* data); + void print_peer_info(peer_iface_info *peer_info); + +}; - int remove_flt_rules(ipa_ip_type iptype, client_info* client); +class IPACM_LanToLan : public IPACM_Listener +{ + +public: + + IPACM_LanToLan(); + +private: - int add_flt_rules(ipa_ip_type iptype, client_info* client); + ~IPACM_LanToLan(); -//the following are for connections + list<class IPACM_LanToLan_Iface> m_iface; - void handle_new_lan2lan_connection(ipacm_event_connection* data); + list<ipacm_event_eth_bridge> m_cached_client_add_event; - bool add_connection(client_info* src_client, client_info* dst_client); + void handle_iface_up(ipacm_event_eth_bridge *data); - void handle_del_lan2lan_connection(ipacm_event_connection* data); + void handle_iface_down(ipacm_event_eth_bridge *data); - bool remove_connection(client_info* src_client, client_info* dst_client); + void handle_client_add(ipacm_event_eth_bridge *data); - void erase_offload_link(ipa_ip_type iptype, client_info* src_client, client_info* dst_client); + void handle_client_del(ipacm_event_eth_bridge *data); - void generate_new_connection(ipa_ip_type iptype, client_info* client); + void handle_wlan_scc_mcc_switch(ipacm_event_eth_bridge *data); - bool is_lan2lan_connection(ipacm_event_connection* data); + void handle_new_iface_up(IPACM_LanToLan_Iface *new_iface, IPACM_LanToLan_Iface *exist_iface); - bool is_potential_lan2lan_connection(ipacm_event_connection* new_conn); + void event_callback(ipa_cm_event_id event, void* param); - void cache_new_connection(ipacm_event_connection* new_conn); + void handle_cached_client_add_event(IPACM_Lan *p_iface); - void remove_cache_connection(ipacm_event_connection* del_conn); + void clear_cached_client_add_event(IPACM_Lan *p_iface); - void check_cache_connection(ipa_ip_type iptype, client_info* client); + void print_data_structure_info(); }; diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h index 8fce44e..dab0280 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Log.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2013, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -68,7 +68,9 @@ 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__);\ + 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); @@ -78,9 +80,9 @@ static char dmesg_cmd[MAX_BUF_LEN]; ipacm_log_send (buffer_send); \ perror(fmt); #define IPACMERR(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\ - snprintf(buffer_send,MAX_BUF_LEN,"ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\ + snprintf(buffer_send,MAX_BUF_LEN,"ERROR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\ ipacm_log_send (buffer_send);\ - printf("ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); + 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);\ diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h index 4f5488f..b5ffabc 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Routing.h @@ -61,7 +61,6 @@ public: bool Reset(enum ipa_ip_type ip); bool GetRoutingTable(struct ipa_ioc_get_rt_tbl *routingTable); - bool PutRoutingTable(uint32_t routingTableHandle); bool DeviceNodeIsOpened(); bool DeleteRoutingHdl(uint32_t rt_rule_hdl, ipa_ip_type ip); @@ -71,6 +70,8 @@ public: 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 index 711f276..e42358f 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wan.h @@ -97,6 +97,7 @@ public: 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(); @@ -140,6 +141,11 @@ public: #endif } + static uint32_t getWANIP() + { + return curr_wan_ip; + } + static bool getXlat_Mux_Id() { return xlat_mux_id; @@ -202,6 +208,7 @@ private: 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; @@ -228,6 +235,8 @@ private: /* 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) { @@ -476,6 +485,7 @@ private: 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(); @@ -483,6 +493,9 @@ private: 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 index 6a2d53a..eb911ac 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Wlan.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +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 @@ -85,61 +85,16 @@ public: static int total_num_wifi_clients; - void event_callback(ipa_cm_event_id event, - void *data); + void event_callback(ipa_cm_event_id event, void *data); - virtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl); + bool is_guest_ap(); private: - eth_bridge_client_flt_info eth_bridge_lan_client_flt_info[IPA_LAN_TO_LAN_MAX_LAN_CLIENT]; - int lan_client_flt_info_count; + bool m_is_guest_ap; - static lan2lan_flt_rule_hdl self_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT]; - static lan2lan_flt_rule_hdl self_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT]; - - static lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v4[IPA_LAN_TO_LAN_MAX_LAN_CLIENT]; - static lan2lan_flt_rule_hdl lan_client_flt_rule_hdl_v6[IPA_LAN_TO_LAN_MAX_LAN_CLIENT]; - - bool is_guest_ap; - - eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_lan_info_v4; - int wlan_client_rt_from_lan_info_count_v4; - eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_lan_info_v6; - int wlan_client_rt_from_lan_info_count_v6; - - eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v4; - int wlan_client_rt_from_wlan_info_count_v4; - eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v6; - int wlan_client_rt_from_wlan_info_count_v6; - - int eth_bridge_install_wlan_guest_ap_ipv6_flt_rule(); - - virtual int eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype); - - virtual int eth_bridge_handle_dummy_lan_client_flt_rule(ipa_ip_type iptype); - - int eth_bridge_add_lan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype); - - int eth_bridge_del_lan_client_flt_rule(uint8_t* mac); - - int eth_bridge_add_self_client_flt_rule(uint8_t* mac, ipa_ip_type iptype); - - int eth_bridge_del_self_client_flt_rule(uint8_t* mac); - - virtual int eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype); - - virtual int eth_bridge_install_cache_lan_client_flt_rule(ipa_ip_type iptype); - - int eth_bridge_add_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype); - - int eth_bridge_del_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src); - - eth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype); - - void eth_bridge_add_wlan_client(uint8_t* mac, int if_num); - - void eth_bridge_del_wlan_client(uint8_t* mac); + /* handle wlan access mode switch in ethernet bridging*/ + void eth_bridge_handle_wlan_mode_switch(); int wlan_client_len; @@ -150,9 +105,6 @@ private: int wlan_ap_index; - static uint32_t* dummy_flt_rule_hdl_v4; - static uint32_t* dummy_flt_rule_hdl_v6; - static int num_wlan_ap_iface; NatApp *Nat_App; @@ -262,9 +214,6 @@ private: /* for handle wifi client initial,copy all partial headers (tx property) */ int handle_wlan_client_init_ex(ipacm_event_data_wlan_ex *data); - /*handle lan2lan internal mesg posting*/ - int handle_lan2lan_msg_post(uint8_t *mac_addr, ipa_cm_event_id event, ipa_ip_type iptype); - /*handle wifi client */ int handle_wlan_client_ipaddr(ipacm_event_data_all *data); @@ -280,49 +229,11 @@ private: /*handle wlan iface down event*/ int handle_down_evt(); - /* add dummy filtering rules for WLAN AP-AP mode support */ - void add_dummy_flt_rule(); - - /* install dummy filtering rules for WLAN AP-AP mode support */ - int install_dummy_flt_rule(ipa_ip_type iptype, int num_rule); - - /* delete dummy flt rule for WLAN AP-AP mode support*/ - void del_dummy_flt_rule(); - - /*Configure the initial filter rules */ - virtual int init_fl_rule(ipa_ip_type iptype); - - virtual int add_dummy_lan2lan_flt_rule(ipa_ip_type iptype); - - virtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype); - - /*configure private subnet filter rules*/ - virtual int handle_private_subnet(ipa_ip_type iptype); - - /* install UL filter rule from Q6 */ - virtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype, uint8_t xlat_mux_id); - - /* install TCP control filter rules */ - virtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype); - /*handle reset wifi-client rt-rules */ int handle_wlan_client_reset_rt(ipa_ip_type iptype); void handle_SCC_MCC_switch(ipa_ip_type); - void eth_bridge_handle_wlan_SCC_MCC_switch(ipa_ip_type iptype); - - int eth_bridge_modify_wlan_client_flt_rule(uint8_t* mac, eth_bridge_dst_iface dst_iface, ipa_ip_type iptype); - - int eth_bridge_modify_wlan_rt_rule(uint8_t* mac, eth_bridge_src_iface src_iface, ipa_ip_type iptyp); - - /*handle wlan access mode switch */ - void eth_bridge_handle_wlan_mode_switch(); - - virtual int install_ipv6_prefix_flt_rule(uint32_t* prefix); - - virtual void delete_ipv6_prefix_flt_rule(); - }; diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h index f645ae1..64c00ed 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Xml.h @@ -178,6 +178,9 @@ if (!(a)) { \ #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. @@ -276,6 +279,7 @@ typedef struct _IPACM_conf_t 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*/ |