Initial Commit4

This commit is contained in:
MandySingh3
2017-04-03 03:20:44 +05:30
parent bc8e833c07
commit 7beda1dfbc
214 changed files with 50630 additions and 45 deletions

View File

@@ -0,0 +1,53 @@
BOARD_PLATFORM_LIST := msm8916
BOARD_PLATFORM_LIST += msm8909
ifneq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true)
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
endif

View File

@@ -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)

View File

@@ -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)

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}