Merge "ipanat: move ipaNatTable device node creation"
diff --git a/ipacm/inc/IPACM_Config.h b/ipacm/inc/IPACM_Config.h
index dbc8789..c6bb06c 100644
--- a/ipacm/inc/IPACM_Config.h
+++ b/ipacm/inc/IPACM_Config.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
@@ -52,20 +52,20 @@
/* for IPACM rm dependency use*/
typedef struct _ipa_rm_client
{
- ipa_rm_resource_name producer_rm1;
+ ipa_rm_resource_name producer_rm1;
ipa_rm_resource_name consumer_rm1;
- ipa_rm_resource_name producer_rm2;
+ ipa_rm_resource_name producer_rm2;
ipa_rm_resource_name consumer_rm2;
bool producer1_up; /* only monitor producer_rm1, not monitor producer_rm2 */
bool consumer1_up; /* only monitor consumer_rm1, not monitor consumer_rm2 */
bool rm_set; /* once producer1_up and consumer1_up, will add bi-directional dependency */
- bool rx_bypass_ipa; /* support WLAN may not register RX-property, should not add dependency */
+ bool rx_bypass_ipa; /* support WLAN may not register RX-property, should not add dependency */
}ipa_rm_client;
#define MAX_NUM_EXT_PROPS 10
/* used to hold extended properties */
-typedef struct
+typedef struct
{
uint8_t num_ext_props;
ipa_ioc_ext_intf_prop prop[MAX_NUM_EXT_PROPS];
@@ -84,7 +84,7 @@
/* IPACM rm_depency a2 endpoint check*/
int ipa_rm_a2_check;
-
+
/* Store interested interface and their configuration from XML file */
ipa_ifi_dev_name_t *iface_table;
@@ -95,7 +95,7 @@
ipa_private_subnet private_subnet_table[IPA_MAX_PRIVATE_SUBNET_ENTRIES];
/* Store the non nat iface names */
- NatIfaces *pNatIfaces;
+ NatIfaces *pNatIfaces;
/* Store the bridge iface names */
char ipa_virtual_iface_name[IPA_IFACE_NAME_LEN];
@@ -111,6 +111,9 @@
int ipa_nat_iface_entries;
+ /* Store SW-enable or not */
+ bool ipa_sw_rt_enable;
+
/* IPACM routing table name for v4/v6 */
struct ipa_ioc_get_rt_tbl rt_tbl_lan_v4, rt_tbl_wan_v4, rt_tbl_default_v4, rt_tbl_v6, rt_tbl_wan_v6;
struct ipa_ioc_get_rt_tbl rt_tbl_wan_dl;
@@ -139,9 +142,9 @@
/* for IPACM resource manager dependency usage */
void AddRmDepend(ipa_rm_resource_name rm1,bool rx_bypass_ipa);
-
+
void DelRmDepend(ipa_rm_resource_name rm1);
-
+
int AddNatIfaces(char *dev_name);
int DelNatIfaces(char *dev_name);
@@ -159,7 +162,7 @@
int SetExtProp(ipa_ioc_query_intf_ext_props *prop);
ipacm_ext_prop* GetExtProp(ipa_ip_type ip_type);
-
+
int DelExtProp(ipa_ip_type ip_type);
int Init(void);
diff --git a/ipacm/inc/IPACM_ConntrackListener.h b/ipacm/inc/IPACM_ConntrackListener.h
index e5827f2..c1249c2 100644
--- a/ipacm/inc/IPACM_ConntrackListener.h
+++ b/ipacm/inc/IPACM_ConntrackListener.h
@@ -76,8 +76,6 @@
int CreateNatThreads(void);
int CreateConnTrackThreads(void);
- void HandleNeighIpAddrAddEvt(void *);
- void HandleNeighIpAddrDelEvt(void *);
#ifdef CT_OPT
void ProcessCTV6Message(void *);
#endif
@@ -93,6 +91,9 @@
{
return WanUp;
}
+
+ void HandleNeighIpAddrAddEvt(ipacm_event_data_all *);
+ void HandleNeighIpAddrDelEvt(uint32_t);
};
extern IPACM_ConntrackListener *CtList;
diff --git a/ipacm/inc/IPACM_Conntrack_NATApp.h b/ipacm/inc/IPACM_Conntrack_NATApp.h
index 63af013..9eb9b4f 100644
--- a/ipacm/inc/IPACM_Conntrack_NATApp.h
+++ b/ipacm/inc/IPACM_Conntrack_NATApp.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
@@ -112,6 +112,7 @@
int UpdatePwrSaveIf(uint32_t);
int ResetPwrSaveIf(uint32_t);
+ int DelEntriesOnClntDiscon(uint32_t);
void UpdateTcpUdpTo(uint32_t, int proto);
diff --git a/ipacm/inc/IPACM_Wan.h b/ipacm/inc/IPACM_Wan.h
index 0b48be1..5ef11f2 100644
--- a/ipacm/inc/IPACM_Wan.h
+++ b/ipacm/inc/IPACM_Wan.h
@@ -169,7 +169,7 @@
int add_dft_filtering_rule(struct ipa_flt_rule_add* rules, int rule_offset, ipa_ip_type iptype);
- int install_wan_filtering_rule();
+ int install_wan_filtering_rule(bool is_sw_routing);
void change_to_network_order(ipa_ip_type iptype, ipa_rule_attrib* attrib);
diff --git a/ipacm/src/Android.mk b/ipacm/src/Android.mk
index 5d06031..1609ce7 100644
--- a/ipacm/src/Android.mk
+++ b/ipacm/src/Android.mk
@@ -1,5 +1,6 @@
ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH)))
+ifneq ($(TARGET_USES_AOSP),true)
LOCAL_PATH := $(call my-dir)
@@ -76,5 +77,6 @@
IPACM_FILE_LIST := IPACM_cfg.xml
$(foreach TEST,$(IPACM_FILE_LIST),$(eval $(call ADD_TEST,$(TEST))))
+endif # not (TARGET_USES_AOSP)
endif # $(TARGET_ARCH)
endif
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
index 07cb440..a934e97 100644
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -59,6 +59,7 @@
ipa_num_alg_ports = 0;
ipa_nat_max_entries = 0;
ipa_nat_iface_entries = 0;
+ ipa_sw_rt_enable = false;
memset(&rt_tbl_default_v4, 0, sizeof(rt_tbl_default_v4));
memset(&rt_tbl_lan_v4, 0, sizeof(rt_tbl_lan_v4));
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
index ae11d34..3559a8c 100644
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.cpp
@@ -56,10 +56,6 @@
IPACM_EvtDispatcher::registr(IPA_PROCESS_CT_MESSAGE_V6, this);
IPACM_EvtDispatcher::registr(IPA_HANDLE_WLAN_UP, this);
IPACM_EvtDispatcher::registr(IPA_HANDLE_LAN_UP, this);
- IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, this);
- IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT, this);
-
- IPACMDBG("creating conntrack threads\n");
#ifdef CT_OPT
p_lan2lan = IPACM_LanToLan::getLan2LanInstance();
@@ -121,28 +117,13 @@
IPACM_ConntrackClient::UpdateTCPFilters(data, false);
break;
- case IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT:
- {
- IPACMDBG("Received IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT event\n");
- HandleNeighIpAddrAddEvt(data);
- }
- break;
-
- case IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT:
- {
- IPACMDBG("Received IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT event\n");
- HandleNeighIpAddrDelEvt(data);
- }
- break;
-
default:
IPACMDBG("Ignore cmd %d\n", evt);
break;
}
}
-void IPACM_ConntrackListener::HandleNeighIpAddrAddEvt(void *in_param)
+void IPACM_ConntrackListener::HandleNeighIpAddrAddEvt(ipacm_event_data_all *data)
{
- ipacm_event_data_all *data = (ipacm_event_data_all *)in_param;
int fd = 0, len = 0, cnt, i, j;
struct ifreq ifr;
bool isNatIface = false;
@@ -152,6 +133,8 @@
IPACMDBG("Ignoring IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT EVENT\n");
return;
}
+
+ IPACMDBG("\n");
IPACMDBG("Received interface index %d with ip type: %d", data->if_index, data->iptype);
iptodot(" and ipv4 address", data->ipv4_addr);
@@ -165,9 +148,8 @@
}
}
+
cnt = pConfig->GetNatIfacesCnt();
- if(NatIfaceCnt != cnt)
- {
NatIfaceCnt = cnt;
if(pNatIfaces != NULL)
{
@@ -189,9 +171,8 @@
IPACMERR("Unable to retrieve non nat ifaces\n");
return;
}
+ IPACMDBG("Update %d Nat ifaces\n", NatIfaceCnt);
- IPACMDBG("Update %d Nat ifaces", NatIfaceCnt);
- }
/* Search/Configure linux interface-index and map it to IPA interface-index */
if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
@@ -265,37 +246,39 @@
}
-void IPACM_ConntrackListener::HandleNeighIpAddrDelEvt(void *in_param)
+void IPACM_ConntrackListener::HandleNeighIpAddrDelEvt(uint32_t ipv4_addr)
{
- ipacm_event_data_all *data = (ipacm_event_data_all *)in_param;
int cnt;
- if(data->ipv4_addr == 0 || data->iptype != IPA_IP_v4)
+ if(ipv4_addr == 0)
{
IPACMDBG("Ignoring IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT EVENT\n");
return;
}
- IPACMDBG("Received interface index %d with ip type:%d", data->if_index, data->iptype);
+
+ IPACMDBG("\n");
+ iptodot("Received ip addr", ipv4_addr);
IPACMDBG("Entering NAT entry deletion checking\n");
for(cnt = 0; cnt<MAX_NAT_IFACES; cnt++)
{
- if(nat_iface_ipv4_addr[cnt] == data->ipv4_addr)
+ if(nat_iface_ipv4_addr[cnt] == ipv4_addr)
{
- IPACMDBG("Reseting ct filters of Interface (%d), entry (%d) ", data->if_index, cnt);
+ IPACMDBG("Reseting ct nat iface, entry (%d) ", cnt);
iptodot("with ipv4 address", nat_iface_ipv4_addr[cnt]);
nat_iface_ipv4_addr[cnt] = 0;
}
- if(nonnat_iface_ipv4_addr[cnt] == data->ipv4_addr)
+ if(nonnat_iface_ipv4_addr[cnt] == ipv4_addr)
{
- IPACMDBG("Reseting ct filters of Interface (%d), entry (%d) ", data->if_index, cnt);
+ IPACMDBG("Reseting ct filters, entry (%d) ", cnt);
iptodot("with ipv4 address", nonnat_iface_ipv4_addr[cnt]);
nonnat_iface_ipv4_addr[cnt] = 0;
}
}
- nat_inst->FlushTempEntries(data->ipv4_addr, false);
+ nat_inst->FlushTempEntries(ipv4_addr, false);
+ nat_inst->DelEntriesOnClntDiscon(ipv4_addr);
return;
}
@@ -303,7 +286,7 @@
{
ipacm_event_iface_up *wanup_data = (ipacm_event_iface_up *)in_param;
- IPACMDBG("Recevied below information during wanup, ");
+ IPACMDBG("Recevied below information during wanup,\n");
IPACMDBG("if_name:%s, ipv4_address:0x%x\n",
wanup_data->ifname, wanup_data->ipv4_addr);
@@ -362,6 +345,7 @@
IPACMDBG("created UDP conntrack event listner thread\n");
}
+
isCTReg = true;
}
diff --git a/ipacm/src/IPACM_Conntrack_NATApp.cpp b/ipacm/src/IPACM_Conntrack_NATApp.cpp
index d6bbc19..b55d7e9 100644
--- a/ipacm/src/IPACM_Conntrack_NATApp.cpp
+++ b/ipacm/src/IPACM_Conntrack_NATApp.cpp
@@ -714,3 +714,49 @@
return;
}
+
+int NatApp::DelEntriesOnClntDiscon(uint32_t ip_addr)
+{
+ int cnt, tmp = curCnt;
+ IPACMDBG("Received IP address: 0x%x\n", ip_addr);
+
+ if(ip_addr == INVALID_IP_ADDR)
+ {
+ IPACMERR("Invalid ip address received\n");
+ return -1;
+ }
+
+ CHK_TBL_HDL();
+
+ for(cnt = 0; cnt < IPA_MAX_NUM_WIFI_CLIENTS; cnt++)
+ {
+ if(PwrSaveIfs[cnt] == ip_addr)
+ {
+ PwrSaveIfs[cnt] = 0;
+ IPACMDBG("Remove %d power save entry\n", cnt);
+ break;
+ }
+ }
+
+ for(cnt = 0; cnt < max_entries; cnt++)
+ {
+ if(cache[cnt].private_ip == ip_addr)
+ {
+
+ if(cache[cnt].enabled == true)
+ {
+ if(ipa_nat_del_ipv4_rule(nat_table_hdl, cache[cnt].rule_hdl) < 0)
+ {
+ IPACMERR("unable to delete the rule\n");
+ continue;
+ }
+ }
+
+ memset(&cache[cnt], 0, sizeof(cache[cnt]));
+ curCnt--;
+ }
+ }
+
+ IPACMDBG("Deleted %d entries\n", (tmp - curCnt));
+ return 0;
+}
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
index 52bf19d..a2be272 100644
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -142,8 +142,8 @@
memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
/* check iface is v4 or v6 or both*/
- if (ip_type == IPA_IP_MAX)
- {
+// if (ip_type == IPA_IP_MAX)
+// {
/* handle v4 */
m_pFilteringTable->ip = IPA_IP_v4;
if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
@@ -183,6 +183,7 @@
/* copy filter hdls */
software_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;
softwarerouting_act = true;
+#if 0
}
else
{
@@ -220,6 +221,7 @@
}
softwarerouting_act = true;
}
+#endif
fail:
free(m_pFilteringTable);
@@ -242,12 +244,12 @@
if (softwarerouting_act == false)
{
- IPACMDBG("already delete AMPDU software_routing rule for (%s)iface ip-family %d\n", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);
+ IPACMDBG("already delete software_routing rule for (%s)iface ip-family %d\n", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);
return IPACM_SUCCESS;
}
- if (ip_type == IPA_IP_MAX)
- {
+// if (ip_type == IPA_IP_MAX)
+// {
/* ipv4 case */
if (m_filtering.DeleteFilteringHdls(&software_routing_fl_rule_hdl[0],
IPA_IP_v4, 1) == false)
@@ -266,6 +268,7 @@
goto fail;
}
softwarerouting_act = false;
+#if 0
}
else
{
@@ -296,6 +299,7 @@
}
softwarerouting_act = false;
}
+#endif
fail:
return res;
diff --git a/ipacm/src/IPACM_IfaceManager.cpp b/ipacm/src/IPACM_IfaceManager.cpp
index bbce080..af9811c 100644
--- a/ipacm/src/IPACM_IfaceManager.cpp
+++ b/ipacm/src/IPACM_IfaceManager.cpp
@@ -229,15 +229,12 @@
IPACMDBG_H("Creating Wan interface\n");
IPACM_Wan *w = new IPACM_Wan(ipa_interface_index, is_sta_mode);
IPACM_EvtDispatcher::registr(IPA_ADDR_ADD_EVENT, w);
-//#ifdef FEATURE_IPA_ANDROID
-#if 0
+#ifdef FEATURE_IPA_ANDROID
IPACM_EvtDispatcher::registr(IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT, w);
- IPACM_EvtDispatcher::registr(IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, w);
-#endif
-//#else/* defined(FEATURE_IPA_ANDROID) */
+#else/* defined(FEATURE_IPA_ANDROID) */
IPACM_EvtDispatcher::registr(IPA_ROUTE_ADD_EVENT, w);
IPACM_EvtDispatcher::registr(IPA_ROUTE_DEL_EVENT, w);
-//#endif /* not defined(FEATURE_IPA_ANDROID)*/
+#endif /* not defined(FEATURE_IPA_ANDROID)*/
IPACM_EvtDispatcher::registr(IPA_FIREWALL_CHANGE_EVENT, w);
IPACM_EvtDispatcher::registr(IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT, w);
IPACM_EvtDispatcher::registr(IPA_SW_ROUTING_ENABLE, w);
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index 0bfe4c7..707083c 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -49,6 +49,8 @@
#include "linux/rmnet_ipa_fd_ioctl.h"
#include "linux/ipa_qmi_service_v01.h"
#include "linux/msm_ipa.h"
+#include "IPACM_ConntrackListener.h"
+
IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
{
@@ -306,6 +308,13 @@
IPACM_EvtDispatcher::PostEvt(&evt_data);
}
IPACMDBG_H("Finish handling IPA_ADDR_ADD_EVENT for ip-family(%d)\n", data->iptype);
+ /* checking if SW-RT_enable */
+ if (IPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true)
+ {
+ /* handle software routing enable event*/
+ IPACMDBG_H("IPA_SW_ROUTING_ENABLE for iface: %s \n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);
+ handle_software_routing_enable();
+ }
}
}
}
@@ -413,6 +422,11 @@
return;
}
handle_eth_client_route_rule(data->mac_addr, data->iptype);
+ if (data->iptype == IPA_IP_v4)
+ {
+ /* Add NAT rules after ipv4 RT rules are set */
+ CtList->HandleNeighIpAddrAddEvt(data);
+ }
return;
}
}
@@ -1284,11 +1298,13 @@
}
else
{
- IPACMDBG_H("ipv4 addr for client:%d is changed \n", clnt_indx);
- delete_eth_rtrules(clnt_indx,IPA_IP_v4);
- get_client_memptr(eth_client, clnt_indx)->route_rule_set_v4 = false;
- get_client_memptr(eth_client, clnt_indx)->v4_addr = data->ipv4_addr;
- }
+ IPACMDBG_H("ipv4 addr for client:%d is changed \n", clnt_indx);
+ /* delete NAT rules first */
+ CtList->HandleNeighIpAddrDelEvt(get_client_memptr(eth_client, clnt_indx)->v4_addr);
+ delete_eth_rtrules(clnt_indx,IPA_IP_v4);
+ 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
@@ -1555,19 +1571,19 @@
/* First reset nat rules and then route rules */
if(get_client_memptr(eth_client, clt_indx)->ipv4_set == true)
{
- IPACMDBG_H("Deleting Nat Rules\n");
- Nat_App->UpdatePwrSaveIf(get_client_memptr(eth_client, clt_indx)->v4_addr);
+ IPACMDBG_H("Clean Nat Rules for ipv4:0x%x\n", get_client_memptr(eth_client, clt_indx)->v4_addr);
+ CtList->HandleNeighIpAddrDelEvt(get_client_memptr(eth_client, clt_indx)->v4_addr);
}
if (delete_eth_rtrules(clt_indx, IPA_IP_v4))
{
- IPACMERR("unbale to delete ecm-client v4 route rules\n");
+ IPACMERR("unbale to delete ecm-client v4 route rules for index: %d\n", clt_indx);
return IPACM_FAILURE;
}
if (delete_eth_rtrules(clt_indx, IPA_IP_v6))
{
- IPACMERR("unbale to delete ecm-client v6 route rules\n");
+ IPACMERR("unbale to delete ecm-client v6 route rules for index: %d\n", clt_indx);
return IPACM_FAILURE;
}
@@ -1704,8 +1720,26 @@
IPACMDBG_H("left %d eth clients need to be deleted \n ", num_eth_client);
for (i = 0; i < num_eth_client; i++)
{
- delete_eth_rtrules(i, IPA_IP_v4);
- delete_eth_rtrules(i, IPA_IP_v6);
+ /* First reset nat rules and then route rules */
+ if(get_client_memptr(eth_client, i)->ipv4_set == true)
+ {
+ IPACMDBG_H("Clean Nat Rules for ipv4:0x%x\n", get_client_memptr(eth_client, i)->v4_addr);
+ CtList->HandleNeighIpAddrDelEvt(get_client_memptr(eth_client, i)->v4_addr);
+ }
+
+ if (delete_eth_rtrules(i, IPA_IP_v4))
+ {
+ IPACMERR("unbale to delete ecm-client v4 route rules for index %d\n", i);
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+
+ if (delete_eth_rtrules(i, IPA_IP_v6))
+ {
+ IPACMERR("unbale to delete ecm-client v6 route rules for index %d\n", i);
+ res = IPACM_FAILURE;
+ goto fail;
+ }
IPACMDBG_H("Delete %d client header\n", num_eth_client);
diff --git a/ipacm/src/IPACM_Main.cpp b/ipacm/src/IPACM_Main.cpp
index 7ddefde..1a1dd03 100644
--- a/ipacm/src/IPACM_Main.cpp
+++ b/ipacm/src/IPACM_Main.cpp
@@ -304,15 +304,13 @@
IPACMDBG_H("Received SW_ROUTING_ENABLE\n");
evt_data.event = IPA_SW_ROUTING_ENABLE;
IPACMDBG_H("Not supported anymore\n");
- return NULL;
- break;
+ continue;
case SW_ROUTING_DISABLE:
IPACMDBG_H("Received SW_ROUTING_DISABLE\n");
evt_data.event = IPA_SW_ROUTING_DISABLE;
IPACMDBG_H("Not supported anymore\n");
- return NULL;
- break;
+ continue;
case WLAN_AP_CONNECT:
event_wlan = (struct ipa_wlan_msg *) (buffer + sizeof(struct ipa_msg_meta));
@@ -543,14 +541,14 @@
/* Add for 8994 Android case */
case WAN_UPSTREAM_ROUTE_ADD:
memcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));
- IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_ADD name: %s\n",event_wan.name);
+ IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_ADD name: %s, tethered name: %s\n", event_wan.upstream_ifname, event_wan.tethered_ifname);
data_iptype = (ipacm_event_data_iptype *)malloc(sizeof(ipacm_event_data_iptype));
if(data_iptype == NULL)
{
IPACMERR("unable to allocate memory for event_ecm data_iptype\n");
return NULL;
}
- ipa_get_if_index(event_wan.name, &(data_iptype->if_index));
+ ipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));
data_iptype->iptype = event_wan.ip;
IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_ADD: fid(%d) ip-type(%d)\n", data_iptype->if_index, data_iptype->iptype);
evt_data.event = IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT;
@@ -558,14 +556,14 @@
break;
case WAN_UPSTREAM_ROUTE_DEL:
memcpy(&event_wan, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_wan_msg));
- IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_DEL name: %s\n",event_wan.name);
+ IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_DEL name: %s, tethered name: %s\n", event_wan.upstream_ifname, event_wan.tethered_ifname);
data_iptype = (ipacm_event_data_iptype *)malloc(sizeof(ipacm_event_data_iptype));
if(data_iptype == NULL)
{
IPACMERR("unable to allocate memory for event_ecm data_iptype\n");
return NULL;
}
- ipa_get_if_index(event_wan.name, &(data_iptype->if_index));
+ ipa_get_if_index(event_wan.upstream_ifname, &(data_iptype->if_index));
data_iptype->iptype = event_wan.ip;
IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_DEL: fid(%d) ip-type(%d)\n", data_iptype->if_index, data_iptype->iptype);
evt_data.event = IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT;
@@ -591,31 +589,29 @@
void IPACM_Sig_Handler(int sig)
{
int cnt;
+ ipacm_cmd_q_data evt_data;
printf("Received Signal: %d\n", sig);
+ memset(&evt_data, 0, sizeof(evt_data));
switch(sig)
{
case SIGUSR1:
- for (cnt=1; cnt<IPACM_EVENT_MAX; cnt++)
- {
- printf("Event[%d:%30s]: %d\n",
- cnt, ipacm_event_name[cnt-1], ipacm_event_stats[cnt]);
- }
+ IPACMDBG_H("Received SW_ROUTING_ENABLE request \n");
+ evt_data.event = IPA_SW_ROUTING_ENABLE;
+ IPACM_Iface::ipacmcfg->ipa_sw_rt_enable = true;
break;
- case SIGUSR2:
- if(ipacm_logging) {
- printf("Disabling logging\n");
- ipacm_logging = false;
- }
- else {
- printf("Enabling logging\n");
- ipacm_logging = true;
- }
+ case SIGUSR2:
+ IPACMDBG_H("Received SW_ROUTING_DISABLE request \n");
+ evt_data.event = IPA_SW_ROUTING_DISABLE;
+ IPACM_Iface::ipacmcfg->ipa_sw_rt_enable = false;
break;
-
}
+ /* finish command queue */
+ IPACMDBG_H("Posting event:%d\n", evt_data.event);
+ IPACM_EvtDispatcher::PostEvt(&evt_data);
+ return;
}
void RegisterForSignals(void)
@@ -707,7 +703,8 @@
===========================================================================*/
/*!
@brief
- Determine if IPACM process exists from its previous Process ID
+ Determine whether there's already an IPACM process running, if so, terminate
+ the current one
@return
None
@@ -724,62 +721,43 @@
void ipa_is_ipacm_running(void) {
- FILE *fp = NULL;
- pid_t ipacm_pid =0;
- char string[IPA_MAX_FILE_LEN];
+ int fd;
+ struct flock lock;
+ int retval;
- /* find the latest pid of executed IPACM */
- fp = fopen(IPACM_PID_FILE, "r");
- if ( fp == NULL )
+ fd = open(IPACM_PID_FILE, O_RDWR | O_CREAT, 0600);
+ if ( fd <= 0 )
{
- IPACMDBG_H("1st IPACM running \n");
+ IPACMERR("Failed to open %s, error is %d - %s\n",
+ IPACM_PID_FILE, errno, strerror(errno));
+ exit(0);
}
- else if (fscanf(fp, "%d", &ipacm_pid) != 1)
+
+ /*
+ * Getting an exclusive Write lock on the file, if it fails,
+ * it means that another instance of IPACM is running and it
+ * got the lock before us.
+ */
+ memset(&lock, 0, sizeof(lock));
+ lock.l_type = F_WRLCK;
+ retval = fcntl(fd, F_SETLK, &lock);
+
+ if (retval != 0)
{
- IPACMERR("Error reading ipacm_pid file \n");
- ipacm_pid = 0;
- fclose(fp);
+ retval = fcntl(fd, F_GETLK, &lock);
+ if (retval == 0)
+ {
+ IPACMERR("Unable to get lock on file %s (my PID %d), PID %d already has it\n",
+ IPACM_PID_FILE, getpid(), lock.l_pid);
+ close(fd);
+ exit(0);
+ }
}
else
{
- IPACMDBG_H("Primary IPACM PID = %d\n",ipacm_pid);
- fclose(fp);
- if (0 == kill(ipacm_pid, 0)) /* Process exists */
- {
- /* check that process is IPACM */
- memset(string, 0, IPA_MAX_FILE_LEN);
- snprintf(string, IPA_MAX_FILE_LEN, "/proc/%d/cmdline", ipacm_pid);
- IPACMDBG_H("open pid file %s \n",string);
- fp = fopen(string, "r");
- if ( fp == NULL )
- {
- IPACMDBG_H("open pid file failed \n");
- return;
- }
- else if (fgets(string, IPA_MAX_FILE_LEN, fp) != NULL)
- {
- IPACMDBG_H("get pid process name (%s)\n",string);
- if( strcmp(string, IPACM_NAME) == 0)
- {
- if(ipacm_pid != getpid())
- {
- IPACMDBG_H("found IPACM already in PID (%d), new PID(%d) exit(0)\n",ipacm_pid, getpid());
- exit(0);
- }
- IPACMDBG_H("same IPACM PID(%d) is running\n", getpid());
- }
- }
- fclose(fp);
- }
+ IPACMERR("PID %d is IPACM main process\n", getpid());
}
- ipacm_pid = getpid();
- fp = fopen(IPACM_PID_FILE, "w");
- if ( fp != NULL )
- {
- IPACMDBG_H(" IPACM current PID: %d \n",ipacm_pid);
- fprintf(fp, "%d", ipacm_pid);
- fclose(fp);
- }
+
return;
}
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 3d47598..c685ba5 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -465,15 +465,23 @@
if( ((data->iptype != ip_type) && (ip_type != IPA_IP_MAX))
|| ((data->iptype==IPA_IP_v6) && (num_dft_rt_v6!=MAX_DEFAULT_v6_ROUTE_RULES)))
{
- IPACMDBG_H("Got IPA_ADDR_ADD_EVENT ip-family:%d, v6 num %d: \n",data->iptype,num_dft_rt_v6);
+ IPACMDBG_H("Got IPA_ADDR_ADD_EVENT ip-family:%d, v6 num %d: \n",data->iptype,num_dft_rt_v6);
handle_addr_evt(data);
+ /* checking if SW-RT_enable */
+ if (IPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true &&
+ m_is_sta_mode != Q6_WAN)
+ {
+ /* handle software routing enable event*/
+ IPACMDBG_H("IPA_SW_ROUTING_ENABLE for iface: %s \n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);
+ handle_software_routing_enable();
+ }
+
}
}
}
break;
-//#ifdef FEATURE_IPA_ANDROID
-#if 0
+
case IPA_WAN_UPSTREAM_ROUTE_ADD_EVENT:
{
ipacm_event_data_iptype *data = (ipacm_event_data_iptype *)param;
@@ -502,7 +510,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v4);
}
else
@@ -518,7 +526,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v6);
}
else
@@ -543,7 +551,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v4);
}
else
@@ -557,7 +565,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v6);
}
else
@@ -569,8 +577,7 @@
}
}
break;
-#endif
-//#else/* defined(FEATURE_IPA_ANDROID) */
+
case IPA_ROUTE_ADD_EVENT:
{
ipacm_event_data_addr *data = (ipacm_event_data_addr *)param;
@@ -607,7 +614,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v4);
}
else
@@ -623,7 +630,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v6);
}
else
@@ -649,7 +656,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v4);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v4);
}
else
@@ -665,7 +672,7 @@
if(m_is_sta_mode == Q6_WAN)
{
del_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v6);
}
else
@@ -677,7 +684,7 @@
}
}
break;
-//#endif /* not defined(FEATURE_IPA_ANDROID)*/
+
case IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT:
{
ipacm_event_data_all *data = (ipacm_event_data_all *)param;
@@ -693,13 +700,29 @@
case IPA_SW_ROUTING_ENABLE:
IPACMDBG_H("Received IPA_SW_ROUTING_ENABLE\n");
/* handle software routing enable event */
- handle_software_routing_enable();
+ if(m_is_sta_mode == Q6_WAN)
+ {
+ install_wan_filtering_rule(true);
+ }
+ else
+ {
+ handle_software_routing_enable();
+ }
break;
case IPA_SW_ROUTING_DISABLE:
IPACMDBG_H("Received IPA_SW_ROUTING_DISABLE\n");
/* handle software routing disable event */
- handle_software_routing_disable();
+ if(m_is_sta_mode == Q6_WAN)
+ {
+ /* send current DL rules to modem */
+ install_wan_filtering_rule(false);
+ softwarerouting_act = false;
+ }
+ else
+ {
+ handle_software_routing_disable();
+ }
break;
case IPA_FIREWALL_CHANGE_EVENT:
@@ -717,13 +740,13 @@
{
del_wan_firewall_rule(IPA_IP_v4);
config_wan_firewall_rule(IPA_IP_v4);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
else if(ip_type == IPA_IP_v6)
{
del_wan_firewall_rule(IPA_IP_v6);
config_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
else if(ip_type == IPA_IP_MAX)
{
@@ -732,7 +755,7 @@
del_wan_firewall_rule(IPA_IP_v6);
config_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
else
{
@@ -1031,7 +1054,7 @@
if(m_is_sta_mode == Q6_WAN)
{
config_wan_firewall_rule(IPA_IP_v4);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
else
{
@@ -1064,7 +1087,7 @@
if(m_is_sta_mode == Q6_WAN)
{
config_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
else
{
@@ -2497,7 +2520,7 @@
res = IPACM_FAILURE;
goto fail;
}
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
fail:
return res;
@@ -3522,7 +3545,7 @@
{
IPACM_Wan::wan_up = 0;
del_wan_firewall_rule(IPA_IP_v4);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v4);
}
@@ -3532,7 +3555,7 @@
IPACMDBG_H("Now the number of modem ipv4 interface is 0, delete default flt rules.\n");
IPACM_Wan::num_v4_flt_rule = 0;
memset(IPACM_Wan::flt_rule_v4, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)
@@ -3551,7 +3574,7 @@
{
IPACM_Wan::wan_up_v6 = 0;
del_wan_firewall_rule(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
handle_route_del_evt_ex(IPA_IP_v6);
}
@@ -3561,7 +3584,7 @@
IPACMDBG_H("Now the number of modem ipv6 interface is 0, delete default flt rules.\n");
IPACM_Wan::num_v6_flt_rule = 0;
memset(IPACM_Wan::flt_rule_v6, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
for (i = 0; i < 2*num_dft_rt_v6; i++)
@@ -3591,7 +3614,7 @@
del_wan_firewall_rule(IPA_IP_v6);
handle_route_del_evt_ex(IPA_IP_v6);
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
/* only when the last ipv4 modem interface goes down, delete ipv4 default flt rules*/
@@ -3600,7 +3623,7 @@
IPACMDBG_H("Now the number of modem ipv4 interface is 0, delete default flt rules.\n");
IPACM_Wan::num_v4_flt_rule = 0;
memset(IPACM_Wan::flt_rule_v4, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
/* only when the last ipv6 modem interface goes down, delete ipv6 default flt rules*/
if(num_ipv6_modem_pdn == 0)
@@ -3608,7 +3631,7 @@
IPACMDBG_H("Now the number of modem ipv6 interface is 0, delete default flt rules.\n");
IPACM_Wan::num_v6_flt_rule = 0;
memset(IPACM_Wan::flt_rule_v6, 0, IPA_MAX_FLT_RULE * sizeof(struct ipa_flt_rule_add));
- install_wan_filtering_rule();
+ install_wan_filtering_rule(false);
}
if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)
@@ -3687,7 +3710,7 @@
return res;
}
-int IPACM_Wan::install_wan_filtering_rule()
+int IPACM_Wan::install_wan_filtering_rule(bool is_sw_routing)
{
int len, res = IPACM_SUCCESS;
uint8_t mux_id;
@@ -3700,13 +3723,27 @@
IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
return IPACM_SUCCESS;
}
-
- if(IPACM_Wan::num_v4_flt_rule > 0)
+ if (is_sw_routing == true ||
+ IPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true)
{
- len = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v4_flt_rule * sizeof(struct ipa_flt_rule_add);
- pFilteringTable_v4 = (struct ipa_ioc_add_flt_rule*)malloc(len);
+ /* contruct SW-RT rules to Q6*/
+ struct ipa_flt_rule_add flt_rule_entry;
+ struct ipa_ioc_get_rt_tbl_indx rt_tbl_idx;
+ ipa_ioc_generate_flt_eq flt_eq;
- IPACMDBG_H("Total number of WAN DL filtering rule for IPv4 is %d\n", IPACM_Wan::num_v4_flt_rule);
+ IPACMDBG("\n");
+ if (softwarerouting_act == true)
+ {
+ IPACMDBG("already setup software_routing rule for (%s)iface ip-family %d\n",
+ IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ip_type);
+ return IPACM_SUCCESS;
+ }
+
+ len = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);
+ pFilteringTable_v4 = (struct ipa_ioc_add_flt_rule*)malloc(len);
+ memset(pFilteringTable_v4, 0, len);
+
+ IPACMDBG_H("Total number of WAN DL filtering rule for IPv4 is 1\n");
if (pFilteringTable_v4 == NULL)
{
@@ -3717,17 +3754,52 @@
pFilteringTable_v4->ep = rx_prop->rx[0].src_pipe;
pFilteringTable_v4->global = false;
pFilteringTable_v4->ip = IPA_IP_v4;
- pFilteringTable_v4->num_rules = (uint8_t)IPACM_Wan::num_v4_flt_rule;
+ pFilteringTable_v4->num_rules = (uint8_t)1;
- memcpy(pFilteringTable_v4->rules, IPACM_Wan::flt_rule_v4, IPACM_Wan::num_v4_flt_rule * sizeof(ipa_flt_rule_add));
- }
+ /* Configuring Software-Routing Filtering Rule */
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
+ memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
+ strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.ip = IPA_IP_v4;
+ if(ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx) < 0)
+ {
+ IPACMERR("Failed to get routing table index from name\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ IPACMDBG_H("Routing table %s has index %d\n", rt_tbl_idx.name, rt_tbl_idx.idx);
- if(IPACM_Wan::num_v6_flt_rule > 0)
- {
- len = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v6_flt_rule * sizeof(struct ipa_flt_rule_add);
+ flt_rule_entry.at_rear = false;
+ flt_rule_entry.flt_rule_hdl = -1;
+ flt_rule_entry.status = -1;
+ flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
+ flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;
+
+ memcpy(&flt_rule_entry.rule.attrib,
+ &rx_prop->rx[0].attrib,
+ sizeof(flt_rule_entry.rule.attrib));
+ flt_rule_entry.rule.retain_hdr = 0;
+ flt_rule_entry.rule.to_uc = 0;
+ flt_rule_entry.rule.eq_attrib_type = 1;
+
+ memset(&flt_eq, 0, sizeof(flt_eq));
+ memcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));
+ flt_eq.ip = IPA_IP_v4;
+ if(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))
+ {
+ IPACMERR("Failed to get eq_attrib\n");
+ return IPACM_FAILURE;
+ }
+ memcpy(&flt_rule_entry.rule.eq_attrib,
+ &flt_eq.eq_attrib,
+ sizeof(flt_rule_entry.rule.eq_attrib));
+ memcpy(&(pFilteringTable_v4->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+
+ len = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);
pFilteringTable_v6 = (struct ipa_ioc_add_flt_rule*)malloc(len);
+ memset(pFilteringTable_v6, 0, len);
- IPACMDBG_H("Total number of WAN DL filtering rule for IPv6 is %d\n", IPACM_Wan::num_v6_flt_rule);
+ IPACMDBG_H("Total number of WAN DL filtering rule for IPv6 is 1\n");
if (pFilteringTable_v6 == NULL)
{
@@ -3739,9 +3811,92 @@
pFilteringTable_v6->ep = rx_prop->rx[0].src_pipe;
pFilteringTable_v6->global = false;
pFilteringTable_v6->ip = IPA_IP_v6;
- pFilteringTable_v6->num_rules = (uint8_t)IPACM_Wan::num_v6_flt_rule;
+ pFilteringTable_v6->num_rules = (uint8_t)1;
- memcpy(pFilteringTable_v6->rules, IPACM_Wan::flt_rule_v6, IPACM_Wan::num_v6_flt_rule * sizeof(ipa_flt_rule_add));
+ /* Configuring Software-Routing Filtering Rule */
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
+ memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx));
+ strncpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX);
+ rt_tbl_idx.ip = IPA_IP_v6;
+ if(ioctl(m_fd_ipa, IPA_IOC_QUERY_RT_TBL_INDEX, &rt_tbl_idx) < 0)
+ {
+ IPACMERR("Failed to get routing table index from name\n");
+ free(pFilteringTable_v4);
+ return IPACM_FAILURE;
+ }
+ IPACMDBG_H("Routing table %s has index %d\n", rt_tbl_idx.name, rt_tbl_idx.idx);
+
+ flt_rule_entry.at_rear = false;
+ flt_rule_entry.flt_rule_hdl = -1;
+ flt_rule_entry.status = -1;
+ flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
+ flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx;
+ memcpy(&flt_rule_entry.rule.attrib,
+ &rx_prop->rx[0].attrib,
+ sizeof(flt_rule_entry.rule.attrib));
+ flt_rule_entry.rule.retain_hdr = 0;
+ flt_rule_entry.rule.to_uc = 0;
+ flt_rule_entry.rule.eq_attrib_type = 1;
+
+ memset(&flt_eq, 0, sizeof(flt_eq));
+ memcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));
+ flt_eq.ip = IPA_IP_v6;
+ if(0 != ioctl(m_fd_ipa, IPA_IOC_GENERATE_FLT_EQ, &flt_eq))
+ {
+ IPACMERR("Failed to get eq_attrib\n");
+ return IPACM_FAILURE;
+ }
+ memcpy(&flt_rule_entry.rule.eq_attrib,
+ &flt_eq.eq_attrib,
+ sizeof(flt_rule_entry.rule.eq_attrib));
+ memcpy(&(pFilteringTable_v6->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+ softwarerouting_act = true;
+ /* end of contruct SW-RT rules to Q6*/
+ }
+ else
+ {
+ if(IPACM_Wan::num_v4_flt_rule > 0)
+ {
+ len = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v4_flt_rule * sizeof(struct ipa_flt_rule_add);
+ pFilteringTable_v4 = (struct ipa_ioc_add_flt_rule*)malloc(len);
+
+ IPACMDBG_H("Total number of WAN DL filtering rule for IPv4 is %d\n", IPACM_Wan::num_v4_flt_rule);
+
+ if (pFilteringTable_v4 == NULL)
+ {
+ IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
+ return IPACM_FAILURE;
+ }
+ pFilteringTable_v4->commit = 1;
+ pFilteringTable_v4->ep = rx_prop->rx[0].src_pipe;
+ pFilteringTable_v4->global = false;
+ pFilteringTable_v4->ip = IPA_IP_v4;
+ pFilteringTable_v4->num_rules = (uint8_t)IPACM_Wan::num_v4_flt_rule;
+
+ memcpy(pFilteringTable_v4->rules, IPACM_Wan::flt_rule_v4, IPACM_Wan::num_v4_flt_rule * sizeof(ipa_flt_rule_add));
+ }
+
+ if(IPACM_Wan::num_v6_flt_rule > 0)
+ {
+ len = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v6_flt_rule * sizeof(struct ipa_flt_rule_add);
+ pFilteringTable_v6 = (struct ipa_ioc_add_flt_rule*)malloc(len);
+
+ IPACMDBG_H("Total number of WAN DL filtering rule for IPv6 is %d\n", IPACM_Wan::num_v6_flt_rule);
+
+ if (pFilteringTable_v6 == NULL)
+ {
+ IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
+ free(pFilteringTable_v4);
+ return IPACM_FAILURE;
+ }
+ pFilteringTable_v6->commit = 1;
+ pFilteringTable_v6->ep = rx_prop->rx[0].src_pipe;
+ pFilteringTable_v6->global = false;
+ pFilteringTable_v6->ip = IPA_IP_v6;
+ pFilteringTable_v6->num_rules = (uint8_t)IPACM_Wan::num_v6_flt_rule;
+
+ memcpy(pFilteringTable_v6->rules, IPACM_Wan::flt_rule_v6, IPACM_Wan::num_v6_flt_rule * sizeof(ipa_flt_rule_add));
+ }
}
if(false == m_filtering.AddWanDLFilteringRule(pFilteringTable_v4, pFilteringTable_v6, mux_id))
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index 5cbcc4c..2ed10c6 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -48,6 +48,8 @@
#include <IPACM_Wan.h>
#include <IPACM_Lan.h>
#include <IPACM_IfaceManager.h>
+#include <IPACM_ConntrackListener.h>
+
/* static member to store the number of total wifi clients within all APs*/
int IPACM_Wlan::total_num_wifi_clients = 0;
@@ -285,6 +287,13 @@
}
IPACMDBG_H("posting IPA_HANDLE_WLAN_UP:Finished checking wan_up\n");
+ /* checking if SW-RT_enable */
+ if (IPACM_Iface::ipacmcfg->ipa_sw_rt_enable == true)
+ {
+ /* handle software routing enable event*/
+ IPACMDBG_H("IPA_SW_ROUTING_ENABLE for iface: %s \n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);
+ handle_software_routing_enable();
+ }
}
}
}
@@ -496,7 +505,9 @@
handle_wlan_client_route_rule(data->mac_addr, data->iptype);
if (data->iptype == IPA_IP_v4)
{
- Nat_App->ResetPwrSaveIf(data->ipv4_addr);
+ /* Add NAT rules after ipv4 RT rules are set */
+ CtList->HandleNeighIpAddrAddEvt(data);
+// Nat_App->ResetPwrSaveIf(data->ipv4_addr);
}
}
}
@@ -1407,6 +1418,8 @@
else
{
IPACMDBG_H("ipv4 addr for client:%d is changed \n", clnt_indx);
+ /* delete NAT rules first */
+ CtList->HandleNeighIpAddrDelEvt(get_client_memptr(wlan_client, clnt_indx)->v4_addr);
delete_default_qos_rtrules(clnt_indx,IPA_IP_v4);
get_client_memptr(wlan_client, clnt_indx)->route_rule_set_v4 = false;
get_client_memptr(wlan_client, clnt_indx)->v4_addr = data->ipv4_addr;
@@ -1721,19 +1734,19 @@
/* First reset nat rules and then route rules */
if(get_client_memptr(wlan_client, clt_indx)->ipv4_set == true)
{
- IPACMDBG_H("Deleting Nat Rules\n");
- Nat_App->UpdatePwrSaveIf(get_client_memptr(wlan_client, clt_indx)->v4_addr);
+ IPACMDBG_H("Clean Nat Rules for ipv4:0x%x\n", get_client_memptr(wlan_client, clt_indx)->v4_addr);
+ CtList->HandleNeighIpAddrDelEvt(get_client_memptr(wlan_client, clt_indx)->v4_addr);
}
if (delete_default_qos_rtrules(clt_indx, IPA_IP_v4))
{
- IPACMERR("unbale to delete v4 default qos route rules\n");
+ IPACMERR("unbale to delete v4 default qos route rules for index: %d\n", clt_indx);
return IPACM_FAILURE;
}
if (delete_default_qos_rtrules(clt_indx, IPA_IP_v6))
{
- IPACMERR("unbale to delete v6 default qos route rules\n");
+ IPACMERR("unbale to delete v6 default qos route rules for indexn: %d\n", clt_indx);
return IPACM_FAILURE;
}
@@ -1996,8 +2009,26 @@
for (i = 0; i < num_wifi_client; i++)
{
- delete_default_qos_rtrules(i, IPA_IP_v4);
- delete_default_qos_rtrules(i, IPA_IP_v6);
+ /* First reset nat rules and then route rules */
+ if(get_client_memptr(wlan_client, i)->ipv4_set == true)
+ {
+ IPACMDBG_H("Clean Nat Rules for ipv4:0x%x\n", get_client_memptr(wlan_client, i)->v4_addr);
+ CtList->HandleNeighIpAddrDelEvt(get_client_memptr(wlan_client, i)->v4_addr);
+ }
+
+ if (delete_default_qos_rtrules(i, IPA_IP_v4))
+ {
+ IPACMERR("unbale to delete v4 default qos route rules for index: %d\n", i);
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+
+ if (delete_default_qos_rtrules(i, IPA_IP_v6))
+ {
+ IPACMERR("unbale to delete v6 default qos route rules for index: %d\n", i);
+ res = IPACM_FAILURE;
+ goto fail;
+ }
IPACMDBG_H("Delete %d client header\n", num_wifi_client);
diff --git a/ipanat/inc/ipa_nat_drvi.h b/ipanat/inc/ipa_nat_drvi.h
index d92d262..4c9f5f3 100644
--- a/ipanat/inc/ipa_nat_drvi.h
+++ b/ipanat/inc/ipa_nat_drvi.h
@@ -461,6 +461,8 @@
del_type *rule_pos);
void ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx);
+uint16_t Read16BitFieldValue(uint32_t param,
+ ipa_nat_rule_field_type fld_type);
/* ========================================================
Debug functions
diff --git a/ipanat/test/Android.mk b/ipanat/test/Android.mk
new file mode 100644
index 0000000..c5336e4
--- /dev/null
+++ b/ipanat/test/Android.mk
@@ -0,0 +1,49 @@
+ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
+ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH)))
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ipanat/inc
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+LOCAL_MODULE := ipa_nat_test
+LOCAL_SRC_FILES := ipa_nat_test000.c \
+ ipa_nat_test001.c \
+ ipa_nat_test002.c \
+ ipa_nat_test003.c \
+ ipa_nat_test004.c \
+ ipa_nat_test005.c \
+ ipa_nat_test006.c \
+ ipa_nat_test007.c \
+ ipa_nat_test008.c \
+ ipa_nat_test009.c \
+ ipa_nat_test010.c \
+ ipa_nat_test011.c \
+ ipa_nat_test012.c \
+ ipa_nat_test013.c \
+ ipa_nat_test014.c \
+ ipa_nat_test015.c \
+ ipa_nat_test016.c \
+ ipa_nat_test017.c \
+ ipa_nat_test018.c \
+ ipa_nat_test019.c \
+ ipa_nat_test020.c \
+ ipa_nat_test021.c \
+ ipa_nat_test022.c \
+ main.c
+
+
+LOCAL_SHARED_LIBRARIES := libipanat
+
+LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/kernel-tests/ip_accelerator
+
+include $(BUILD_EXECUTABLE)
+
+endif # $(TARGET_ARCH)
+endif
diff --git a/ipanat/test/Makefile.am b/ipanat/test/Makefile.am
new file mode 100644
index 0000000..3aec070
--- /dev/null
+++ b/ipanat/test/Makefile.am
@@ -0,0 +1,42 @@
+AM_CPPFLAGS = -I./../inc \
+ -I$(top_srcdir)/ipanat/inc
+
+AM_CPPFLAGS += -Wall -Wundef -Wno-trigraphs
+AM_CPPFLAGS += -g
+
+ipanattest_SOURCES = ipa_nat_test000.c \
+ ipa_nat_test001.c \
+ ipa_nat_test002.c \
+ ipa_nat_test003.c \
+ ipa_nat_test004.c \
+ ipa_nat_test005.c \
+ ipa_nat_test006.c \
+ ipa_nat_test007.c \
+ ipa_nat_test008.c \
+ ipa_nat_test009.c \
+ ipa_nat_test010.c \
+ ipa_nat_test011.c \
+ ipa_nat_test012.c \
+ ipa_nat_test013.c \
+ ipa_nat_test014.c \
+ ipa_nat_test015.c \
+ ipa_nat_test016.c \
+ ipa_nat_test017.c \
+ ipa_nat_test018.c \
+ ipa_nat_test019.c \
+ ipa_nat_test020.c \
+ ipa_nat_test021.c \
+ ipa_nat_test022.c \
+ main.c
+
+
+bin_PROGRAMS = ipanattest
+
+requiredlibs = ../src/libipanat.la
+
+ipanattest_LDADD = $(requiredlibs)
+
+LOCAL_MODULE := libipanat
+LOCAL_PRELINK_MODULE := false
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/ipanat/test/README.txt b/ipanat/test/README.txt
new file mode 100644
index 0000000..4e87121
--- /dev/null
+++ b/ipanat/test/README.txt
@@ -0,0 +1,18 @@
+1 To run this suite separately(each test case creates table and delete table) use below command
+ - To execute test suite nt times with n entries, command "ipanatest sep nt n"
+
+ Example: To execute test suite 1 time with 100 entries, command "ipanattest sep 100"
+
+
+2. To run test suite not separately(creates table and delete table only once) use below command
+ - To execute test suite nt times with n entries, command "ipanatest reg nt n"
+
+ Example: To execute test suite 5 times with 32 entries, command "ipanattest reg 5 32"
+
+
+3. To run inotify regression test use command, "ipanattest inotify nt"
+
+ Example: To execute inotify 5 times, command "ipanattest inotify 5"
+
+
+4. if we just give command "ipanattest", runs test suite 1 time with 100 entries (non separate)
diff --git a/ipanat/test/ipa_nat_test.h b/ipanat/test/ipa_nat_test.h
new file mode 100644
index 0000000..d5ac0d5
--- /dev/null
+++ b/ipanat/test/ipa_nat_test.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*===========================================================================
+
+ INCLUDE FILES FOR MODULE
+
+===========================================================================*/
+#include "stdint.h" /* uint32_t */
+#include "stdio.h"
+#include <netinet/in.h> /* for proto definitions */
+
+#define u32 uint32_t
+#define u16 uint16_t
+#define u8 uint8_t
+
+/*============ Preconditions to run NAT Test cases =========*/
+#define IPA_NAT_TEST_PRE_COND_TE 20
+
+#define CHECK_ERR1(x, tbl_hdl) \
+ if(ipa_nat_validate_ipv4_table(tbl_hdl)) { \
+ if(sep) {\
+ ipa_nat_del_ipv4_tbl(tbl_hdl); \
+ }\
+ return -1;\
+ }\
+ if(x) { \
+ IPAERR("%d\n", ret); \
+ if(sep) {\
+ ipa_nat_del_ipv4_tbl(tbl_hdl); \
+ }\
+ return -1; \
+ }
+
+#define CHECK_ERR(x) if(x) { \
+ IPAERR("%d\n", ret); \
+ return -1;\
+ }
+
+#if 0
+#define CHECK_ERR(x) if(x) { \
+ IPAERR("%d\n", ret); \
+ if(sep) {\
+ ipa_nat_del_ipv4_tbl(tbl_hdl); \
+ }\
+ return -1;\
+ }
+#endif
+
+#define IPADBG(fmt, args...) printf(" %s:%d " fmt, __FUNCTION__, __LINE__, ## args)
+#define IPAERR(fmt, args...) printf(" %s:%d " fmt, __FUNCTION__, __LINE__, ## args)
+
+#define NAT_DUMP
+int ipa_nat_validate_ipv4_table(u32);
+
+int ipa_nat_test000(int, u32, u8);
+int ipa_nat_test001(int, u32, u8);
+int ipa_nat_test002(int, u32, u8);
+int ipa_nat_test003(int, u32, u8);
+int ipa_nat_test004(int, u32, u8);
+int ipa_nat_test005(int, u32, u8);
+int ipa_nat_test006(int, u32, u8);
+int ipa_nat_test007(int, u32, u8);
+int ipa_nat_test008(int, u32, u8);
+int ipa_nat_test009(int, u32, u8);
+int ipa_nat_test010(int, u32, u8);
+int ipa_nat_test011(int, u32, u8);
+int ipa_nat_test012(int, u32, u8);
+int ipa_nat_test013(int, u32, u8);
+int ipa_nat_test014(int, u32, u8);
+int ipa_nat_test015(int, u32, u8);
+int ipa_nat_test016(int, u32, u8);
+int ipa_nat_test017(int, u32, u8);
+int ipa_nat_test018(int, u32, u8);
+int ipa_nat_test019(int, u32, u8);
+int ipa_nat_test020(int, u32, u8);
+int ipa_nat_test021(int, int);
+int ipa_nat_test022(int, u32, u8);
diff --git a/ipanat/test/ipa_nat_test000.c b/ipanat/test/ipa_nat_test000.c
new file mode 100644
index 0000000..09914ea
--- /dev/null
+++ b/ipanat/test/ipa_nat_test000.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test000.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Delete ipv4 table
+*/
+/*===========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test000(int total_entries, u32 tbl_hdl, u8 sep)
+{
+
+ int ret;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("unable to create ipv4 nat table and returning Error:%d\n", ret);
+ return -1;
+ }
+ IPADBG("create nat ipv4 table successfully() \n");
+
+ IPADBG("calling ipa_nat_del_ipv4_tbl() \n");
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("Unable to delete ipv4 nat table %d\n", ret);
+ return -1;
+ }
+ IPADBG("deleted ipv4 nat table successfully. Test passed \n");
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test001.c b/ipanat/test/ipa_nat_test001.c
new file mode 100644
index 0000000..8daef33
--- /dev/null
+++ b/ipanat/test/ipa_nat_test001.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test001.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. Delete ipv4 table
+*/
+/*===========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test001(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s()\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test002.c b/ipanat/test/ipa_nat_test002.c
new file mode 100644
index 0000000..e6f5ae3
--- /dev/null
+++ b/ipanat/test/ipa_nat_test002.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test002.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. delete ipv4 rule
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test002(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s()\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test003.c b/ipanat/test/ipa_nat_test003.c
new file mode 100644
index 0000000..0634265
--- /dev/null
+++ b/ipanat/test/ipa_nat_test003.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ IPA_NAT_ipa_nat_test003.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. Add ipv4 rule
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test003(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test004.c b/ipanat/test/ipa_nat_test004.c
new file mode 100644
index 0000000..02378ff
--- /dev/null
+++ b/ipanat/test/ipa_nat_test004.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test004.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Query nat table handle
+ 3. Delete ipv4 table
+*/
+/*===========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test004(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret = 0;
+ u32 tbl_hdl1 = 0;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl1);
+ if(ret == 0)
+ {
+ IPAERR("able to delete table using invalid table handle\n");
+ return -1;
+ }
+ }
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test005.c b/ipanat/test/ipa_nat_test005.c
new file mode 100644
index 0000000..12228d1
--- /dev/null
+++ b/ipanat/test/ipa_nat_test005.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test005.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Add ipv4 rule
+ 3. Delete ipv4 rule
+ 4. Add ipv4 rule
+ 5. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test005(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret = 0;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ if (sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test006.c b/ipanat/test/ipa_nat_test006.c
new file mode 100644
index 0000000..36f0171
--- /dev/null
+++ b/ipanat/test/ipa_nat_test006.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test006.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same ipv rules
+ 3. delete first followed by second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test006(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret=0;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test007.c b/ipanat/test/ipa_nat_test007.c
new file mode 100644
index 0000000..4160c02
--- /dev/null
+++ b/ipanat/test/ipa_nat_test007.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test007.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same ipv rules
+ 3. delete second followed by first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test007(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test008.c b/ipanat/test/ipa_nat_test008.c
new file mode 100644
index 0000000..d016055
--- /dev/null
+++ b/ipanat/test/ipa_nat_test008.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test008.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 2 distinct rules
+ 3. delete first followed by second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test008(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+ ipv4_rule1.target_ip = 0xC1171602; /* 193.23.22.2 */
+ ipv4_rule1.target_port = 1234;
+ ipv4_rule1.private_ip = 0xC2171602; /* 194.23.22.2 */
+ ipv4_rule1.private_port = 5678;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test009.c b/ipanat/test/ipa_nat_test009.c
new file mode 100644
index 0000000..cf3c40f
--- /dev/null
+++ b/ipanat/test/ipa_nat_test009.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test009.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 2 distinct rules
+ 3. delete second followed by first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test009(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xC1171602; /* 193.23.22.2 */
+ ipv4_rule1.target_port = 1234;
+ ipv4_rule1.private_ip = 0xC2171602; /* 194.23.22.2 */
+ ipv4_rule1.private_port = 5678;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test010.c b/ipanat/test/ipa_nat_test010.c
new file mode 100644
index 0000000..42d7fee
--- /dev/null
+++ b/ipanat/test/ipa_nat_test010.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test010.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. delete first, second followed by last
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test010(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule1.target_port = 1235;
+ ipv4_rule1.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule1.private_port = 5679;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9051;
+
+ ipv4_rule2.target_ip = 0xC1171602; /* 193.23.22.2 */
+ ipv4_rule2.target_port = 1235;
+ ipv4_rule2.private_ip = 0xC2171602; /* 194.23.22.2 */
+ ipv4_rule2.private_port = 5679;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 9051;
+
+ IPADBG("%s():\n",__FUNCTION__);
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test011.c b/ipanat/test/ipa_nat_test011.c
new file mode 100644
index 0000000..bcce76c
--- /dev/null
+++ b/ipanat/test/ipa_nat_test011.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test011.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. delete second, first followed by last
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test011(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xF1181601;
+ ipv4_rule1.target_port = 1555;
+ ipv4_rule1.private_ip = 0xF2151601;
+ ipv4_rule1.private_port = 5999;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 9111;
+
+ ipv4_rule2.target_ip = 0xC1166602;
+ ipv4_rule2.target_port = 1555;
+ ipv4_rule2.private_ip = 0xC2155602;
+ ipv4_rule2.private_port = 5777;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 9000;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test012.c b/ipanat/test/ipa_nat_test012.c
new file mode 100644
index 0000000..9d3c835
--- /dev/null
+++ b/ipanat/test/ipa_nat_test012.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test012.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. Delete third, second, first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+
+int ipa_nat_test012(int totoal_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xD1171601;
+ ipv4_rule1.target_port = 3512;
+ ipv4_rule1.private_ip = 0xD2471601;
+ ipv4_rule1.private_port = 9997;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 8881;
+
+ ipv4_rule2.target_ip = 0xC1172452;
+ ipv4_rule2.target_port = 1895;
+ ipv4_rule2.private_ip = 0xC2172452;
+ ipv4_rule2.private_port = 6668;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 5551;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, totoal_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test013.c b/ipanat/test/ipa_nat_test013.c
new file mode 100644
index 0000000..2b9b005
--- /dev/null
+++ b/ipanat/test/ipa_nat_test013.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test013.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add 3 distinct ipv4 rules
+ 3. Delete third, first and second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test013(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl, rule_hdl1, rule_hdl2;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule1, ipv4_rule2;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ ipv4_rule1.target_ip = 0xC1171609; /* 193.23.22.9 */
+ ipv4_rule1.target_port = 1235;
+ ipv4_rule1.private_ip = 0xC2171609; /* 194.23.22.9 */
+ ipv4_rule1.private_port = 6579;
+ ipv4_rule1.protocol = IPPROTO_TCP;
+ ipv4_rule1.public_port = 8951;
+
+ ipv4_rule2.target_ip = 0xC1171606; /* 193.23.22.6 */
+ ipv4_rule2.target_port = 1235;
+ ipv4_rule2.private_ip = 0xC2171606; /* 194.23.22.6 */
+ ipv4_rule2.private_port = 7956;
+ ipv4_rule2.protocol = IPPROTO_TCP;
+ ipv4_rule2.public_port = 5109;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule1, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test014.c b/ipanat/test/ipa_nat_test014.c
new file mode 100644
index 0000000..fd30317
--- /dev/null
+++ b/ipanat/test/ipa_nat_test014.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test014.cpp
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete first, second and third
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test014(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s()\n", __FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test015.c b/ipanat/test/ipa_nat_test015.c
new file mode 100644
index 0000000..eaef923
--- /dev/null
+++ b/ipanat/test/ipa_nat_test015.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test015.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete first, third and second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+
+int ipa_nat_test015(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test016.c b/ipanat/test/ipa_nat_test016.c
new file mode 100644
index 0000000..23157e2
--- /dev/null
+++ b/ipanat/test/ipa_nat_test016.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test016.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete second, first and third
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test016(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test017.c b/ipanat/test/ipa_nat_test017.c
new file mode 100644
index 0000000..d88e611
--- /dev/null
+++ b/ipanat/test/ipa_nat_test017.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test017.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete second, third and first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test017(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test018.c b/ipanat/test/ipa_nat_test018.c
new file mode 100644
index 0000000..c885d4d
--- /dev/null
+++ b/ipanat/test/ipa_nat_test018.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test018.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete third, second and first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test018(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test019.c b/ipanat/test/ipa_nat_test019.c
new file mode 100644
index 0000000..3ba3119
--- /dev/null
+++ b/ipanat/test/ipa_nat_test019.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test019.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete third, first and second
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test019(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test020.c b/ipanat/test/ipa_nat_test020.c
new file mode 100644
index 0000000..e6871b5
--- /dev/null
+++ b/ipanat/test/ipa_nat_test020.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test020.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 4 ipv rules
+ 3. delete third, second, fourth and first
+ 4. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test020(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3, rule_hdl4;
+ ipa_nat_ipv4_rule ipv4_rule;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl4);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl2);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl4);
+ CHECK_ERR(ret);
+
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR(ret);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test021.c b/ipanat/test/ipa_nat_test021.c
new file mode 100644
index 0000000..48c4321
--- /dev/null
+++ b/ipanat/test/ipa_nat_test021.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test021.c
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test021(int total_entries, int reg)
+{
+
+ int ret, i;
+ u32 tbl_hdl;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ for(i=0; i<reg; i++)
+ {
+ IPADBG("executing %d th time:\n",i);
+
+ IPADBG("calling ipa_nat_add_ipv4_tbl() \n");
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("unable to create ipv4 nat table and returning Error:%d\n", ret);
+ IPADBG("executed %d times:\n",i);
+ return -1;
+ }
+ IPADBG("create nat ipv4 table successfully() \n");
+
+ IPADBG("calling ipa_nat_del_ipv4_tbl() \n");
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ if (0 != ret)
+ {
+ IPAERR("Unable to delete ipv4 nat table %d\n", ret);
+ IPADBG("executed %d times:\n",i);
+ return -1;
+ }
+ IPADBG("deleted ipv4 nat table successfully. Test passed \n");
+ }
+
+ IPADBG("executed %d times:\n",(i+1));
+ return 0;
+}
diff --git a/ipanat/test/ipa_nat_test022.c b/ipanat/test/ipa_nat_test022.c
new file mode 100644
index 0000000..ebdd291
--- /dev/null
+++ b/ipanat/test/ipa_nat_test022.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*=========================================================================*/
+/*!
+ @file
+ ipa_nat_test022.cpp
+
+ @brief
+ Verify the following scenario:
+ 1. Add ipv4 table
+ 2. add same 3 ipv rules
+ 3. delete Head and last entry
+ 4. add 2 new same ip4 entries
+ 5. Add head entry again
+ 6. Delete ipv4 table
+*/
+/*=========================================================================*/
+
+#include "ipa_nat_test.h"
+#include "ipa_nat_drv.h"
+
+int ipa_nat_test022(int total_entries, u32 tbl_hdl, u8 sep)
+{
+ int ret;
+ u32 rule_hdl1, rule_hdl2, rule_hdl3;
+ ipa_nat_ipv4_rule ipv4_rule, ipv4_rule2;
+ u32 rule_hdl21, rule_hdl22;
+
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ /* Rule 1 */
+ ipv4_rule.target_ip = 0xC1171601; /* 193.23.22.1 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171601; /* 194.23.22.1 */
+ ipv4_rule.private_port = 5678;
+ ipv4_rule.protocol = IPPROTO_TCP;
+ ipv4_rule.public_port = 9050;
+
+ /* Rule 2*/
+ ipv4_rule.target_ip = 0xC1171604; /* 193.23.22.4 */
+ ipv4_rule.target_port = 1234;
+ ipv4_rule.private_ip = 0xC2171603; /* 194.23.22.3 */
+ ipv4_rule.private_port = 5680;
+ ipv4_rule.protocol = IPPROTO_UDP;
+ ipv4_rule.public_port = 9066;
+
+ IPADBG("%s():\n",__FUNCTION__);
+
+ if(sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR1(ret, tbl_hdl);
+ }
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl1);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl2);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Delete head entry */
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl1);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Delete Last Entry */
+ ret = ipa_nat_del_ipv4_rule(tbl_hdl, rule_hdl3);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Add 2 different Entries */
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl21);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule2, &rule_hdl22);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ /* Add first entry again */
+ ret = ipa_nat_add_ipv4_rule(tbl_hdl, &ipv4_rule, &rule_hdl3);
+ CHECK_ERR1(ret, tbl_hdl);
+
+ if(sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR1(ret, tbl_hdl);
+ }
+
+ return 0;
+}
diff --git a/ipanat/test/main.c b/ipanat/test/main.c
new file mode 100644
index 0000000..c49ce3b
--- /dev/null
+++ b/ipanat/test/main.c
@@ -0,0 +1,640 @@
+/*
+ * Copyright (c) 2014, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "ipa_nat_drv.h"
+#include "ipa_nat_drvi.h"
+#include "ipa_nat_test.h"
+
+extern struct ipa_nat_cache ipv4_nat_cache;
+
+int chk_for_loop(u32 tbl_hdl)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ int cnt;
+ uint16_t cur_entry;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
+ IPAERR("invalid table handle passed \n");
+ return -EINVAL;
+ }
+
+ IPADBG("checking ipv4 rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,ENABLE_FIELD)) {
+ if(Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == cnt)
+ {
+ IPAERR("Infinite loop detected, entry\n");
+ ipa_nati_print_rule(&tbl_ptr[cnt], cnt);
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* Print ipv4 expansion rules */
+ IPADBG("checking ipv4 active expansion rules:\n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ cur_entry =
+ cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ if (Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD) == cur_entry)
+ {
+ IPAERR("Infinite loop detected\n");
+ ipa_nati_print_rule(&tbl_ptr[cnt],
+ (cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries));
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* Print ipv4 index rules */
+ IPADBG("checking ipv4 index active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED) == cnt)
+ {
+ IPAERR("Infinite loop detected\n");
+ ipa_nati_print_index_rule(&indx_tbl_ptr[cnt], cnt, 0);
+ return -EINVAL;
+ }
+ }
+ }
+
+ /* Print ipv4 index expansion rules */
+ IPADBG("Checking ipv4 index expansion active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ cur_entry =
+ cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED) == cur_entry)
+ {
+ IPAERR("Infinite loop detected\n");
+ ipa_nati_print_index_rule(&indx_tbl_ptr[cnt],
+ (cnt + ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries),
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].index_expn_table_meta[cnt].prev_index);
+ return -EINVAL;
+ }
+ }
+ }
+ return 0;
+}
+
+uint8_t is_base_entry_valid(u32 tbl_hdl, u16 entry)
+{
+ struct ipa_nat_rule *tbl_ptr;
+
+ if (entry >
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries)
+ {
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;
+ entry -=
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ }
+ else
+ {
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;
+ }
+ return (Read16BitFieldValue(tbl_ptr[entry].ip_cksm_enbl,
+ ENABLE_FIELD));
+}
+
+uint8_t is_index_entry_valid(u32 tbl_hdl, u16 entry)
+{
+ struct ipa_nat_indx_tbl_rule *tbl_ptr;
+
+ if (entry >
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries)
+ {
+ tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;
+ entry -=
+ ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ }
+ else
+ {
+ tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;
+ }
+ if (Read16BitFieldValue(tbl_ptr[entry].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+int chk_for_validity(u32 tbl_hdl)
+{
+ struct ipa_nat_rule *tbl_ptr;
+ struct ipa_nat_indx_tbl_rule *indx_tbl_ptr;
+ uint16_t nxt_index, prv_index;
+ int cnt;
+
+ if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
+ tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
+ IPAERR("invalid table handle passed \n");
+ return -EINVAL;
+ }
+
+ /* Validate base table next_indx and prev_indx values */
+ IPADBG("Validating ipv4 active rules: \n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_rules_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ nxt_index =
+ Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+ if (!is_base_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ IPADBG("Validating ipv4 expansion active rules: \n");
+ tbl_ptr = (struct ipa_nat_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].ipv4_expn_rules_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(tbl_ptr[cnt].ip_cksm_enbl,
+ ENABLE_FIELD)) {
+ /* Validate next index */
+ nxt_index =
+ Read16BitFieldValue(tbl_ptr[cnt].nxt_indx_pub_port,
+ NEXT_INDEX_FIELD);
+ if (!is_base_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+ /* Validate previous index */
+ prv_index =
+ Read16BitFieldValue(tbl_ptr[cnt].sw_spec_params,
+ SW_SPEC_PARAM_PREV_INDEX_FIELD);
+ if (!is_base_entry_valid(tbl_hdl, prv_index)) {
+ IPAERR("Invalid Previous index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ IPADBG("Validating ipv4 index active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_addr;
+ for (cnt = 0;
+ cnt < ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ nxt_index =
+ Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+ if (!is_index_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ IPADBG("Validating ipv4 index expansion active rules: \n");
+ indx_tbl_ptr = (struct ipa_nat_indx_tbl_rule *)
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_table_expn_addr;
+ for (cnt = 0;
+ cnt <= ipv4_nat_cache.ip4_tbl[tbl_hdl - 1].expn_table_entries;
+ cnt++) {
+ if (Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_TBL_ENTRY_FIELD)) {
+ /* Validate next index*/
+ nxt_index =
+ Read16BitFieldValue(indx_tbl_ptr[cnt].tbl_entry_nxt_indx,
+ INDX_TBL_NEXT_INDEX_FILED);
+ if (!is_index_entry_valid(tbl_hdl, nxt_index)) {
+ IPAERR("Invalid next index found, entry:%d\n", cnt);
+ }
+
+ /* Validate previous index*/
+ prv_index =
+ ipv4_nat_cache.ip4_tbl[tbl_hdl-1].index_expn_table_meta[cnt].prev_index;
+
+ if (!is_index_entry_valid(tbl_hdl, prv_index)) {
+ IPAERR("Invalid Previous index found, entry:%d\n", cnt);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int ipa_nat_validate_ipv4_table(u32 tbl_hdl)
+{
+ int ret = 0;
+
+ ret = chk_for_loop(tbl_hdl);
+ if (ret)
+ return ret;
+ ret = chk_for_validity(tbl_hdl);
+
+ return ret;
+}
+
+int main(int argc, char* argv[])
+{
+ int exec = 0, pass = 0, ret;
+ int cnt, nt=1;
+ int total_entries = 100;
+ u8 sep = 0;
+ u32 tbl_hdl = 0;
+ u32 pub_ip_add = 0x011617c0; /* "192.23.22.1" */
+
+ IPADBG("ipa_nat_testing user space nat driver\n");
+
+ if (argc == 4)
+ {
+ if (!strncmp(argv[1], "reg", 3))
+ {
+ nt = atoi(argv[2]);
+ total_entries = atoi(argv[3]);
+ IPADBG("Reg: %d, Nat Entries: %d\n", nt, total_entries);
+ }
+ else if (!strncmp(argv[1], "sep", 3))
+ {
+ sep = 1;
+ nt = atoi(argv[2]);
+ total_entries = atoi(argv[3]);
+ }
+ }
+ else if (argc == 3)
+ {
+ if (!strncmp(argv[1], "inotify", 7))
+ {
+ ipa_nat_test021(total_entries, atoi(argv[2]));
+ return 0;
+ }
+ else if (!strncmp(argv[1], "sep", 3))
+ {
+ sep = 1;
+ total_entries = atoi(argv[2]);
+ }
+ }
+ else if (argc == 2)
+ {
+ total_entries = atoi(argv[1]);
+ IPADBG("Nat Entries: %d\n", total_entries);
+ }
+
+
+ for (cnt=0; cnt<nt; cnt++)
+ {
+ IPADBG("%s():Executing %d time \n",__FUNCTION__, cnt);
+
+ if (!sep)
+ {
+ ret = ipa_nat_add_ipv4_tbl(pub_ip_add, total_entries, &tbl_hdl);
+ CHECK_ERR(ret);
+ }
+
+ if (sep)
+ {
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test000(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test001(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+ }
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test002(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ if (sep)
+ {
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test003(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test004(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test005(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+ }
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test006(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test007(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test008(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test00%d\n", exec);
+ ret = ipa_nat_test009(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test00%d Fail\n", exec);
+ }
+ exec++;
+
+ if (total_entries >= IPA_NAT_TEST_PRE_COND_TE)
+ {
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test010(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test011(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test012(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test013(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test014(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test015(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test016(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test017(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test018(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test019(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test020(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+
+ IPADBG("\n\nExecuting ipa_nat_test0%d\n", exec);
+ ret = ipa_nat_test022(total_entries, tbl_hdl, sep);
+ if (!ret)
+ {
+ pass++;
+ }
+ else
+ {
+ IPAERR("ipa_nat_test0%d Fail\n", exec);
+ }
+ exec++;
+ }
+
+ if (!sep)
+ {
+ ret = ipa_nat_del_ipv4_tbl(tbl_hdl);
+ CHECK_ERR(ret);
+ }
+ }
+ /*======= Printing Results ==========*/
+ IPADBG("Total ipa_nat Tests Run:%d, Pass:%d, Fail:%d\n",exec, pass, exec-pass);
+ return 0;
+}