Merge "IPACM: add flt rule counter on each prod client"
diff --git a/ipacm/inc/IPACM_Defs.h b/ipacm/inc/IPACM_Defs.h
index 72c348c..37f3ff4 100644
--- a/ipacm/inc/IPACM_Defs.h
+++ b/ipacm/inc/IPACM_Defs.h
@@ -278,6 +278,7 @@
{
enum ipa_ip_type iptype;
int if_index;
+ uint32_t ipv4_addr_gw;
uint32_t ipv4_addr;
uint32_t ipv4_addr_mask;
uint32_t ipv6_addr[4];
diff --git a/ipacm/inc/IPACM_Wan.h b/ipacm/inc/IPACM_Wan.h
index 96bb0e6..5160ac3 100644
--- a/ipacm/inc/IPACM_Wan.h
+++ b/ipacm/inc/IPACM_Wan.h
@@ -134,7 +134,9 @@
uint32_t ODU_fl_hdl[IPA_NUM_DEFAULT_WAN_FILTER_RULES];
int num_firewall_v4,num_firewall_v6;
uint32_t wan_v4_addr;
+ uint32_t wan_v4_addr_gw;
bool wan_v4_addr_set;
+ bool wan_v4_addr_gw_set;
bool active_v4;
bool active_v6;
bool header_set_v4;
@@ -204,6 +206,39 @@
return IPACM_INVALID_INDEX;
}
+ inline int get_wan_client_index_ipv4(uint32_t ipv4_addr)
+ {
+ int cnt;
+ int num_wan_client_tmp = num_wan_client;
+
+ IPACMDBG_H("Passed IPv4 %x\n", ipv4_addr);
+
+ for(cnt = 0; cnt < num_wan_client_tmp; cnt++)
+ {
+ if (get_client_memptr(wan_client, cnt)->ipv4_set)
+ {
+ IPACMDBG_H("stored IPv4 %x\n", get_client_memptr(wan_client, cnt)->v4_addr);
+
+ if(ipv4_addr == get_client_memptr(wan_client, cnt)->v4_addr)
+ {
+ IPACMDBG_H("Matched client index: %d\n", cnt);
+ IPACMDBG_H("The MAC is %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(wan_client, cnt)->mac[0],
+ get_client_memptr(wan_client, cnt)->mac[1],
+ get_client_memptr(wan_client, cnt)->mac[2],
+ get_client_memptr(wan_client, cnt)->mac[3],
+ get_client_memptr(wan_client, cnt)->mac[4],
+ get_client_memptr(wan_client, cnt)->mac[5]);
+ IPACMDBG_H("header set ipv4(%d) ipv6(%d)\n",
+ get_client_memptr(wan_client, cnt)->ipv4_header_set,
+ get_client_memptr(wan_client, cnt)->ipv6_header_set);
+ return cnt;
+ }
+ }
+ }
+ return IPACM_INVALID_INDEX;
+ }
+
inline int delete_wan_rtrules(int clt_indx, ipa_ip_type iptype)
{
uint32_t tx_index;
@@ -279,8 +314,8 @@
/* wan default route/filter rule configuration */
int handle_route_add_evt(ipa_ip_type iptype);
- /* construct complete ethernet header */
- int handle_header_add_evt(uint8_t *mac_addr);
+ /* construct complete STA ethernet header */
+ int handle_sta_header_add_evt();
int config_dft_firewall_rules(ipa_ip_type iptype);
diff --git a/ipacm/inc/IPACM_Wlan.h b/ipacm/inc/IPACM_Wlan.h
index 37584e2..fb5555a 100644
--- a/ipacm/inc/IPACM_Wlan.h
+++ b/ipacm/inc/IPACM_Wlan.h
@@ -322,6 +322,11 @@
int handle_wlan_client_reset_rt(ipa_ip_type iptype);
void handle_SCC_MCC_switch(ipa_ip_type);
+
+ void eth_bridge_handle_wlan_SCC_MCC_switch(ipa_ip_type iptype);
+
+ int eth_bridge_modify_wlan_rt_rule(uint8_t* mac, eth_bridge_src_iface src_iface, ipa_ip_type iptyp);
+
};
diff --git a/ipacm/src/Android.mk b/ipacm/src/Android.mk
index d80be81..fcf65d3 100644
--- a/ipacm/src/Android.mk
+++ b/ipacm/src/Android.mk
@@ -54,7 +54,7 @@
IPACM_Log.cpp
LOCAL_MODULE := ipacm
-LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libipanat
LOCAL_SHARED_LIBRARIES += libxml2
diff --git a/ipacm/src/IPACM_Main.cpp b/ipacm/src/IPACM_Main.cpp
index 0aef584..3cc58e1 100644
--- a/ipacm/src/IPACM_Main.cpp
+++ b/ipacm/src/IPACM_Main.cpp
@@ -611,16 +611,22 @@
case WLAN_SWITCH_TO_SCC:
IPACMDBG_H("Received WLAN_SWITCH_TO_SCC\n");
- IPACM_Iface::ipacmcfg->isMCC_Mode = false;
- evt_data.event = IPA_WLAN_SWITCH_TO_SCC;
- break;
-
+ if (IPACM_Iface::ipacmcfg->isMCC_Mode == true)
+ {
+ IPACM_Iface::ipacmcfg->isMCC_Mode = false;
+ evt_data.event = IPA_WLAN_SWITCH_TO_SCC;
+ break;
+ }
+ continue;
case WLAN_SWITCH_TO_MCC:
IPACMDBG_H("Received WLAN_SWITCH_TO_MCC\n");
- IPACM_Iface::ipacmcfg->isMCC_Mode = true;
- evt_data.event = IPA_WLAN_SWITCH_TO_MCC;
- break;
-
+ if (IPACM_Iface::ipacmcfg->isMCC_Mode == false)
+ {
+ IPACM_Iface::ipacmcfg->isMCC_Mode == true;
+ evt_data.event = IPA_WLAN_SWITCH_TO_MCC;
+ break;
+ }
+ continue;
default:
IPACMDBG_H("Unhandled message type: %d\n", event_hdr.msg_type);
continue;
diff --git a/ipacm/src/IPACM_Netlink.cpp b/ipacm/src/IPACM_Netlink.cpp
index 9db578c..13b1d6e 100644
--- a/ipacm/src/IPACM_Netlink.cpp
+++ b/ipacm/src/IPACM_Netlink.cpp
@@ -610,7 +610,7 @@
int ret_val, mask_value, mask_index, mask_value_v6;
struct nlmsghdr *nlh = (struct nlmsghdr *)buffer;
- uint32_t if_ipv4_addr =0, if_ipipv4_addr_mask =0, temp =0;
+ uint32_t if_ipv4_addr =0, if_ipipv4_addr_mask =0, temp =0, if_ipv4_addr_gw =0;
ipacm_cmd_q_data evt_data;
ipacm_event_data_all *data_all;
@@ -996,17 +996,20 @@
IPACM_EVENT_COPY_ADDR_v4( if_ipv4_addr, msg_ptr->nl_route_info.attr_info.dst_addr);
IPACM_EVENT_COPY_ADDR_v4( if_ipipv4_addr_mask, msg_ptr->nl_route_info.attr_info.dst_addr);
+ IPACM_EVENT_COPY_ADDR_v4( if_ipv4_addr_gw, msg_ptr->nl_route_info.attr_info.gateway_addr);
evt_data.event = IPA_ROUTE_ADD_EVENT;
data_addr->if_index = msg_ptr->nl_route_info.attr_info.oif_index;
data_addr->iptype = IPA_IP_v4;
data_addr->ipv4_addr = ntohl(if_ipv4_addr);
+ data_addr->ipv4_addr_gw = ntohl(if_ipv4_addr_gw);
data_addr->ipv4_addr_mask = ntohl(if_ipipv4_addr_mask);
- IPACMDBG_H("Posting IPA_ROUTE_ADD_EVENT with if index:%d, ipv4 addr:0x%x and maxk: 0x%x\n",
+ IPACMDBG_H("Posting IPA_ROUTE_ADD_EVENT with if index:%d, ipv4 addr:0x%x, mask: 0x%x and gw: 0x%x\n",
data_addr->if_index,
data_addr->ipv4_addr,
- data_addr->ipv4_addr_mask);
+ data_addr->ipv4_addr_mask,
+ data_addr->ipv4_addr_gw);
evt_data.evt_data = data_addr;
IPACM_EvtDispatcher::PostEvt(&evt_data);
/* finish command queue */
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 57c6537..3527f13 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -91,6 +91,7 @@
m_is_sta_mode = is_sta_mode;
wan_v4_addr_set = false;
+ wan_v4_addr_gw_set = false;
active_v4 = false;
active_v6 = false;
header_set_v4 = false;
@@ -672,8 +673,11 @@
/* The special below condition is to handle default gateway */
if ((data->iptype == IPA_IP_v4) && (active_v4 == false) && (ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX))
{
- IPACMDBG_H("adding routing table(upstream), dev (%s) ip-type(%d)\n", dev_name,data->iptype);
+// wan_v4_addr_gw = data->ipv4_addr_gw; /* android requires CnE change too */
+// wan_v4_addr_gw_set = true;
+ IPACMDBG_H("adding routing table, dev (%s) ip-type(%d), default gw (%x)\n", dev_name,data->iptype, wan_v4_addr_gw);
handle_route_add_evt(data->iptype);
+
}
else if ((data->iptype == IPA_IP_v6) && (active_v6 == false) && (ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX))
{
@@ -687,6 +691,7 @@
{
IPACMDBG_H("Received v4 IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT for other iface (%s)\n", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name);
IPACMDBG_H("need clean default v4 route (dst:0.0.0.0) for old iface (%s)\n", dev_name);
+// wan_v4_addr_gw_set = false; /* android requires CnE change too */
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
@@ -728,6 +733,8 @@
IPACMDBG_H("Received IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT\n");
if ((data->iptype == IPA_IP_v4) && (active_v4 == true))
{
+ IPACMDBG_H("get del default v4 route (dst:0.0.0.0)\n");
+// wan_v4_addr_gw_set = false; /* android requires CnE change too */
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
@@ -772,7 +779,11 @@
if ((data->iptype == IPA_IP_v4) && (!data->ipv4_addr) && (!data->ipv4_addr_mask) && (active_v4 == false)
&& (ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX))
{
- IPACMDBG_H("adding routing table, dev (%s) ip-type(%d)\n", dev_name,data->iptype);
+ wan_v4_addr_gw = data->ipv4_addr_gw;
+ wan_v4_addr_gw_set = true;
+ IPACMDBG_H("adding routing table, dev (%s) ip-type(%d), default gw (%x)\n", dev_name,data->iptype, wan_v4_addr_gw);
+ /* Check & construct STA header */
+ handle_sta_header_add_evt();
handle_route_add_evt(data->iptype);
}
else if ((data->iptype == IPA_IP_v6) &&
@@ -793,6 +804,7 @@
IPACMDBG_H("ipv4 addr 0x%x\n", data->ipv4_addr);
IPACMDBG_H("ipv4 addr mask 0x%x\n", data->ipv4_addr_mask);
IPACMDBG_H("need clean default v4 route (dst:0.0.0.0) for old iface (%s)\n", dev_name);
+ wan_v4_addr_gw_set = false;
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
@@ -835,6 +847,7 @@
if ((data->iptype == IPA_IP_v4) && (!data->ipv4_addr) && (!data->ipv4_addr_mask) && (active_v4 == true))
{
IPACMDBG_H("get del default v4 route (dst:0.0.0.0)\n");
+ wan_v4_addr_gw_set = false;
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
@@ -878,7 +891,6 @@
if (m_is_sta_mode == WLAN_WAN)
{
- handle_header_add_evt(ext_router_mac_addr);
if (data->iptype == IPA_IP_v4 && data->ipv4_addr == wan_v4_addr)
{
IPACMDBG_H("Ignore IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT in STA mode\n");
@@ -914,18 +926,17 @@
return;
}
- handle_header_add_evt(data->mac_addr);
-
handle_wan_hdr_init(data->mac_addr);
- IPACMDBG_H("construct wan header and route rules \n");
+ IPACMDBG_H("construct wan-client header and route rules \n");
/* Associate with IP and construct RT-rule */
if (handle_wan_client_ipaddr(data) == IPACM_FAILURE)
{
return;
}
handle_wan_client_route_rule(data->mac_addr, data->iptype);
+ /* Check & construct STA header */
+ handle_sta_header_add_evt();
return;
-
}
}
break;
@@ -1133,7 +1144,7 @@
return IPACM_FAILURE;
}
}
-
+#if 0
for (cnt=0; cnt<tx_prop->num_tx_props; cnt++)
{
if(tx_prop->tx[cnt].ip==iptype)
@@ -1179,6 +1190,7 @@
}
}
}
+#endif
rt_rule = (struct ipa_ioc_add_rt_rule *)
calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
@@ -1211,29 +1223,16 @@
continue;
}
+ /* use the STA-header handler */
if (iptype == IPA_IP_v4)
{
strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.name);
+ rt_rule_entry->rule.hdr_hdl = hdr_hdl_sta_v4;
}
else
{
strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_v6.name);
- }
-
- if (tx_prop->tx[tx_index].hdr_name != NULL)
- {
- IPACMDBG_H(" TX- header hdl %s \n", tx_prop->tx[tx_index].hdr_name);
- memset(&sRetHeader, 0, sizeof(sRetHeader));
- strncpy(sRetHeader.name,
- tx_prop->tx[tx_index].hdr_name,
- sizeof(tx_prop->tx[tx_index].hdr_name));
- if (false == m_header.GetHeaderHandle(&sRetHeader))
- {
- IPACMERR("\n ioctl failed\n");
- free(rt_rule);
- return IPACM_FAILURE;
- }
- rt_rule_entry->rule.hdr_hdl = sRetHeader.hdl;
+ rt_rule_entry->rule.hdr_hdl = hdr_hdl_sta_v6;
}
if(IPACM_Iface::ipacmcfg->isMCC_Mode == true)
@@ -1422,217 +1421,58 @@
}
/* construct complete ethernet header */
-int IPACM_Wan::handle_header_add_evt(uint8_t *mac_addr)
+int IPACM_Wan::handle_sta_header_add_evt()
{
- #define WAN_IFACE_INDEX_LEN 2
-
- uint32_t tx_index,cnt;
- int res = IPACM_SUCCESS, len = 0;
- char index[WAN_IFACE_INDEX_LEN];
- struct ipa_ioc_copy_hdr sCopyHeader;
- struct ipa_ioc_add_hdr *pHeaderDescriptor = NULL;
-
- /* start of adding header */
-
- IPACMDBG_H("Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
- mac_addr[0], mac_addr[1], mac_addr[2],
- mac_addr[3], mac_addr[4], mac_addr[5]);
-
+ int res = IPACM_SUCCESS, index = IPACM_INVALID_INDEX;
if((header_set_v4 == true) || (header_set_v6 == true))
{
IPACMDBG_H("Already add STA full header\n");
return IPACM_SUCCESS;
}
- /* add header to IPA */
- len = sizeof(struct ipa_ioc_add_hdr) + (1 * sizeof(struct ipa_hdr_add));
- pHeaderDescriptor = (struct ipa_ioc_add_hdr *)calloc(1, len);
- if (pHeaderDescriptor == NULL)
+
+ /* checking if the ipv4 same as default route */
+ if(wan_v4_addr_gw_set)
{
- IPACMERR("calloc failed to allocate pHeaderDescriptor\n");
- return IPACM_FAILURE;
- }
-
- /* copy partial header for v4 */
- for (cnt=0; cnt<tx_prop->num_tx_props; cnt++)
- {
- if(tx_prop->tx[cnt].ip==IPA_IP_v4)
- {
- memset(&sCopyHeader, 0, sizeof(sCopyHeader));
- memcpy(sCopyHeader.name,
- tx_prop->tx[cnt].hdr_name,
- sizeof(sCopyHeader.name));
-
- IPACMDBG_H("header name: %s from tx: %d\n", sCopyHeader.name,cnt);
- if (m_header.CopyHeader(&sCopyHeader) == false)
- {
- IPACMERR("ioctl copy header failed");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- if(sCopyHeader.is_eth2_ofst_valid == false)
- {
- eth2_ofst_v4 = 0;
- }
- else
- {
- eth2_ofst_v4 = sCopyHeader.eth2_ofst;
- }
-
- 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(pHeaderDescriptor->hdr[0].hdr,
- sCopyHeader.hdr,
- sCopyHeader.hdr_len);
- }
-
- /* copy client mac_addr to partial header */
- memcpy(&pHeaderDescriptor->hdr[0].hdr[eth2_ofst_v4], mac_addr,
- IPA_MAC_ADDR_SIZE); /* only copy 6 bytes mac-address */
-
- pHeaderDescriptor->commit = true;
- pHeaderDescriptor->num_hdrs = 1;
-
- memset(pHeaderDescriptor->hdr[0].name, 0,
- sizeof(pHeaderDescriptor->hdr[0].name));
-
- snprintf(index,sizeof(index), "%d", ipa_if_num);
- strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
- if ( strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v4, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
- {
- IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeaderDescriptor->hdr[0].name));
- res = IPACM_FAILURE;
- goto fail;
- }
-
- pHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;
- pHeaderDescriptor->hdr[0].hdr_hdl = -1;
- pHeaderDescriptor->hdr[0].is_partial = 0;
- pHeaderDescriptor->hdr[0].status = -1;
-
- if (m_header.AddHeader(pHeaderDescriptor) == false ||
- pHeaderDescriptor->hdr[0].status != 0)
- {
- IPACMERR("ioctl IPA_IOC_ADD_HDR failed: %d\n", pHeaderDescriptor->hdr[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- hdr_hdl_sta_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;
- header_set_v4 = true;
- IPACMDBG_H("add full header name: %s (%x)\n", pHeaderDescriptor->hdr[0].name, pHeaderDescriptor->hdr[0].hdr_hdl);
- }
-
- /* copy ipv4 full header to each TX endpoint property*/
- for (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
- {
- if(tx_prop->tx[tx_index].ip==IPA_IP_v4)
- {
- memcpy(tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].name,
- sizeof(tx_prop->tx[tx_index].hdr_name));
- IPACMDBG_H("replace full header name: %s (%x) in tx:%d\n", tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].hdr_hdl,tx_index);
- }
- }
- break;
- }
- }
-
- /* copy partial header for v6 */
- for (cnt=0; cnt<tx_prop->num_tx_props; cnt++)
- {
- if(tx_prop->tx[cnt].ip == IPA_IP_v6)
- {
- IPACMDBG_H("Got partial v6-header name from %d tx props\n", cnt);
- memset(&sCopyHeader, 0, sizeof(sCopyHeader));
- memcpy(sCopyHeader.name,
- tx_prop->tx[cnt].hdr_name,
- sizeof(sCopyHeader.name));
-
- IPACMDBG_H("header name: %s from tx: %d\n", sCopyHeader.name,cnt);
- if (m_header.CopyHeader(&sCopyHeader) == false)
+ index = get_wan_client_index_ipv4(wan_v4_addr_gw);
+ if (index != IPACM_INVALID_INDEX)
+ {
+ IPACMDBG_H("Matched client index: %d\n", index);
+ IPACMDBG_H("Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(wan_client, index)->mac[0],
+ get_client_memptr(wan_client, index)->mac[1],
+ get_client_memptr(wan_client, index)->mac[2],
+ get_client_memptr(wan_client, index)->mac[3],
+ get_client_memptr(wan_client, index)->mac[4],
+ get_client_memptr(wan_client, index)->mac[5]);
+ if(get_client_memptr(wan_client, index)->ipv4_header_set)
{
- IPACMERR("ioctl copy header failed");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- if(sCopyHeader.is_eth2_ofst_valid == false)
- {
- eth2_ofst_v6 = 0;
+ hdr_hdl_sta_v4 = get_client_memptr(wan_client, index)->hdr_hdl_v4;
+ header_set_v4 = true;
+ IPACMDBG_H("add full ipv4 header hdl: (%x)\n", get_client_memptr(wan_client, index)->hdr_hdl_v4);
}
else
{
- eth2_ofst_v6 = sCopyHeader.eth2_ofst;
+ IPACMERR(" wan-client got ipv4 however didn't construct complete ipv4 header \n");
+ return IPACM_FAILURE;
}
- 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(pHeaderDescriptor->hdr[0].hdr,
- sCopyHeader.hdr,
- sCopyHeader.hdr_len);
- }
- /* copy client mac_addr to partial header */
- memcpy(&pHeaderDescriptor->hdr[0].hdr[eth2_ofst_v6], mac_addr,
- IPA_MAC_ADDR_SIZE); /* only copy 6 bytes mac-address */
- pHeaderDescriptor->commit = true;
- pHeaderDescriptor->num_hdrs = 1;
-
- memset(pHeaderDescriptor->hdr[0].name, 0,
- sizeof(pHeaderDescriptor->hdr[0].name));
-
- snprintf(index,sizeof(index), "%d", ipa_if_num);
- strlcpy(pHeaderDescriptor->hdr[0].name, index, sizeof(pHeaderDescriptor->hdr[0].name));
- if (strlcat(pHeaderDescriptor->hdr[0].name, IPA_WAN_PARTIAL_HDR_NAME_v6, sizeof(pHeaderDescriptor->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
- {
- IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeaderDescriptor->hdr[0].name));
- res = IPACM_FAILURE;
- goto fail;
- }
- pHeaderDescriptor->hdr[0].hdr_len = sCopyHeader.hdr_len;
- pHeaderDescriptor->hdr[0].hdr_hdl = -1;
- pHeaderDescriptor->hdr[0].is_partial = 0;
- pHeaderDescriptor->hdr[0].status = -1;
-
- if (m_header.AddHeader(pHeaderDescriptor) == false ||
- pHeaderDescriptor->hdr[0].status != 0)
- {
- IPACMERR("ioctl IPA_IOC_ADD_HDR failed: %d\n", pHeaderDescriptor->hdr[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
- else
- {
- header_set_v6 = true;
- hdr_hdl_sta_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;
- IPACMDBG_H("add full header name: %s (%x)\n", pHeaderDescriptor->hdr[0].name, pHeaderDescriptor->hdr[0].hdr_hdl);
- }
- /* copy ipv6 full header to each TX endpoint property*/
- for (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
- {
- if(tx_prop->tx[tx_index].ip==IPA_IP_v6)
- {
- memcpy(tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].name,
- sizeof(tx_prop->tx[tx_index].hdr_name));
- IPACMDBG_H("replace full header name: %s (%x) in tx:%d\n", tx_prop->tx[tx_index].hdr_name, pHeaderDescriptor->hdr[0].hdr_hdl,tx_index);
- }
- }
- break;
- }
+ if(get_client_memptr(wan_client, index)->ipv6_header_set)
+ {
+ hdr_hdl_sta_v6 = get_client_memptr(wan_client, index)->hdr_hdl_v6;
+ header_set_v6 = true;
+ IPACMDBG_H("add full ipv6 header hdl: (%x)\n", get_client_memptr(wan_client, index)->hdr_hdl_v6);
+ }
+ else
+ {
+ IPACMERR(" wan-client got ipv6 however didn't construct complete ipv6 header \n");
+ return IPACM_FAILURE;
+ }
+ }
+ else
+ {
+ IPACMDBG_H(" currently can't find matched wan-client's MAC-addr, waiting for header construction\n");
+ return IPACM_SUCCESS;
+ }
}
/* see if default routes are setup before constructing full header */
@@ -1645,10 +1485,6 @@
{
handle_route_add_evt(IPA_IP_v6);
}
-
-fail:
- free(pHeaderDescriptor);
-
return res;
}
@@ -2901,7 +2737,7 @@
if(iptype == IPA_IP_v4)
{
- if(modem_ipv4_pdn_index == 0) //install ipv4 default modem DL filtering rules only once
+ if(modem_ipv4_pdn_index == 0) /* install ipv4 default modem DL filtering rules only once */
{
/* reset the num_v4_flt_rule*/
IPACM_Wan::num_v4_flt_rule = 0;
@@ -2910,7 +2746,7 @@
}
else if(iptype == IPA_IP_v6)
{
- if(modem_ipv6_pdn_index == 0) //install ipv6 default modem DL filtering rules only once
+ if(modem_ipv6_pdn_index == 0) /* install ipv6 default modem DL filtering rules only once */
{
/* reset the num_v6_flt_rule*/
IPACM_Wan::num_v6_flt_rule = 0;
@@ -3572,7 +3408,7 @@
uint32_t tx_index;
ipacm_cmd_q_data evt_data;
- IPACMDBG_H("got handle_route_del_evt with ip-family:%d \n", iptype);
+ IPACMDBG_H("got handle_route_del_evt for STA-mode with ip-family:%d \n", iptype);
if(tx_prop == NULL)
{
@@ -4081,24 +3917,6 @@
IPACMDBG_H("finished delete default v6 filtering rules\n ");
}
- /* delete the complete header for STA mode*/
- if((header_set_v4 == true) || (header_set_v6 == true))
- {
- if (m_header.DeleteHeaderHdl(hdr_hdl_sta_v4) == false)
- {
- IPACMERR("ErrorDeleting STA header for v4, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- if (m_header.DeleteHeaderHdl(hdr_hdl_sta_v6) == false)
- {
- IPACMERR("ErrorDeleting STA header for v6, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
-
fail:
if (tx_prop != NULL)
{
@@ -4284,24 +4102,6 @@
handle_software_routing_disable();
}
- /* delete the complete header for STA mode*/
- if((header_set_v4 == true) || (header_set_v6 == true))
- {
- if (m_header.DeleteHeaderHdl(hdr_hdl_sta_v4) == false)
- {
- IPACMERR("ErrorDeleting STA header for v4, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
-
- if (m_header.DeleteHeaderHdl(hdr_hdl_sta_v6) == false)
- {
- IPACMERR("ErrorDeleting STA header for v6, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
-
fail:
if (tx_prop != NULL)
{
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index 2bd0333..27e27f6 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -754,10 +754,13 @@
{
handle_SCC_MCC_switch(IPA_IP_v4);
handle_SCC_MCC_switch(IPA_IP_v6);
+ eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v4);
+ eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v6);
}
else
{
handle_SCC_MCC_switch(ip_type);
+ eth_bridge_handle_wlan_SCC_MCC_switch(ip_type);
}
break;
@@ -767,10 +770,13 @@
{
handle_SCC_MCC_switch(IPA_IP_v4);
handle_SCC_MCC_switch(IPA_IP_v6);
+ eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v4);
+ eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v6);
}
else
{
handle_SCC_MCC_switch(ip_type);
+ eth_bridge_handle_wlan_SCC_MCC_switch(ip_type);
}
break;
@@ -4325,8 +4331,18 @@
res = IPACM_FAILURE;
goto fail;
}
+ /* Handle MCC Mode case */
+ if (IPACM_Iface::ipacmcfg->isMCC_Mode == true)
+ {
+ IPACMDBG_H("In 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
+ {
+ rt_rule.rule.dst = 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(src == SRC_WLAN) //src is WLAN means packet is from WLAN
{
@@ -4863,3 +4879,257 @@
}
return;
}
+
+void IPACM_Wlan::eth_bridge_handle_wlan_SCC_MCC_switch(ipa_ip_type iptype)
+{
+
+ for (int i= 0; i < IPACM_Lan::num_wlan_client; i++)
+ {
+ if (IPACM_Lan::eth_bridge_wlan_client[i].ipa_if_num == ipa_if_num)
+ {
+ if (IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
+ {
+ if (eth_bridge_modify_wlan_rt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, SRC_WLAN, iptype) == IPACM_FAILURE)
+ {
+ IPACMDBG_H("SCC/MCC switch is failed for iptype: %d src_iface: %d \n", iptype, SRC_WLAN);
+ return;
+ }
+ }
+ if (IPACM_Lan::usb_to_wlan_hdr_proc_ctx.valid == true)
+ {
+ if (eth_bridge_modify_wlan_rt_rule(IPACM_Lan::eth_bridge_wlan_client[i].mac, SRC_USB, iptype) == IPACM_FAILURE)
+ {
+ IPACMDBG_H("SCC/MCC switch is failed for iptype: %d src_iface: %d \n", iptype, SRC_USB);
+ return;
+ }
+ }
+ }
+ }
+
+ IPACMDBG_H("SCC/MCC switch is successful for iptype: %d\n", iptype);
+}
+
+int IPACM_Wlan::eth_bridge_modify_wlan_rt_rule(uint8_t* mac, eth_bridge_src_iface src_iface, ipa_ip_type iptype)
+{
+ struct ipa_ioc_mdfy_rt_rule *rt_rule = NULL;
+ struct ipa_rt_rule_mdfy *rt_rule_entry;
+ uint32_t index = 0, num_rt_rule = 0, position;
+
+ if (tx_prop == NULL)
+ {
+ IPACMDBG_H("No tx properties \n");
+ return IPACM_FAILURE;
+ }
+
+ if (mac == NULL)
+ {
+ IPACMERR("Client MAC address is empty.\n");
+ return IPACM_FAILURE;
+ }
+
+ 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]);
+
+ if (iptype == IPA_IP_v4)
+ {
+ num_rt_rule = each_client_rt_rule_count_v4;
+ }
+ else
+ {
+ num_rt_rule = each_client_rt_rule_count_v6;
+ }
+
+ if (src_iface == SRC_WLAN)
+ {
+ if (iptype == IPA_IP_v4)
+ {
+ for (index = 0; index < wlan_client_rt_from_wlan_info_count_v4; index++)
+ {
+ if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac, mac,
+ sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac)) == 0)
+ {
+ position = index;
+ IPACMDBG_H("The client is found at position %d.\n", position);
+ break;
+ }
+ }
+ if (index == wlan_client_rt_from_wlan_info_count_v4)
+ {
+ IPACMERR("The client is not found.\n");
+ return IPACM_FAILURE;
+ }
+ }
+ else
+ {
+ for (index =0 ; index < wlan_client_rt_from_wlan_info_count_v6; index++)
+ {
+ if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac, mac,
+ sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac)) == 0)
+ {
+ position = index;
+ IPACMDBG_H("The client is found at position %d.\n", position);
+ break;
+ }
+ }
+ if (index == wlan_client_rt_from_wlan_info_count_v6)
+ {
+ IPACMERR("The client is not found.\n");
+ return IPACM_FAILURE;
+ }
+ }
+ }
+ else
+ {
+ if (iptype == IPA_IP_v4)
+ {
+ for (index = 0; index < wlan_client_rt_from_usb_info_count_v4; index++)
+ {
+ if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac, mac,
+ sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac)) == 0)
+ {
+ position = index;
+ IPACMDBG_H("The client is found at position %d.\n", position);
+ break;
+ }
+ }
+ if (index == wlan_client_rt_from_usb_info_count_v4)
+ {
+ IPACMERR("The client is not found.\n");
+ return IPACM_FAILURE;
+ }
+ }
+ else
+ {
+ for (index = 0; index < wlan_client_rt_from_usb_info_count_v6; index++)
+ {
+ if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac, mac,
+ sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac)) == 0)
+ {
+ position = index;
+ IPACMDBG_H("The client is found at position %d.\n", position);
+ break;
+ }
+ }
+ if (index == wlan_client_rt_from_usb_info_count_v6)
+ {
+ IPACMERR("The client is not found.\n");
+ return IPACM_FAILURE;
+ }
+ }
+ }
+
+ rt_rule = (struct ipa_ioc_mdfy_rt_rule *)
+ calloc(1, sizeof(struct ipa_ioc_mdfy_rt_rule) +
+ (num_rt_rule) * sizeof(struct ipa_rt_rule_mdfy));
+
+ if (rt_rule == NULL)
+ {
+ IPACMERR("Unable to allocate memory for modify rt rule\n");
+ return IPACM_FAILURE;
+ }
+ IPACMDBG("Allocated memory for %d rules successfully\n", num_rt_rule);
+
+ 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 >= num_rt_rule)
+ {
+ IPACMERR("Number of routing rules exceeds limit.\n");
+ free(rt_rule);
+ return IPACM_FAILURE;
+ }
+
+ rt_rule_entry = &rt_rule->rules[rt_rule->num_rules];
+
+ if (IPACM_Iface::ipacmcfg->isMCC_Mode)
+ {
+ IPACMDBG_H("In 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
+ {
+ rt_rule_entry->rule.dst = tx_prop->tx[index].dst_pipe;
+ }
+
+ rt_rule_entry->rule.hdr_hdl = 0;
+
+ if (src_iface == SRC_WLAN)
+ {
+ rt_rule_entry->rule.hdr_proc_ctx_hdl =
+ IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl;
+ }
+ else
+ {
+ rt_rule_entry->rule.hdr_proc_ctx_hdl =
+ IPACM_Lan::usb_to_wlan_hdr_proc_ctx.proc_ctx_hdl;
+ }
+
+ memcpy(&rt_rule_entry->rule.attrib,
+ &tx_prop->tx[index].attrib,
+ sizeof(rt_rule_entry->rule.attrib));
+
+ if (src_iface == SRC_WLAN) //src is WLAN means packet is from WLAN
+ {
+ if (IPACM_Lan::wlan_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;
+ }
+ }
+ else //packet is from USB
+ {
+ if (IPACM_Lan::usb_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 =
+ eth_bridge_get_client_rt_info_ptr(position, src_iface, iptype)->rt_rule_hdl[rt_rule->num_rules];
+ IPACMDBG_H("tx:%d, rt rule hdl=%x ip-type: %d\n", index,
+ eth_bridge_get_client_rt_info_ptr(position, src_iface, iptype)->rt_rule_hdl[rt_rule->num_rules], iptype);
+
+ rt_rule->num_rules++;
+ }
+ }
+
+ if (rt_rule->num_rules > 0)
+ {
+ if (false == m_routing.ModifyRoutingRule(rt_rule))
+ {
+ IPACMERR("Routing rule modify failed!\n");
+ free(rt_rule);
+ return IPACM_FAILURE;
+ }
+ if (false == m_routing.Commit(iptype))
+ {
+ IPACMERR("Routing rule modify commit failed!\n");
+ free(rt_rule);
+ return IPACM_FAILURE;
+ }
+ IPACMDBG("Routing rule modified successfully \n");
+ }
+
+ if (rt_rule)
+ {
+ free(rt_rule);
+ }
+ return IPACM_SUCCESS;
+}
diff --git a/ipanat/src/Android.mk b/ipanat/src/Android.mk
index a1116df..a97b6ce 100644
--- a/ipanat/src/Android.mk
+++ b/ipanat/src/Android.mk
@@ -15,7 +15,7 @@
LOCAL_CFLAGS := -DDEBUG
LOCAL_MODULE := libipanat
-LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)