Merge "IPACM: fix ipv6 ecm-backhaul issue"
diff --git a/ipacm/inc/IPACM_CmdQueue.h b/ipacm/inc/IPACM_CmdQueue.h
index 4eb4be7..2f7709a 100644
--- a/ipacm/inc/IPACM_CmdQueue.h
+++ b/ipacm/inc/IPACM_CmdQueue.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -39,13 +39,12 @@
#ifndef IPA_CONNTRACK_MESSAGE_H
#define IPA_CONNTRACK_MESSAGE_H
-#include <iostream>
#include <pthread.h>
#include "IPACM_Defs.h"
-/*---------------------------------------------------------------------------
+/*---------------------------------------------------------------------------
Event data required by IPA_CM
---------------------------------------------------------------------------*/
diff --git a/ipacm/inc/IPACM_ConntrackClient.h b/ipacm/inc/IPACM_ConntrackClient.h
index ef0a2ca..ea956da 100644
--- a/ipacm/inc/IPACM_ConntrackClient.h
+++ b/ipacm/inc/IPACM_ConntrackClient.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,6 @@
#ifndef IPACM_CONNTRACK_FILTER_H
#define IPACM_CONNTRACK_FILTER_H
-#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/ipacm/inc/IPACM_ConntrackListener.h b/ipacm/inc/IPACM_ConntrackListener.h
index fc7282c..e5827f2 100644
--- a/ipacm/inc/IPACM_ConntrackListener.h
+++ b/ipacm/inc/IPACM_ConntrackListener.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,6 @@
#ifndef IPACM_CONNTRACK_LISTENER
#define IPACM_CONNTRACK_LISTENER
-#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -68,7 +67,7 @@
#ifdef CT_OPT
IPACM_LanToLan *p_lan2lan;
#endif
-
+
void ProcessCTMessage(void *);
void ProcessTCPorUDPMsg(struct nf_conntrack *,
enum nf_conntrack_msg_type, u_int8_t);
diff --git a/ipacm/inc/IPACM_LanToLan.h b/ipacm/inc/IPACM_LanToLan.h
index 480f76c..570db14 100644
--- a/ipacm/inc/IPACM_LanToLan.h
+++ b/ipacm/inc/IPACM_LanToLan.h
@@ -39,11 +39,16 @@
#include <stdint.h>
#include "linux/msm_ipa.h"
-#include <list>
-#include <unordered_map>
#include "IPACM_Iface.h"
#include "IPACM_Defs.h"
#include "IPACM_Lan.h"
+#include <unordered_map>
+
+#ifdef FEATURE_IPA_ANDROID
+#include <libxml/list.h>
+#else/* defined(FEATURE_IPA_ANDROID) */
+#include <list>
+#endif /* ndefined(FEATURE_IPA_ANDROID)*/
struct client_info;
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
index d3d84dc..7f169c5 100644
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -52,7 +52,7 @@
alg_table = NULL;
memset(&ipa_client_rm_map_tbl, 0, sizeof(ipa_client_rm_map_tbl));
memset(&ipa_rm_tbl, 0, sizeof(ipa_rm_tbl));
- ipa_rm_a2_check=0;
+ ipa_rm_a2_check=0;
ipa_num_ipa_interfaces = 0;
ipa_num_private_subnet = 0;
@@ -90,16 +90,15 @@
uint32_t subnet_addr;
uint32_t subnet_mask;
int i, ret = IPACM_SUCCESS;
+ struct in_addr in_addr_print;
m_fd = open(DEVICE_NAME, O_RDWR);
- if (0 > m_fd)
- {
- IPACMERR("Failed opening %s.\n", DEVICE_NAME);
- }
-
+ if (0 > m_fd)
+ {
+ IPACMERR("Failed opening %s.\n", DEVICE_NAME);
+ }
strncpy(IPACM_config_file, "/etc/IPACM_cfg.xml", sizeof(IPACM_config_file));
-
IPACMDBG("\n IPACM XML file is %s \n", IPACM_config_file);
if (IPACM_SUCCESS == ipacm_read_cfg_xml(IPACM_config_file, cfg))
{
@@ -121,7 +120,7 @@
IPACMDBG("RESET IPACM_Config::iface_table\n");
}
iface_table = (ipa_ifi_dev_name_t *)calloc(ipa_num_ipa_interfaces,
- sizeof(ipa_ifi_dev_name_t));
+ sizeof(ipa_ifi_dev_name_t));
if(iface_table == NULL)
{
IPACMERR("Unable to allocate iface_table memory.\n");
@@ -157,12 +156,14 @@
sizeof(cfg->private_subnet_config.private_subnet_entries[i].subnet_mask));
subnet_addr = htonl(private_subnet_table[i].subnet_addr);
- IPACMDBG("%dst::private_subnet_table= %s \n ", i+1,
- inet_ntoa(*(struct in_addr *)&(subnet_addr)));
+ memcpy(&in_addr_print,&subnet_addr,sizeof(in_addr_print));
+ IPACMDBG("%dst::private_subnet_table= %s \n ", i,
+ inet_ntoa(in_addr_print));
subnet_mask = htonl(private_subnet_table[i].subnet_mask);
- IPACMDBG("%dst::private_subnet_mask= %s \n ", i+1,
- inet_ntoa(*(struct in_addr *)&(subnet_mask)));
+ memcpy(&in_addr_print,&subnet_mask,sizeof(in_addr_print));
+ IPACMDBG("%dst::private_subnet_table= %s \n ", i,
+ inet_ntoa(in_addr_print));
}
/* Construct IPACM ALG table */
@@ -174,7 +175,7 @@
IPACMDBG("RESET IPACM_Config::alg_table \n");
}
alg_table = (ipacm_alg *)calloc(ipa_num_alg_ports,
- sizeof(ipacm_alg));
+ sizeof(ipacm_alg));
if(alg_table == NULL)
{
IPACMERR("Unable to allocate alg_table memory.\n");
@@ -218,7 +219,7 @@
rt_tbl_wan_v4.ip = IPA_IP_v4;
strncpy(rt_tbl_wan_v4.name, V4_WAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_v4.name));
-
+
rt_tbl_v6.ip = IPA_IP_v6;
strncpy(rt_tbl_v6.name, V6_COMMON_ROUTE_TABLE_NAME, sizeof(rt_tbl_v6.name));
@@ -250,12 +251,12 @@
ipa_client_rm_map_tbl[IPA_CLIENT_A2_TETHERED_CONS]= IPA_RM_RESOURCE_Q6_CONS;
ipa_client_rm_map_tbl[IPA_CLIENT_APPS_WAN_CONS]= IPA_RM_RESOURCE_Q6_CONS;
- /* Create the entries which IPACM wants to add dependencies on */
+ /* Create the entries which IPACM wants to add dependencies on */
ipa_rm_tbl[0].producer_rm1 = IPA_RM_RESOURCE_WLAN_PROD;
ipa_rm_tbl[0].consumer_rm1 = IPA_RM_RESOURCE_Q6_CONS;
ipa_rm_tbl[0].producer_rm2 = IPA_RM_RESOURCE_Q6_PROD;
ipa_rm_tbl[0].consumer_rm2 = IPA_RM_RESOURCE_WLAN_CONS;
-
+
ipa_rm_tbl[1].producer_rm1 = IPA_RM_RESOURCE_USB_PROD;
ipa_rm_tbl[1].consumer_rm1 = IPA_RM_RESOURCE_Q6_CONS;
ipa_rm_tbl[1].producer_rm2 = IPA_RM_RESOURCE_Q6_PROD;
@@ -265,7 +266,7 @@
ipa_rm_tbl[2].consumer_rm1 = IPA_RM_RESOURCE_USB_CONS;
ipa_rm_tbl[2].producer_rm2 = IPA_RM_RESOURCE_USB_PROD;
ipa_rm_tbl[2].consumer_rm2 = IPA_RM_RESOURCE_WLAN_CONS;
-
+
fail:
if (cfg != NULL)
{
@@ -323,8 +324,8 @@
for (int cnt=0; cnt<nIfaces; cnt++)
{
- memcpy(pIfaces[cnt].iface_name,
- pNatIfaces[cnt].iface_name,
+ memcpy(pIfaces[cnt].iface_name,
+ pNatIfaces[cnt].iface_name,
sizeof(pIfaces[cnt].iface_name));
}
@@ -334,7 +335,7 @@
int IPACM_Config::AddNatIfaces(char *dev_name)
{
- IPACMDBG("Add iface %s to NAT-ifaces, origin it has %d nat ifaces\n",
+ IPACMDBG("Add iface %s to NAT-ifaces, origin it has %d nat ifaces\n",
dev_name, ipa_nat_iface_entries);
ipa_nat_iface_entries++;
@@ -344,10 +345,10 @@
dev_name, IPA_IFACE_NAME_LEN);
IPACMDBG("Add Nat IfaceName: %s ,update nat-ifaces number: %d\n",
- pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
+ pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
ipa_nat_iface_entries);
}
-
+
return 0;
}
@@ -391,107 +392,104 @@
also indicate that endpoint property if valid */
void IPACM_Config::AddRmDepend(ipa_rm_resource_name rm1,bool rx_bypass_ipa)
{
- int retval = 0;
- struct ipa_ioc_rm_dependency dep;
+ int retval = 0;
+ struct ipa_ioc_rm_dependency dep;
- /* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/
- if(rm1 == IPA_RM_RESOURCE_Q6_CONS)
- {
- ipa_rm_a2_check+=1;
- IPACMDBG("got %d times default RT routing from A2 \n", ipa_rm_a2_check);
- }
-
- for(int i=0;i<IPA_MAX_PRIVATE_SUBNET_ENTRIES;i++)
- {
- if(rm1 == ipa_rm_tbl[i].producer_rm1)
- {
- ipa_rm_tbl[i].producer1_up = true;
-
- /* entry1's producer actually dun have registered Rx-property */
- ipa_rm_tbl[i].rx_bypass_ipa = rx_bypass_ipa;
- IPACMDBG("Matched RM_table entry: %d's producer_rm1 with non_rx_prop: %d \n", i,ipa_rm_tbl[i].rx_bypass_ipa);
-
- if(ipa_rm_tbl[i].consumer1_up == true && ipa_rm_tbl[i].rm_set == false)
- {
- IPACMDBG("SETUP RM_table entry %d's bi-direction dependency \n", i);
- /* add bi-directional dependency*/
- if(ipa_rm_tbl[i].rx_bypass_ipa)
- {
- IPACMDBG("Skip ADD entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
- }
- else
- {
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm1;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
- retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
- IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- }
-
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm2;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
- retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
- IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- ipa_rm_tbl[i].rm_set = true;
- }
- else
- {
- IPACMDBG("Not SETUP RM_table entry %d: prod_up:%d, cons_up:%d, rm_set: %d \n", i,ipa_rm_tbl[i].producer1_up, ipa_rm_tbl[i].consumer1_up, ipa_rm_tbl[i].rm_set);
- }
+ /* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/
+ if(rm1 == IPA_RM_RESOURCE_Q6_CONS)
+ {
+ ipa_rm_a2_check+=1;
+ IPACMDBG("got %d times default RT routing from A2 \n", ipa_rm_a2_check);
+ }
+
+ for(int i=0;i<IPA_MAX_PRIVATE_SUBNET_ENTRIES;i++)
+ {
+ if(rm1 == ipa_rm_tbl[i].producer_rm1)
+ {
+ ipa_rm_tbl[i].producer1_up = true;
+ /* entry1's producer actually dun have registered Rx-property */
+ ipa_rm_tbl[i].rx_bypass_ipa = rx_bypass_ipa;
+ IPACMDBG("Matched RM_table entry: %d's producer_rm1 with non_rx_prop: %d \n", i,ipa_rm_tbl[i].rx_bypass_ipa);
+
+ if(ipa_rm_tbl[i].consumer1_up == true && ipa_rm_tbl[i].rm_set == false)
+ {
+ IPACMDBG("SETUP RM_table entry %d's bi-direction dependency \n", i);
+ /* add bi-directional dependency*/
+ if(ipa_rm_tbl[i].rx_bypass_ipa)
+ {
+ IPACMDBG("Skip ADD entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
+ }
+ else
+ {
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm1;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
+ retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
+ IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ }
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm2;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
+ retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
+ IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ ipa_rm_tbl[i].rm_set = true;
+ }
+ else
+ {
+ IPACMDBG("Not SETUP RM_table entry %d: prod_up:%d, cons_up:%d, rm_set: %d \n", i,ipa_rm_tbl[i].producer1_up, ipa_rm_tbl[i].consumer1_up, ipa_rm_tbl[i].rm_set);
+ }
+ }
+
+ if(rm1 == ipa_rm_tbl[i].consumer_rm1)
+ {
+ ipa_rm_tbl[i].consumer1_up = true;
+ IPACMDBG("Matched RM_table entry: %d's consumer_rm1 \n", i);
+
+ if(ipa_rm_tbl[i].producer1_up == true && ipa_rm_tbl[i].rm_set == false)
+ {
+ IPACMDBG("SETUP RM_table entry %d's bi-direction dependency \n", i);
+ /* add bi-directional dependency*/
+ if(ipa_rm_tbl[i].rx_bypass_ipa)
+ {
+ IPACMDBG("Skip ADD entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
+ }
+ else
+ {
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm1;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
+ retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
+ IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ }
+
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm2;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
+ retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
+ IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ ipa_rm_tbl[i].rm_set = true;
+ }
+ else
+ {
+ IPACMDBG("Not SETUP RM_table entry %d: prod_up:%d, cons_up:%d, rm_set: %d \n", i,ipa_rm_tbl[i].producer1_up, ipa_rm_tbl[i].consumer1_up, ipa_rm_tbl[i].rm_set);
+ }
}
-
- if(rm1 == ipa_rm_tbl[i].consumer_rm1)
- {
- ipa_rm_tbl[i].consumer1_up = true;
- IPACMDBG("Matched RM_table entry: %d's consumer_rm1 \n", i);
-
- if(ipa_rm_tbl[i].producer1_up == true && ipa_rm_tbl[i].rm_set == false)
- {
- IPACMDBG("SETUP RM_table entry %d's bi-direction dependency \n", i);
- /* add bi-directional dependency*/
- if(ipa_rm_tbl[i].rx_bypass_ipa)
- {
- IPACMDBG("Skip ADD entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
- }
- else
- {
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm1;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
- retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
- IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- }
-
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm2;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
- retval = ioctl(m_fd, IPA_IOC_RM_ADD_DEPENDENCY, &dep);
- IPACMDBG("ADD entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed adding dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- ipa_rm_tbl[i].rm_set = true;
- }
- else
- {
- IPACMDBG("Not SETUP RM_table entry %d: prod_up:%d, cons_up:%d, rm_set: %d \n", i,ipa_rm_tbl[i].producer1_up, ipa_rm_tbl[i].consumer1_up, ipa_rm_tbl[i].rm_set);
- }
-
- }
}
return ;
}
@@ -501,104 +499,101 @@
void IPACM_Config::DelRmDepend(ipa_rm_resource_name rm1)
{
- int retval = 0;
- struct ipa_ioc_rm_dependency dep;
+ int retval = 0;
+ struct ipa_ioc_rm_dependency dep;
- /* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/
- if(rm1 == IPA_RM_RESOURCE_Q6_CONS)
- {
- ipa_rm_a2_check-=1;
- IPACMDBG("Left %d times default RT routing from A2 \n", ipa_rm_a2_check);
- }
-
- for(int i=0;i<IPA_MAX_PRIVATE_SUBNET_ENTRIES;i++)
- {
-
- if(rm1 == ipa_rm_tbl[i].producer_rm1)
- {
- if(ipa_rm_tbl[i].rm_set == true)
- {
- IPACMDBG("Matched RM_table entry: %d's producer_rm1 and dependency is up \n", i);
- ipa_rm_tbl[i].rm_set = false;
+ /* ipa_rm_a2_check: IPA_RM_RESOURCE_Q6_CONS*/
+ if(rm1 == IPA_RM_RESOURCE_Q6_CONS)
+ {
+ ipa_rm_a2_check-=1;
+ IPACMDBG("Left %d times default RT routing from A2 \n", ipa_rm_a2_check);
+ }
- /* delete bi-directional dependency*/
- if(ipa_rm_tbl[i].rx_bypass_ipa)
- {
- IPACMDBG("Skip DEL entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
- }
- else
- {
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm1;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
- retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
- IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- }
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm2;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
- retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
- IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- }
- ipa_rm_tbl[i].producer1_up = false;
- ipa_rm_tbl[i].rx_bypass_ipa = false;
- }
-
- if(rm1 == ipa_rm_tbl[i].consumer_rm1)
- {
-
- /* ipa_rm_a2_check: IPA_RM_RESOURCE_!6_CONS*/
- if(ipa_rm_tbl[i].consumer_rm1 == IPA_RM_RESOURCE_Q6_CONS && ipa_rm_a2_check == 1)
- {
- IPACMDBG(" still have %d default RT routing from A2 \n", ipa_rm_a2_check);
- continue;
- }
-
- if(ipa_rm_tbl[i].rm_set == true)
- {
- IPACMDBG("Matched RM_table entry: %d's consumer_rm1 and dependency is up \n", i);
- ipa_rm_tbl[i].rm_set = false;
-
- /* delete bi-directional dependency*/
- if(ipa_rm_tbl[i].rx_bypass_ipa)
- {
- IPACMDBG("Skip DEL entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
- }
- else
- {
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm1;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
- retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
- IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- }
-
- memset(&dep, 0, sizeof(dep));
- dep.resource_name = ipa_rm_tbl[i].producer_rm2;
- dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
- retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
- IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
- if (retval)
- {
- IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
- }
- }
- ipa_rm_tbl[i].consumer1_up = false;
- }
- }
- return ;
+ for(int i=0;i<IPA_MAX_PRIVATE_SUBNET_ENTRIES;i++)
+ {
+
+ if(rm1 == ipa_rm_tbl[i].producer_rm1)
+ {
+ if(ipa_rm_tbl[i].rm_set == true)
+ {
+ IPACMDBG("Matched RM_table entry: %d's producer_rm1 and dependency is up \n", i);
+ ipa_rm_tbl[i].rm_set = false;
+
+ /* delete bi-directional dependency*/
+ if(ipa_rm_tbl[i].rx_bypass_ipa)
+ {
+ IPACMDBG("Skip DEL entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
+ }
+ else
+ {
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm1;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
+ retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
+ IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ }
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm2;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
+ retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
+ IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ }
+ ipa_rm_tbl[i].producer1_up = false;
+ ipa_rm_tbl[i].rx_bypass_ipa = false;
+ }
+ if(rm1 == ipa_rm_tbl[i].consumer_rm1)
+ {
+ /* ipa_rm_a2_check: IPA_RM_RESOURCE_!6_CONS*/
+ if(ipa_rm_tbl[i].consumer_rm1 == IPA_RM_RESOURCE_Q6_CONS && ipa_rm_a2_check == 1)
+ {
+ IPACMDBG(" still have %d default RT routing from A2 \n", ipa_rm_a2_check);
+ continue;
+ }
+
+ if(ipa_rm_tbl[i].rm_set == true)
+ {
+ IPACMDBG("Matched RM_table entry: %d's consumer_rm1 and dependency is up \n", i);
+ ipa_rm_tbl[i].rm_set = false;
+ /* delete bi-directional dependency*/
+ if(ipa_rm_tbl[i].rx_bypass_ipa)
+ {
+ IPACMDBG("Skip DEL entry %d's dependency between WLAN-Pro: %d, Con: %d \n", i, ipa_rm_tbl[i].producer_rm1,ipa_rm_tbl[i].consumer_rm1);
+ }
+ else
+ {
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm1;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm1;
+ retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
+ IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ }
+
+ memset(&dep, 0, sizeof(dep));
+ dep.resource_name = ipa_rm_tbl[i].producer_rm2;
+ dep.depends_on_name = ipa_rm_tbl[i].consumer_rm2;
+ retval = ioctl(m_fd, IPA_IOC_RM_DEL_DEPENDENCY, &dep);
+ IPACMDBG("Delete entry %d's dependency between Pro: %d, Con: %d \n", i,dep.resource_name,dep.depends_on_name);
+ if (retval)
+ {
+ IPACMERR("Failed deleting dependecny for RM_table entry %d's bi-direction dependency (error:%d) \n", i,retval);
+ }
+ }
+ ipa_rm_tbl[i].consumer1_up = false;
+ }
+ }
+ return ;
}
int IPACM_Config::SetExtProp(ipa_ioc_query_intf_ext_props *prop)
@@ -665,8 +660,8 @@
{
memset(&ext_prop_v4, 0, sizeof(ext_prop_v4));
}
-
- if(ip_type != IPA_IP_v4)
+
+ if(ip_type != IPA_IP_v4)
{
memset(&ext_prop_v6, 0, sizeof(ext_prop_v6));
}
diff --git a/ipacm/src/IPACM_ConntrackClient.cpp b/ipacm/src/IPACM_ConntrackClient.cpp
index b820db3..448fa8f 100644
--- a/ipacm/src/IPACM_ConntrackClient.cpp
+++ b/ipacm/src/IPACM_ConntrackClient.cpp
@@ -1,4 +1,4 @@
-/*
+/*
Copyright (c) 2013, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -35,7 +35,7 @@
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <net/if.h>
-
+#include "IPACM_Iface.h"
#include "IPACM_ConntrackListener.h"
#include "IPACM_ConntrackClient.h"
#include "IPACM_Log.h"
@@ -171,14 +171,13 @@
)
{
int fd;
-
fd = socket(AF_INET, SOCK_DGRAM, 0);
if(fd < 0)
{
PERROR("unable to open socket");
return -1;
}
-
+
int ret;
uint32_t ipv4_addr;
struct ifreq ifr;
@@ -202,7 +201,7 @@
/* ignore whatever is destined to or originates from broadcast ip address */
struct nfct_filter_ipv4 filter_ipv4;
-
+
filter_ipv4.addr = ipv4_addr;
filter_ipv4.mask = 0xffffffff;
@@ -461,15 +460,15 @@
/* Register callback with netfilter handler */
IPACMDBG("tcp handle:%p, fd:%d\n", pClient->tcp_hdl, nfct_fd(pClient->tcp_hdl));
#ifndef CT_OPT
- nfct_callback_register(pClient->tcp_hdl,
- (NFCT_T_UPDATE | NFCT_T_DESTROY | NFCT_T_NEW),
+ nfct_callback_register(pClient->tcp_hdl,
+ (nf_conntrack_msg_type) (NFCT_T_UPDATE | NFCT_T_DESTROY | NFCT_T_NEW),
IPAConntrackEventCB, NULL);
#else
- nfct_callback_register(pClient->tcp_hdl, NFCT_T_ALL, IPAConntrackEventCB, NULL);
+ nfct_callback_register(pClient->tcp_hdl, (nf_conntrack_msg_type) NFCT_T_ALL, IPAConntrackEventCB, NULL);
#endif
/* Block to catch events from net filter connection track */
- /* nfct_catch() receives conntrack events from kernel-space, by default it
+ /* nfct_catch() receives conntrack events from kernel-space, by default it
blocks waiting for events. */
IPACMDBG("Waiting for events\n");
@@ -501,7 +500,7 @@
{
int ret;
IPACM_ConntrackClient *pClient = NULL;
-
+
IPACMDBG("\n");
pClient = IPACM_ConntrackClient::GetInstance();
@@ -566,8 +565,8 @@
nfct_callback_unregister(pClient->udp_hdl);
/* close the handle */
nfct_close(pClient->udp_hdl);
- pClient->udp_hdl = NULL;
-
+ pClient->udp_hdl = NULL;
+
pthread_exit(NULL);
return NULL;
}
@@ -696,7 +695,7 @@
{
fd = fopen(IPACM_TCP_FULL_FILE_NAME, "r");
}
- else
+ else
{
fd = fopen(IPACM_UDP_FULL_FILE_NAME, "r");
}
@@ -733,7 +732,7 @@
IPACMERR("unable to create nat instance\n");
return NULL;
}
-
+
to_fd = fopen(IPACM_TCP_FULL_FILE_NAME, "r");
if(to_fd == NULL)
{
@@ -746,7 +745,7 @@
IPACMDBG("ip conntrack tcp timeout initial value:%d\n", value);
nat_inst->UpdateTcpUdpTo(value, IPPROTO_TCP);
fclose(to_fd);
-
+
to_fd = fopen(IPACM_UDP_FULL_FILE_NAME, "r");
if(to_fd == NULL)
{
@@ -796,7 +795,7 @@
}
}
}
-
+
(void)inotify_rm_watch(inotify_fd, wd);
(void)close(inotify_fd);
return NULL;
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
index 0d53841..239d6f4 100644
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.cpp
@@ -361,23 +361,12 @@
IPACMDBG("created UDP conntrack event listner thread\n");
}
-
isCTReg = true;
}
return 0;
error:
- if(tcp_thread)
- {
- pthread_cancel(tcp_thread);
- }
-
- if(udp_thread)
- {
- pthread_cancel(tcp_thread);
- }
-
return -1;
}
int IPACM_ConntrackListener::CreateNatThreads(void)
@@ -419,16 +408,6 @@
return 0;
error:
- if(udpcto_thread)
- {
- pthread_cancel(udpcto_thread);
- }
-
- if(to_monitor_thread)
- {
- pthread_cancel(to_monitor_thread);
- }
-
return -1;
}
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
index 10bbcb6..6fb2e5c 100644
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -39,16 +39,19 @@
*/
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <ifaddrs.h>
-
#include <IPACM_Netlink.h>
#include <IPACM_Iface.h>
#include <IPACM_Lan.h>
#include <IPACM_Wan.h>
#include <IPACM_Wlan.h>
-#include <ifaddrs.h>
#include <string.h>
+extern "C"
+{
+#include <ifaddrs.h>
+}
+
+
const char *IPACM_Iface::DEVICE_NAME = "/dev/ipa";
IPACM_Routing IPACM_Iface::m_routing;
IPACM_Filtering IPACM_Iface::m_filtering;
diff --git a/ipacm/src/IPACM_IfaceManager.cpp b/ipacm/src/IPACM_IfaceManager.cpp
index e0e115b..811f7c9 100644
--- a/ipacm/src/IPACM_IfaceManager.cpp
+++ b/ipacm/src/IPACM_IfaceManager.cpp
@@ -73,7 +73,13 @@
break;
case IPA_LINK_UP_EVENT:
IPACMDBG("link up %d: \n", evt_data->if_index);
+ ipa_interface_index = IPACM_Iface::iface_ipa_index_query(evt_data->if_index);
+ /* LTE-backhaul */
+ if(IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].if_cat == WAN_IF)
+ {
+ IPACMDBG("WAN-LTE (%s) link up, iface: %d: \n", IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,evt_data->if_index);
create_iface_instance(evt_data->if_index, Q6_WAN);
+ }
break;
case IPA_USB_LINK_UP_EVENT:
@@ -161,10 +167,10 @@
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, lan);
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, lan);
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, lan);
- IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, lan);
- IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, lan);
IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, lan); // register for IPA_CFG_CHANGE event
IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, lan); // register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event
+ IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, lan);
+ IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, lan);
IPACMDBG("ipa_LAN (%s):ipa_index (%d) instance open/registr ok\n", lan->dev_name, lan->ipa_if_num);
registr(ipa_interface_index, lan);
/* solve the new_addr comes earlier issue */
@@ -206,9 +212,9 @@
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, wl);
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, wl);
IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, wl);
+ IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, wl); // register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event
IPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, wl);
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, wl);
- IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, wl); // register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event
IPACMDBG("ipa_WLAN (%s):ipa_index (%d) instance open/registr ok\n", wl->dev_name, wl->ipa_if_num);
registr(ipa_interface_index, wl);
/* solve the new_addr comes earlier issue */
@@ -227,9 +233,9 @@
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, w);
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, w);
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_DISABLE, w);
- IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, w);
- IPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, w); // for STA mode
IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, w); // register for IPA_CFG_CHANGE event
+ IPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, w); // for STA mode
+ IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, w);
IPACMDBG("ipa_WAN (%s):ipa_index (%d) instance open/registr ok\n", w->dev_name, w->ipa_if_num);
registr(ipa_interface_index, w);
/* solve the new_addr comes earlier issue */
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index 5d48d87..fa6d101 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -194,7 +194,7 @@
if(data_fid == NULL)
{
IPACMERR("unable to allocate memory for IPA_USB_LINK_UP_EVENT data_fid\n");
- return NULL;
+ return;
}
if(IPACM_Iface::ipa_get_if_index(dev_name, &(data_fid->if_index)))
{
@@ -304,6 +304,7 @@
info->ipv4_addr, info->addr_mask);
IPACM_EvtDispatcher::PostEvt(&evt_data);
}
+ IPACMDBG("Finish handling IPA_ADDR_ADD_EVENT for ip-family(%d)\n", data->iptype);
}
}
}
@@ -675,9 +676,10 @@
init_fl_rule(data->iptype);
}
num_dft_rt_v6++;
+ IPACMDBG("number of default route rules %d\n", num_dft_rt_v6);
}
- IPACMDBG("number of default route rules %d\n", num_dft_rt_v6);
+ IPACMDBG("finish route/filter rule ip-type: %d, res(%d)\n", data->iptype, res);
fail:
free(rt_rule);
@@ -773,6 +775,10 @@
}
free(m_pFilteringTable);
}
+ else
+ {
+ IPACMDBG("No private subnet rules for ipv6 iface %s\n", dev_name);
+ }
return IPACM_SUCCESS;
}
@@ -3273,6 +3279,11 @@
return 0;
}
+ if(iptype == IPA_IP_v6)
+ {
+ IPACMDBG("There is no ipv6 dummy filter rules needed for iface %s\n", dev_name);
+ return 0;
+ }
int i, len, res = IPACM_SUCCESS;
struct ipa_flt_rule_add flt_rule;
ipa_ioc_add_flt_rule* pFilteringTable;
@@ -3360,7 +3371,12 @@
return IPACM_SUCCESS;
}
- if (iptype == IPA_IP_v4)
+ if(iptype == IPA_IP_v6)
+ {
+ IPACMDBG("There is no ipv6 dummy filter rules needed for iface %s\n", dev_name);
+ return 0;
+ }
+ else
{
for(i=0; i<IPA_MAX_PRIVATE_SUBNET_ENTRIES; i++)
{
@@ -3407,6 +3423,7 @@
flt_rule.rule.attrib.u.v4.dst_addr_mask = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask;
flt_rule.rule.attrib.u.v4.dst_addr = IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr;
memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
+ IPACMDBG(" IPACM private subnet_addr as: 0x%x entry(%d)\n", flt_rule.rule.attrib.u.v4.dst_addr, i);
}
if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
diff --git a/ipacm/src/IPACM_LanToLan.cpp b/ipacm/src/IPACM_LanToLan.cpp
index 562c233..dcd7a08 100644
--- a/ipacm/src/IPACM_LanToLan.cpp
+++ b/ipacm/src/IPACM_LanToLan.cpp
@@ -51,7 +51,6 @@
num_offload_pair_v6_ = 0;
client_info_v4_.reserve(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT);
client_info_v6_.reserve(3*(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_USB_CLIENT));
-
p_instance = this;
IPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_ACTIVE, this);
diff --git a/ipacm/src/IPACM_Main.cpp b/ipacm/src/IPACM_Main.cpp
index 54d049b..e096eed 100644
--- a/ipacm/src/IPACM_Main.cpp
+++ b/ipacm/src/IPACM_Main.cpp
@@ -68,9 +68,14 @@
#include "IPACM_ConntrackListener.h"
#include "IPACM_ConntrackClient.h"
-#include "IPACM_LanToLan.h"
#include "IPACM_Netlink.h"
+/* not defined(FEATURE_IPA_ANDROID)*/
+#ifndef FEATURE_IPA_ANDROID
+#include "IPACM_LanToLan.h"
+#endif
+
+
const char *ipacm_event_name[] = {
__stringify(IPA_CFG_CHANGE_EVENT), /* 1 NULL */
__stringify(IPA_LINK_UP_EVENT), /* 2 ipacm_event_data_fid */
@@ -531,7 +536,7 @@
void IPACM_Sig_Handler(int sig)
{
- int cnt = 0;
+ int cnt;
printf("Received Signal: %d\n", sig);
@@ -579,7 +584,9 @@
IPACMDBG("In main()\n");
IPACM_Neighbor *neigh = new IPACM_Neighbor();
IPACM_IfaceManager *ifacemgr = new IPACM_IfaceManager();
+#ifndef FEATURE_IPA_ANDROID
IPACM_LanToLan* lan2lan = new IPACM_LanToLan();
+#endif /* defined(FEATURE_IPA_ANDROID)*/
IPACM_ConntrackClient *cc = IPACM_ConntrackClient::GetInstance();
CtList = new IPACM_ConntrackListener();
diff --git a/ipacm/src/IPACM_Netlink.cpp b/ipacm/src/IPACM_Netlink.cpp
index 114e6d6..d579952 100644
--- a/ipacm/src/IPACM_Netlink.cpp
+++ b/ipacm/src/IPACM_Netlink.cpp
@@ -265,7 +265,6 @@
if(msgh == NULL)
{
IPACMERR("Failed malloc for msghdr\n");
- free(msgh);
return NULL;
}
@@ -273,7 +272,6 @@
if(nladdr == NULL)
{
IPACMERR("Failed malloc for sockaddr\n");
- free(nladdr);
free(msgh);
return NULL;
}
@@ -282,7 +280,6 @@
if(iov == NULL)
{
PERROR("Failed malloc for iovec");
- free(iov);
free(nladdr);
free(msgh);
return NULL;
@@ -292,7 +289,6 @@
if(buf == NULL)
{
IPACMERR("Failed malloc for mglen\n");
- free(buf);
free(iov);
free(nladdr);
free(msgh);
@@ -337,11 +333,22 @@
buf = (unsigned char *)msgh->msg_iov->iov_base;
}
+ if(buf)
+ {
free(buf);
+ }
+ if(iov)
+ {
free(iov);
+ }
+ if(nladdr)
+ {
free(nladdr);
+ }
+ if(msgh)
+ {
free(msgh);
-
+ }
return;
}
@@ -593,7 +600,7 @@
ipa_nl_msg_t *msg_ptr
)
{
- char dev_name[IF_NAME_LEN];
+ char dev_name[IF_NAME_LEN]={0};
int ret_val, mask_value, mask_index, mask_value_v6;
struct nlmsghdr *nlh = (struct nlmsghdr *)buffer;
@@ -607,6 +614,7 @@
while(NLMSG_OK(nlh, buflen))
{
+ memset(dev_name,0,IF_NAME_LEN);
IPACMDBG("Received msg:%d from netlink\n", nlh->nlmsg_type)
switch(nlh->nlmsg_type)
{
@@ -628,8 +636,13 @@
if(IFF_UP & msg_ptr->nl_link_info.metainfo.ifi_change)
{
- IPACMDBG("\n GOT useful newlink event\n");
+ IPACMDBG("GOT useful newlink event\n");
ret_val = ipa_get_if_name(dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);
+ if(ret_val != IPACM_SUCCESS)
+ {
+ IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
+ }
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
if(data_fid == NULL)
@@ -645,7 +658,7 @@
/* post link up to command queue */
evt_data.event = IPA_LINK_UP_EVENT;
IPACMDBG("Posting IPA_LINK_UP_EVENT with if index: %d\n",
- data_fid->if_index);
+ msg_ptr->nl_link_info.metainfo.ifi_index);
}
else
{
@@ -679,7 +692,12 @@
data_fid->if_index = msg_ptr->nl_link_info.metainfo.ifi_index;
ret_val = ipa_get_if_name(dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);
- IPACMDBG("Got a ECM link_up event (Interface %s) \n", dev_name);
+ if(ret_val != IPACM_SUCCESS)
+ {
+ IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
+ }
+ IPACMDBG("sky 8994 Got a usb link_up event (Interface %s, %d) \n", dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);
/*--------------------------------------------------------------------------
Post LAN iface (ECM) link up event
@@ -687,6 +705,8 @@
evt_data.event = IPA_USB_LINK_UP_EVENT;
evt_data.evt_data = data_fid;
IPACM_EvtDispatcher::PostEvt(&evt_data);
+ IPACMDBG("Posting usb IPA_LINK_UP_EVENT with if index: %d\n",
+ data_fid->if_index);
}
else if(!(msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_LOWER_UP))
{
@@ -699,7 +719,12 @@
data_fid->if_index = msg_ptr->nl_link_info.metainfo.ifi_index;
ret_val = ipa_get_if_name(dev_name, msg_ptr->nl_link_info.metainfo.ifi_index);
- IPACMDBG("Got a ECM link_down event (Interface %s) \n", dev_name);
+ if(ret_val != IPACM_SUCCESS)
+ {
+ IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
+ }
+ IPACMDBG("Got a usb link_down event (Interface %s) \n", dev_name);
/*--------------------------------------------------------------------------
Post LAN iface (ECM) link down event
@@ -707,6 +732,8 @@
evt_data.event = IPA_LINK_DOWN_EVENT;
evt_data.evt_data = data_fid;
IPACM_EvtDispatcher::PostEvt(&evt_data);
+ IPACMDBG("Posting usb IPA_LINK_DOWN_EVENT with if index: %d\n",
+ data_fid->if_index);
}
}
@@ -728,6 +755,7 @@
if(ret_val != IPACM_SUCCESS)
{
IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
}
IPACMDBG("Interface %s bring down \n", dev_name);
@@ -845,6 +873,7 @@
if(ret_val != IPACM_SUCCESS)
{
IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
}
IPACM_NL_REPORT_ADDR( "route add -host", msg_ptr->nl_route_info.attr_info.dst_addr );
@@ -882,6 +911,7 @@
if(ret_val != IPACM_SUCCESS)
{
IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
}
if(AF_INET6 == msg_ptr->nl_route_info.metainfo.rtm_family)
@@ -1097,6 +1127,7 @@
if(ret_val != IPACM_SUCCESS)
{
IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
}
IPACM_NL_REPORT_ADDR( "route del -host ", msg_ptr->nl_route_info.attr_info.dst_addr);
IPACM_NL_REPORT_ADDR( " gw ", msg_ptr->nl_route_info.attr_info.gateway_addr);
@@ -1133,6 +1164,7 @@
if(ret_val != IPACM_SUCCESS)
{
IPACMERR("Error while getting interface name\n");
+ return IPACM_FAILURE;
}
/* insert to command queue */
@@ -1206,6 +1238,7 @@
if(ret_val != IPACM_SUCCESS)
{
IPACMERR("Error while getting interface name");
+ return IPACM_FAILURE;
}
if(msg_ptr->nl_route_info.attr_info.param_mask & IPA_RTA_PARAM_DST)
@@ -1471,10 +1504,16 @@
IPACMERR("Failed to decode nl message \n");
goto error;
}
-
+ /* Release NetLink message buffer */
+ if(msghdr)
+ {
ipa_nl_release_msg(msghdr);
+ }
+ if(nlmsg)
+ {
free(nlmsg);
}
+ }
return IPACM_SUCCESS;
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index fd724cb..8671fe7 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -324,7 +324,7 @@
if(data_fid == NULL)
{
IPACMERR("unable to allocate memory for IPA_USB_LINK_UP_EVENT data_fid\n");
- return NULL;
+ return;
}
if(IPACM_Iface::ipa_get_if_index(dev_name, &(data_fid->if_index)))
{
diff --git a/ipacm/src/IPACM_Xml.cpp b/ipacm/src/IPACM_Xml.cpp
index 87a72cd..02ca8e4 100644
--- a/ipacm/src/IPACM_Xml.cpp
+++ b/ipacm/src/IPACM_Xml.cpp
@@ -273,14 +273,11 @@
memset(content_buf, 0, sizeof(content_buf));
memcpy(content_buf, (void *)content, str_size);
content_buf[MAX_XML_STR_LEN-1] = '\0';
- if(content_buf)
- {
config->private_subnet_config.private_subnet_entries[config->private_subnet_config.num_subnet_entries - 1].subnet_addr
= ntohl(inet_addr(content_buf));
IPACMDBG("subnet_addr: %s \n", content_buf);
}
}
- }
else if (IPACM_util_icmp_string((char*)xml_node->name,
SUBNETMASK_TAG) == 0)
{
@@ -291,14 +288,11 @@
memset(content_buf, 0, sizeof(content_buf));
memcpy(content_buf, (void *)content, str_size);
content_buf[MAX_XML_STR_LEN-1] = '\0';
- if(content_buf)
- {
config->private_subnet_config.private_subnet_entries[config->private_subnet_config.num_subnet_entries - 1].subnet_mask
= ntohl(inet_addr(content_buf));
IPACMDBG("subnet_mask: %s \n", content_buf);
}
}
- }
else if (IPACM_util_icmp_string((char*)xml_node->name,
Protocol_TAG) == 0)
{
@@ -525,14 +519,11 @@
memset(content_buf, 0, sizeof(content_buf));
memcpy(content_buf, (void *)content, str_size);
content_buf[MAX_XML_STR_LEN-1] = '\0';
- if (content_buf)
- {
config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.src_addr
= ntohl(inet_addr(content_buf));
IPACMDBG("IPv4 source address is: %s \n", content_buf);
}
}
- }
else if (0 == IPACM_util_icmp_string((char*)xml_node->name,
IPV4SourceSubnetMask_TAG))
{
@@ -543,14 +534,11 @@
memset(content_buf, 0, sizeof(content_buf));
memcpy(content_buf, (void *)content, str_size);
content_buf[MAX_XML_STR_LEN-1] = '\0';
- if (content_buf)
- {
config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.src_addr_mask
= ntohl(inet_addr(content_buf));
IPACMDBG("IPv4 source subnet mask is: %s \n", content_buf);
}
}
- }
else if (0 == IPACM_util_icmp_string((char*)xml_node->name,
IPV4DestinationAddress_TAG))
{
@@ -569,14 +557,11 @@
memset(content_buf, 0, sizeof(content_buf));
memcpy(content_buf, (void *)content, str_size);
content_buf[MAX_XML_STR_LEN-1] = '\0';
- if (content_buf)
- {
config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.dst_addr
= ntohl(inet_addr(content_buf));
IPACMDBG("IPv4 destination address is: %s \n", content_buf);
}
}
- }
else if (0 == IPACM_util_icmp_string((char*)xml_node->name,
IPV4DestinationSubnetMask_TAG))
{