aboutsummaryrefslogtreecommitdiff
path: root/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-05-17 13:50:43 -0700
committerdavidevinavil <davidevinavil@gmail.com>2017-01-21 18:20:40 +0100
commit9b2f586aa30c3802a7663a25cf98eb8f06309d2f (patch)
treedf43e5bb7aeb9957b31ebdfbdce45baec7744f20 /data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp
parent11e7b3c6aa71b15800f7cf989ac71bbd85a68e51 (diff)
z2_plus: Update IPA connection manager to 1.0 branch
Change-Id: I20555a4bd9981f652f71360bdb7d83e822fad883
Diffstat (limited to 'data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp')
-rw-r--r--data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp4065
1 files changed, 540 insertions, 3525 deletions
diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp
index 2cc5088..eadf159 100644
--- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp
+++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp
@@ -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
@@ -55,28 +55,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bool IPACM_Lan::odu_up = false;
-ipa_hdr_l2_type IPACM_Lan::lan_hdr_type = IPA_HDR_L2_NONE;
-ipa_hdr_l2_type IPACM_Lan::wlan_hdr_type = IPA_HDR_L2_NONE;
-
-uint32_t IPACM_Lan::usb_hdr_template_hdl = 0;
-uint32_t IPACM_Lan::wlan_hdr_template_hdl = 0;
-uint32_t IPACM_Lan::cpe_hdr_template_hdl = 0;
-
-hdr_proc_ctx_info IPACM_Lan::lan_to_wlan_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::wlan_to_usb_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::wlan_to_cpe_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::wlan_to_wlan_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::usb_to_cpe_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::cpe_to_usb_hdr_proc_ctx;
-
-eth_bridge_subnet_client_info IPACM_Lan::eth_bridge_wlan_client[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
-eth_bridge_subnet_client_info IPACM_Lan::eth_bridge_lan_client[IPA_LAN_TO_LAN_MAX_LAN_CLIENT];
-
-int IPACM_Lan::num_wlan_client = 0;
-int IPACM_Lan::num_lan_client = 0;
-bool IPACM_Lan::is_usb_up = false;
-bool IPACM_Lan::is_cpe_up = false;
-
IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
{
num_eth_client = 0;
@@ -87,8 +65,7 @@ IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
odu_route_rule_v4_hdl = NULL;
odu_route_rule_v6_hdl = NULL;
eth_client = NULL;
- int m_fd_odu, ret = IPACM_SUCCESS;
- uint32_t* hdr_template_ptr;
+ int i, m_fd_odu, ret = IPACM_SUCCESS;
Nat_App = NatApp::GetInstance();
if (Nat_App == NULL)
@@ -100,7 +77,7 @@ IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
/* support eth multiple clients */
if(iface_query != NULL)
{
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat != WLAN_IF)
+ if(ipa_if_cate != WLAN_IF)
{
eth_client_len = (sizeof(ipa_eth_client)) + (iface_query->num_tx_props * sizeof(eth_client_rt_hdl));
eth_client = (ipa_eth_client *)calloc(IPA_MAX_NUM_ETH_CLIENTS, eth_client_len);
@@ -113,42 +90,9 @@ IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
IPACMDBG_H(" IPACM->IPACM_Lan(%d) constructor: Tx:%d Rx:%d \n", ipa_if_num,
iface_query->num_tx_props, iface_query->num_rx_props);
-#ifdef FEATURE_ETH_BRIDGE_LE
- if((IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF
- || IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF) && tx_prop != NULL)
- {
- if (IPACM_Lan::lan_hdr_type != IPA_HDR_L2_NONE && tx_prop->tx[0].hdr_l2_type != IPACM_Lan::lan_hdr_type)
- {
- IPACMERR("The LAN header format is not consistent! Now header format is %d.\n", tx_prop->tx[0].hdr_l2_type);
- }
- else
- {
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- hdr_template_ptr = &IPACM_Lan::usb_hdr_template_hdl;
- IPACM_Lan::is_usb_up = true;
- }
- else //else it is ODU_IF (cpe)
- {
- hdr_template_ptr = &IPACM_Lan::cpe_hdr_template_hdl;
- IPACM_Lan::is_cpe_up = true;
- }
- if(eth_bridge_get_hdr_template_hdl(hdr_template_ptr) == IPACM_FAILURE)
- {
- IPACMERR("Failed to setup lan hdr template.\n");
- }
- else
- {
- IPACM_Lan::lan_hdr_type = tx_prop->tx[0].hdr_l2_type;
- IPACMDBG_H("The LAN header format is %d.\n", tx_prop->tx[0].hdr_l2_type);
- add_hdr_proc_ctx();
- }
- }
- }
-#endif
/* ODU routing table initilization */
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
+ if(ipa_if_cate == ODU_IF)
{
odu_route_rule_v4_hdl = (uint32_t *)calloc(iface_query->num_tx_props, sizeof(uint32_t));
odu_route_rule_v6_hdl = (uint32_t *)calloc(iface_query->num_tx_props, sizeof(uint32_t));
@@ -166,24 +110,9 @@ IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
memset(wan_ul_fl_rule_hdl_v4, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));
memset(wan_ul_fl_rule_hdl_v6, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));
- memset(lan2lan_flt_rule_hdl_v4, 0, MAX_OFFLOAD_PAIR * sizeof(lan2lan_flt_rule_hdl));
- num_lan2lan_flt_rule_v4 = 0;
-
- memset(lan2lan_flt_rule_hdl_v6, 0, MAX_OFFLOAD_PAIR * sizeof(lan2lan_flt_rule_hdl));
- num_lan2lan_flt_rule_v6 = 0;
-
- memset(lan2lan_hdr_hdl_v4, 0, MAX_OFFLOAD_PAIR*sizeof(lan2lan_hdr_hdl));
- memset(lan2lan_hdr_hdl_v6, 0, MAX_OFFLOAD_PAIR*sizeof(lan2lan_hdr_hdl));
-
- memset(lan_client_flt_rule_hdl_v4, 0, IPA_LAN_TO_LAN_MAX_LAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));
- memset(lan_client_flt_rule_hdl_v6, 0, IPA_LAN_TO_LAN_MAX_LAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));
- memset(wlan_client_flt_rule_hdl_v4, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));
- memset(wlan_client_flt_rule_hdl_v6, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(lan2lan_flt_rule_hdl));
-
is_active = true;
memset(ipv4_icmp_flt_rule_hdl, 0, NUM_IPV4_ICMP_FLT_RULE * sizeof(uint32_t));
- memset(tcp_ctl_flt_rule_hdl_v4, 0, NUM_TCP_CTL_FLT_RULE*sizeof(uint32_t));
- memset(tcp_ctl_flt_rule_hdl_v6, 0, NUM_TCP_CTL_FLT_RULE*sizeof(uint32_t));
+
is_mode_switch = false;
if_ipv4_subnet =0;
memset(private_fl_rule_hdl, 0, IPA_MAX_PRIVATE_SUBNET_ENTRIES * sizeof(uint32_t));
@@ -191,35 +120,11 @@ IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
memset(ipv6_icmp_flt_rule_hdl, 0, NUM_IPV6_ICMP_FLT_RULE * sizeof(uint32_t));
modem_ul_v4_set = false;
modem_ul_v6_set = false;
-
-#ifdef FEATURE_ETH_BRIDGE_LE
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- exp_index_v4 = IPV4_DEFAULT_FILTERTING_RULES + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_CPE_CLIENT + NUM_IPV4_ICMP_FLT_RULE + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
- exp_index_v6 = IPV6_DEFAULT_FILTERTING_RULES + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_CPE_CLIENT + NUM_IPV6_ICMP_FLT_RULE + NUM_IPV6_PREFIX_FLT_RULE;
- }
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- exp_index_v4 = IPV4_DEFAULT_FILTERTING_RULES + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT + NUM_IPV4_ICMP_FLT_RULE + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
- exp_index_v6 = IPV6_DEFAULT_FILTERTING_RULES + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT + NUM_IPV6_ICMP_FLT_RULE + NUM_IPV6_PREFIX_FLT_RULE;
- }
-#else
-#ifdef CT_OPT
- exp_index_v4 = IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + NUM_TCP_CTL_FLT_RULE + NUM_IPV4_ICMP_FLT_RULE +IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
- exp_index_v6 = IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + NUM_IPV6_ICMP_FLT_RULE + NUM_IPV6_PREFIX_FLT_RULE;
-#else
- exp_index_v4 = IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + NUM_IPV4_ICMP_FLT_RULE + IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
- exp_index_v6 = IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + NUM_IPV6_ICMP_FLT_RULE + NUM_IPV6_PREFIX_FLT_RULE;
-#endif
-#ifdef FEATURE_IPA_ANDROID
- exp_index_v4 = exp_index_v4 - IPACM_Iface::ipacmcfg->ipa_num_private_subnet + IPA_MAX_PRIVATE_SUBNET_ENTRIES;
-#endif
-#endif
+ memset(ipv6_prefix, 0, sizeof(ipv6_prefix));
/* ODU routing table initilization */
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
+ if(ipa_if_cate == ODU_IF)
{
-
/* only do one time ioctl to odu-driver to infrom in router or bridge mode*/
if (IPACM_Lan::odu_up != true)
{
@@ -252,55 +157,18 @@ IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
}
}
- int i;
- each_client_rt_rule_count_v4 = 0;
- each_client_rt_rule_count_v6 = 0;
+ each_client_rt_rule_count[IPA_IP_v4] = 0;
+ each_client_rt_rule_count[IPA_IP_v6] = 0;
if(iface_query != NULL && tx_prop != NULL)
{
for(i=0; i<iface_query->num_tx_props; i++)
- {
- if(tx_prop->tx[i].ip == IPA_IP_v4)
- {
- each_client_rt_rule_count_v4++;
- }
- else
- {
- each_client_rt_rule_count_v6++;
- }
- }
- }
- IPACMDBG_H("Need to add %d IPv4 and %d IPv6 routing rules for eth bridge for each client.\n", each_client_rt_rule_count_v4, each_client_rt_rule_count_v6);
-
- memset(eth_bridge_lan_client_flt_info, 0, IPA_LAN_TO_LAN_MAX_LAN_CLIENT * sizeof(eth_bridge_client_flt_info));
- memset(eth_bridge_wlan_client_flt_info, 0, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(eth_bridge_client_flt_info));
-
- lan_client_flt_info_count = 0;
- wlan_client_flt_info_count = 0;
-
- eth_bridge_lan_client_rt_from_lan_info_v4 = NULL;
- eth_bridge_lan_client_rt_from_lan_info_v6 = NULL;
- eth_bridge_lan_client_rt_from_wlan_info_v4 = NULL;
- eth_bridge_lan_client_rt_from_wlan_info_v6 = NULL;
-#ifdef FEATURE_ETH_BRIDGE_LE
- if(tx_prop != NULL)
- {
- client_rt_info_size_v4 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v4 * sizeof(uint32_t);
- eth_bridge_lan_client_rt_from_lan_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_LAN_CLIENT, client_rt_info_size_v4);
- eth_bridge_lan_client_rt_from_wlan_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_LAN_CLIENT, client_rt_info_size_v4);
- client_rt_info_size_v6 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v6 * sizeof(uint32_t);
- eth_bridge_lan_client_rt_from_lan_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);
- eth_bridge_lan_client_rt_from_wlan_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);
-
+ each_client_rt_rule_count[tx_prop->tx[i].ip]++;
}
-#endif
- lan_client_rt_from_lan_info_count_v4 = 0;
- lan_client_rt_from_lan_info_count_v6 = 0;
- lan_client_rt_from_wlan_info_count_v4 = 0;
- lan_client_rt_from_wlan_info_count_v6 = 0;
+ IPACMDBG_H("Need to add %d IPv4 and %d IPv6 routing rules for eth bridge for each client.\n", each_client_rt_rule_count[IPA_IP_v4], each_client_rt_rule_count[IPA_IP_v6]);
#ifdef FEATURE_IPA_ANDROID
/* set the IPA-client pipe enum */
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
+ if(ipa_if_cate == LAN_IF)
{
handle_tethering_client(false, IPACM_CLIENT_USB);
}
@@ -457,8 +325,8 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
IPACMDBG_H("Received IPA_ADDR_ADD_EVENT\n");
/* only call ioctl for ODU iface with bridge mode */
- if((IPACM_Iface::ipacmcfg->ipacm_odu_enable == true) && (IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false)
- && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF))
+ if(IPACM_Iface::ipacmcfg->ipacm_odu_enable == true && IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false
+ && ipa_if_cate == ODU_IF)
{
if((data->iptype == IPA_IP_v6) && (num_dft_rt_v6 == 0))
{
@@ -483,16 +351,6 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
{
return;
}
- /* ADD ipv4 icmp rule */
- if (data->iptype == IPA_IP_v4)
- {
- install_ipv4_icmp_flt_rule();
- }
- /* ADD ipv6 icmp rule */
- if ((num_dft_rt_v6 == 1) && (data->iptype == IPA_IP_v6))
- {
- install_ipv6_icmp_flt_rule();
- }
#ifdef FEATURE_IPA_ANDROID
add_dummy_private_subnet_flt_rule(data->iptype);
@@ -522,6 +380,7 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
{
if((data->iptype == IPA_IP_v6 || data->iptype == IPA_IP_MAX) && num_dft_rt_v6 == 1)
{
+ memcpy(ipv6_prefix, IPACM_Wan::backhaul_ipv6_prefix, sizeof(ipv6_prefix));
install_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);
if(IPACM_Wan::backhaul_is_sta_mode == false)
{
@@ -624,6 +483,7 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
{
if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
{
+ memcpy(ipv6_prefix, data_wan_tether->ipv6_prefix, sizeof(ipv6_prefix));
install_ipv6_prefix_flt_rule(data_wan_tether->ipv6_prefix);
if(data_wan_tether->is_sta == false)
{
@@ -719,16 +579,17 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
IPACMDBG_H("Backhaul is sta mode?%d\n", data_wan->is_sta);
if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
{
+ memcpy(ipv6_prefix, data_wan->ipv6_prefix, sizeof(ipv6_prefix));
install_ipv6_prefix_flt_rule(data_wan->ipv6_prefix);
- if(data_wan->is_sta == false)
- {
+ if(data_wan->is_sta == false)
+ {
ext_prop = IPACM_Iface::ipacmcfg->GetExtProp(IPA_IP_v6);
handle_wan_up_ex(ext_prop, IPA_IP_v6, 0);
}
- else
- {
- handle_wan_up(IPA_IP_v6);
- }
+ else
+ {
+ handle_wan_up(IPA_IP_v6);
+ }
}
break;
@@ -773,9 +634,9 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
ipacm_event_data_all *data = (ipacm_event_data_all *)param;
ipa_interface_index = iface_ipa_index_query(data->if_index);
IPACMDBG_H("Recieved IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT event \n");
- IPACMDBG_H("check iface %s category: %d\n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat);
+ IPACMDBG_H("check iface %s category: %d\n", dev_name, ipa_if_cate);
- if ((ipa_interface_index == ipa_if_num) && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF))
+ if (ipa_interface_index == ipa_if_num && ipa_if_cate == ODU_IF)
{
IPACMDBG_H("ODU iface got v4-ip \n");
/* first construc ODU full header */
@@ -806,7 +667,6 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
IPACMDBG_H("ETH iface got client \n");
/* first construc ETH full header */
handle_eth_hdr_init(data->mac_addr);
- handle_lan2lan_client_active(data, IPA_LAN_CLIENT_ACTIVE);
IPACMDBG_H("construct ETH header and route rules \n");
/* Associate with IP and construct RT-rule */
if (handle_eth_client_ipaddr(data) == IPACM_FAILURE)
@@ -819,36 +679,7 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
/* Add NAT rules after ipv4 RT rules are set */
CtList->HandleNeighIpAddrAddEvt(data);
}
-#ifdef FEATURE_ETH_BRIDGE_LE
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- if (IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == true)
- {
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v4);
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v6);
- }
- if (IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)
- {
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v4);
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v6);
- }
- }
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- if (IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == true)
- {
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v4);
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v6);
- }
- if (IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == true)
- {
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v4);
- eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v6);
- }
- }
- eth_bridge_post_lan_client_event(data->mac_addr, IPA_ETH_BRIDGE_LAN_CLIENT_ADD_EVENT);
- eth_bridge_add_lan_client(data->mac_addr);
-#endif
+ eth_bridge_post_event(IPA_ETH_BRIDGE_CLIENT_ADD, IPA_IP_MAX, data->mac_addr);
return;
}
}
@@ -860,10 +691,9 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
ipa_interface_index = iface_ipa_index_query(data->if_index);
IPACMDBG_H("Received IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT event. \n");
- IPACMDBG_H("check iface %s category: %d\n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat);
+ IPACMDBG_H("check iface %s category: %d\n", dev_name, ipa_if_cate);
/* if ODU in bridge mode, directly return */
- if ((ipa_interface_index == ipa_if_num) && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- && (IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false))
+ if (ipa_if_cate == ODU_IF && IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false)
{
IPACMDBG_H("ODU is in bridge mode, no action \n");
return;
@@ -876,35 +706,11 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
handle_del_ipv6_addr(data);
return;
}
-#ifdef FEATURE_ETH_BRIDGE_LE
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- if (IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == true)
- {
- eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_LAN);
- }
- if (IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)
- {
- eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_WLAN);
- }
- }
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- if (IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == true)
- {
- eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_LAN);
- }
- if (IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == true)
- {
- eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_WLAN);
- }
- }
- eth_bridge_post_lan_client_event(data->mac_addr, IPA_ETH_BRIDGE_LAN_CLIENT_DEL_EVENT);
- eth_bridge_del_lan_client(data->mac_addr);
-#endif
+
+ eth_bridge_post_event(IPA_ETH_BRIDGE_CLIENT_DEL, IPA_IP_MAX, data->mac_addr);
+
IPACMDBG_H("LAN iface delete client \n");
handle_eth_client_down_evt(data->mac_addr);
- handle_lan2lan_client_active(data, IPA_LAN_CLIENT_INACTIVE);
return;
}
}
@@ -922,164 +728,6 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param)
handle_software_routing_disable();
break;
- case IPA_ETH_BRIDGE_LAN_CLIENT_ADD_EVENT:
- {
- IPACMDBG_H("Received IPA_ETH_BRIDGE_LAN_CLIENT_ADD_EVENT event.\n");
- ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
- if(mac != NULL)
- {
- if (mac->if_index == ipa_if_num)
- {
- IPACMDBG_H("The event was sent by same interface, if_index: %d ignore. \n", mac->if_index);
- return;
- }
- if(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)
- {
- eth_bridge_add_lan_client_flt_rule(mac->mac_addr, IPA_IP_v4);
- }
- if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
- {
- eth_bridge_add_lan_client_flt_rule(mac->mac_addr, IPA_IP_v6);
- }
- }
- else
- {
- IPACMERR("Event MAC is empty.\n");
- }
- }
- break;
-
- case IPA_ETH_BRIDGE_LAN_CLIENT_DEL_EVENT:
- {
- IPACMDBG_H("Received IPA_ETH_BRIDGE_LAN_CLIENT_DEL_EVENT event.\n");
- ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
- if(mac != NULL)
- {
- if (mac->if_index == ipa_if_num)
- {
- IPACMDBG_H("The event was sent by same interface, if_index: %d ignore. \n", mac->if_index);
- return;
- }
- if(eth_bridge_del_lan_client_flt_rule(mac->mac_addr) == IPACM_FAILURE)
- {
- IPACMDBG_H("Failed to delete lan client MAC based flt rule.\n");
- }
- }
- else
- {
- IPACMERR("Event MAC is empty.\n");
- }
- }
- break;
-
- case IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT:
- {
- IPACMDBG_H("Received IPA_ETH_BRIDGE_WLAN_CLIENT_ADD_EVENT event.\n");
- ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
- if(mac != NULL)
- {
- if(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)
- {
- eth_bridge_add_wlan_client_flt_rule(mac->mac_addr, IPA_IP_v4);
- }
- if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
- {
- eth_bridge_add_wlan_client_flt_rule(mac->mac_addr, IPA_IP_v6);
- }
- }
- else
- {
- IPACMERR("Event MAC is empty.\n");
- }
- }
- break;
-
- case IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT:
- {
- IPACMDBG_H("Received IPA_ETH_BRIDGE_WLAN_CLIENT_DEL_EVENT event.\n");
- ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
- if(mac != NULL)
- {
- if(eth_bridge_del_wlan_client_flt_rule(mac->mac_addr) == IPACM_FAILURE)
- {
- IPACMDBG_H("Failed to delete wlan client MAC based flt rule.\n");
- }
- }
- else
- {
- IPACMERR("Event MAC is empty.\n");
- }
- }
- break;
-
- case IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT:
- {
- IPACMDBG_H("Received IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT event.\n");
- int i;
- ipacm_event_data_if_cat* cat = (ipacm_event_data_if_cat*)param;
- if(cat == NULL)
- {
- IPACMERR("Event data is empty.\n");
- return;
- }
- if (cat->if_cat == IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat)
- {
- IPACMDBG_H("The event was sent by same interface, if_cat: %d ignore. \n", cat->if_cat);
- return;
- }
-
- for(i=0; i<IPACM_Lan::num_lan_client; i++)
- {
- if(IPACM_Lan::eth_bridge_lan_client[i].ipa_if_num == ipa_if_num)
- {
- if (cat->if_cat == WLAN_IF)
- {
- eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_lan_client[i].mac, SRC_WLAN, IPA_IP_v4);
- eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_lan_client[i].mac, SRC_WLAN, IPA_IP_v6);
- }
- else
- {
- eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_lan_client[i].mac, SRC_LAN, IPA_IP_v4);
- eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_lan_client[i].mac, SRC_LAN, IPA_IP_v6);
- }
- }
- }
- }
- break;
-
- case IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT:
- {
- IPACMDBG_H("Received IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT event.\n");
- int i;
- ipacm_event_data_if_cat* cat = (ipacm_event_data_if_cat*)param;
- if(cat == NULL)
- {
- IPACMERR("Event data is empty.\n");
- return;
- }
- if (cat->if_cat == IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat)
- {
- IPACMDBG_H("The event was sent by same interface, if_cat: %d ignore.\n", cat->if_cat);
- return;
- }
-
- for(i=0; i<IPACM_Lan::num_lan_client; i++)
- {
- if(IPACM_Lan::eth_bridge_lan_client[i].ipa_if_num == ipa_if_num)
- {
- if (cat->if_cat == WLAN_IF)
- {
- eth_bridge_del_lan_client_rt_rule(IPACM_Lan::eth_bridge_lan_client[i].mac, SRC_WLAN);
- }
- else
- {
- eth_bridge_del_lan_client_rt_rule(IPACM_Lan::eth_bridge_lan_client[i].mac, SRC_LAN);
- }
- }
- }
- }
- break;
-
case IPA_CRADLE_WAN_MODE_SWITCH:
{
IPACMDBG_H("Received IPA_CRADLE_WAN_MODE_SWITCH event.\n");
@@ -1292,16 +940,16 @@ int IPACM_Lan::handle_addr_evt(ipacm_event_data_addr *data)
/* Add private subnet*/
#ifdef FEATURE_IPA_ANDROID
-if (data->iptype == IPA_IP_v4)
-{
- IPACMDBG_H("current IPACM private subnet_addr number(%d)\n", IPACM_Iface::ipacmcfg->ipa_num_private_subnet);
- if_ipv4_subnet = (data->ipv4_addr >> 8) << 8;
- IPACMDBG_H(" Add IPACM private subnet_addr as: 0x%x \n", if_ipv4_subnet);
- if(IPACM_Iface::ipacmcfg->AddPrivateSubnet(if_ipv4_subnet, ipa_if_num) == false)
+ if (data->iptype == IPA_IP_v4)
{
- IPACMERR(" can't Add IPACM private subnet_addr as: 0x%x \n", if_ipv4_subnet);
+ IPACMDBG_H("current IPACM private subnet_addr number(%d)\n", IPACM_Iface::ipacmcfg->ipa_num_private_subnet);
+ if_ipv4_subnet = (data->ipv4_addr >> 8) << 8;
+ IPACMDBG_H(" Add IPACM private subnet_addr as: 0x%x \n", if_ipv4_subnet);
+ if(IPACM_Iface::ipacmcfg->AddPrivateSubnet(if_ipv4_subnet, ipa_if_num) == false)
+ {
+ IPACMERR(" can't Add IPACM private subnet_addr as: 0x%x \n", if_ipv4_subnet);
+ }
}
-}
#endif /* defined(FEATURE_IPA_ANDROID)*/
if (data->iptype == IPA_IP_v4)
@@ -1323,9 +971,12 @@ if (data->iptype == IPA_IP_v4)
rt_rule_entry->at_rear = false;
rt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS; //go to A5
rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name);
+ strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, sizeof(rt_rule->rt_tbl_name));
rt_rule_entry->rule.attrib.u.v4.dst_addr = data->ipv4_addr;
rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -1341,19 +992,13 @@ if (data->iptype == IPA_IP_v4)
dft_rt_rule_hdl[0] = rt_rule_entry->rt_rule_hdl;
IPACMDBG_H("ipv4 iface rt-rule hdl1=0x%x\n", dft_rt_rule_hdl[0]);
/* initial multicast/broadcast/fragment filter rule */
-#ifdef FEATURE_ETH_BRIDGE_LE
- init_fl_rule(data->iptype);
- eth_bridge_handle_dummy_wlan_client_flt_rule(data->iptype);
- eth_bridge_handle_dummy_lan_client_flt_rule(data->iptype);
- eth_bridge_install_cache_wlan_client_flt_rule(data->iptype);
- eth_bridge_install_cache_lan_client_flt_rule(data->iptype);
-#else
-#ifdef CT_OPT
- install_tcp_ctl_flt_rule(IPA_IP_v4);
-#endif
+
init_fl_rule(data->iptype);
- add_dummy_lan2lan_flt_rule(data->iptype);
-#endif
+ install_ipv4_icmp_flt_rule();
+
+ /* populate the flt rule offset for eth bridge */
+ eth_bridge_flt_rule_offset[data->iptype] = ipv4_icmp_flt_rule_hdl[0];
+ eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_UP, IPA_IP_v4, NULL);
}
else
{
@@ -1383,7 +1028,7 @@ if (data->iptype == IPA_IP_v4)
rt_rule->commit = 1;
rt_rule->num_rules = NUM_RULES;
rt_rule->ip = data->iptype;
- strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_v6.name);
+ strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_v6.name, sizeof(rt_rule->rt_tbl_name));
rt_rule_entry = &rt_rule->rules[0];
rt_rule_entry->at_rear = false;
@@ -1401,6 +1046,9 @@ if (data->iptype == IPA_IP_v4)
ipv6_addr[num_dft_rt_v6][1] = data->ipv6_addr[1];
ipv6_addr[num_dft_rt_v6][2] = data->ipv6_addr[2];
ipv6_addr[num_dft_rt_v6][3] = data->ipv6_addr[3];
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -1416,7 +1064,7 @@ if (data->iptype == IPA_IP_v4)
dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES + 2*num_dft_rt_v6] = rt_rule_entry->rt_rule_hdl;
/* setup same rule for v6_wan table*/
- strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name);
+ strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name, sizeof(rt_rule->rt_tbl_name));
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -1437,20 +1085,13 @@ if (data->iptype == IPA_IP_v4)
if (num_dft_rt_v6 == 0)
{
- /* initial multicast/broadcast/fragment filter rule */
-#ifdef FEATURE_ETH_BRIDGE_LE
- eth_bridge_handle_dummy_wlan_client_flt_rule(data->iptype);
- eth_bridge_handle_dummy_lan_client_flt_rule(data->iptype);
- eth_bridge_install_cache_wlan_client_flt_rule(data->iptype);
- eth_bridge_install_cache_lan_client_flt_rule(data->iptype);
- init_fl_rule(data->iptype);
-#else
-#ifdef CT_OPT
- install_tcp_ctl_flt_rule(IPA_IP_v6);
-#endif
- add_dummy_lan2lan_flt_rule(data->iptype);
+ install_ipv6_icmp_flt_rule();
+
+ /* populate the flt rule offset for eth bridge */
+ eth_bridge_flt_rule_offset[data->iptype] = ipv6_icmp_flt_rule_hdl[0];
+ eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_UP, IPA_IP_v6, NULL);
+
init_fl_rule(data->iptype);
-#endif
}
num_dft_rt_v6++;
IPACMDBG_H("number of default route rules %d\n", num_dft_rt_v6);
@@ -1498,13 +1139,6 @@ int IPACM_Lan::handle_private_subnet(ipa_ip_type iptype)
m_pFilteringTable->ip = IPA_IP_v4;
m_pFilteringTable->num_rules = (uint8_t)IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
- if (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan_v4))
- {
- IPACMERR("LAN m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan_v4=0x%p) Failed.\n", &IPACM_Iface::ipacmcfg->rt_tbl_lan_v4);
- free(m_pFilteringTable);
- return IPACM_FAILURE;
- }
-
/* Make LAN-traffic always go A5, use default IPA-RT table */
if (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_default_v4))
{
@@ -1521,6 +1155,9 @@ int IPACM_Lan::handle_private_subnet(ipa_ip_type iptype)
flt_rule_entry.flt_rule_hdl = -1;
flt_rule_entry.status = -1;
flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
+#ifdef FEATURE_IPA_V3
+ flt_rule_entry.rule.hashable = true;
+#endif
/* Support private subnet feature including guest-AP can't talk to primary AP etc */
flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_default_v4.hdl;
IPACMDBG_H(" private filter rule use table: %s\n",IPACM_Iface::ipacmcfg->rt_tbl_default_v4.name);
@@ -1613,6 +1250,9 @@ int IPACM_Lan::handle_wan_up(ipa_ip_type ip_type)
{
flt_rule_entry.rule.action = IPA_PASS_TO_SRC_NAT; //IPA_PASS_TO_ROUTING
}
+#ifdef FEATURE_IPA_V3
+ flt_rule_entry.rule.hashable = true;
+#endif
flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.hdl;
memcpy(&flt_rule_entry.rule.attrib,
@@ -1675,6 +1315,9 @@ int IPACM_Lan::handle_wan_up(ipa_ip_type ip_type)
flt_rule_entry.flt_rule_hdl = -1;
flt_rule_entry.status = -1;
flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
+#ifdef FEATURE_IPA_V3
+ flt_rule_entry.rule.hashable = true;
+#endif
flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_v6.hdl;
memcpy(&flt_rule_entry.rule.attrib,
@@ -2039,6 +1682,8 @@ int IPACM_Lan::handle_eth_client_ipaddr(ipacm_event_data_all *data)
{
int clnt_indx;
int v6_num;
+ uint32_t ipv6_link_local_prefix = 0xFE800000;
+ uint32_t ipv6_link_local_prefix_mask = 0xFFC00000;
IPACMDBG_H("number of eth clients: %d\n", num_eth_client);
IPACMDBG_H("event MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -2085,10 +1730,10 @@ int IPACM_Lan::handle_eth_client_ipaddr(ipacm_event_data_all *data)
get_client_memptr(eth_client, clnt_indx)->route_rule_set_v4 = false;
get_client_memptr(eth_client, clnt_indx)->v4_addr = data->ipv4_addr;
}
+ }
}
- }
- else
- {
+ else
+ {
IPACMDBG_H("Invalid client IPv4 address \n");
return IPACM_FAILURE;
}
@@ -2098,21 +1743,28 @@ int IPACM_Lan::handle_eth_client_ipaddr(ipacm_event_data_all *data)
if ((data->ipv6_addr[0] != 0) || (data->ipv6_addr[1] != 0) ||
(data->ipv6_addr[2] != 0) || (data->ipv6_addr[3] || 0)) /* check if all 0 not valid ipv6 address */
{
- IPACMDBG_H("ipv6 address: 0x%x:%x:%x:%x\n", data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);
- if(get_client_memptr(eth_client, clnt_indx)->ipv6_set < IPV6_NUM_ADDR)
- {
+ IPACMDBG_H("ipv6 address: 0x%x:%x:%x:%x\n", data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);
+ if( (data->ipv6_addr[0] & ipv6_link_local_prefix_mask) != (ipv6_link_local_prefix & ipv6_link_local_prefix_mask) &&
+ memcmp(ipv6_prefix, data->ipv6_addr, sizeof(ipv6_prefix)) != 0)
+ {
+ IPACMDBG_H("This IPv6 address is not global IPv6 address with correct prefix, ignore.\n");
+ return IPACM_FAILURE;
+ }
+
+ if(get_client_memptr(eth_client, clnt_indx)->ipv6_set < IPV6_NUM_ADDR)
+ {
for(v6_num=0;v6_num < get_client_memptr(eth_client, clnt_indx)->ipv6_set;v6_num++)
- {
- if( data->ipv6_addr[0] == get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][0] &&
+ {
+ if( data->ipv6_addr[0] == get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][0] &&
data->ipv6_addr[1] == get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][1] &&
data->ipv6_addr[2]== get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][2] &&
data->ipv6_addr[3] == get_client_memptr(eth_client, clnt_indx)->v6_addr[v6_num][3])
- {
- IPACMDBG_H("Already see this ipv6 addr at position: %d for client:%d\n", v6_num, clnt_indx);
- return IPACM_FAILURE; /* not setup the RT rules*/
- }
- }
+ {
+ IPACMDBG_H("Already see this ipv6 addr at position: %d for client:%d\n", v6_num, clnt_indx);
+ return IPACM_FAILURE; /* not setup the RT rules*/
+ }
+ }
/* not see this ipv6 before for wifi client*/
get_client_memptr(eth_client, clnt_indx)->v6_addr[get_client_memptr(eth_client, clnt_indx)->ipv6_set][0] = data->ipv6_addr[0];
@@ -2123,8 +1775,8 @@ int IPACM_Lan::handle_eth_client_ipaddr(ipacm_event_data_all *data)
}
else
{
- IPACMDBG_H("Already got 3 ipv6 addr for client:%d\n", clnt_indx);
- return IPACM_FAILURE; /* not setup the RT rules*/
+ IPACMDBG_H("Already got %d ipv6 addr for client:%d\n", IPV6_NUM_ADDR, clnt_indx);
+ return IPACM_FAILURE; /* not setup the RT rules*/
}
}
}
@@ -2229,6 +1881,9 @@ int IPACM_Lan::handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptyp
rt_rule_entry->rule.hdr_hdl = get_client_memptr(eth_client, eth_index)->hdr_hdl_v4;
rt_rule_entry->rule.attrib.u.v4.dst_addr = get_client_memptr(eth_client, eth_index)->v4_addr;
rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -2268,6 +1923,9 @@ int IPACM_Lan::handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptyp
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -2297,6 +1955,9 @@ int IPACM_Lan::handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptyp
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -2400,7 +2061,7 @@ int IPACM_Lan::handle_odu_hdr_init(uint8_t *mac_addr)
memset(pHeaderDescriptor->hdr[0].name, 0,
sizeof(pHeaderDescriptor->hdr[0].name));
- strcpy(pHeaderDescriptor->hdr[0].name, IPA_ODU_HDR_NAME_v4);
+ strlcpy(pHeaderDescriptor->hdr[0].name, IPA_ODU_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name));
pHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;
pHeaderDescriptor->hdr[0].hdr_hdl = -1;
pHeaderDescriptor->hdr[0].is_partial = 0;
@@ -2480,7 +2141,7 @@ int IPACM_Lan::handle_odu_hdr_init(uint8_t *mac_addr)
memset(pHeaderDescriptor->hdr[0].name, 0,
sizeof(pHeaderDescriptor->hdr[0].name));
- strcpy(pHeaderDescriptor->hdr[0].name, IPA_ODU_HDR_NAME_v6);
+ strlcpy(pHeaderDescriptor->hdr[0].name, IPA_ODU_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name));
pHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;
pHeaderDescriptor->hdr[0].hdr_hdl = -1;
pHeaderDescriptor->hdr[0].is_partial = 0;
@@ -2547,13 +2208,13 @@ int IPACM_Lan::handle_odu_route_add()
if (IPA_IP_v4 == tx_prop->tx[tx_index].ip)
{
- strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v4.name);
+ strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v4.name, sizeof(rt_rule->rt_tbl_name));
rt_rule_entry->rule.hdr_hdl = ODU_hdr_hdl_v4;
rt_rule->ip = IPA_IP_v4;
}
else
{
- strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v6.name);
+ strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_odu_v6.name, sizeof(rt_rule->rt_tbl_name));
rt_rule_entry->rule.hdr_hdl = ODU_hdr_hdl_v6;
rt_rule->ip = IPA_IP_v6;
}
@@ -2568,6 +2229,9 @@ int IPACM_Lan::handle_odu_route_add()
{
rt_rule_entry->rule.attrib.u.v4.dst_addr = 0;
rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0;
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -2590,6 +2254,9 @@ int IPACM_Lan::handle_odu_route_add()
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0;
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0;
rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0;
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
if (false == m_routing.AddRoutingRule(rt_rule))
{
IPACMERR("Routing rule addition failed!\n");
@@ -2779,10 +2446,9 @@ int IPACM_Lan::handle_down_evt()
{
int i;
int res = IPACM_SUCCESS;
- uint32_t temp_eth_bridge_flt_rule[IPA_LAN_TO_LAN_MAX_WLAN_CLIENT];
IPACMDBG_H("lan handle_down_evt\n ");
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
+ if (ipa_if_cate == ODU_IF)
{
/* delete ODU default RT rules */
if (IPACM_Iface::ipacmcfg->ipacm_odu_embms_enable == true)
@@ -2823,28 +2489,6 @@ int IPACM_Lan::handle_down_evt()
goto fail;
}
-#ifdef FEATURE_ETH_BRIDGE_LE
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- IPACM_Lan::usb_hdr_template_hdl = 0;
- IPACM_Lan::is_usb_up = false;
- if(IPACM_Lan::is_cpe_up == false) //if all LAN ifaces are down
- {
- IPACM_Lan::lan_hdr_type = IPA_HDR_L2_NONE;
- }
- }
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- IPACM_Lan::cpe_hdr_template_hdl = 0;
- IPACM_Lan::is_cpe_up = false;
- if(IPACM_Lan::is_usb_up == false) //if all LAN ifaces are down
- {
- IPACM_Lan::lan_hdr_type = IPA_HDR_L2_NONE;
- }
- }
- del_hdr_proc_ctx();
-#endif
-
/* delete wan filter rule */
if (IPACM_Wan::isWanUP(ipa_if_num) && rx_prop != NULL)
{
@@ -2876,71 +2520,6 @@ int IPACM_Lan::handle_down_evt()
goto fail;
}
IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, IPV4_DEFAULT_FILTERTING_RULES);
-#ifdef FEATURE_ETH_BRIDGE_LE
- for(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- temp_eth_bridge_flt_rule[i] = wlan_client_flt_rule_hdl_v4[i].rule_hdl;
- }
- if (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v4, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT) == false)
- {
- IPACMERR("Error Deleting Filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT);
-
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- for(i=0; i<IPA_LAN_TO_LAN_MAX_CPE_CLIENT; i++)
- {
- temp_eth_bridge_flt_rule[i] = lan_client_flt_rule_hdl_v4[i].rule_hdl;
- }
- if (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v4, IPA_LAN_TO_LAN_MAX_CPE_CLIENT) == false)
- {
- IPACMERR("Error Deleting Filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, IPA_LAN_TO_LAN_MAX_CPE_CLIENT);
- }
-
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- for(i=0; i<IPA_LAN_TO_LAN_MAX_USB_CLIENT; i++)
- {
- temp_eth_bridge_flt_rule[i] = lan_client_flt_rule_hdl_v4[i].rule_hdl;
- }
- if (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v4, IPA_LAN_TO_LAN_MAX_USB_CLIENT) == false)
- {
- IPACMERR("Error Deleting Filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, IPA_LAN_TO_LAN_MAX_USB_CLIENT);
- }
-#endif
-#ifndef FEATURE_ETH_BRIDGE_LE
-#ifdef CT_OPT
- if (m_filtering.DeleteFilteringHdls(tcp_ctl_flt_rule_hdl_v4, IPA_IP_v4, NUM_TCP_CTL_FLT_RULE) == false)
- {
- IPACMERR("Error deleting default filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, NUM_TCP_CTL_FLT_RULE);
-#endif
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(m_filtering.DeleteFilteringHdls(&(lan2lan_flt_rule_hdl_v4[i].rule_hdl), IPA_IP_v4, 1) == false)
- {
- IPACMERR("Error deleting lan2lan IPv4 flt rules.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
- }
- IPACMDBG_H("Deleted lan2lan IPv4 flt rules.\n");
-#endif
/* free private-subnet ipv4 filter rules */
if (IPACM_Iface::ipacmcfg->ipa_num_private_subnet > IPA_PRIV_SUBNET_FILTER_RULE_HANDLES)
@@ -2961,12 +2540,13 @@ int IPACM_Lan::handle_down_evt()
#else
if (m_filtering.DeleteFilteringHdls(private_fl_rule_hdl, IPA_IP_v4, IPACM_Iface::ipacmcfg->ipa_num_private_subnet) == false)
{
- IPACMERR("Error Deleting RuleTable(1) to Filtering, aborting...\n");
+ IPACMERR("Error deleting private subnet IPv4 flt rules.\n");
res = IPACM_FAILURE;
goto fail;
}
IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, IPACM_Iface::ipacmcfg->ipa_num_private_subnet);
#endif
+ IPACMDBG_H("Deleted private subnet v4 filter rules successfully.\n");
}
IPACMDBG_H("Finished delete default iface ipv4 filtering rules \n ");
@@ -2987,71 +2567,6 @@ int IPACM_Lan::handle_down_evt()
goto fail;
}
IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, IPV6_DEFAULT_FILTERTING_RULES);
-#ifdef FEATURE_ETH_BRIDGE_LE
- for(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- temp_eth_bridge_flt_rule[i] = wlan_client_flt_rule_hdl_v6[i].rule_hdl;
- }
- if (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v6, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT) == false)
- {
- IPACMERR("Error Deleting Filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT);
-
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- for(i=0; i<IPA_LAN_TO_LAN_MAX_CPE_CLIENT; i++)
- {
- temp_eth_bridge_flt_rule[i] = lan_client_flt_rule_hdl_v6[i].rule_hdl;
- }
- if (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v6, IPA_LAN_TO_LAN_MAX_CPE_CLIENT) == false)
- {
- IPACMERR("Error Deleting Filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, IPA_LAN_TO_LAN_MAX_CPE_CLIENT);
- }
-
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- for(i=0; i<IPA_LAN_TO_LAN_MAX_USB_CLIENT; i++)
- {
- temp_eth_bridge_flt_rule[i] = lan_client_flt_rule_hdl_v6[i].rule_hdl;
- }
- if (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, IPA_IP_v6, IPA_LAN_TO_LAN_MAX_USB_CLIENT) == false)
- {
- IPACMERR("Error Deleting Filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, IPA_LAN_TO_LAN_MAX_USB_CLIENT);
- }
-#endif
-#ifndef FEATURE_ETH_BRIDGE_LE
-#ifdef CT_OPT
- if (m_filtering.DeleteFilteringHdls(tcp_ctl_flt_rule_hdl_v6, IPA_IP_v6, NUM_TCP_CTL_FLT_RULE) == false)
- {
- IPACMERR("Error deleting default filtering Rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, NUM_TCP_CTL_FLT_RULE);
-#endif
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(m_filtering.DeleteFilteringHdls(&(lan2lan_flt_rule_hdl_v6[i].rule_hdl), IPA_IP_v6, 1) == false)
- {
- IPACMERR("Error deleting lan2lan IPv4 flt rules.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
- }
- IPACMDBG_H("Deleted lan2lan IPv6 flt rules.\n");
-#endif
}
IPACMDBG_H("Finished delete default iface ipv6 filtering rules \n ");
@@ -3088,13 +2603,6 @@ int IPACM_Lan::handle_down_evt()
IPACMDBG_H("left %d eth clients need to be deleted \n ", num_eth_client);
for (i = 0; i < num_eth_client; i++)
{
-#ifdef FEATURE_ETH_BRIDGE_LE
- eth_bridge_del_lan_client_rt_rule(get_client_memptr(eth_client, i)->mac, SRC_LAN);
- eth_bridge_del_lan_client_rt_rule(get_client_memptr(eth_client, i)->mac, SRC_WLAN);
- eth_bridge_post_lan_client_event(get_client_memptr(eth_client, i)->mac, IPA_ETH_BRIDGE_LAN_CLIENT_DEL_EVENT);
- eth_bridge_del_lan_client(get_client_memptr(eth_client, i)->mac);
-#endif
-
/* First reset nat rules and then route rules */
if(get_client_memptr(eth_client, i)->ipv4_set == true)
{
@@ -3156,9 +2664,7 @@ int IPACM_Lan::handle_down_evt()
handle_software_routing_disable();
}
- /* posting ip to lan2lan module to delete RT/FILTER rules*/
- post_lan2lan_client_disconnect_msg(IPA_IP_v4);
- post_lan2lan_client_disconnect_msg(IPA_IP_v6);
+ eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_DOWN, IPA_IP_MAX, NULL);
/* Delete private subnet*/
#ifdef FEATURE_IPA_ANDROID
@@ -3173,7 +2679,7 @@ int IPACM_Lan::handle_down_evt()
}
/* reset the IPA-client pipe enum */
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat != WAN_IF)
+ if(ipa_if_cate != WAN_IF)
{
handle_tethering_client(true, IPACM_CLIENT_USB);
}
@@ -3210,24 +2716,7 @@ fail:
{
free(iface_query);
}
-#ifdef FEATURE_ETH_BRIDGE_LE
- if(eth_bridge_lan_client_rt_from_lan_info_v4 != NULL)
- {
- free(eth_bridge_lan_client_rt_from_lan_info_v4);
- }
- if(eth_bridge_lan_client_rt_from_lan_info_v6 != NULL)
- {
- free(eth_bridge_lan_client_rt_from_lan_info_v6);
- }
- if(eth_bridge_lan_client_rt_from_wlan_info_v4 != NULL)
- {
- free(eth_bridge_lan_client_rt_from_wlan_info_v4);
- }
- if(eth_bridge_lan_client_rt_from_wlan_info_v6 != NULL)
- {
- free(eth_bridge_lan_client_rt_from_wlan_info_v6);
- }
-#endif
+
is_active = false;
post_del_self_evt();
@@ -3245,7 +2734,7 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp
int i, index;
uint32_t value = 0;
- IPACMDBG_H("Set extended property rules in LAN\n");
+ IPACMDBG_H("Set modem UL flt rules\n");
if (rx_prop == NULL)
{
@@ -3324,8 +2813,7 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp
flt_rule_entry.rule.eq_attrib_type = 1;
if(iptype == IPA_IP_v4)
{
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF &&
- IPACM_Wan::isWan_Bridge_Mode())
+ if (ipa_if_cate == ODU_IF && IPACM_Wan::isWan_Bridge_Mode())
{
IPACMDBG_H("WAN, ODU are in bridge mode \n");
flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
@@ -3346,19 +2834,6 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp
index = IPACM_Iface::ipacmcfg->getFltRuleCount(rx_prop->rx[0].src_pipe, iptype);
-#ifndef FEATURE_IPA_ANDROID
- if(iptype == IPA_IP_v4 && index != exp_index_v4)
- {
- IPACMDBG_DMESG("### WARNING ### num flt rules for IPv4 on client %d is not expected: %d expected value: %d",
- rx_prop->rx[0].src_pipe, index, exp_index_v4);
- }
- if(iptype == IPA_IP_v6 && index != exp_index_v6)
- {
- IPACMDBG_DMESG("### WARNING ### num flt rules for IPv6 on client %d is not expected: %d expected value: %d",
- rx_prop->rx[0].src_pipe, index, exp_index_v6);
- }
-#endif
-
for(cnt=0; cnt<prop->num_ext_props; cnt++)
{
memcpy(&flt_rule_entry.rule.eq_attrib,
@@ -3381,6 +2856,14 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp
#ifdef FEATURE_IPA_V3
flt_rule_entry.rule.hashable = prop->prop[cnt].is_rule_hashable;
flt_rule_entry.rule.rule_id = prop->prop[cnt].rule_id;
+ if(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA) //turn on meta-data equation
+ {
+ flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<9);
+ flt_rule_entry.rule.eq_attrib.metadata_meq32_present = 1;
+ flt_rule_entry.rule.eq_attrib.metadata_meq32.offset = 0;
+ flt_rule_entry.rule.eq_attrib.metadata_meq32.value |= rx_prop->rx[0].attrib.meta_data;
+ flt_rule_entry.rule.eq_attrib.metadata_meq32.mask |= rx_prop->rx[0].attrib.meta_data_mask;
+ }
#endif
memcpy(&pFilteringTable->rules[cnt], &flt_rule_entry, sizeof(flt_rule_entry));
@@ -3454,6 +2937,8 @@ int IPACM_Lan::handle_wan_down_v6(bool is_sta_mode)
delete_ipv6_prefix_flt_rule();
+ memset(ipv6_prefix, 0, sizeof(ipv6_prefix));
+
if(is_sta_mode == false)
{
if (num_wan_ul_fl_rule_v6 > MAX_WAN_UL_FILTER_RULES)
@@ -3518,466 +3003,6 @@ int IPACM_Lan::handle_wan_down_v6(bool is_sta_mode)
return IPACM_SUCCESS;
}
-
-/*handle lan2lan client active*/
-int IPACM_Lan::handle_lan2lan_client_active(ipacm_event_data_all *data, ipa_cm_event_id event)
-{
- if((tx_prop == NULL) || (rx_prop == NULL))
- {
- IPACMDBG_H("No tx/rx properties registered for iface %s, not posting lan2lan event(%d)\n", dev_name, event);
- return IPACM_SUCCESS;
- }
-
- if(data == NULL)
- {
- IPACMERR("Event data is empty.\n");
- return IPACM_FAILURE;
- }
-
- if(data->iptype == IPA_IP_v4 && ip_type != IPA_IP_v4 && ip_type != IPA_IP_MAX)
- {
- IPACMERR("Client has IPv4 addr but iface does not have IPv4 up.\n");
- return IPACM_FAILURE;
- }
- if(data->iptype == IPA_IP_v6 && ip_type != IPA_IP_v6 && ip_type != IPA_IP_MAX)
- {
- IPACMERR("Client has IPv6 addr but iface does not have IPv6 up.\n");
- return IPACM_FAILURE;
- }
-
- ipacm_cmd_q_data evt_data;
- memset(&evt_data, 0, sizeof(evt_data));
-
- ipacm_event_lan_client* lan_client;
- lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
- if(lan_client == NULL)
- {
- IPACMERR("Unable to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(lan_client, 0, sizeof(ipacm_event_lan_client));
- lan_client->iptype = data->iptype;
- lan_client->ipv4_addr = data->ipv4_addr;
- memcpy(lan_client->ipv6_addr, data->ipv6_addr, 4 * sizeof(uint32_t));
- memcpy(lan_client->mac_addr, data->mac_addr, 6 * sizeof(uint8_t));
- lan_client->p_iface = this;
-
- evt_data.event = event;
- evt_data.evt_data = (void*)lan_client;
-
- IPACMDBG_H("Posting event: %d\n", event);
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::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)
-{
- if(rx_prop == NULL)
- {
- IPACMERR("There is no rx_prop for iface %s, not able to add lan2lan filtering rule.\n", dev_name);
- return IPACM_FAILURE;
- }
- if(rule_hdl == NULL)
- {
- IPACMERR("Filteing rule handle is empty.\n");
- return IPACM_FAILURE;
- }
-
- IPACMDBG_H("Got a new lan2lan flt rule with IP type: %d\n", iptype);
-
- int i, len, res = IPACM_SUCCESS;
- struct ipa_flt_rule_mdfy flt_rule;
- struct ipa_ioc_mdfy_flt_rule* pFilteringTable;
-
- len = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);
-
- pFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);
-
- if (pFilteringTable == NULL)
- {
- IPACMERR("Error allocate lan2lan flt rule memory...\n");
- return IPACM_FAILURE;
- }
- memset(pFilteringTable, 0, len);
-
- pFilteringTable->commit = 1;
- pFilteringTable->ip = iptype;
- pFilteringTable->num_rules = 1;
-
- memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));
-
- if(iptype == IPA_IP_v4)
- {
- IPACMDBG_H("src_v4_addr: %d dst_v4_addr: %d\n", src_v4_addr, dst_v4_addr);
-
- if(num_lan2lan_flt_rule_v4 >= MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Lan2lan flt rule table is full, not able to add.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- if(false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4))
- {
- IPACMERR("Failed to get routing table %s handle.\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name);
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("Routing handle for table %s: %d\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name,
- IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.hdl);
-
- flt_rule.status = -1;
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(lan2lan_flt_rule_hdl_v4[i].valid == false)
- {
- flt_rule.rule_hdl = lan2lan_flt_rule_hdl_v4[i].rule_hdl;
- break;
- }
- }
- if(i == MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Failed to find a filtering rule.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- flt_rule.rule.retain_hdr = 0;
- flt_rule.rule.to_uc = 0;
- flt_rule.rule.eq_attrib_type = 0;
- flt_rule.rule.action = IPA_PASS_TO_ROUTING;
- flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.hdl;
-
- memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
- sizeof(flt_rule.rule.attrib));
- IPACMDBG_H("Rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask);
-
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
- flt_rule.rule.attrib.u.v4.src_addr = src_v4_addr;
- flt_rule.rule.attrib.u.v4.src_addr_mask = 0xFFFFFFFF;
-
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v4.dst_addr = dst_v4_addr;
- flt_rule.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
-
- memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
- if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
- {
- IPACMERR("Error modifying filtering rule.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- lan2lan_flt_rule_hdl_v4[i].valid = true;
- *rule_hdl = lan2lan_flt_rule_hdl_v4[i].rule_hdl;
- num_lan2lan_flt_rule_v4++;
- IPACMDBG_H("Flt rule modified, hdl: 0x%x, status: %d\n", pFilteringTable->rules[0].rule_hdl,
- pFilteringTable->rules[0].status);
- }
- }
- else if(iptype == IPA_IP_v6)
- {
- if(num_lan2lan_flt_rule_v6 >= MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Lan2lan flt rule table is full, not able to add.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- if(src_v6_addr == NULL || dst_v6_addr == NULL)
- {
- IPACMERR("Got IPv6 flt rule but without IPv6 src/dst addr.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\n", src_v6_addr[0], src_v6_addr[1],
- src_v6_addr[2], src_v6_addr[3], dst_v6_addr[0], dst_v6_addr[1], dst_v6_addr[2], dst_v6_addr[3]);
-
- if(false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6))
- {
- IPACMERR("Failed to get routing table %s handle.\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name);
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("Routing handle for table %s: %d\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name,
- IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.hdl);
-
- flt_rule.status = -1;
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(lan2lan_flt_rule_hdl_v6[i].valid == false)
- {
- flt_rule.rule_hdl = lan2lan_flt_rule_hdl_v6[i].rule_hdl;
- break;
- }
- }
- if(i == MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Failed to find a filtering rule handle.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- flt_rule.rule.retain_hdr = 0;
- flt_rule.rule.to_uc = 0;
- flt_rule.rule.eq_attrib_type = 0;
- flt_rule.rule.action = IPA_PASS_TO_ROUTING;
- flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.hdl;
-
- memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
- sizeof(flt_rule.rule.attrib));
- IPACMDBG_H("Rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask);
-
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
- flt_rule.rule.attrib.u.v6.src_addr[0] = src_v6_addr[0];
- flt_rule.rule.attrib.u.v6.src_addr[1] = src_v6_addr[1];
- flt_rule.rule.attrib.u.v6.src_addr[2] = src_v6_addr[2];
- flt_rule.rule.attrib.u.v6.src_addr[3] = src_v6_addr[3];
- flt_rule.rule.attrib.u.v6.src_addr_mask[0] = 0xFFFFFFFF;
- flt_rule.rule.attrib.u.v6.src_addr_mask[1] = 0xFFFFFFFF;
- flt_rule.rule.attrib.u.v6.src_addr_mask[2] = 0xFFFFFFFF;
- flt_rule.rule.attrib.u.v6.src_addr_mask[3] = 0xFFFFFFFF;
-
-
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v6.dst_addr[0] = dst_v6_addr[0];
- flt_rule.rule.attrib.u.v6.dst_addr[1] = dst_v6_addr[1];
- flt_rule.rule.attrib.u.v6.dst_addr[2] = dst_v6_addr[2];
- flt_rule.rule.attrib.u.v6.dst_addr[3] = dst_v6_addr[3];
- flt_rule.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
-
- memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
- if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
- {
- IPACMERR("Error modifying filtering rule.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- lan2lan_flt_rule_hdl_v6[i].valid = true;
- *rule_hdl = lan2lan_flt_rule_hdl_v6[i].rule_hdl;
- num_lan2lan_flt_rule_v6++;
- IPACMDBG_H("Flt rule modified, hdl: 0x%x, status: %d\n", pFilteringTable->rules[0].rule_hdl,
- pFilteringTable->rules[0].status);
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
-fail:
- free(pFilteringTable);
- return res;
-}
-
-int IPACM_Lan::add_dummy_lan2lan_flt_rule(ipa_ip_type iptype)
-{
- if(rx_prop == NULL)
- {
- IPACMDBG_H("There is no rx_prop for iface %s, not able to add dummy lan2lan filtering rule.\n", dev_name);
- return 0;
- }
-
- int i, len, res = IPACM_SUCCESS;
- struct ipa_flt_rule_add flt_rule;
- ipa_ioc_add_flt_rule* pFilteringTable;
-
- len = sizeof(struct ipa_ioc_add_flt_rule) + MAX_OFFLOAD_PAIR * sizeof(struct ipa_flt_rule_add);
-
- pFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);
- if (pFilteringTable == NULL)
- {
- IPACMERR("Error allocate flt table memory...\n");
- return IPACM_FAILURE;
- }
- memset(pFilteringTable, 0, len);
-
- pFilteringTable->commit = 1;
- pFilteringTable->ep = rx_prop->rx[0].src_pipe;
- pFilteringTable->global = false;
- pFilteringTable->ip = iptype;
- pFilteringTable->num_rules = MAX_OFFLOAD_PAIR;
-
- memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));
-
- flt_rule.rule.retain_hdr = 0;
- flt_rule.at_rear = true;
- flt_rule.flt_rule_hdl = -1;
- flt_rule.status = -1;
- flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
- memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
- sizeof(flt_rule.rule.attrib));
-
- if(iptype == IPA_IP_v4)
- {
- flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v4.src_addr_mask = ~0;
- flt_rule.rule.attrib.u.v4.src_addr = ~0;
- flt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;
- flt_rule.rule.attrib.u.v4.dst_addr = ~0;
-
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
- }
-
- if (false == m_filtering.AddFilteringRule(pFilteringTable))
- {
- IPACMERR("Error adding dummy lan2lan v4 flt rule\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, MAX_OFFLOAD_PAIR);
- /* copy filter rule hdls */
- for (int i = 0; i < MAX_OFFLOAD_PAIR; i++)
- {
- if (pFilteringTable->rules[i].status == 0)
- {
- lan2lan_flt_rule_hdl_v4[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
- IPACMDBG_H("Lan2lan v4 flt rule %d hdl:0x%x\n", i, lan2lan_flt_rule_hdl_v4[i].rule_hdl);
- }
- else
- {
- IPACMERR("Failed adding lan2lan v4 flt rule %d\n", i);
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- }
- }
- else if(iptype == IPA_IP_v6)
- {
- flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[0] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[1] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[2] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[3] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;
-
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
- }
-
- if (false == m_filtering.AddFilteringRule(pFilteringTable))
- {
- IPACMERR("Error adding dummy lan2lan v6 flt rule\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, MAX_OFFLOAD_PAIR);
- /* copy filter rule hdls */
- for (int i = 0; i < MAX_OFFLOAD_PAIR; i++)
- {
- if (pFilteringTable->rules[i].status == 0)
- {
- lan2lan_flt_rule_hdl_v6[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
- IPACMDBG_H("Lan2lan v6 flt rule %d hdl:0x%x\n", i, lan2lan_flt_rule_hdl_v6[i].rule_hdl);
- }
- else
- {
- IPACMERR("Failed adding lan2lan v6 flt rule %d\n", i);
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- goto fail;
- }
-
-fail:
- free(pFilteringTable);
- return res;
-}
-
-int IPACM_Lan::del_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl)
-{
- int i;
-
- IPACMDBG_H("Del lan2lan flt rule with IP type: %d hdl: %d\n", iptype, rule_hdl);
- if(iptype == IPA_IP_v4)
- {
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(lan2lan_flt_rule_hdl_v4[i].rule_hdl == rule_hdl)
- {
- if(reset_to_dummy_flt_rule(IPA_IP_v4, rule_hdl) == IPACM_FAILURE)
- {
- IPACMERR("Failed to delete lan2lan v4 flt rule %d\n", rule_hdl);
- return IPACM_FAILURE;
- }
- IPACMDBG_H("Deleted lan2lan v4 flt rule %d\n", rule_hdl);
- lan2lan_flt_rule_hdl_v4[i].valid = false;
- num_lan2lan_flt_rule_v4--;
- break;
- }
- }
-
- if(i == MAX_OFFLOAD_PAIR) //not finding the rule
- {
- IPACMERR("The rule is not found.\n");
- return IPACM_FAILURE;
- }
- }
- else if(iptype == IPA_IP_v6)
- {
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(lan2lan_flt_rule_hdl_v6[i].rule_hdl == rule_hdl)
- {
- if(reset_to_dummy_flt_rule(IPA_IP_v6, rule_hdl) == IPACM_FAILURE)
- {
- IPACMERR("Failed to delete lan2lan v6 flt rule %d\n", rule_hdl);
- return IPACM_FAILURE;
- }
- IPACMDBG_H("Deleted lan2lan v6 flt rule %d\n", rule_hdl);
- lan2lan_flt_rule_hdl_v6[i].valid = false;
- num_lan2lan_flt_rule_v6--;
- break;
- }
- }
-
- if(i == MAX_OFFLOAD_PAIR) //not finding the rule
- {
- IPACMERR("The rule is not found.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- return IPACM_FAILURE;
- }
-
- return IPACM_SUCCESS;
-}
-
int IPACM_Lan::reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl)
{
int len, res = IPACM_SUCCESS;
@@ -4077,451 +3102,6 @@ fail:
return res;
}
-int IPACM_Lan::add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl)
-{
- if(tx_prop == NULL)
- {
- IPACMERR("There is no tx_prop, cannot add header.\n");
- return IPACM_FAILURE;
- }
- if(src_mac == NULL || dst_mac == NULL)
- {
- IPACMERR("Either src_mac or dst_mac is null, cannot add header.\n");
- return IPACM_FAILURE;
- }
- if(hdr_hdl == NULL)
- {
- IPACMERR("Header handle is empty.\n");
- return IPACM_FAILURE;
- }
-
- int i, j, len;
- int res = IPACM_SUCCESS;
- char index[4];
- struct ipa_ioc_copy_hdr sCopyHeader;
- struct ipa_ioc_add_hdr *pHeader;
-
- IPACMDBG_H("Get lan2lan header request, src_mac: 0x%02x%02x%02x%02x%02x%02x dst_mac: 0x%02x%02x%02x%02x%02x%02x\n",
- src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], dst_mac[0], dst_mac[1],
- dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]);
-
- len = sizeof(struct ipa_ioc_add_hdr) + sizeof(struct ipa_hdr_add);
- pHeader = (struct ipa_ioc_add_hdr *)malloc(len);
- if (pHeader == NULL)
- {
- IPACMERR("Failed to allocate header\n");
- return IPACM_FAILURE;
- }
- memset(pHeader, 0, len);
-
- if(iptype == IPA_IP_v4)
- { /* copy partial header for v4*/
- for(i=0; i<tx_prop->num_tx_props; i++)
- {
- if(tx_prop->tx[i].ip == IPA_IP_v4)
- {
- IPACMDBG_H("Got v4-header name from %d tx props\n", i);
- memset(&sCopyHeader, 0, sizeof(sCopyHeader));
- memcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));
-
- IPACMDBG_H("Header name: %s\n", sCopyHeader.name);
- if(m_header.CopyHeader(&sCopyHeader) == false)
- {
- IPACMERR("Copy header failed\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- IPACMDBG_H("Header length: %d, paritial: %d\n", sCopyHeader.hdr_len, sCopyHeader.is_partial);
- if (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)
- {
- IPACMERR("Header oversize\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- memcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);
- }
-
- if(sCopyHeader.is_eth2_ofst_valid)
- {
- memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst], dst_mac, IPA_MAC_ADDR_SIZE);
- memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst+IPA_MAC_ADDR_SIZE], src_mac, IPA_MAC_ADDR_SIZE);
- }
- else
- {
- IPACMERR("Ethernet 2 header offset is invalid.\n");
- }
-
- pHeader->commit = true;
- pHeader->num_hdrs = 1;
-
- memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
- strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V4, sizeof(pHeader->hdr[0].name));
- pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
- for(j=0; j<MAX_OFFLOAD_PAIR; j++)
- {
- if( lan2lan_hdr_hdl_v4[j].valid == false)
- {
- IPACMDBG_H("Construct lan2lan hdr with index %d.\n", j);
- break;
- }
- }
- if(j == MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Failed to find an available hdr index.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- lan2lan_hdr_hdl_v4[j].valid = true;
- snprintf(index,sizeof(index), "%d", j);
- if (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
- {
- IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeader->hdr[0].name));
- res = IPACM_FAILURE;
- goto fail;
- }
-
- pHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;
- pHeader->hdr[0].is_partial = 0;
- pHeader->hdr[0].hdr_hdl = -1;
- pHeader->hdr[0].status = -1;
-
- if (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)
- {
- IPACMERR("Ioctl IPA_IOC_ADD_HDR failed with status: %d\n", pHeader->hdr[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("Installed v4 full header %s header handle 0x%08x\n", pHeader->hdr[0].name,
- pHeader->hdr[0].hdr_hdl);
- *hdr_hdl = pHeader->hdr[0].hdr_hdl;
- lan2lan_hdr_hdl_v4[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;
- break;
- }
- }
- }
- else if(iptype == IPA_IP_v6)
- { /* copy partial header for v6*/
- for(i=0; i<tx_prop->num_tx_props; i++)
- {
- if(tx_prop->tx[i].ip == IPA_IP_v6)
- {
- IPACMDBG_H("Got v6-header name from %d tx props\n", i);
- memset(&sCopyHeader, 0, sizeof(sCopyHeader));
- memcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));
-
- IPACMDBG_H("Header name: %s\n", sCopyHeader.name);
- if(m_header.CopyHeader(&sCopyHeader) == false)
- {
- IPACMERR("Copy header failed\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- IPACMDBG_H("Header length: %d, paritial: %d\n", sCopyHeader.hdr_len, sCopyHeader.is_partial);
- if (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)
- {
- IPACMERR("Header oversize\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- memcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);
- }
- if(sCopyHeader.is_eth2_ofst_valid)
- {
- memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst], dst_mac, IPA_MAC_ADDR_SIZE);
- memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst+IPA_MAC_ADDR_SIZE], src_mac, IPA_MAC_ADDR_SIZE);
- }
- else
- {
- IPACMERR("Ethernet 2 header offset is invalid.\n");
- }
-
- pHeader->commit = true;
- pHeader->num_hdrs = 1;
-
- memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
- strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V6, sizeof(pHeader->hdr[0].name));
- pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
- for(j=0; j<MAX_OFFLOAD_PAIR; j++)
- {
- if( lan2lan_hdr_hdl_v6[j].valid == false)
- {
- IPACMDBG_H("Construct lan2lan hdr with index %d.\n", j);
- break;
- }
- }
- if(j == MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Failed to find an available hdr index.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- lan2lan_hdr_hdl_v6[j].valid = true;
- snprintf(index,sizeof(index), "%d", j);
- if (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
- {
- IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeader->hdr[0].name));
- res = IPACM_FAILURE;
- goto fail;
- }
-
- pHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;
- pHeader->hdr[0].is_partial = 0;
- pHeader->hdr[0].hdr_hdl = -1;
- pHeader->hdr[0].status = -1;
-
- if (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)
- {
- IPACMERR("Ioctl IPA_IOC_ADD_HDR failed with status: %d\n", pHeader->hdr[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("Installed v6 full header %s header handle 0x%08x\n", pHeader->hdr[0].name,
- pHeader->hdr[0].hdr_hdl);
- *hdr_hdl = pHeader->hdr[0].hdr_hdl;
- lan2lan_hdr_hdl_v6[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;
- break;
- }
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- }
-
-fail:
- free(pHeader);
- return res;
-}
-
-int IPACM_Lan::del_lan2lan_hdr(ipa_ip_type iptype, uint32_t hdr_hdl)
-{
- int i;
- if (m_header.DeleteHeaderHdl(hdr_hdl) == false)
- {
- IPACMERR("Failed to delete header %d\n", hdr_hdl);
- return IPACM_FAILURE;
- }
- IPACMDBG_H("Deleted header %d\n", hdr_hdl);
-
- if(iptype == IPA_IP_v4)
- {
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(lan2lan_hdr_hdl_v4[i].hdr_hdl == hdr_hdl)
- {
- lan2lan_hdr_hdl_v4[i].valid = false;
- break;
- }
- }
- if(i == MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Failed to find corresponding hdr hdl.\n");
- return IPACM_FAILURE;
- }
- }
- else if(iptype == IPA_IP_v6)
- {
- for(i=0; i<MAX_OFFLOAD_PAIR; i++)
- {
- if(lan2lan_hdr_hdl_v6[i].hdr_hdl == hdr_hdl)
- {
- lan2lan_hdr_hdl_v6[i].valid = false;
- break;
- }
- }
- if(i == MAX_OFFLOAD_PAIR)
- {
- IPACMERR("Failed to find corresponding hdr hdl.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- return IPACM_FAILURE;
- }
- return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::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)
-{
- struct ipa_ioc_add_rt_rule *rt_rule;
- struct ipa_rt_rule_add *rt_rule_entry;
- uint32_t tx_index;
- int len;
- int res = IPACM_SUCCESS;
-
- IPACMDBG_H("Got a new lan2lan rt rule with IP type: %d\n", iptype);
-
- if(rule_hdl == NULL)
- {
- IPACMERR("Rule hdl is empty.\n");
- return IPACM_FAILURE;
- }
- memset(rule_hdl, 0, sizeof(lan_to_lan_rt_rule_hdl));
-
- if(tx_prop == NULL)
- {
- IPACMDBG_H("There is no tx_prop for iface %s, not able to add lan2lan routing rule.\n", dev_name);
- return IPACM_FAILURE;
- }
-
- len = sizeof(struct ipa_ioc_add_rt_rule) + sizeof(struct ipa_rt_rule_add);
- rt_rule = (struct ipa_ioc_add_rt_rule *)malloc(len);
- if (!rt_rule)
- {
- IPACMERR("Failed to allocate memory for rt rule\n");
- return IPACM_FAILURE;
- }
- memset(rt_rule, 0, len);
-
- rt_rule->commit = 1;
- rt_rule->num_rules = 1;
- rt_rule->ip = iptype;
-
- if(iptype == IPA_IP_v4)
- {
- IPACMDBG_H("src_v4_addr: 0x%08x dst_v4_addr: 0x%08x\n", src_v4_addr, dst_v4_addr);
-
- strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name);
- rt_rule_entry = &rt_rule->rules[0];
- rt_rule_entry->at_rear = false;
- rt_rule_entry->rt_rule_hdl = 0;
- rt_rule_entry->status = -1;
-
- for (tx_index = 0; tx_index<iface_query->num_tx_props; tx_index++)
- {
- if(tx_prop->tx[tx_index].ip != IPA_IP_v4)
- {
- IPACMDBG_H("Tx:%d, iptype: %d conflict ip-type: %d bypass\n",
- tx_index, tx_prop->tx[tx_index].ip, IPA_IP_v4);
- continue;
- }
-
- rt_rule_entry->rule.hdr_hdl = hdr_hdl;
- rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;
- memcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[tx_index].attrib,
- sizeof(rt_rule_entry->rule.attrib));
-
- rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
- rt_rule_entry->rule.attrib.u.v4.src_addr = src_v4_addr;
- rt_rule_entry->rule.attrib.u.v4.src_addr_mask = 0xFFFFFFFF;
-
- rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
- rt_rule_entry->rule.attrib.u.v4.dst_addr = dst_v4_addr;
- rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
- if(m_routing.AddRoutingRule(rt_rule) == false)
- {
- IPACMERR("Routing rule addition failed\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("Added rt rule hdl: 0x%08x\n", rt_rule_entry->rt_rule_hdl);
- rule_hdl->rule_hdl[rule_hdl->num_rule] = rt_rule_entry->rt_rule_hdl;
- rule_hdl->num_rule++;
- }
- }
- else if(iptype == IPA_IP_v6)
- {
- if(src_v6_addr == NULL || dst_v6_addr == NULL)
- {
- IPACMERR("Got IPv6 rt rule but without IPv6 src/dst addr.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\n", src_v6_addr[0], src_v6_addr[1],
- src_v6_addr[2], src_v6_addr[3], dst_v6_addr[0], dst_v6_addr[1], dst_v6_addr[2], dst_v6_addr[3]);
-
- strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name);
- rt_rule_entry = &rt_rule->rules[0];
- rt_rule_entry->at_rear = false;
- rt_rule_entry->rt_rule_hdl = 0;
- rt_rule_entry->status = -1;
-
- for (tx_index = 0; tx_index<iface_query->num_tx_props; tx_index++)
- {
- if(tx_prop->tx[tx_index].ip != IPA_IP_v6)
- {
- IPACMDBG_H("Tx:%d, iptype: %d conflict ip-type: %d bypass\n",
- tx_index, tx_prop->tx[tx_index].ip, IPA_IP_v6);
- continue;
- }
-
- rt_rule_entry->rule.hdr_hdl = hdr_hdl;
- rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;
- memcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[tx_index].attrib,
- sizeof(rt_rule_entry->rule.attrib));
-
- rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
- rt_rule_entry->rule.attrib.u.v6.src_addr[0] = src_v6_addr[0];
- rt_rule_entry->rule.attrib.u.v6.src_addr[1] = src_v6_addr[1];
- rt_rule_entry->rule.attrib.u.v6.src_addr[2] = src_v6_addr[2];
- rt_rule_entry->rule.attrib.u.v6.src_addr[3] = src_v6_addr[3];
- rt_rule_entry->rule.attrib.u.v6.src_addr_mask[0] = 0xFFFFFFFF;
- rt_rule_entry->rule.attrib.u.v6.src_addr_mask[1] = 0xFFFFFFFF;
- rt_rule_entry->rule.attrib.u.v6.src_addr_mask[2] = 0xFFFFFFFF;
- rt_rule_entry->rule.attrib.u.v6.src_addr_mask[3] = 0xFFFFFFFF;
-
- rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = dst_v6_addr[0];
- rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = dst_v6_addr[1];
- rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = dst_v6_addr[2];
- rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = dst_v6_addr[3];
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
- if(m_routing.AddRoutingRule(rt_rule) == false)
- {
- IPACMERR("Routing rule addition failed\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACMDBG_H("Added rt rule hdl: 0x%08x\n", rt_rule_entry->rt_rule_hdl);
- rule_hdl->rule_hdl[rule_hdl->num_rule] = rt_rule_entry->rt_rule_hdl;
- rule_hdl->num_rule++;
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- }
-
-fail:
- free(rt_rule);
- return res;
-}
-
-int IPACM_Lan::del_lan2lan_rt_rule(ipa_ip_type iptype, lan_to_lan_rt_rule_hdl rule_hdl)
-{
- if(rule_hdl.num_rule <= 0 || rule_hdl.num_rule > MAX_NUM_PROP)
- {
- IPACMERR("The number of rule handles are not correct.\n");
- return IPACM_FAILURE;
- }
-
- int i, res = IPACM_SUCCESS;
-
- IPACMDBG_H("Get %d rule handles with IP type %d\n", rule_hdl.num_rule, iptype);
- for(i=0; i<rule_hdl.num_rule; i++)
- {
- if(m_routing.DeleteRoutingHdl(rule_hdl.rule_hdl[i], iptype) == false)
- {
- IPACMERR("Failed to delete routing rule hdl %d.\n", rule_hdl.rule_hdl[i]);
- res = IPACM_FAILURE;
- }
- IPACMDBG_H("Deleted routing rule handle %d\n",rule_hdl.rule_hdl[i]);
- }
- return res;
-}
-
void IPACM_Lan::post_del_self_evt()
{
ipacm_cmd_q_data evt;
@@ -4561,13 +3141,6 @@ int IPACM_Lan::handle_lan_client_reset_rt(ipa_ip_type iptype)
}
} /* end of for loop */
- /* Pass info to LAN2LAN module */
- res = post_lan2lan_client_disconnect_msg(iptype);
- if (res != IPACM_SUCCESS)
- {
- IPACMERR("Failed to posting delete old iptype(%d) address.\n", iptype);
- return res;
- }
/* Reset ip-address */
for (i = 0; i < num_eth_client; i++)
{
@@ -4583,68 +3156,6 @@ int IPACM_Lan::handle_lan_client_reset_rt(ipa_ip_type iptype)
return res;
}
-/*handle lan2lan internal mesg posting*/
-int IPACM_Lan::post_lan2lan_client_disconnect_msg(ipa_ip_type iptype)
-{
- int i, j;
- ipacm_cmd_q_data evt_data;
- ipacm_event_lan_client* lan_client;
-
- for (i = 0; i < num_eth_client; i++)
- {
- if((get_client_memptr(eth_client, i)->ipv4_set == true)
- && (iptype == IPA_IP_v4))
- {
- lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
- if(lan_client == NULL)
- {
- IPACMERR("Failed to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(lan_client, 0, sizeof(ipacm_event_lan_client));
- lan_client->iptype = IPA_IP_v4;
- lan_client->ipv4_addr = get_client_memptr(eth_client, i)->v4_addr;
- lan_client->p_iface = this;
-
- memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
- evt_data.evt_data = (void*)lan_client;
- evt_data.event = IPA_LAN_CLIENT_DISCONNECT;
-
- IPACMDBG_H("Posting event IPA_LAN_CLIENT_DISCONNECT\n");
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- }
-
- if((get_client_memptr(eth_client, i)->ipv6_set > 0)
- && (iptype == IPA_IP_v6))
- {
- for (j = 0; j < get_client_memptr(eth_client, i)->ipv6_set; j++)
- {
- lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
- if(lan_client == NULL)
- {
- IPACMERR("Failed to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(lan_client, 0, sizeof(ipacm_event_lan_client));
- lan_client->iptype = IPA_IP_v6;
- lan_client->ipv6_addr[0] = get_client_memptr(eth_client, i)->v6_addr[j][0];
- lan_client->ipv6_addr[1] = get_client_memptr(eth_client, i)->v6_addr[j][1];
- lan_client->ipv6_addr[2] = get_client_memptr(eth_client, i)->v6_addr[j][2];
- lan_client->ipv6_addr[3] = get_client_memptr(eth_client, i)->v6_addr[j][3];
- lan_client->p_iface = this;
-
- memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
- evt_data.evt_data = (void*)lan_client;
- evt_data.event = IPA_LAN_CLIENT_DISCONNECT;
-
- IPACMDBG_H("Posting event IPA_LAN_CLIENT_DISCONNECT\n");
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- }
- }
- } /* end of for loop */
- return IPACM_SUCCESS;
-}
-
int IPACM_Lan::install_ipv4_icmp_flt_rule()
{
int len;
@@ -4677,10 +3188,12 @@ int IPACM_Lan::install_ipv4_icmp_flt_rule()
flt_rule_entry.flt_rule_hdl = -1;
flt_rule_entry.status = -1;
flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
+#ifdef FEATURE_IPA_V3
+ flt_rule_entry.rule.hashable = true;
+#endif
memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
- flt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);
- flt_rule_entry.rule.attrib.attrib_mask = IPA_FLT_PROTOCOL;
+ flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;
flt_rule_entry.rule.attrib.u.v4.protocol = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP;
memcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
@@ -4701,110 +3214,62 @@ int IPACM_Lan::install_ipv4_icmp_flt_rule()
return IPACM_SUCCESS;
}
-void IPACM_Lan::install_tcp_ctl_flt_rule(ipa_ip_type iptype)
+int IPACM_Lan::install_ipv6_icmp_flt_rule()
{
- if (rx_prop == NULL)
- {
- IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
- return;
- }
-
- int len, i;
- struct ipa_flt_rule_add flt_rule;
- ipa_ioc_add_flt_rule* pFilteringTable;
- len = sizeof(struct ipa_ioc_add_flt_rule) + NUM_TCP_CTL_FLT_RULE * sizeof(struct ipa_flt_rule_add);
+ int len;
+ struct ipa_ioc_add_flt_rule* flt_rule;
+ struct ipa_flt_rule_add flt_rule_entry;
- pFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);
- if (pFilteringTable == NULL)
+ if(rx_prop != NULL)
{
- IPACMERR("Error allocate flt table memory...\n");
- return;
- }
- memset(pFilteringTable, 0, len);
+ len = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);
- pFilteringTable->commit = 1;
- pFilteringTable->ip = iptype;
- pFilteringTable->ep = rx_prop->rx[0].src_pipe;
- pFilteringTable->global = false;
- pFilteringTable->num_rules = NUM_TCP_CTL_FLT_RULE;
+ flt_rule = (struct ipa_ioc_add_flt_rule *)calloc(1, len);
+ if (!flt_rule)
+ {
+ IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
+ return IPACM_FAILURE;
+ }
- memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));
+ flt_rule->commit = 1;
+ flt_rule->ep = rx_prop->rx[0].src_pipe;
+ flt_rule->global = false;
+ flt_rule->ip = IPA_IP_v6;
+ flt_rule->num_rules = 1;
- flt_rule.at_rear = true;
- flt_rule.flt_rule_hdl = -1;
- flt_rule.status = -1;
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
- flt_rule.rule.retain_hdr = 1;
- flt_rule.rule.to_uc = 0;
- flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
+ flt_rule_entry.rule.retain_hdr = 1;
+ flt_rule_entry.rule.to_uc = 0;
+ flt_rule_entry.rule.eq_attrib_type = 0;
+ flt_rule_entry.at_rear = true;
+ flt_rule_entry.flt_rule_hdl = -1;
+ flt_rule_entry.status = -1;
+ flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
#ifdef FEATURE_IPA_V3
- flt_rule.rule.hashable = IPA_RULE_NON_HASHABLE;
+ flt_rule_entry.rule.hashable = false;
#endif
- flt_rule.rule.eq_attrib_type = 1;
-
- flt_rule.rule.eq_attrib.rule_eq_bitmap = 0;
-
- if(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA)
- {
- flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<14);
- flt_rule.rule.eq_attrib.metadata_meq32_present = 1;
- flt_rule.rule.eq_attrib.metadata_meq32.offset = 0;
- flt_rule.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;
- flt_rule.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;
- }
-
- flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<1);
- flt_rule.rule.eq_attrib.protocol_eq_present = 1;
- flt_rule.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;
-
- flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<8);
- flt_rule.rule.eq_attrib.num_ihl_offset_meq_32 = 1;
- flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;
-
- /* add TCP FIN rule*/
- flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);
- flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);
- memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_add));
-
- /* add TCP SYN rule*/
- flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);
- flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);
- memcpy(&(pFilteringTable->rules[1]), &flt_rule, sizeof(struct ipa_flt_rule_add));
-
- /* add TCP RST rule*/
- flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);
- flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);
- memcpy(&(pFilteringTable->rules[2]), &flt_rule, sizeof(struct ipa_flt_rule_add));
+ memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
+ flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;
+ flt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;
+ memcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
- if (false == m_filtering.AddFilteringRule(pFilteringTable))
- {
- IPACMERR("Error adding tcp control flt rule\n");
- goto fail;
- }
- else
- {
- if(iptype == IPA_IP_v4)
+ if (m_filtering.AddFilteringRule(flt_rule) == false)
{
- for(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)
- {
- tcp_ctl_flt_rule_hdl_v4[i] = pFilteringTable->rules[i].flt_rule_hdl;
- }
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, NUM_TCP_CTL_FLT_RULE);
+ IPACMERR("Error Adding Filtering rule, aborting...\n");
+ free(flt_rule);
+ return IPACM_FAILURE;
}
else
{
- for(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)
- {
- tcp_ctl_flt_rule_hdl_v6[i] = pFilteringTable->rules[i].flt_rule_hdl;
- }
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, NUM_TCP_CTL_FLT_RULE);
+ IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
+ ipv6_icmp_flt_rule_hdl[0] = flt_rule->rules[0].flt_rule_hdl;
+ IPACMDBG_H("IPv6 icmp filter rule HDL:0x%x\n", ipv6_icmp_flt_rule_hdl[0]);
+ free(flt_rule);
}
}
-
-fail:
- free(pFilteringTable);
- return;
+ return IPACM_SUCCESS;
}
int IPACM_Lan::add_dummy_private_subnet_flt_rule(ipa_ip_type iptype)
@@ -4847,6 +3312,9 @@ int IPACM_Lan::add_dummy_private_subnet_flt_rule(ipa_ip_type iptype)
flt_rule.flt_rule_hdl = -1;
flt_rule.status = -1;
flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
+#ifdef FEATURE_IPA_V3
+ flt_rule.rule.hashable = true;
+#endif
memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
sizeof(flt_rule.rule.attrib));
@@ -5016,10 +3484,9 @@ int IPACM_Lan::install_ipv6_prefix_flt_rule(uint32_t* prefix)
flt_rule_entry.status = -1;
flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
#ifdef FEATURE_IPA_V3
- flt_rule_entry.rule.hashable = IPA_RULE_NON_HASHABLE;
+ flt_rule_entry.rule.hashable = false;
#endif
memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
- flt_rule_entry.rule.attrib.attrib_mask = flt_rule_entry.rule.attrib.attrib_mask & ~((uint32_t)IPA_FLT_META_DATA);
flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = prefix[0];
flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = prefix[1];
@@ -5059,65 +3526,6 @@ void IPACM_Lan::delete_ipv6_prefix_flt_rule()
return;
}
-int IPACM_Lan::install_ipv6_icmp_flt_rule()
-{
-
- int len;
- struct ipa_ioc_add_flt_rule* flt_rule;
- struct ipa_flt_rule_add flt_rule_entry;
-
- if(rx_prop != NULL)
- {
- len = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);
-
- flt_rule = (struct ipa_ioc_add_flt_rule *)calloc(1, len);
- if (!flt_rule)
- {
- IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
- return IPACM_FAILURE;
- }
-
- flt_rule->commit = 1;
- flt_rule->ep = rx_prop->rx[0].src_pipe;
- flt_rule->global = false;
- flt_rule->ip = IPA_IP_v6;
- flt_rule->num_rules = 1;
-
- memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
-
- flt_rule_entry.rule.retain_hdr = 1;
- flt_rule_entry.rule.to_uc = 0;
- flt_rule_entry.rule.eq_attrib_type = 0;
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1;
- flt_rule_entry.status = -1;
- flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
-#ifdef FEATURE_IPA_V3
- flt_rule_entry.rule.hashable = IPA_RULE_NON_HASHABLE;
-#endif
- memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
- flt_rule_entry.rule.attrib.attrib_mask = flt_rule_entry.rule.attrib.attrib_mask & ~((uint32_t)IPA_FLT_META_DATA);
- flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;
- flt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;
- memcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
-
- if (m_filtering.AddFilteringRule(flt_rule) == false)
- {
- IPACMERR("Error Adding Filtering rule, aborting...\n");
- free(flt_rule);
- return IPACM_FAILURE;
- }
- else
- {
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
- ipv6_icmp_flt_rule_hdl[0] = flt_rule->rules[0].flt_rule_hdl;
- IPACMDBG_H("IPv6 icmp filter rule HDL:0x%x\n", ipv6_icmp_flt_rule_hdl[0]);
- free(flt_rule);
- }
- }
- return IPACM_SUCCESS;
-}
-
int IPACM_Lan::handle_addr_evt_odu_bridge(ipacm_event_data_addr* data)
{
int fd, res = IPACM_SUCCESS;
@@ -5151,1062 +3559,7 @@ int IPACM_Lan::handle_addr_evt_odu_bridge(ipacm_event_data_addr* data)
return res;
}
-int IPACM_Lan::eth_bridge_handle_dummy_wlan_client_flt_rule(ipa_ip_type iptype)
-{
- if(rx_prop == NULL)
- {
- IPACMDBG_H("There is no rx_prop for iface %s, not able to add dummy wlan client specific filtering rule.\n", dev_name);
- return 0;
- }
-
- int i, len, res = IPACM_SUCCESS;
- struct ipa_flt_rule_add flt_rule;
- ipa_ioc_add_flt_rule* pFilteringTable;
-
- len = sizeof(struct ipa_ioc_add_flt_rule) + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT * sizeof(struct ipa_flt_rule_add);
-
- pFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);
- if (pFilteringTable == NULL)
- {
- IPACMERR("Error allocate flt table memory...\n");
- return IPACM_FAILURE;
- }
- memset(pFilteringTable, 0, len);
-
- pFilteringTable->commit = 1;
- pFilteringTable->ep = rx_prop->rx[0].src_pipe;
- pFilteringTable->global = false;
- pFilteringTable->ip = iptype;
- pFilteringTable->num_rules = IPA_LAN_TO_LAN_MAX_WLAN_CLIENT;
-
- memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));
-
- flt_rule.rule.retain_hdr = 0;
- flt_rule.at_rear = true;
- flt_rule.flt_rule_hdl = -1;
- flt_rule.status = -1;
- flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
- memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
- sizeof(flt_rule.rule.attrib));
-
- if(iptype == IPA_IP_v4)
- {
- flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v4.src_addr_mask = ~0;
- flt_rule.rule.attrib.u.v4.src_addr = ~0;
- flt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;
- flt_rule.rule.attrib.u.v4.dst_addr = ~0;
-
- for(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
- }
-
- if (false == m_filtering.AddFilteringRule(pFilteringTable))
- {
- IPACMERR("Error adding dummy lan2lan v4 flt rule\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT);
- /* copy filter rule hdls */
- for (int i = 0; i < IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- if (pFilteringTable->rules[i].status == 0)
- {
- wlan_client_flt_rule_hdl_v4[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
- wlan_client_flt_rule_hdl_v4[i].valid = true;
- IPACMDBG_H("Wlan client v4 flt rule %d hdl:0x%x\n", i, wlan_client_flt_rule_hdl_v4[i].rule_hdl);
- }
- else
- {
- IPACMERR("Failed adding wlan client v4 flt rule %d\n", i);
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- }
- }
- else if(iptype == IPA_IP_v6)
- {
- flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[0] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[1] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[2] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[3] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;
-
- for(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
- }
-
- if (false == m_filtering.AddFilteringRule(pFilteringTable))
- {
- IPACMERR("Error adding dummy lan2lan v6 flt rule\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, IPA_LAN_TO_LAN_MAX_WLAN_CLIENT);
- /* copy filter rule hdls */
- for (int i = 0; i < IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- if (pFilteringTable->rules[i].status == 0)
- {
- wlan_client_flt_rule_hdl_v6[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
- wlan_client_flt_rule_hdl_v6[i].valid = true;
- IPACMDBG_H("Wlan client v6 flt rule %d hdl:0x%x\n", i, wlan_client_flt_rule_hdl_v6[i].rule_hdl);
- }
- else
- {
- IPACMERR("Failed adding wlan client v6 flt rule %d\n", i);
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- goto fail;
- }
-
-fail:
- free(pFilteringTable);
- return res;
-}
-
-int IPACM_Lan::eth_bridge_handle_dummy_lan_client_flt_rule(ipa_ip_type iptype)
-{
- if(rx_prop == NULL)
- {
- IPACMDBG_H("There is no rx_prop for iface %s, not able to add dummy lan client specific filtering rule.\n", dev_name);
- return 0;
- }
-
- int i, len, res = IPACM_SUCCESS, num_dummy_rules;
- struct ipa_flt_rule_add flt_rule;
- ipa_ioc_add_flt_rule* pFilteringTable;
-
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- num_dummy_rules = IPA_LAN_TO_LAN_MAX_CPE_CLIENT;
- }
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- num_dummy_rules = IPA_LAN_TO_LAN_MAX_USB_CLIENT;
- }
-
- len = sizeof(struct ipa_ioc_add_flt_rule) + num_dummy_rules * sizeof(struct ipa_flt_rule_add);
-
- pFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);
- if (pFilteringTable == NULL)
- {
- IPACMERR("Error allocate flt table memory...\n");
- return IPACM_FAILURE;
- }
- memset(pFilteringTable, 0, len);
-
- pFilteringTable->commit = 1;
- pFilteringTable->ep = rx_prop->rx[0].src_pipe;
- pFilteringTable->global = false;
- pFilteringTable->ip = iptype;
- pFilteringTable->num_rules = num_dummy_rules;
-
- memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));
-
- flt_rule.rule.retain_hdr = 0;
- flt_rule.at_rear = true;
- flt_rule.flt_rule_hdl = -1;
- flt_rule.status = -1;
- flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
- memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
- sizeof(flt_rule.rule.attrib));
-
- if(iptype == IPA_IP_v4)
- {
- flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v4.src_addr_mask = ~0;
- flt_rule.rule.attrib.u.v4.src_addr = ~0;
- flt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;
- flt_rule.rule.attrib.u.v4.dst_addr = ~0;
-
- for(i=0; i < num_dummy_rules; i++)
- {
- memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
- }
-
- if (false == m_filtering.AddFilteringRule(pFilteringTable))
- {
- IPACMERR("Error adding dummy lan2lan v4 flt rule\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, num_dummy_rules);
- /* copy filter rule hdls */
- for (int i = 0; i < num_dummy_rules; i++)
- {
- if (pFilteringTable->rules[i].status == 0)
- {
- lan_client_flt_rule_hdl_v4[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
- lan_client_flt_rule_hdl_v4[i].valid = true;
- IPACMDBG_H("Lan client v4 flt rule %d hdl:0x%x\n", i, lan_client_flt_rule_hdl_v4[i].rule_hdl);
- }
- else
- {
- IPACMERR("Failed adding lan client v4 flt rule %d\n", i);
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- }
- }
- else if(iptype == IPA_IP_v6)
- {
- flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
- flt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[0] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[1] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[2] = ~0;
- flt_rule.rule.attrib.u.v6.src_addr[3] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;
- flt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;
-
- for(i=0; i<num_dummy_rules; i++)
- {
- memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
- }
-
- if (false == m_filtering.AddFilteringRule(pFilteringTable))
- {
- IPACMERR("Error adding dummy lan2lan v6 flt rule\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, num_dummy_rules);
- /* copy filter rule hdls */
- for (int i = 0; i < num_dummy_rules; i++)
- {
- if (pFilteringTable->rules[i].status == 0)
- {
- lan_client_flt_rule_hdl_v6[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
- lan_client_flt_rule_hdl_v6[i].valid = true;
- IPACMDBG_H("Lan client v6 flt rule %d hdl:0x%x\n", i, lan_client_flt_rule_hdl_v6[i].rule_hdl);
- }
- else
- {
- IPACMERR("Failed adding lan client v6 flt rule %d\n", i);
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- }
- }
- else
- {
- IPACMERR("IP type is not expected.\n");
- goto fail;
- }
-
-fail:
- free(pFilteringTable);
- return res;
-}
-
-int IPACM_Lan::eth_bridge_post_lan_client_event(uint8_t* mac_addr, ipa_cm_event_id evt)
-{
- if(mac_addr == NULL)
- {
- IPACMERR("Event mac is empty.\n");
- return IPACM_FAILURE;
- }
-
- ipacm_cmd_q_data evt_data;
- memset(&evt_data, 0, sizeof(evt_data));
-
- ipacm_event_data_mac* mac;
- mac = (ipacm_event_data_mac*)malloc(sizeof(ipacm_event_data_mac));
- if(mac == NULL)
- {
- IPACMERR("Unable to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(mac, 0, sizeof(ipacm_event_data_mac));
- memcpy(mac->mac_addr, mac_addr, 6 * sizeof(uint8_t));
- mac->if_index = ipa_if_num;
-
- evt_data.event = evt;
- evt_data.evt_data = (void*)mac;
- IPACMDBG_H("Posting event: %d if_index: %d \n", evt, mac->if_index);
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::eth_bridge_add_wlan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype)
-{
- int i, len, res = IPACM_SUCCESS, client_position;
- struct ipa_flt_rule_mdfy flt_rule;
- struct ipa_ioc_mdfy_flt_rule* pFilteringTable = NULL;
- bool client_is_found = false;
-
- if (rx_prop == NULL)
- {
- IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
- return IPACM_FAILURE;
- }
- if(mac == NULL)
- {
- IPACMERR("MAC address is empty.\n");
- return IPACM_FAILURE;
- }
- if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == false)
- {
- IPACMDBG_H("USB to WLAN hdr proc ctx has not been set, don't add client specific flt rule.\n");
- return IPACM_FAILURE;
- }
-
- IPACMDBG_H("Received WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-
- for(i=0; i<wlan_client_flt_info_count; i++)
- {
- if(memcmp(eth_bridge_wlan_client_flt_info[i].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[i].mac)) == 0)
- {
- client_is_found = true;
- client_position = i;
- if( (iptype == IPA_IP_v4 && eth_bridge_wlan_client_flt_info[i].flt_rule_set_v4 == true)
- || (iptype == IPA_IP_v6 && eth_bridge_wlan_client_flt_info[i].flt_rule_set_v6 == true))
- {
- IPACMDBG_H("Flt rule for iptype %d has been set.\n", iptype);
- return IPACM_SUCCESS;
- }
- break;
- }
- }
-
- if(client_is_found == false && wlan_client_flt_info_count == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
- {
- IPACMDBG_H("The wlan client flt table is already full.\n");
- return IPACM_FAILURE;
- }
-
- len = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);
- pFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);
- if (!pFilteringTable)
- {
- IPACMERR("Failed to allocate ipa_ioc_mdfy_flt_rule memory...\n");
- return IPACM_FAILURE;
- }
- memset(pFilteringTable, 0, len);
-
- /* add mac based rule*/
- pFilteringTable->commit = 1;
- pFilteringTable->ip = iptype;
- pFilteringTable->num_rules = 1;
-
- memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));
- flt_rule.status = -1;
-
- flt_rule.rule.retain_hdr = 0;
- flt_rule.rule.to_uc = 0;
- flt_rule.rule.action = IPA_PASS_TO_ROUTING;
- flt_rule.rule.eq_attrib_type = 0;
-
- /* point to USB-WLAN routing table */
- if(iptype == IPA_IP_v4)
- {
- if (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4))
- {
- IPACMERR("Failed to get routing table handle.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.hdl;
- IPACMDBG_H("LAN->WLAN filter rule use table: %s\n",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name);
- }
- else
- {
- if (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6))
- {
- IPACMERR("Failed to get routing table handle.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.hdl;
- IPACMDBG_H("LAN->WLAN filter rule use table: %s\n",IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name);
- }
-
- memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));
- if(IPACM_Lan::lan_hdr_type == IPA_HDR_L2_ETHERNET_II)
- {
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
- }
- else if(IPACM_Lan::lan_hdr_type == IPA_HDR_L2_802_3)
- {
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
- }
- else
- {
- IPACMERR("USB hdr type is not expected.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- memcpy(flt_rule.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule.rule.attrib.dst_mac_addr));
- memset(flt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule.rule.attrib.dst_mac_addr_mask));
-
- if(iptype == IPA_IP_v4)
- {
- for(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- if(wlan_client_flt_rule_hdl_v4[i].valid == true)
- {
- flt_rule.rule_hdl = wlan_client_flt_rule_hdl_v4[i].rule_hdl;
- wlan_client_flt_rule_hdl_v4[i].valid = false;
- break;
- }
- }
- if(i == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
- {
- IPACMDBG_H("Cannot find a valid flt rule hdl.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- else
- {
- for(i=0; i<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; i++)
- {
- if(wlan_client_flt_rule_hdl_v6[i].valid == true)
- {
- flt_rule.rule_hdl = wlan_client_flt_rule_hdl_v6[i].rule_hdl;
- wlan_client_flt_rule_hdl_v6[i].valid = false;
- break;
- }
- }
- if(i == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
- {
- IPACMDBG_H("Cannot find a valid flt rule hdl.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
-
- memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
- if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
- {
- IPACMERR("Failed to add wlan client filtering rules.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- if(client_is_found == false)
- {
- client_position = wlan_client_flt_info_count;
- wlan_client_flt_info_count++;
- }
-
- memcpy(eth_bridge_wlan_client_flt_info[client_position].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[client_position].mac));
- if(iptype == IPA_IP_v4)
- {
- eth_bridge_wlan_client_flt_info[client_position].flt_rule_set_v4 = true;
- eth_bridge_wlan_client_flt_info[client_position].flt_rule_hdl_v4 = wlan_client_flt_rule_hdl_v4[i].rule_hdl;
- }
- else
- {
- eth_bridge_wlan_client_flt_info[client_position].flt_rule_set_v6 = true;
- eth_bridge_wlan_client_flt_info[client_position].flt_rule_hdl_v6 = wlan_client_flt_rule_hdl_v6[i].rule_hdl;
- }
-
-fail:
- free(pFilteringTable);
-
- return res;
-}
-
-int IPACM_Lan::eth_bridge_del_wlan_client_flt_rule(uint8_t* mac)
-{
- if(mac == NULL)
- {
- IPACMERR("Client MAC address is empty.\n");
- return IPACM_FAILURE;
- }
-
- IPACMDBG_H("Received WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-
- int i, j, res = IPACM_SUCCESS;
- for(i=0; i<wlan_client_flt_info_count; i++)
- {
- if(memcmp(eth_bridge_wlan_client_flt_info[i].mac, mac, sizeof(eth_bridge_wlan_client_flt_info[i].mac)) == 0)
- {
- break;
- }
- }
-
- if(i == wlan_client_flt_info_count)
- {
- IPACMERR("Do not find the wlan client.\n");
- return IPACM_FAILURE;
- }
-
- if(eth_bridge_wlan_client_flt_info[i].flt_rule_set_v4 == true)
- {
- if(reset_to_dummy_flt_rule(IPA_IP_v4, eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v4) == IPACM_SUCCESS)
- {
- for(j=0; j<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; j++)
- {
- if(wlan_client_flt_rule_hdl_v4[j].rule_hdl == eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v4)
- {
- wlan_client_flt_rule_hdl_v4[j].valid = true;
- break;
- }
- }
- if(j == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
- {
- IPACMERR("Not finding the rule handle in handle pool.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- IPACMERR("Failed to delete the wlan client specific flt rule.\n");
- return IPACM_FAILURE;
- }
- }
- if(eth_bridge_wlan_client_flt_info[i].flt_rule_set_v6 == true)
- {
- if(reset_to_dummy_flt_rule(IPA_IP_v6, eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v6) == IPACM_SUCCESS)
- {
- for(j=0; j<IPA_LAN_TO_LAN_MAX_WLAN_CLIENT; j++)
- {
- if(wlan_client_flt_rule_hdl_v6[j].rule_hdl == eth_bridge_wlan_client_flt_info[i].flt_rule_hdl_v6)
- {
- wlan_client_flt_rule_hdl_v6[j].valid = true;
- break;
- }
- }
- if(j == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
- {
- IPACMERR("Not finding the rule handle in handle pool.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- IPACMERR("Failed to delete the wlan client specific flt rule.\n");
- return IPACM_FAILURE;
- }
- }
-
- for(j=i+1; j<wlan_client_flt_info_count; j++)
- {
- memcpy(&(eth_bridge_wlan_client_flt_info[j-1]), &(eth_bridge_wlan_client_flt_info[j]), sizeof(eth_bridge_client_flt_info));
- }
- memset(&(eth_bridge_wlan_client_flt_info[wlan_client_flt_info_count-1]), 0, sizeof(eth_bridge_client_flt_info));
- wlan_client_flt_info_count--;
-
- return res;
-}
-
-int IPACM_Lan::eth_bridge_add_lan_client_flt_rule(uint8_t* mac, ipa_ip_type iptype)
-{
- int i, len, res = IPACM_SUCCESS, client_position;
- struct ipa_flt_rule_mdfy flt_rule;
- struct ipa_ioc_mdfy_flt_rule* pFilteringTable = NULL;
- bool client_is_found = false;
-
- if (rx_prop == NULL)
- {
- IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
- return IPACM_FAILURE;
- }
- if (mac == NULL)
- {
- IPACMERR("MAC address is empty.\n");
- return IPACM_FAILURE;
- }
- if (IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == false && IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == false)
- {
- IPACMDBG_H("USB to CPE and CPE to USB hdr proc ctx have not been set, don't add client specific flt rule.\n");
- return IPACM_FAILURE;
- }
-
- IPACMDBG_H("Received LAN client MAC 0x%02x%02x%02x%02x%02x%02x. if_cat: %d \n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
- IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat);
-
- for (i=0; i<lan_client_flt_info_count; i++)
- {
- if (memcmp(eth_bridge_lan_client_flt_info[i].mac, mac, sizeof(eth_bridge_lan_client_flt_info[i].mac)) == 0)
- {
- client_is_found = true;
- client_position = i;
- if ((iptype == IPA_IP_v4 && eth_bridge_lan_client_flt_info[i].flt_rule_set_v4 == true)
- || (iptype == IPA_IP_v6 && eth_bridge_lan_client_flt_info[i].flt_rule_set_v6 == true))
- {
- IPACMDBG_H("Flt rule for iptype %d has been set.\n", iptype);
- return IPACM_SUCCESS;
- }
- break;
- }
- }
-
- if (client_is_found == false && lan_client_flt_info_count == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- {
- IPACMDBG_H("The lan client flt table is already full.\n");
- return IPACM_FAILURE;
- }
-
- len = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);
- pFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);
- if (!pFilteringTable)
- {
- IPACMERR("Failed to allocate ipa_ioc_mdfy_flt_rule memory...\n");
- return IPACM_FAILURE;
- }
- memset(pFilteringTable, 0, len);
-
- /* add mac based rule*/
- pFilteringTable->commit = 1;
- pFilteringTable->ip = iptype;
- pFilteringTable->num_rules = 1;
-
- memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));
- flt_rule.status = -1;
-
- flt_rule.rule.retain_hdr = 0;
- flt_rule.rule.to_uc = 0;
- flt_rule.rule.action = IPA_PASS_TO_ROUTING;
- flt_rule.rule.eq_attrib_type = 0;
-
- /* point to LAN-LAN routing table */
- if (iptype == IPA_IP_v4)
- {
- if (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4))
- {
- IPACMERR("Failed to get routing table handle.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4.hdl;
- IPACMDBG_H("LAN->LAN filter rule use table: %s\n", IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4.name);
- }
- else
- {
- if (false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6))
- {
- IPACMERR("Failed to get routing table handle.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6.hdl;
- IPACMDBG_H("LAN->LAN filter rule use table: %s\n", IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6.name);
- }
-
- memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib));
-
- if (IPACM_Lan::lan_hdr_type == IPA_HDR_L2_ETHERNET_II)
- {
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
- }
- else if (IPACM_Lan::lan_hdr_type == IPA_HDR_L2_802_3)
- {
- flt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
- }
- else
- {
- IPACMERR("LAN hdr type is not expected.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- memcpy(flt_rule.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule.rule.attrib.dst_mac_addr));
- memset(flt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule.rule.attrib.dst_mac_addr_mask));
-
- if (iptype == IPA_IP_v4)
- {
- for (i=0; i<IPA_LAN_TO_LAN_MAX_LAN_CLIENT; i++)
- {
- if (lan_client_flt_rule_hdl_v4[i].valid == true)
- {
- flt_rule.rule_hdl = lan_client_flt_rule_hdl_v4[i].rule_hdl;
- lan_client_flt_rule_hdl_v4[i].valid = false;
- break;
- }
- }
- if (i == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- {
- IPACMDBG_H("Cannot find a valid flt rule hdl.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- else
- {
- for (i=0; i<IPA_LAN_TO_LAN_MAX_LAN_CLIENT; i++)
- {
- if (lan_client_flt_rule_hdl_v6[i].valid == true)
- {
- flt_rule.rule_hdl = lan_client_flt_rule_hdl_v6[i].rule_hdl;
- lan_client_flt_rule_hdl_v6[i].valid = false;
- break;
- }
- }
- if (i == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- {
- IPACMDBG_H("Cannot find a valid flt rule hdl.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
-
- memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
-
- if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
- {
- IPACMERR("Failed to add wlan client filtering rules.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- if (client_is_found == false)
- {
- client_position = lan_client_flt_info_count;
- lan_client_flt_info_count++;
- }
-
- memcpy(eth_bridge_lan_client_flt_info[client_position].mac, mac, sizeof(eth_bridge_lan_client_flt_info[client_position].mac));
-
- if (iptype == IPA_IP_v4)
- {
- eth_bridge_lan_client_flt_info[client_position].flt_rule_set_v4 = true;
- eth_bridge_lan_client_flt_info[client_position].flt_rule_hdl_v4 = lan_client_flt_rule_hdl_v4[i].rule_hdl;
- }
- else
- {
- eth_bridge_lan_client_flt_info[client_position].flt_rule_set_v6 = true;
- eth_bridge_lan_client_flt_info[client_position].flt_rule_hdl_v6 = lan_client_flt_rule_hdl_v6[i].rule_hdl;
- }
-
-fail:
- free(pFilteringTable);
-
- return res;
-}
-
-int IPACM_Lan::eth_bridge_del_lan_client_flt_rule(uint8_t* mac)
-{
- if (mac == NULL)
- {
- IPACMERR("Client MAC address is empty.\n");
- return IPACM_FAILURE;
- }
-
- IPACMDBG_H("Received LAN client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-
- int i, j, res = IPACM_SUCCESS;
- for (i=0; i<lan_client_flt_info_count; i++)
- {
- if (memcmp(eth_bridge_lan_client_flt_info[i].mac, mac, sizeof(eth_bridge_lan_client_flt_info[i].mac)) == 0)
- {
- break;
- }
- }
-
- if (i == lan_client_flt_info_count)
- {
- IPACMERR("Do not find the lan client.\n");
- return IPACM_FAILURE;
- }
-
- if (eth_bridge_lan_client_flt_info[i].flt_rule_set_v4 == true)
- {
- if (reset_to_dummy_flt_rule(IPA_IP_v4, eth_bridge_lan_client_flt_info[i].flt_rule_hdl_v4) == IPACM_SUCCESS)
- {
- for (j=0; j<IPA_LAN_TO_LAN_MAX_LAN_CLIENT; j++)
- {
- if (lan_client_flt_rule_hdl_v4[j].rule_hdl == eth_bridge_lan_client_flt_info[i].flt_rule_hdl_v4)
- {
- lan_client_flt_rule_hdl_v4[j].valid = true;
- break;
- }
- }
- if (j == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- {
- IPACMERR("Not finding the rule handle in handle pool.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- IPACMERR("Failed to delete the lan client specific flt rule.\n");
- return IPACM_FAILURE;
- }
- }
- if (eth_bridge_lan_client_flt_info[i].flt_rule_set_v6 == true)
- {
- if (reset_to_dummy_flt_rule(IPA_IP_v6, eth_bridge_lan_client_flt_info[i].flt_rule_hdl_v6) == IPACM_SUCCESS)
- {
- for (j=0; j<IPA_LAN_TO_LAN_MAX_LAN_CLIENT; j++)
- {
- if (lan_client_flt_rule_hdl_v6[j].rule_hdl == eth_bridge_lan_client_flt_info[i].flt_rule_hdl_v6)
- {
- lan_client_flt_rule_hdl_v6[j].valid = true;
- break;
- }
- }
- if (j == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- {
- IPACMERR("Not finding the rule handle in handle pool.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- IPACMERR("Failed to delete the lan client specific flt rule.\n");
- return IPACM_FAILURE;
- }
- }
-
- for (j=i+1; j<lan_client_flt_info_count; j++)
- {
- memcpy(&(eth_bridge_lan_client_flt_info[j-1]), &(eth_bridge_lan_client_flt_info[j]), sizeof(eth_bridge_client_flt_info));
- }
- memset(&(eth_bridge_lan_client_flt_info[lan_client_flt_info_count-1]), 0, sizeof(eth_bridge_client_flt_info));
- lan_client_flt_info_count--;
-
- return res;
-}
-
-int IPACM_Lan::add_hdr_proc_ctx()
-{
- int len, res = IPACM_SUCCESS;
- struct ipa_ioc_add_hdr_proc_ctx* pHeaderProcTable = NULL;
-
- len = sizeof(struct ipa_ioc_add_hdr_proc_ctx) + sizeof(struct ipa_hdr_proc_ctx_add);
- pHeaderProcTable = (ipa_ioc_add_hdr_proc_ctx*)malloc(len);
- if(pHeaderProcTable == NULL)
- {
- IPACMERR("Cannot allocate header processing table.\n");
- return IPACM_FAILURE;
- }
-
- if(IPACM_Lan::wlan_hdr_type != IPA_HDR_L2_NONE)
- {
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF)
- {
- if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == false)
- {
- memset(pHeaderProcTable, 0, len);
- pHeaderProcTable->commit = 1;
- pHeaderProcTable->num_proc_ctxs = 1;
- pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::wlan_hdr_type);
- pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::wlan_hdr_template_hdl;
- if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
- {
- IPACMERR("Adding WLAN to WLAN hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
- res = IPACM_FAILURE;
- }
- else
- {
- IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
- IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid = true;
- IPACMDBG_H("WLAN to WLAN hdr proc ctx is added successfully. \n");
- }
- }
- }
-
- if(IPACM_Lan::lan_hdr_type != IPA_HDR_L2_NONE)
- {
- if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == false)
- {
- memset(pHeaderProcTable, 0, len);
- pHeaderProcTable->commit = 1;
- pHeaderProcTable->num_proc_ctxs = 1;
- pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::lan_hdr_type, IPACM_Lan::wlan_hdr_type);
- pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::wlan_hdr_template_hdl;
- if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
- {
- IPACMERR("Adding LAN to WLAN hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Lan::lan_to_wlan_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
- IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid = true;
- IPACMDBG_H("LAN to WLAN hdr proc ctx is added successfully. \n");
- }
-
- ipacm_cmd_q_data evt_data;
- memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
- ipacm_event_data_if_cat* cat;
- cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
- if(cat == NULL)
- {
- IPACMERR("Unable to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(cat, 0, sizeof(ipacm_event_data_if_cat));
- cat->if_cat = IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat;
-
- evt_data.evt_data = cat;
- evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT;
- IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT\n");
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- }
-
- if(IPACM_Lan::is_usb_up == true && IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == false)
- {
- memset(pHeaderProcTable, 0, len);
- pHeaderProcTable->commit = 1;
- pHeaderProcTable->num_proc_ctxs = 1;
- pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::lan_hdr_type);
- pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::usb_hdr_template_hdl;
- if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
- {
- IPACMERR("Adding WLAN to USB hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
- IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid = true;
- IPACMDBG_H("WLAN to USB hdr proc ctx is added successfully. \n");
- }
- }
-
- if(IPACM_Lan::is_cpe_up == true && IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == false)
- {
- memset(pHeaderProcTable, 0, len);
- pHeaderProcTable->commit = 1;
- pHeaderProcTable->num_proc_ctxs = 1;
- pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::lan_hdr_type);
- pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::cpe_hdr_template_hdl;
- if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
- {
- IPACMERR("Adding WLAN to CPE hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
- IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid = true;
- IPACMDBG_H("WLAN to CPE hdr proc ctx is added successfully. \n");
-
- }
- }
- }
- }
-
- if(IPACM_Lan::lan_hdr_type != IPA_HDR_L2_NONE)
- {
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF ||
- (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF))
- {
- if(IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false)
- {
- IPACMDBG_H("ODU is in bridge mode, do not set CPE to USB and USB to CPE hdr proc ctx.\n");
- return res;
- }
- if(IPACM_Lan::is_cpe_up == true && IPACM_Lan::is_usb_up == true &&
- IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == false && IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == false)
- {
- memset(pHeaderProcTable, 0, len);
- pHeaderProcTable->commit = 1;
- pHeaderProcTable->num_proc_ctxs = 1;
- pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::lan_hdr_type, IPACM_Lan::lan_hdr_type);
- pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::usb_hdr_template_hdl;
- if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
- {
- IPACMERR("Adding CPE to USB hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Lan::cpe_to_usb_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
- IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid = true;
- IPACMDBG_H("CPE to USB hdr proc ctx is added successfully. \n");
- }
-
- pHeaderProcTable->commit = 1;
- pHeaderProcTable->num_proc_ctxs = 1;
- pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::lan_hdr_type, IPACM_Lan::lan_hdr_type);
- pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::cpe_hdr_template_hdl;
- if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
- {
- IPACMERR("Adding USB to CPE hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- IPACM_Lan::usb_to_cpe_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
- IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid = true;
- IPACMDBG_H("USB to CPE hdr proc ctx is added successfully. \n");
- }
-
- ipacm_cmd_q_data evt_data;
- memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
- ipacm_event_data_if_cat* cat;
- cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
- if(cat == NULL)
- {
- IPACMERR("Unable to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(cat, 0, sizeof(ipacm_event_data_if_cat));
- cat->if_cat = IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat;
-
- evt_data.evt_data = cat;
- evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT;
- IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT\n");
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- }
- }
- }
- else
- {
- IPACMDBG_H("Not adding header processing context.\n");
- }
-
-fail:
- free(pHeaderProcTable);
- return res;
-}
-
-ipa_hdr_proc_type IPACM_Lan::get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2)
+ipa_hdr_proc_type IPACM_Lan::eth_bridge_get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2)
{
if(t1 == IPA_HDR_L2_ETHERNET_II)
{
@@ -6235,592 +3588,6 @@ ipa_hdr_proc_type IPACM_Lan::get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_ty
return IPA_HDR_PROC_NONE;
}
-int IPACM_Lan::eth_bridge_install_cache_wlan_client_flt_rule(ipa_ip_type iptype)
-{
- int i;
-
- IPACMDBG_H("There are %d wlan clients cached.\n",IPACM_Lan::num_wlan_client);
- for(i=0; i<IPACM_Lan::num_wlan_client; i++)
- {
- eth_bridge_add_wlan_client_flt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, iptype);
- }
- return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::eth_bridge_install_cache_lan_client_flt_rule(ipa_ip_type iptype)
-{
- int i;
-
- IPACMDBG_H("There are %d lan clients cached.\n", IPACM_Lan::num_lan_client);
- for(i=0; i<IPACM_Lan::num_lan_client; i++)
- {
- if (IPACM_Lan::eth_bridge_lan_client[i].ipa_if_num != ipa_if_num)
- {
- eth_bridge_add_lan_client_flt_rule(IPACM_Lan::eth_bridge_lan_client[i].mac, iptype);
- }
- }
- return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::eth_bridge_add_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype)
-{
- if (tx_prop == NULL)
- {
- IPACMDBG_H("Tx prop is empty, not adding routing rule.\n");
- return IPACM_SUCCESS;
- }
- if (mac == NULL)
- {
- IPACMERR("Client MAC address is empty.\n");
- return IPACM_FAILURE;
- }
-
- IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x. src_iface: %d if_cat: %d \n",
- mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], src, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat );
-
- if (src == SRC_WLAN && IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF
- && IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == false)
- {
- IPACMDBG_H("WLAN to USB hdr proc ctx has not been set, don't add USB routing rule.\n");
- return IPACM_FAILURE;
- }
- if (src == SRC_WLAN && IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF
- && IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == false)
- {
- IPACMDBG_H("WLAN to CPE hdr proc ctx has not been set, don't add CPE routing rule.\n");
- return IPACM_FAILURE;
- }
-
- if (src == SRC_LAN && IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == false
- && IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == false)
- {
- IPACMDBG_H("hdr proc ctx between USB and CPE has not been set, don't add routing rule.\n");
- return IPACM_FAILURE;
- }
-
- if(iptype == IPA_IP_v4)
- {
- if((src == SRC_LAN && lan_client_rt_from_lan_info_count_v4 == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- || (src == SRC_WLAN && lan_client_rt_from_wlan_info_count_v4 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))
- {
- IPACMDBG_H("client number has reached maximum.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- if ((src == SRC_LAN && lan_client_rt_from_lan_info_count_v6 == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- || (src == SRC_WLAN && lan_client_rt_from_wlan_info_count_v6 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))
- {
- IPACMDBG_H("client number has reached maximum.\n");
- return IPACM_FAILURE;
- }
- }
-
- int i, len, res = IPACM_SUCCESS;
- struct ipa_ioc_add_rt_rule* rt_rule_table = NULL;
- struct ipa_rt_rule_add rt_rule;
- int position, num_rt_rule;
-
- if (src == SRC_LAN)
- {
- if (iptype == IPA_IP_v4)
- {
- for (i=0; i<lan_client_rt_from_lan_info_count_v4; i++)
- {
- if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
- {
- IPACMDBG_H("The client's routing rule was added before.\n");
- return IPACM_SUCCESS;
- }
- }
- memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4, src, iptype)->mac, mac,
- sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4, src, iptype)->mac));
- }
- else
- {
- for (i=0; i<lan_client_rt_from_lan_info_count_v6; i++)
- {
- if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
- {
- IPACMDBG_H("The client's routing rule was added before.\n");
- return IPACM_SUCCESS;
- }
- }
- memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6, src, iptype)->mac, mac,
- sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6, src, iptype)->mac));
- }
- }
- else
- {
- if (iptype == IPA_IP_v4)
- {
- for (i=0; i<lan_client_rt_from_wlan_info_count_v4; i++)
- {
- if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
- {
- IPACMDBG_H("The client's routing rule was added before.\n");
- return IPACM_SUCCESS;
- }
- }
- memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4, src, iptype)->mac, mac,
- sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4, src, iptype)->mac));
- }
- else
- {
- for (i=0; i<lan_client_rt_from_wlan_info_count_v6; i++)
- {
- if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
- {
- IPACMDBG_H("The client's routing rule was added before.\n");
- return IPACM_SUCCESS;
- }
- }
- memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6, src, iptype)->mac, mac,
- sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6, src, iptype)->mac));
- }
- }
-
- if (iptype == IPA_IP_v4)
- {
- num_rt_rule = each_client_rt_rule_count_v4;
- }
- else
- {
- num_rt_rule = each_client_rt_rule_count_v6;
- }
-
- len = sizeof(ipa_ioc_add_rt_rule) + num_rt_rule * sizeof(ipa_rt_rule_add);
- rt_rule_table = (ipa_ioc_add_rt_rule*)malloc(len);
- if (rt_rule_table == NULL)
- {
- IPACMERR("Failed to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(rt_rule_table, 0, len);
-
- rt_rule_table->commit = 1;
- rt_rule_table->ip = iptype;
- rt_rule_table->num_rules = num_rt_rule;
- if (src == SRC_LAN)
- {
- if (iptype == IPA_IP_v4)
- {
- strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
- }
- else
- {
- strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
- }
- }
- else
- {
- if (iptype == IPA_IP_v4)
- {
- strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
- }
- else
- {
- strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
- }
- }
- rt_rule_table->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
- memset(&rt_rule, 0, sizeof(ipa_rt_rule_add));
- rt_rule.at_rear = false;
- rt_rule.status = -1;
- rt_rule.rt_rule_hdl = -1;
-
- rt_rule.rule.hdr_hdl = 0;
- if(src == SRC_LAN)
- {
- if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::cpe_to_usb_hdr_proc_ctx.proc_ctx_hdl;
- }
- else if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::usb_to_cpe_hdr_proc_ctx.proc_ctx_hdl;
- }
- else
- {
- IPACMERR("Iface category is not expected.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- else
- {
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- {
- rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl;
- }
- else if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF)
- {
- rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.proc_ctx_hdl;
- }
- else
- {
- IPACMERR("Iface category is not expected.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- position = 0;
- for(i=0; i<iface_query->num_tx_props; i++)
- {
- if(tx_prop->tx[i].ip == iptype)
- {
- if(position >= num_rt_rule)
- {
- IPACMERR("Number of routing rules already exceeds limit.\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- rt_rule.rule.dst = tx_prop->tx[i].dst_pipe;
-
- memcpy(&rt_rule.rule.attrib, &tx_prop->tx[i].attrib, sizeof(rt_rule.rule.attrib));
- if(src == SRC_WLAN) //src is WLAN means packet is from WLAN
- {
- if(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)
- {
- rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
- }
- else
- {
- rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
- }
- }
- else //packet is from LAN
- {
- if(IPACM_Lan::lan_hdr_type == IPA_HDR_L2_ETHERNET_II)
- {
- rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
- }
- else
- {
- rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
- }
- }
- memcpy(rt_rule.rule.attrib.dst_mac_addr, mac, sizeof(rt_rule.rule.attrib.dst_mac_addr));
- memset(rt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(rt_rule.rule.attrib.dst_mac_addr_mask));
-
- memcpy(&(rt_rule_table->rules[position]), &rt_rule, sizeof(rt_rule_table->rules[position]));
- position++;
- }
- }
- if(false == m_routing.AddRoutingRule(rt_rule_table))
- {
- IPACMERR("Routing rule addition failed!\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- if(src == SRC_LAN)
- {
- for(i=0; i<num_rt_rule; i++)
- {
- if(iptype == IPA_IP_v4)
- {
- eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
- }
- else
- {
- eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
- }
- }
- if(iptype == IPA_IP_v4)
- {
- lan_client_rt_from_lan_info_count_v4++;
- IPACMDBG_H("Now the number of IPv4 rt rule on lan-lan rt table is %d.\n", lan_client_rt_from_lan_info_count_v4);
- }
- else
- {
- lan_client_rt_from_lan_info_count_v6++;
- IPACMDBG_H("Now the number of IPv6 rt rule on lan-lan rt table is %d.\n", lan_client_rt_from_lan_info_count_v6);
- }
- }
- else
- {
- for(i=0; i<num_rt_rule; i++)
- {
- if(iptype == IPA_IP_v4)
- {
- eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
- }
- else
- {
- eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
- }
- }
- if(iptype == IPA_IP_v4)
- {
- lan_client_rt_from_wlan_info_count_v4++;
- IPACMDBG_H("Now the number of IPv4 rt rule on lan-wlan rt table is %d.\n", lan_client_rt_from_wlan_info_count_v4);
- }
- else
- {
- lan_client_rt_from_wlan_info_count_v6++;
- IPACMDBG_H("Now the number of IPv6 rt rule on lan-wlan rt table is %d.\n", lan_client_rt_from_wlan_info_count_v6);
- }
- }
- }
-
-fail:
- if(rt_rule_table != NULL)
- {
- free(rt_rule_table);
- }
- return res;
-}
-
-int IPACM_Lan::eth_bridge_del_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src)
-{
- if(tx_prop == NULL)
- {
- IPACMDBG_H("Tx prop is empty, not deleting routing rule.\n");
- return IPACM_SUCCESS;
- }
- if(mac == NULL)
- {
- IPACMERR("Client MAC address is empty.\n");
- return IPACM_FAILURE;
- }
-
- IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x. src_iface: %d \n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], src);
-
- int i, position;
-
- /* first delete the rt rules from IPv4 rt table*/
- if(src == SRC_LAN)
- {
- for(i=0; i<lan_client_rt_from_lan_info_count_v4; i++)
- {
- if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)
- {
- position = i;
- IPACMDBG_H("The client is found at position %d.\n", position);
- break;
- }
- }
- if(i == lan_client_rt_from_lan_info_count_v4)
- {
- IPACMERR("The client is not found.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- for(i=0; i<lan_client_rt_from_wlan_info_count_v4; i++)
- {
- if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)
- {
- position = i;
- IPACMDBG_H("The client is found at position %d.\n", position);
- break;
- }
- }
- if(i == lan_client_rt_from_wlan_info_count_v4)
- {
- IPACMERR("The client is not found.\n");
- return IPACM_FAILURE;
- }
- }
-
- for(i=0; i<each_client_rt_rule_count_v4; i++)
- {
- if(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v4)->rt_rule_hdl[i], IPA_IP_v4) == false)
- {
- IPACMERR("Failed to delete routing rule %d.\n", i);
- return IPACM_FAILURE;
- }
- }
-
- if(src == SRC_LAN)
- {
- for(i=position+1; i<lan_client_rt_from_lan_info_count_v4; i++)
- {
- memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);
- }
- memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);
- lan_client_rt_from_lan_info_count_v4--;
- IPACMDBG_H("Now the number of IPv4 rt rule from lan info is %d.\n", lan_client_rt_from_lan_info_count_v4);
- }
- else
- {
- for(i=position+1; i<lan_client_rt_from_wlan_info_count_v4; i++)
- {
- memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);
- }
- memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);
- lan_client_rt_from_wlan_info_count_v4--;
- IPACMDBG_H("Now the number of IPv4 rt rule from wlan info is %d.\n", lan_client_rt_from_wlan_info_count_v4);
- }
-
- /*delete rt rules from IPv6 rt table */
- if(src == SRC_LAN)
- {
- for(i=0; i<lan_client_rt_from_lan_info_count_v6; i++)
- {
- if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)
- {
- position = i;
- IPACMDBG_H("The client is found at position %d.\n", position);
- break;
- }
- }
- if(i == lan_client_rt_from_lan_info_count_v6)
- {
- IPACMERR("The client is not found.\n");
- return IPACM_FAILURE;
- }
- }
- else
- {
- for(i=0; i<lan_client_rt_from_wlan_info_count_v6; i++)
- {
- if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)
- {
- position = i;
- IPACMDBG_H("The client is found at position %d.\n", position);
- break;
- }
- }
- if(i == lan_client_rt_from_wlan_info_count_v6)
- {
- IPACMERR("The client is not found.\n");
- return IPACM_FAILURE;
- }
- }
-
- for(i=0; i<each_client_rt_rule_count_v6; i++)
- {
- if(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v6)->rt_rule_hdl[i], IPA_IP_v6) == false)
- {
- IPACMERR("Failed to delete routing rule %d.\n", i);
- return IPACM_FAILURE;
- }
- }
-
- if(src == SRC_LAN)
- {
- for(i=position+1; i<lan_client_rt_from_lan_info_count_v6; i++)
- {
- memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);
- }
- memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);
- lan_client_rt_from_lan_info_count_v6--;
- IPACMDBG_H("Now the number of IPv6 rt rule from lan info is %d.\n", lan_client_rt_from_lan_info_count_v6);
- }
- else
- {
- for(i=position+1; i<lan_client_rt_from_wlan_info_count_v6; i++)
- {
- memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);
- }
- memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);
- lan_client_rt_from_wlan_info_count_v6--;
- IPACMDBG_H("Now the number of IPv6 rt rule from wlan info is %d.\n", lan_client_rt_from_wlan_info_count_v6);
- }
-
- return IPACM_SUCCESS;
-}
-
-eth_bridge_client_rt_info* IPACM_Lan::eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype)
-{
- void* result;
-
- if(src == SRC_LAN)
- {
- if(iptype == IPA_IP_v4)
- {
- result = (void*)((void*)eth_bridge_lan_client_rt_from_lan_info_v4 + index * client_rt_info_size_v4);
- }
- else
- {
- result = (void*)((void*)eth_bridge_lan_client_rt_from_lan_info_v6 + index * client_rt_info_size_v6);
- }
- }
- else
- {
- if(iptype == IPA_IP_v4)
- {
- result = (void*)((void*)eth_bridge_lan_client_rt_from_wlan_info_v4 + index * client_rt_info_size_v4);
- }
- else
- {
- result = (void*)((void*)eth_bridge_lan_client_rt_from_wlan_info_v6 + index * client_rt_info_size_v6);
- }
- }
- return (eth_bridge_client_rt_info*)result;
-}
-
-
-void IPACM_Lan::eth_bridge_add_lan_client(uint8_t* mac)
-{
- if(IPACM_Lan::num_lan_client == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
- {
- IPACMDBG_H("USB client table is already full.\n");
- return;
- }
-
- if(mac == NULL)
- {
- IPACMERR("Mac address is empty.\n");
- return;
- }
-
- int i;
- for(i=0; i<IPACM_Lan::num_lan_client; i++)
- {
- if(memcmp(IPACM_Lan::eth_bridge_lan_client[i].mac, mac, sizeof(IPACM_Lan::eth_bridge_lan_client[i].mac)) == 0)
- {
- IPACMDBG_H("The lan client mac has been added before at position %d.\n", i);
- return;
- }
- }
-
- memcpy(IPACM_Lan::eth_bridge_lan_client[IPACM_Lan::num_lan_client].mac, mac, sizeof(IPACM_Lan::eth_bridge_lan_client[IPACM_Lan::num_lan_client].mac));
- IPACM_Lan::eth_bridge_lan_client[IPACM_Lan::num_lan_client].ipa_if_num = ipa_if_num;
- IPACM_Lan::num_lan_client++;
- IPACMDBG_H("Now total num of lan clients is %d\n", IPACM_Lan::num_lan_client);
- return;
-}
-
-void IPACM_Lan::eth_bridge_del_lan_client(uint8_t* mac)
-{
- if(mac == NULL)
- {
- IPACMERR("Mac address is empty.\n");
- return;
- }
-
- int i, j;
- for(i=0; i<IPACM_Lan::num_lan_client; i++)
- {
- if(memcmp(IPACM_Lan::eth_bridge_lan_client[i].mac, mac, sizeof(IPACM_Lan::eth_bridge_lan_client[i].mac)) == 0)
- {
- IPACMDBG_H("Found LAN client at position %d.\n", i);
- break;
- }
- }
-
- if(i == IPACM_Lan::num_lan_client)
- {
- IPACMDBG_H("Not finding the LAN client.\n");
- return;
- }
-
- for(j=i+1; j<IPACM_Lan::num_lan_client; j++)
- {
- memcpy(IPACM_Lan::eth_bridge_lan_client[j-1].mac, IPACM_Lan::eth_bridge_lan_client[j].mac, sizeof(IPACM_Lan::eth_bridge_lan_client[j].mac));
- IPACM_Lan::eth_bridge_lan_client[j-1].ipa_if_num = IPACM_Lan::eth_bridge_lan_client[j].ipa_if_num;
- }
- IPACM_Lan::num_lan_client--;
- IPACMDBG_H("Now total num of lan clients is %d\n", IPACM_Lan::num_lan_client);
- return;
-}
-
int IPACM_Lan::eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl)
{
if(hdr_hdl == NULL)
@@ -6843,120 +3610,6 @@ int IPACM_Lan::eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl)
return IPACM_SUCCESS;
}
-int IPACM_Lan::del_hdr_proc_ctx()
-{
- if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == true)
- {
- if((IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF)
- || (IPACM_Lan::is_usb_up == false && IPACM_Lan::is_cpe_up == false))
- {
- if(m_header.DeleteHeaderProcCtx(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.proc_ctx_hdl) == false)
- {
- IPACMERR("Failed to delete usb to wlan hdr proc ctx.\n");
- return IPACM_FAILURE;
- }
- IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid = false;
-
- ipacm_cmd_q_data evt_data;
- memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
- ipacm_event_data_if_cat* cat;
- cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
- if(cat == NULL)
- {
- IPACMERR("Unable to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(cat, 0, sizeof(ipacm_event_data_if_cat));
- cat->if_cat = IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat;
-
- evt_data.evt_data = cat;
- evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT;
- IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT\n");
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- }
- }
-
- if(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)
- {
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF || IPACM_Lan::is_usb_up == false)
- {
- if(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl) == false)
- {
- IPACMERR("Failed to delete wlan to usb hdr proc ctx.\n");
- return IPACM_FAILURE;
- }
- IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid = false;
- }
- }
-
- if(IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == true)
- {
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF || IPACM_Lan::is_cpe_up == false)
- {
- if(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.proc_ctx_hdl) == false)
- {
- IPACMERR("Failed to delete wlan to cpe hdr proc ctx.\n");
- return IPACM_FAILURE;
- }
- IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid = false;
- }
- }
-
- if(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == WLAN_IF)
- {
- if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
- {
- if(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl) == false)
- {
- IPACMERR("Failed to delete wlan to wlan hdr proc ctx.\n");
- return IPACM_FAILURE;
- }
- IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid = false;
- }
- }
-
- if(IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == true && IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == true)
- {
- if((IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == LAN_IF)
- || (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat == ODU_IF))
- {
- if(m_header.DeleteHeaderProcCtx(IPACM_Lan::cpe_to_usb_hdr_proc_ctx.proc_ctx_hdl) == false)
- {
- IPACMERR("Failed to delete cpe to usb hdr proc ctx.\n");
- return IPACM_FAILURE;
- }
- IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid = false;
-
- if(m_header.DeleteHeaderProcCtx(IPACM_Lan::usb_to_cpe_hdr_proc_ctx.proc_ctx_hdl) == false)
- {
- IPACMERR("Failed to delete usb to cpe hdr proc ctx.\n");
- return IPACM_FAILURE;
- }
- IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid = false;
-
- ipacm_cmd_q_data evt_data;
- memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
- ipacm_event_data_if_cat* cat;
- cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
- if(cat == NULL)
- {
- IPACMERR("Unable to allocate memory.\n");
- return IPACM_FAILURE;
- }
- memset(cat, 0, sizeof(ipacm_event_data_if_cat));
- cat->if_cat = IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].if_cat;
-
- evt_data.evt_data = cat;
- evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT;
- IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT\n");
- IPACM_EvtDispatcher::PostEvt(&evt_data);
- }
- }
- return IPACM_SUCCESS;
-}
-
int IPACM_Lan::handle_cradle_wan_mode_switch(bool is_wan_bridge_mode)
{
struct ipa_flt_rule_mdfy flt_rule_entry;
@@ -7204,3 +3857,365 @@ int IPACM_Lan::handle_tethering_client(bool reset, ipacm_client_enum ipa_client)
close(fd_wwan_ioctl);
return ret;
}
+
+/* mac address has to be provided for client related events */
+void IPACM_Lan::eth_bridge_post_event(ipa_cm_event_id evt, ipa_ip_type iptype, uint8_t *mac)
+{
+ ipacm_cmd_q_data eth_bridge_evt;
+ ipacm_event_eth_bridge *evt_data;
+
+ evt_data = (ipacm_event_eth_bridge*)malloc(sizeof(ipacm_event_eth_bridge));
+ if(evt_data == NULL)
+ {
+ IPACMERR("Failed to allocate memory.\n");
+ return;
+ }
+ memset(evt_data, 0, sizeof(ipacm_event_eth_bridge));
+
+ evt_data->p_iface = this;
+ evt_data->iptype = iptype;
+ if(mac)
+ {
+ IPACMDBG_H("Client mac: 0x%02x%02x%02x%02x%02x%02x \n",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ memcpy(evt_data->mac_addr, mac, sizeof(evt_data->mac_addr));
+ }
+
+ memset(&eth_bridge_evt, 0, sizeof(ipacm_cmd_q_data));
+ eth_bridge_evt.evt_data = (void*)evt_data;
+ eth_bridge_evt.event = evt;
+
+ IPACMDBG_H("Posting event %s\n",
+ IPACM_Iface::ipacmcfg->getEventName(evt));
+ IPACM_EvtDispatcher::PostEvt(&eth_bridge_evt);
+}
+
+/* add header processing context and return handle to lan2lan controller */
+int IPACM_Lan::eth_bridge_add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_hdr_type, uint32_t *hdl)
+{
+ int len, res = IPACM_SUCCESS;
+ uint32_t hdr_template;
+ ipa_ioc_add_hdr_proc_ctx* pHeaderProcTable = NULL;
+
+ len = sizeof(struct ipa_ioc_add_hdr_proc_ctx) + sizeof(struct ipa_hdr_proc_ctx_add);
+ pHeaderProcTable = (ipa_ioc_add_hdr_proc_ctx*)malloc(len);
+ if(pHeaderProcTable == NULL)
+ {
+ IPACMERR("Cannot allocate header processing context table.\n");
+ return IPACM_FAILURE;
+ }
+
+ memset(pHeaderProcTable, 0, len);
+ pHeaderProcTable->commit = 1;
+ pHeaderProcTable->num_proc_ctxs = 1;
+ pHeaderProcTable->proc_ctx[0].type = eth_bridge_get_hdr_proc_type(peer_l2_hdr_type, tx_prop->tx[0].hdr_l2_type);
+ eth_bridge_get_hdr_template_hdl(&hdr_template);
+ pHeaderProcTable->proc_ctx[0].hdr_hdl = hdr_template;
+ if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
+ {
+ IPACMERR("Adding hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
+ res = IPACM_FAILURE;
+ goto end;
+ }
+
+ *hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
+
+end:
+ free(pHeaderProcTable);
+ return res;
+}
+
+/* add routing rule and return handle to lan2lan controller */
+int IPACM_Lan::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)
+{
+ int i, len, res = IPACM_SUCCESS;
+ struct ipa_ioc_add_rt_rule* rt_rule_table = NULL;
+ struct ipa_rt_rule_add rt_rule;
+ int position, num_rt_rule;
+
+ IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ num_rt_rule = each_client_rt_rule_count[iptype];
+
+ len = sizeof(ipa_ioc_add_rt_rule) + num_rt_rule * sizeof(ipa_rt_rule_add);
+ rt_rule_table = (ipa_ioc_add_rt_rule*)malloc(len);
+ if (rt_rule_table == NULL)
+ {
+ IPACMERR("Failed to allocate memory.\n");
+ return IPACM_FAILURE;
+ }
+ memset(rt_rule_table, 0, len);
+
+ rt_rule_table->commit = 1;
+ rt_rule_table->ip = iptype;
+ rt_rule_table->num_rules = num_rt_rule;
+ strlcpy(rt_rule_table->rt_tbl_name, rt_tbl_name, sizeof(rt_rule_table->rt_tbl_name));
+ rt_rule_table->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = 0;
+
+ memset(&rt_rule, 0, sizeof(ipa_rt_rule_add));
+ rt_rule.at_rear = false;
+ rt_rule.status = -1;
+ rt_rule.rt_rule_hdl = -1;
+#ifdef FEATURE_IPA_V3
+ rt_rule.rule.hashable = true;
+#endif
+ rt_rule.rule.hdr_hdl = 0;
+ rt_rule.rule.hdr_proc_ctx_hdl = hdr_proc_ctx_hdl;
+
+ position = 0;
+ for(i=0; i<iface_query->num_tx_props; i++)
+ {
+ if(tx_prop->tx[i].ip == iptype)
+ {
+ if(position >= num_rt_rule || position >= MAX_NUM_PROP)
+ {
+ IPACMERR("Number of routing rules already exceeds limit.\n");
+ res = IPACM_FAILURE;
+ goto end;
+ }
+
+ if(ipa_if_cate == WLAN_IF && IPACM_Iface::ipacmcfg->isMCC_Mode)
+ {
+ IPACMDBG_H("In WLAN MCC mode, use alt dst pipe: %d\n",
+ tx_prop->tx[i].alt_dst_pipe);
+ rt_rule.rule.dst = tx_prop->tx[i].alt_dst_pipe;
+ }
+ else
+ {
+ IPACMDBG_H("It is not WLAN MCC mode, use dst pipe: %d\n",
+ tx_prop->tx[i].dst_pipe);
+ rt_rule.rule.dst = tx_prop->tx[i].dst_pipe;
+ }
+
+ memcpy(&rt_rule.rule.attrib, &tx_prop->tx[i].attrib, sizeof(rt_rule.rule.attrib));
+ if(peer_l2_hdr_type == IPA_HDR_L2_ETHERNET_II)
+ rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
+ else
+ rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
+ memcpy(rt_rule.rule.attrib.dst_mac_addr, mac, sizeof(rt_rule.rule.attrib.dst_mac_addr));
+ memset(rt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(rt_rule.rule.attrib.dst_mac_addr_mask));
+
+ memcpy(&(rt_rule_table->rules[position]), &rt_rule, sizeof(rt_rule_table->rules[position]));
+ position++;
+ }
+ }
+ if(false == m_routing.AddRoutingRule(rt_rule_table))
+ {
+ IPACMERR("Routing rule addition failed!\n");
+ res = IPACM_FAILURE;
+ goto end;
+ }
+ else
+ {
+ *rt_rule_count = position;
+ for(i=0; i<position; i++)
+ rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
+ }
+
+end:
+ free(rt_rule_table);
+ return res;
+}
+
+/* modify routing rule*/
+int IPACM_Lan::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)
+{
+ struct ipa_ioc_mdfy_rt_rule *rt_rule = NULL;
+ struct ipa_rt_rule_mdfy *rt_rule_entry;
+ int len, index, res = IPACM_SUCCESS;
+
+ if(tx_prop == NULL)
+ {
+ IPACMDBG_H("No tx properties \n");
+ return IPACM_FAILURE;
+ }
+
+ if(ipa_if_cate != WLAN_IF)
+ {
+ IPACMDBG_H("This is not WLAN IF, no need to modify rt rule.\n");
+ return IPACM_SUCCESS;
+ }
+
+ IPACMDBG_H("Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\n",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ len = sizeof(struct ipa_ioc_mdfy_rt_rule) + rt_rule_count * sizeof(struct ipa_rt_rule_mdfy);
+ rt_rule = (struct ipa_ioc_mdfy_rt_rule *)malloc(len);
+ if(rt_rule == NULL)
+ {
+ IPACMERR("Unable to allocate memory for modify rt rule\n");
+ return IPACM_FAILURE;
+ }
+ memset(rt_rule, 0, len);
+
+ rt_rule->commit = 1;
+ rt_rule->num_rules = 0;
+ rt_rule->ip = iptype;
+
+ for (index = 0; index < tx_prop->num_tx_props; index++)
+ {
+ if (tx_prop->tx[index].ip == iptype)
+ {
+ if (rt_rule->num_rules >= rt_rule_count)
+ {
+ IPACMERR("Number of routing rules exceeds limit.\n");
+ res = IPACM_FAILURE;
+ goto end;
+ }
+
+ rt_rule_entry = &rt_rule->rules[rt_rule->num_rules];
+
+ if (IPACM_Iface::ipacmcfg->isMCC_Mode)
+ {
+ IPACMDBG_H("In WLAN MCC mode, use alt dst pipe: %d\n",
+ tx_prop->tx[index].alt_dst_pipe);
+ rt_rule_entry->rule.dst = tx_prop->tx[index].alt_dst_pipe;
+ }
+ else
+ {
+ IPACMDBG_H("In WLAN SCC mode, use dst pipe: %d\n",
+ tx_prop->tx[index].dst_pipe);
+ rt_rule_entry->rule.dst = tx_prop->tx[index].dst_pipe;
+ }
+
+ rt_rule_entry->rule.hdr_hdl = 0;
+ rt_rule_entry->rule.hdr_proc_ctx_hdl = hdr_proc_ctx_hdl;
+#ifdef FEATURE_IPA_V3
+ rt_rule_entry->rule.hashable = true;
+#endif
+ memcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[index].attrib,
+ sizeof(rt_rule_entry->rule.attrib));
+ if(peer_l2_hdr_type == IPA_HDR_L2_ETHERNET_II)
+ rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
+ else
+ rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
+ memcpy(rt_rule_entry->rule.attrib.dst_mac_addr, mac,
+ sizeof(rt_rule_entry->rule.attrib.dst_mac_addr));
+ memset(rt_rule_entry->rule.attrib.dst_mac_addr_mask, 0xFF,
+ sizeof(rt_rule_entry->rule.attrib.dst_mac_addr_mask));
+
+ rt_rule_entry->rt_rule_hdl = rt_rule_hdl[rt_rule->num_rules];
+ rt_rule->num_rules++;
+ }
+ }
+
+ if(m_routing.ModifyRoutingRule(rt_rule) == false)
+ {
+ IPACMERR("Failed to modify routing rules.\n");
+ res = IPACM_FAILURE;
+ goto end;
+ }
+ if(m_routing.Commit(iptype) == false)
+ {
+ IPACMERR("Failed to commit routing rules.\n");
+ res = IPACM_FAILURE;
+ goto end;
+ }
+ IPACMDBG("Modified routing rules successfully.\n");
+
+end:
+ free(rt_rule);
+ return res;
+}
+
+int IPACM_Lan::eth_bridge_add_flt_rule(uint8_t *mac, uint32_t rt_tbl_hdl, ipa_ip_type iptype, uint32_t *flt_rule_hdl)
+{
+ int len, res = IPACM_SUCCESS;
+ struct ipa_flt_rule_add flt_rule_entry;
+ struct ipa_ioc_add_flt_rule_after *pFilteringTable = NULL;
+
+#ifdef FEATURE_IPA_V3
+ if (rx_prop == NULL || tx_prop == NULL)
+ {
+ IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name);
+ return IPACM_FAILURE;
+ }
+
+ IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add);
+ pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len);
+ if (!pFilteringTable)
+ {
+ IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n");
+ return IPACM_FAILURE;
+ }
+ memset(pFilteringTable, 0, len);
+
+ /* add mac based rule*/
+ pFilteringTable->commit = 1;
+ pFilteringTable->ep = rx_prop->rx[0].src_pipe;
+ pFilteringTable->ip = iptype;
+ pFilteringTable->num_rules = 1;
+ pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[iptype];
+
+ memset(&flt_rule_entry, 0, sizeof(flt_rule_entry));
+ flt_rule_entry.at_rear = 1;
+
+ flt_rule_entry.rule.retain_hdr = 0;
+ flt_rule_entry.rule.to_uc = 0;
+ flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
+ flt_rule_entry.rule.eq_attrib_type = 0;
+ flt_rule_entry.rule.rt_tbl_hdl = rt_tbl_hdl;
+
+ memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
+ if(tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_ETHERNET_II)
+ {
+ flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
+ }
+ else
+ {
+ flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
+ }
+
+ memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr));
+ memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask));
+
+ memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry));
+ if (false == m_filtering.AddFilteringRuleAfter(pFilteringTable))
+ {
+ IPACMERR("Failed to add client filtering rules.\n");
+ res = IPACM_FAILURE;
+ goto end;
+ }
+ *flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl;
+
+end:
+ free(pFilteringTable);
+#endif
+ return res;
+}
+
+int IPACM_Lan::eth_bridge_del_flt_rule(uint32_t flt_rule_hdl, ipa_ip_type iptype)
+{
+ if(m_filtering.DeleteFilteringHdls(&flt_rule_hdl, iptype, 1) == false)
+ {
+ IPACMERR("Failed to delete the client specific flt rule.\n");
+ return IPACM_FAILURE;
+ }
+ return IPACM_SUCCESS;
+}
+
+int IPACM_Lan::eth_bridge_del_rt_rule(uint32_t rt_rule_hdl, ipa_ip_type iptype)
+{
+ if(m_routing.DeleteRoutingHdl(rt_rule_hdl, iptype) == false)
+ {
+ IPACMERR("Failed to delete routing rule.\n");
+ return IPACM_FAILURE;
+ }
+ return IPACM_SUCCESS;
+}
+
+/* delete header processing context */
+int IPACM_Lan::eth_bridge_del_hdr_proc_ctx(uint32_t hdr_proc_ctx_hdl)
+{
+ if(m_header.DeleteHeaderProcCtx(hdr_proc_ctx_hdl) == false)
+ {
+ IPACMERR("Failed to delete hdr proc ctx.\n");
+ return IPACM_FAILURE;
+ }
+ return IPACM_SUCCESS;
+}