potter: ipacm: fix build

Change-Id: I129c15664047306530225a5405970966c0edbf93
This commit is contained in:
Vachounet
2017-09-14 10:15:20 +02:00
parent 150294a722
commit f512e6b4b9
8 changed files with 93 additions and 54 deletions

View File

@@ -24,9 +24,8 @@ LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_CFLAGS := -v
LOCAL_CFLAGS += -DFEATURE_IPA_ANDROID
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS := -DFEATURE_IPA_ANDROID
ifneq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DDEBUG
endif

View File

@@ -482,7 +482,7 @@ int IPACM_Config::AddNatIfaces(char *dev_name)
if (ipa_nat_iface_entries < ipa_num_ipa_interfaces)
{
memcpy(pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
strlcpy(pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
dev_name, IPA_IFACE_NAME_LEN);
IPACMDBG_H("Add Nat IfaceName: %s ,update nat-ifaces number: %d\n",

View File

@@ -169,10 +169,18 @@ int IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Bridge_Addrs
uint32_t ipv4_addr;
struct ifreq ifr;
if(strlen(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name) >= sizeof(ifr.ifr_name))
{
IPACMERR("interface name overflows: len %d\n",
strlen(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name));
close(fd);
return -1;
}
/* retrieve bridge interface ipv4 address */
memset(&ifr, 0, sizeof(struct ifreq));
ifr.ifr_addr.sa_family = AF_INET;
(void)strncpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));
(void)strlcpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));
IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name);
ret = ioctl(fd, SIOCGIFADDR, &ifr);

View File

@@ -924,30 +924,37 @@ int IPACM_Iface::ipa_get_if_index
int * if_index
)
{
int fd;
struct ifreq ifr;
int fd;
struct ifreq ifr;
if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
IPACMERR("get interface index socket create failed \n");
return IPACM_FAILURE;
}
if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
IPACMERR("get interface index socket create failed \n");
return IPACM_FAILURE;
}
memset(&ifr, 0, sizeof(struct ifreq));
(void)strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));
IPACMDBG_H("interface name (%s)\n", if_name);
if(strlen(if_name) >= sizeof(ifr.ifr_name))
{
IPACMERR("interface name overflows: len %d\n", strlen(if_name));
close(fd);
return IPACM_FAILURE;
}
if (ioctl(fd,SIOCGIFINDEX , &ifr) < 0)
{
IPACMERR("call_ioctl_on_dev: ioctl failed, interface name (%s):\n", ifr.ifr_name);
close(fd);
return IPACM_FAILURE;
}
memset(&ifr, 0, sizeof(struct ifreq));
(void)strlcpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));
IPACMDBG_H("interface name (%s)\n", if_name);
*if_index = ifr.ifr_ifindex;
IPACMDBG_H("Interface index %d\n", *if_index);
close(fd);
return IPACM_SUCCESS;
if(ioctl(fd,SIOCGIFINDEX , &ifr) < 0)
{
IPACMERR("call_ioctl_on_dev: ioctl failed, interface name (%s):\n", ifr.ifr_name);
close(fd);
return IPACM_FAILURE;
}
*if_index = ifr.ifr_ifindex;
IPACMDBG_H("Interface index %d\n", *if_index);
close(fd);
return IPACM_SUCCESS;
}
void IPACM_Iface::config_ip_type(ipa_ip_type iptype)

View File

@@ -689,12 +689,12 @@ static int ipa_nl_decode_nlmsg
/* Add IPACM support for ECM plug-in/plug_out */
/*--------------------------------------------------------------------------
Check if the interface is running.If its a RTM_NEWLINK and the interface
is running then it means that its a link up event
---------------------------------------------------------------------------*/
if((msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_RUNNING) &&
(msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_LOWER_UP))
{
Check if the interface is running.If its a RTM_NEWLINK and the interface
is running then it means that its a link up event
---------------------------------------------------------------------------*/
if((msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_RUNNING) &&
(msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_LOWER_UP))
{
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
if(data_fid == NULL)
@@ -712,17 +712,17 @@ static int ipa_nl_decode_nlmsg
}
IPACMDBG("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
---------------------------------------------------------------------------*/
evt_data.event = IPA_USB_LINK_UP_EVENT;
/*--------------------------------------------------------------------------
Post LAN iface (ECM) link up event
---------------------------------------------------------------------------*/
evt_data.event = IPA_USB_LINK_UP_EVENT;
evt_data.evt_data = data_fid;
IPACM_EvtDispatcher::PostEvt(&evt_data);
IPACMDBG_H("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))
{
IPACM_EvtDispatcher::PostEvt(&evt_data);
}
else if (!(msg_ptr->nl_link_info.metainfo.ifi_flags & IFF_LOWER_UP))
{
data_fid = (ipacm_event_data_fid *)malloc(sizeof(ipacm_event_data_fid));
if(data_fid == NULL)
{
@@ -744,10 +744,10 @@ static int ipa_nl_decode_nlmsg
---------------------------------------------------------------------------*/
evt_data.event = IPA_LINK_DOWN_EVENT;
evt_data.evt_data = data_fid;
IPACM_EvtDispatcher::PostEvt(&evt_data);
IPACMDBG_H("Posting usb IPA_LINK_DOWN_EVENT with if index: %d\n",
data_fid->if_index);
}
IPACM_EvtDispatcher::PostEvt(&evt_data);
}
}
break;

View File

@@ -267,8 +267,8 @@ static int ipacm_cfg_xml_parse_tree
{
str_size = strlen(content);
memset(content_buf, 0, sizeof(content_buf));
memcpy(content_buf, (void *)content, str_size);
strlcpy(config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name, content_buf, str_size+1);
strlcpy(content_buf, content, MAX_XML_STR_LEN);
strlcpy(config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name, content_buf, IPA_IFACE_NAME_LEN);
IPACMDBG_H("Name %s\n", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name);
}
}
@@ -644,12 +644,9 @@ static int IPACM_firewall_xml_parse_tree
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 > 0)
{
config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.dst_addr_mask
= ntohl(inet_addr(content_buf));
IPACMDBG_H("IPv4 destination subnet mask is: %s \n", content_buf);
}
config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.dst_addr_mask
= ntohl(inet_addr(content_buf));
IPACMDBG_H("IPv4 destination subnet mask is: %s \n", content_buf);
}
}
else if (0 == IPACM_util_icmp_string((char*)xml_node->name, IPV4TypeOfService_TAG))