Initial Commit4
This commit is contained in:
116
data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drv.h
Normal file
116
data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drv.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Copyright (c) 2013, 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 "string.h" /* memset */
|
||||
#include "stdlib.h" /* free, malloc */
|
||||
#include "stdint.h" /* uint32_t */
|
||||
|
||||
/**
|
||||
* struct ipa_nat_ipv4_rule - To hold ipv4 nat rule
|
||||
* @target_ip: destination ip address
|
||||
* @private_ip: private ip address
|
||||
* @target_port: destination port
|
||||
* @private_port: private port
|
||||
* @protocol: protocol of rule (tcp/udp)
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t target_ip;
|
||||
uint32_t private_ip;
|
||||
uint16_t target_port;
|
||||
uint16_t private_port;
|
||||
uint16_t public_port;
|
||||
uint8_t protocol;
|
||||
} ipa_nat_ipv4_rule;
|
||||
|
||||
/**
|
||||
* ipa_nat_add_ipv4_tbl() - create ipv4 nat table
|
||||
* @public_ip_addr: [in] public ipv4 address
|
||||
* @number_of_entries: [in] number of nat entries
|
||||
* @table_handle: [out] Handle of new ipv4 nat table
|
||||
*
|
||||
* To create new ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_add_ipv4_tbl(uint32_t public_ip_addr,
|
||||
uint16_t number_of_entries,
|
||||
uint32_t *table_handle);
|
||||
|
||||
/**
|
||||
* ipa_nat_del_ipv4_tbl() - delete ipv4 table
|
||||
* @table_handle: [in] Handle of ipv4 nat table
|
||||
*
|
||||
* To delete given ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_del_ipv4_tbl(uint32_t table_handle);
|
||||
|
||||
/**
|
||||
* ipa_nat_add_ipv4_rule() - to insert new ipv4 rule
|
||||
* @table_handle: [in] handle of ipv4 nat table
|
||||
* @rule: [in] Pointer to new rule
|
||||
* @rule_handle: [out] Return the handle to rule
|
||||
*
|
||||
* To insert new ipv4 nat rule into ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_add_ipv4_rule(uint32_t table_handle,
|
||||
const ipa_nat_ipv4_rule * rule,
|
||||
uint32_t *rule_handle);
|
||||
|
||||
/**
|
||||
* ipa_nat_del_ipv4_rule() - to delete ipv4 nat rule
|
||||
* @table_handle: [in] handle of ipv4 nat table
|
||||
* @rule_handle: [in] ipv4 nat rule handle
|
||||
*
|
||||
* To insert new ipv4 nat rule into ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_del_ipv4_rule(uint32_t table_handle,
|
||||
uint32_t rule_handle);
|
||||
|
||||
|
||||
/**
|
||||
* ipa_nat_query_timestamp() - to query timestamp
|
||||
* @table_handle: [in] handle of ipv4 nat table
|
||||
* @rule_handle: [in] ipv4 nat rule handle
|
||||
* @time_stamp: [out] time stamp of rule
|
||||
*
|
||||
* To retrieve the timestamp that lastly the
|
||||
* nat rule was accessed
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_query_timestamp(uint32_t table_handle,
|
||||
uint32_t rule_handle,
|
||||
uint32_t *time_stamp);
|
||||
|
||||
482
data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h
Normal file
482
data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h
Normal file
@@ -0,0 +1,482 @@
|
||||
/*
|
||||
Copyright (c) 2013, 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.
|
||||
*/
|
||||
|
||||
#ifndef IPA_NAT_DRVI_H
|
||||
#define IPA_NAT_DRVI_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <linux/msm_ipa.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "ipa_nat_logi.h"
|
||||
|
||||
#define NAT_DUMP
|
||||
|
||||
/*======= IMPLEMENTATION related data structures and functions ======= */
|
||||
#ifdef IPA_ON_R3PC
|
||||
#define NAT_MMAP_MEM_SIZE (2 * 1024UL * 1024UL - 1)
|
||||
#endif
|
||||
|
||||
#define IPA_DEV_NAME "/dev/ipa"
|
||||
#define NAT_DEV_DIR "/dev"
|
||||
#define NAT_DEV_NAME "ipaNatTable"
|
||||
#define NAT_DEV_FULL_NAME "/dev/ipaNatTable"
|
||||
|
||||
#define IPA_NAT_TABLE_VALID 1
|
||||
#define IPA_NAT_MAX_IP4_TBLS 1
|
||||
#define IPA_NAT_BASE_TABLE_PERCENTAGE .8
|
||||
#define IPA_NAT_EXPANSION_TABLE_PERCENTAGE .2
|
||||
|
||||
#define IPA_NAT_NUM_OF_BASE_TABLES 2
|
||||
#define IPA_NAT_UNUSED_BASE_ENTRIES 2
|
||||
|
||||
#define IPA_NAT_RULE_FLAG_FIELD_OFFSET 18
|
||||
#define IPA_NAT_RULE_NEXT_FIELD_OFFSET 8
|
||||
#define IPA_NAT_RULE_PROTO_FIELD_OFFSET 22
|
||||
|
||||
#define IPA_NAT_INDEX_RULE_NEXT_FIELD_OFFSET 2
|
||||
#define IPA_NAT_INDEX_RULE_NAT_INDEX_FIELD_OFFSET 0
|
||||
|
||||
#define IPA_NAT_RULE_FLAG_FIELD_SIZE 2
|
||||
#define IPA_NAT_RULE_NEXTFIELD_FIELD_SIZE 2
|
||||
|
||||
#define IPA_NAT_FLAG_ENABLE_BIT_MASK 0x8000
|
||||
#define IPA_NAT_FLAG_DISABLE_BIT_MASK 0x0000
|
||||
|
||||
#define IPA_NAT_FLAG_ENABLE_BIT 1
|
||||
#define IPA_NAT_FLAG_DISABLE_BIT 0
|
||||
|
||||
#define IPA_NAT_INVALID_PROTO_FIELD_VALUE 0xFF00
|
||||
#define IPA_NAT_INVALID_PROTO_FIELD_CMP 0xFF
|
||||
|
||||
#define IPA_NAT_INVALID_INDEX 0xFF
|
||||
#define IPA_NAT_INVALID_NAT_ENTRY 0x0
|
||||
|
||||
#define INDX_TBL_ENTRY_SIZE_IN_BITS 16
|
||||
|
||||
/* ----------- Rule id -----------------------
|
||||
|
||||
------------------------------------------------
|
||||
| 3bits | 12 bits | 1 bit |
|
||||
------------------------------------------------
|
||||
| reserved | index into table | 0 - base |
|
||||
| | | 1 - expansion |
|
||||
------------------------------------------------
|
||||
|
||||
*/
|
||||
#define IPA_NAT_RULE_HDL_TBL_TYPE_BITS 0x1
|
||||
#define IPA_NAT_RULE_HDL_TBL_TYPE_MASK 0x1
|
||||
|
||||
/* ----------- sw specif parameter -----
|
||||
------------------------------------
|
||||
| 16 bits | 16 bits |
|
||||
------------------------------------
|
||||
| index table | prev index |
|
||||
| entry | |
|
||||
------------------------------------
|
||||
-----------------------------------------*/
|
||||
#define IPA_NAT_SW_PARAM_PREV_INDX_BYTE 0
|
||||
#define IPA_NAT_SW_PARAM_INDX_TBL_ENTRY_BYTE 1
|
||||
|
||||
typedef enum {
|
||||
IPA_NAT_BASE_TBL = 0,
|
||||
IPA_NAT_EXPN_TBL = 1,
|
||||
IPA_NAT_INDX_TBL = 2,
|
||||
IPA_NAT_INDEX_EXPN_TBL = 3,
|
||||
} nat_table_type;
|
||||
|
||||
typedef enum {
|
||||
NEXT_INDEX_FIELD,
|
||||
PUBLIC_PORT_FILED,
|
||||
PRIVATE_PORT_FIELD,
|
||||
TARGET_PORT_FIELD,
|
||||
IP_CHKSUM_FIELD,
|
||||
ENABLE_FIELD,
|
||||
TIME_STAMP_FIELD,
|
||||
PROTOCOL_FIELD,
|
||||
TCP_UDP_CHKSUM_FIELD,
|
||||
SW_SPEC_PARAM_PREV_INDEX_FIELD,
|
||||
SW_SPEC_PARAM_INDX_TBL_ENTRY_FIELD,
|
||||
INDX_TBL_TBL_ENTRY_FIELD,
|
||||
INDX_TBL_NEXT_INDEX_FILED
|
||||
} ipa_nat_rule_field_type;
|
||||
|
||||
/*
|
||||
---------------------------------------------
|
||||
| 3 | 2 | 1 | 0 |
|
||||
---------------------------------------------
|
||||
| Public Port(2B) | Next Index(2B) |
|
||||
---------------------------------------------
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t next_index:16;
|
||||
uint32_t public_port:16;
|
||||
} next_index_pub_port;
|
||||
|
||||
|
||||
/*
|
||||
---------------------------------------------
|
||||
| 3 | 2 | 1 | 0 |
|
||||
---------------------------------------------
|
||||
| Flags(2B) | IP check sum Diff(2B)|
|
||||
|EN|FIN|Resv | | |
|
||||
---------------------------------------------
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t ip_chksum:16;
|
||||
uint32_t rsvd1:14;
|
||||
uint32_t redirect:1;
|
||||
uint32_t enable:1;
|
||||
} ipcksum_enbl;
|
||||
|
||||
|
||||
/*
|
||||
---------------------------------------
|
||||
| 7 | 6 | 5 | 4 |
|
||||
---------------------------------------
|
||||
| Proto | TimeStamp(3B) |
|
||||
| (1B) | |
|
||||
---------------------------------------
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t time_stamp:24;
|
||||
uint32_t protocol:8;
|
||||
} time_stamp_proto;
|
||||
|
||||
|
||||
/*
|
||||
---------------------------------------------
|
||||
| 3 | 2 | 1 | 0 |
|
||||
---------------------------------------------
|
||||
| next_index | Table entry |
|
||||
----------------------------------------------
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t tbl_entry;
|
||||
uint16_t next_index;
|
||||
} tbl_ent_nxt_indx;
|
||||
|
||||
/*--------------------------------------------------
|
||||
32 bit sw_spec_params is interpreted as follows
|
||||
------------------------------------
|
||||
| 16 bits | 16 bits |
|
||||
------------------------------------
|
||||
| index table | prev index |
|
||||
| entry | |
|
||||
------------------------------------
|
||||
--------------------------------------------------*/
|
||||
typedef struct {
|
||||
uint16_t prev_index;
|
||||
uint16_t index_table_entry;
|
||||
} sw_spec_params;
|
||||
|
||||
/*------------------------ NAT Table Entry ---------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------------
|
||||
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
-----------------------------------------------------------------------------------
|
||||
| Target IP(4B) | Private IP(4B) |
|
||||
-----------------------------------------------------------------------------------
|
||||
|Target Port(2B) | Private Port(2B) | Public Port(2B) | Next Index(2B) |
|
||||
-----------------------------------------------------------------------------------
|
||||
| Proto | TimeStamp(3B) | Flags(2B) | IP check sum Diff(2B)|
|
||||
| (1B) | |EN|FIN|Resv | | |
|
||||
-----------------------------------------------------------------------------------
|
||||
| TCP/UDP checksum | Reserved(2B) | SW Specific Parameters(4B) |
|
||||
| diff (2B) | |
|
||||
-----------------------------------------------------------------------------------
|
||||
|
||||
Dont change below structure definition.
|
||||
It should be same as above(little endian order)
|
||||
-------------------------------------------------------------------------------*/
|
||||
struct ipa_nat_rule {
|
||||
uint64_t private_ip:32;
|
||||
uint64_t target_ip:32;
|
||||
|
||||
uint64_t nxt_indx_pub_port:32;
|
||||
uint64_t private_port:16;
|
||||
uint64_t target_port:16;
|
||||
|
||||
uint64_t ip_cksm_enbl:32;
|
||||
uint64_t ts_proto:32;
|
||||
|
||||
/*--------------------------------------------------
|
||||
32 bit sw_spec_params is interpreted as follows
|
||||
------------------------------------
|
||||
| 16 bits | 16 bits |
|
||||
------------------------------------
|
||||
| index table | prev index |
|
||||
| entry | |
|
||||
------------------------------------
|
||||
--------------------------------------------------*/
|
||||
uint64_t sw_spec_params:32;
|
||||
|
||||
uint64_t rsvd2:16;
|
||||
uint64_t tcp_udp_chksum:16;
|
||||
};
|
||||
|
||||
struct ipa_nat_sw_rule {
|
||||
uint64_t private_ip:32;
|
||||
uint64_t target_ip:32;
|
||||
|
||||
uint64_t next_index:16;
|
||||
uint64_t public_port:16;
|
||||
uint64_t private_port:16;
|
||||
uint64_t target_port:16;
|
||||
|
||||
uint64_t ip_chksum:16;
|
||||
uint64_t rsvd1:14;
|
||||
uint64_t redirect:1;
|
||||
uint64_t enable:1;
|
||||
uint64_t time_stamp:24;
|
||||
uint64_t protocol:8;
|
||||
|
||||
/*--------------------------------------------------
|
||||
32 bit sw_spec_params is interpreted as follows
|
||||
------------------------------------
|
||||
| 16 bits | 16 bits |
|
||||
------------------------------------
|
||||
| index table | prev index |
|
||||
| entry | |
|
||||
------------------------------------
|
||||
--------------------------------------------------*/
|
||||
uint64_t prev_index:16;
|
||||
uint64_t indx_tbl_entry:16;
|
||||
uint64_t rsvd2:16;
|
||||
uint64_t tcp_udp_chksum:16;
|
||||
};
|
||||
#define IPA_NAT_TABLE_ENTRY_SIZE 32
|
||||
#define IPA_NAT_INDEX_TABLE_ENTRY_SIZE 4
|
||||
|
||||
struct ipa_nat_indx_tbl_rule {
|
||||
uint32_t tbl_entry_nxt_indx;
|
||||
};
|
||||
|
||||
struct ipa_nat_sw_indx_tbl_rule {
|
||||
uint16_t tbl_entry;
|
||||
uint16_t next_index;
|
||||
};
|
||||
|
||||
struct ipa_nat_indx_tbl_meta_info {
|
||||
uint16_t prev_index;
|
||||
};
|
||||
|
||||
struct ipa_nat_ip4_table_cache {
|
||||
uint8_t valid;
|
||||
uint32_t public_addr;
|
||||
|
||||
int nat_fd;
|
||||
int size;
|
||||
uint32_t tbl_addr_offset;
|
||||
char table_name[IPA_RESOURCE_NAME_MAX];
|
||||
|
||||
char *ipv4_rules_addr;
|
||||
char *index_table_addr;
|
||||
uint16_t table_entries;
|
||||
|
||||
char *ipv4_expn_rules_addr;
|
||||
char *index_table_expn_addr;
|
||||
uint16_t expn_table_entries;
|
||||
|
||||
struct ipa_nat_indx_tbl_meta_info *index_expn_table_meta;
|
||||
|
||||
uint16_t *rule_id_array;
|
||||
#ifdef IPA_ON_R3PC
|
||||
uint32_t mmap_offset;
|
||||
#endif
|
||||
|
||||
uint16_t cur_tbl_cnt;
|
||||
uint16_t cur_expn_tbl_cnt;
|
||||
};
|
||||
|
||||
struct ipa_nat_cache {
|
||||
struct ipa_nat_ip4_table_cache ip4_tbl[IPA_NAT_MAX_IP4_TBLS];
|
||||
int ipa_fd;
|
||||
uint8_t table_cnt;
|
||||
};
|
||||
|
||||
struct ipa_nat_indx_tbl_sw_rule {
|
||||
uint16_t tbl_entry;
|
||||
uint16_t next_index;
|
||||
uint16_t prev_index;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
IPA_NAT_DEL_TYPE_ONLY_ONE,
|
||||
IPA_NAT_DEL_TYPE_HEAD,
|
||||
IPA_NAT_DEL_TYPE_MIDDLE,
|
||||
IPA_NAT_DEL_TYPE_LAST,
|
||||
} del_type;
|
||||
|
||||
/**
|
||||
* ipa_nati_parse_ipv4_rule_hdl() - prase rule handle
|
||||
* @tbl_hdl: [in] nat table rule
|
||||
* @rule_hdl: [in] nat rule handle
|
||||
* @expn_tbl: [out] expansion table or not
|
||||
* @tbl_entry: [out] index into table
|
||||
*
|
||||
* Parse the rule handle to retrieve the nat table
|
||||
* type and entry of nat table
|
||||
*
|
||||
* Returns: None
|
||||
*/
|
||||
void ipa_nati_parse_ipv4_rule_hdl(uint8_t tbl_hdl,
|
||||
uint16_t rule_hdl,
|
||||
uint8_t *expn_tbl,
|
||||
uint16_t *tbl_entry);
|
||||
|
||||
/**
|
||||
* ipa_nati_make_rule_hdl() - makes nat rule handle
|
||||
* @tbl_hdl: [in] nat table handle
|
||||
* @tbl_entry: [in] nat table entry
|
||||
*
|
||||
* Calculate the nat rule handle which from
|
||||
* nat entry which will be returned to client of
|
||||
* nat driver
|
||||
*
|
||||
* Returns: >0 nat rule handle
|
||||
*/
|
||||
uint16_t ipa_nati_make_rule_hdl(uint16_t tbl_hdl,
|
||||
uint16_t tbl_entry);
|
||||
|
||||
uint32_t ipa_nati_get_index_entry_offset(
|
||||
struct ipa_nat_ip4_table_cache*,
|
||||
nat_table_type tbl_type,
|
||||
uint16_t indx_tbl_entry);
|
||||
uint32_t ipa_nati_get_entry_offset(
|
||||
struct ipa_nat_ip4_table_cache*,
|
||||
nat_table_type tbl_type,
|
||||
uint16_t tbl_entry);
|
||||
|
||||
int ipa_nati_add_ipv4_tbl(uint32_t public_ip_addr,
|
||||
uint16_t number_of_entries,
|
||||
uint32_t *table_hanle);
|
||||
|
||||
int ipa_nati_alloc_table(uint16_t number_of_entries,
|
||||
struct ipa_ioc_nat_alloc_mem *mem,
|
||||
uint16_t*, uint16_t*);
|
||||
|
||||
int ipa_nati_update_cache(struct ipa_ioc_nat_alloc_mem *,
|
||||
uint32_t public_ip_addr,
|
||||
uint16_t tbl_entries,
|
||||
uint16_t expn_tbl_entries);
|
||||
|
||||
int ipa_nati_del_ipv4_table(uint32_t tbl_hdl);
|
||||
int ipa_nati_reset_ipv4_table(uint32_t tbl_hdl);
|
||||
int ipa_nati_post_ipv4_init_cmd(uint8_t tbl_index);
|
||||
|
||||
int ipa_nati_query_timestamp(uint32_t tbl_hdl,
|
||||
uint32_t rule_hdl,
|
||||
uint32_t *time_stamp);
|
||||
|
||||
int ipa_nati_add_ipv4_rule(uint32_t tbl_hdl,
|
||||
const ipa_nat_ipv4_rule *clnt_rule,
|
||||
uint32_t *rule_hdl);
|
||||
|
||||
int ipa_nati_generate_rule(uint32_t tbl_hdl,
|
||||
const ipa_nat_ipv4_rule *clnt_rule,
|
||||
struct ipa_nat_sw_rule *rule,
|
||||
struct ipa_nat_indx_tbl_sw_rule *index_sw_rule,
|
||||
uint16_t *tbl_entry,
|
||||
uint16_t *indx_tbl_entry);
|
||||
|
||||
uint16_t ipa_nati_expn_tbl_free_entry(struct ipa_nat_rule *expn_tbl,
|
||||
uint16_t size);
|
||||
|
||||
uint16_t ipa_nati_generate_tbl_rule(const ipa_nat_ipv4_rule *clnt_rule,
|
||||
struct ipa_nat_sw_rule *sw_rule,
|
||||
struct ipa_nat_ip4_table_cache *tbl_ptr);
|
||||
|
||||
uint16_t ipa_nati_generate_index_rule(const ipa_nat_ipv4_rule *clnt_rule,
|
||||
struct ipa_nat_indx_tbl_sw_rule *sw_rule,
|
||||
struct ipa_nat_ip4_table_cache *tbl_ptr);
|
||||
|
||||
uint16_t ipa_nati_index_expn_get_free_entry(struct ipa_nat_indx_tbl_rule *tbl,
|
||||
uint16_t size);
|
||||
|
||||
void ipa_nati_copy_ipv4_rule_to_hw(
|
||||
struct ipa_nat_ip4_table_cache *ipv4_cache,
|
||||
struct ipa_nat_sw_rule *rule,
|
||||
uint16_t entry, uint8_t tbl_index);
|
||||
|
||||
void ipa_nati_copy_ipv4_index_rule_to_hw(
|
||||
struct ipa_nat_ip4_table_cache *ipv4_cache,
|
||||
struct ipa_nat_indx_tbl_sw_rule *indx_sw_rule,
|
||||
uint16_t entry, uint8_t tbl_index);
|
||||
|
||||
void ipa_nati_write_next_index(uint8_t tbl_indx,
|
||||
nat_table_type tbl_type,
|
||||
uint16_t value,
|
||||
uint32_t offset);
|
||||
|
||||
int ipa_nati_post_ipv4_dma_cmd(uint8_t tbl_indx,
|
||||
uint16_t entry);
|
||||
|
||||
int ipa_nati_del_ipv4_rule(uint32_t tbl_hdl,
|
||||
uint32_t rule_hdl);
|
||||
|
||||
int ipa_nati_post_del_dma_cmd(uint8_t tbl_indx,
|
||||
uint16_t tbl_entry,
|
||||
uint8_t expn_tbl,
|
||||
del_type rule_pos);
|
||||
|
||||
void ipa_nati_find_index_rule_pos(
|
||||
struct ipa_nat_ip4_table_cache *cache_ptr,
|
||||
uint16_t tbl_entry,
|
||||
del_type *rule_pos);
|
||||
|
||||
void ipa_nati_del_dead_ipv4_head_nodes(uint8_t tbl_indx);
|
||||
void ipa_nati_find_rule_pos(struct ipa_nat_ip4_table_cache *cache_ptr,
|
||||
uint8_t expn_tbl,
|
||||
uint16_t tbl_entry,
|
||||
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
|
||||
========================================================*/
|
||||
#ifdef NAT_DUMP
|
||||
void ipa_nati_print_rule(struct ipa_nat_rule*, uint32_t);
|
||||
void ipa_nat_dump_ipv4_table(uint32_t);
|
||||
void ipa_nati_print_index_rule(struct ipa_nat_indx_tbl_rule*,
|
||||
uint32_t, uint16_t);
|
||||
int ipa_nati_query_nat_rules(uint32_t, nat_table_type);
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef IPA_NAT_DRVI_H */
|
||||
73
data-ipa-cfg-mgr/ipanat/inc/ipa_nat_logi.h
Normal file
73
data-ipa-cfg-mgr/ipanat/inc/ipa_nat_logi.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (c) 2013, 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_logi.h
|
||||
|
||||
@brief
|
||||
This file implements the IPAM log functionality.
|
||||
|
||||
@Author
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef IPA_NAT_LOGI_H
|
||||
#define IPA_NAT_LOGI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#define PERROR(fmt) printf("%s:%d %s()", __FILE__, __LINE__, __FUNCTION__);\
|
||||
perror(fmt);
|
||||
|
||||
#define IPAERR(fmt, ...) printf("ERR: %s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
|
||||
|
||||
#ifdef DEBUG
|
||||
#define IPADBG(fmt, ...) printf("%s:%d %s() " fmt, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);
|
||||
|
||||
#define IPADUMP(fmt, ...) printf(fmt, ##__VA_ARGS__);
|
||||
|
||||
#else
|
||||
#define IPADBG(fmt, ...)
|
||||
#define IPADUMP(fmt, ...)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPA_NAT_LOGI_H */
|
||||
28
data-ipa-cfg-mgr/ipanat/src/Android.mk
Normal file
28
data-ipa-cfg-mgr/ipanat/src/Android.mk
Normal file
@@ -0,0 +1,28 @@
|
||||
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)/../inc
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)
|
||||
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
|
||||
|
||||
LOCAL_SRC_FILES := ipa_nat_drv.c \
|
||||
ipa_nat_drvi.c
|
||||
|
||||
LOCAL_CFLAGS := -DDEBUG
|
||||
LOCAL_MODULE := libipanat
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
LOCAL_CLANG := true
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
endif # $(TARGET_ARCH)
|
||||
endif
|
||||
endif
|
||||
21
data-ipa-cfg-mgr/ipanat/src/Makefile.am
Normal file
21
data-ipa-cfg-mgr/ipanat/src/Makefile.am
Normal file
@@ -0,0 +1,21 @@
|
||||
AM_CFLAGS = -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
|
||||
AM_CFLAGS += -I./../inc
|
||||
#AM_CFLAGS += -DDEBUG -g
|
||||
|
||||
common_CFLAGS = -DUSE_GLIB @GLIB_CFLAGS@
|
||||
common_LDFLAGS = -lrt @GLIB_LIBS@
|
||||
|
||||
c_sources = ipa_nat_drv.c \
|
||||
ipa_nat_drvi.c \
|
||||
ipa_nat_logi.c
|
||||
|
||||
library_includedir = $(pkgincludedir)
|
||||
library_include_HEADERS = ./../inc/ipa_nat_drvi.h \
|
||||
./../inc/ipa_nat_drv.h \
|
||||
./../inc/ipa_nat_logi.h
|
||||
|
||||
lib_LTLIBRARIES = libipanat.la
|
||||
libipanat_la_C = @C@
|
||||
libipanat_la_SOURCES = $(c_sources)
|
||||
libipanat_la_CFLAGS = $(AM_CFLAGS) $(common_CFLAGS)
|
||||
libipanat_la_LDFLAGS = -shared $(common_LDFLAGS) -version-info 1:0:0
|
||||
175
data-ipa-cfg-mgr/ipanat/src/ipa_nat_drv.c
Normal file
175
data-ipa-cfg-mgr/ipanat/src/ipa_nat_drv.c
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
Copyright (c) 2013, 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 "ipa_nat_drv.h"
|
||||
#include "ipa_nat_drvi.h"
|
||||
|
||||
/**
|
||||
* ipa_nat_add_ipv4_tbl() - create ipv4 nat table
|
||||
* @public_ip_addr: [in] public ipv4 address
|
||||
* @number_of_entries: [in] number of nat entries
|
||||
* @table_handle: [out] Handle of new ipv4 nat table
|
||||
*
|
||||
* To create new ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_add_ipv4_tbl(uint32_t public_ip_addr,
|
||||
uint16_t number_of_entries,
|
||||
uint32_t *tbl_hdl)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (NULL == tbl_hdl || 0 == number_of_entries) {
|
||||
IPAERR("Invalid parameters \n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = ipa_nati_add_ipv4_tbl(public_ip_addr,
|
||||
number_of_entries,
|
||||
tbl_hdl);
|
||||
if (ret != 0) {
|
||||
IPAERR("unable to add table \n");
|
||||
return -EINVAL;
|
||||
}
|
||||
IPADBG("Returning table handle 0x%x\n", *tbl_hdl);
|
||||
|
||||
return ret;
|
||||
} /* __ipa_nat_add_ipv4_tbl() */
|
||||
|
||||
/**
|
||||
* ipa_nat_del_ipv4_tbl() - delete ipv4 table
|
||||
* @table_handle: [in] Handle of ipv4 nat table
|
||||
*
|
||||
* To delete given ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_del_ipv4_tbl(uint32_t tbl_hdl)
|
||||
{
|
||||
if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
|
||||
tbl_hdl > IPA_NAT_MAX_IP4_TBLS) {
|
||||
IPAERR("invalid table handle passed \n");
|
||||
return -EINVAL;
|
||||
}
|
||||
IPADBG("Passed Table Handle: 0x%x\n", tbl_hdl);
|
||||
|
||||
return ipa_nati_del_ipv4_table(tbl_hdl);
|
||||
}
|
||||
|
||||
/**
|
||||
* ipa_nat_add_ipv4_rule() - to insert new ipv4 rule
|
||||
* @table_handle: [in] handle of ipv4 nat table
|
||||
* @rule: [in] Pointer to new rule
|
||||
* @rule_handle: [out] Return the handle to rule
|
||||
*
|
||||
* To insert new ipv4 nat rule into ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_add_ipv4_rule(uint32_t tbl_hdl,
|
||||
const ipa_nat_ipv4_rule *clnt_rule,
|
||||
uint32_t *rule_hdl)
|
||||
{
|
||||
int result = -EINVAL;
|
||||
|
||||
if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
|
||||
tbl_hdl > IPA_NAT_MAX_IP4_TBLS || NULL == rule_hdl ||
|
||||
NULL == clnt_rule) {
|
||||
IPAERR("invalide table handle passed \n");
|
||||
return result;
|
||||
}
|
||||
IPADBG("Passed Table handle: 0x%x\n", tbl_hdl);
|
||||
|
||||
if (ipa_nati_add_ipv4_rule(tbl_hdl, clnt_rule, rule_hdl) != 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
IPADBG("returning rule handle 0x%x\n", *rule_hdl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ipa_nat_del_ipv4_rule() - to delete ipv4 nat rule
|
||||
* @table_handle: [in] handle of ipv4 nat table
|
||||
* @rule_handle: [in] ipv4 nat rule handle
|
||||
*
|
||||
* To insert new ipv4 nat rule into ipv4 nat table
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_del_ipv4_rule(uint32_t tbl_hdl,
|
||||
uint32_t rule_hdl)
|
||||
{
|
||||
int result = -EINVAL;
|
||||
|
||||
if (IPA_NAT_INVALID_NAT_ENTRY == tbl_hdl ||
|
||||
IPA_NAT_INVALID_NAT_ENTRY == rule_hdl) {
|
||||
IPAERR("invalide parameters\n");
|
||||
return result;
|
||||
}
|
||||
IPADBG("Passed Table: 0x%x and rule handle 0x%x\n", tbl_hdl, rule_hdl);
|
||||
|
||||
result = ipa_nati_del_ipv4_rule(tbl_hdl, rule_hdl);
|
||||
if (result) {
|
||||
IPAERR("unable to delete rule from hw \n");
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ipa_nat_query_timestamp() - to query timestamp
|
||||
* @table_handle: [in] handle of ipv4 nat table
|
||||
* @rule_handle: [in] ipv4 nat rule handle
|
||||
* @time_stamp: [out] time stamp of rule
|
||||
*
|
||||
* To retrieve the timestamp that lastly the
|
||||
* nat rule was accessed
|
||||
*
|
||||
* Returns: 0 On Success, negative on failure
|
||||
*/
|
||||
int ipa_nat_query_timestamp(uint32_t tbl_hdl,
|
||||
uint32_t rule_hdl,
|
||||
uint32_t *time_stamp)
|
||||
{
|
||||
|
||||
if (0 == tbl_hdl || tbl_hdl > IPA_NAT_MAX_IP4_TBLS ||
|
||||
NULL == time_stamp) {
|
||||
IPAERR("invalid parameters passed \n");
|
||||
return -EINVAL;
|
||||
}
|
||||
IPADBG("Passed Table: 0x%x and rule handle 0x%x\n", tbl_hdl, rule_hdl);
|
||||
|
||||
return ipa_nati_query_timestamp(tbl_hdl, rule_hdl, time_stamp);
|
||||
}
|
||||
|
||||
|
||||
2340
data-ipa-cfg-mgr/ipanat/src/ipa_nat_drvi.c
Normal file
2340
data-ipa-cfg-mgr/ipanat/src/ipa_nat_drvi.c
Normal file
File diff suppressed because it is too large
Load Diff
49
data-ipa-cfg-mgr/ipanat/src/ipa_nat_logi.c
Normal file
49
data-ipa-cfg-mgr/ipanat/src/ipa_nat_logi.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Copyright (c) 2013, 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
|
||||
IPACM_log.cpp
|
||||
|
||||
@brief
|
||||
This file implements the IPAM log functionality.
|
||||
|
||||
@Author
|
||||
Skylar Chang
|
||||
|
||||
*/
|
||||
#include "ipa_nat_logi.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void log_nat_message(char *msg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
53
data-ipa-cfg-mgr/ipanat/test/Android.mk
Normal file
53
data-ipa-cfg-mgr/ipanat/test/Android.mk
Normal 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
|
||||
42
data-ipa-cfg-mgr/ipanat/test/Makefile.am
Normal file
42
data-ipa-cfg-mgr/ipanat/test/Makefile.am
Normal 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)
|
||||
|
||||
18
data-ipa-cfg-mgr/ipanat/test/README.txt
Normal file
18
data-ipa-cfg-mgr/ipanat/test/README.txt
Normal 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)
|
||||
104
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test.h
Normal file
104
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test.h
Normal 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);
|
||||
69
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test000.c
Normal file
69
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test000.c
Normal 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;
|
||||
}
|
||||
77
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test001.c
Normal file
77
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test001.c
Normal 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;
|
||||
}
|
||||
85
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test002.c
Normal file
85
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test002.c
Normal 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;
|
||||
}
|
||||
82
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test003.c
Normal file
82
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test003.c
Normal 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;
|
||||
}
|
||||
70
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test004.c
Normal file
70
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test004.c
Normal 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;
|
||||
}
|
||||
83
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test005.c
Normal file
83
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test005.c
Normal 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;
|
||||
}
|
||||
91
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test006.c
Normal file
91
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test006.c
Normal 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;
|
||||
}
|
||||
88
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test007.c
Normal file
88
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test007.c
Normal 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;
|
||||
}
|
||||
94
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test008.c
Normal file
94
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test008.c
Normal 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;
|
||||
}
|
||||
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test009.c
Normal file
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test009.c
Normal 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;
|
||||
}
|
||||
108
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test010.c
Normal file
108
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test010.c
Normal 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;
|
||||
}
|
||||
108
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test011.c
Normal file
108
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test011.c
Normal 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;
|
||||
}
|
||||
109
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test012.c
Normal file
109
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test012.c
Normal 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;
|
||||
}
|
||||
108
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test013.c
Normal file
108
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test013.c
Normal 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;
|
||||
}
|
||||
95
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test014.c
Normal file
95
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test014.c
Normal 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;
|
||||
}
|
||||
97
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test015.c
Normal file
97
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test015.c
Normal 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;
|
||||
}
|
||||
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test016.c
Normal file
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test016.c
Normal 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;
|
||||
}
|
||||
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test017.c
Normal file
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test017.c
Normal 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;
|
||||
}
|
||||
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test018.c
Normal file
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test018.c
Normal 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;
|
||||
}
|
||||
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test019.c
Normal file
96
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test019.c
Normal 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;
|
||||
}
|
||||
100
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test020.c
Normal file
100
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test020.c
Normal 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;
|
||||
}
|
||||
81
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test021.c
Normal file
81
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test021.c
Normal 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;
|
||||
}
|
||||
118
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test022.c
Normal file
118
data-ipa-cfg-mgr/ipanat/test/ipa_nat_test022.c
Normal 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;
|
||||
}
|
||||
640
data-ipa-cfg-mgr/ipanat/test/main.c
Normal file
640
data-ipa-cfg-mgr/ipanat/test/main.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user