1/* 2 * Copyright (c) 2014, The Linux Foundation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer in the documentation and/or other materials provided 12 * with the distribution. 13 * * Neither the name of The Linux Foundation nor the names of its 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30/*=========================================================================== 31 32 INCLUDE FILES FOR MODULE 33 34===========================================================================*/ 35#include "stdint.h" /* uint32_t */ 36#include "stdio.h" 37#include <netinet/in.h> /* for proto definitions */ 38 39#define u32 uint32_t 40#define u16 uint16_t 41#define u8 uint8_t 42 43/*============ Preconditions to run NAT Test cases =========*/ 44#define IPA_NAT_TEST_PRE_COND_TE 20 45 46#define CHECK_ERR1(x, tbl_hdl) \ 47 if(ipa_nat_validate_ipv4_table(tbl_hdl)) { \ 48 if(sep) {\ 49 ipa_nat_del_ipv4_tbl(tbl_hdl); \ 50 }\ 51 return -1;\ 52 }\ 53 if(x) { \ 54 IPAERR("%d\n", ret); \ 55 if(sep) {\ 56 ipa_nat_del_ipv4_tbl(tbl_hdl); \ 57 }\ 58 return -1; \ 59 } 60 61#define CHECK_ERR(x) if(x) { \ 62 IPAERR("%d\n", ret); \ 63 return -1;\ 64 } 65 66#if 0 67#define CHECK_ERR(x) if(x) { \ 68 IPAERR("%d\n", ret); \ 69 if(sep) {\ 70 ipa_nat_del_ipv4_tbl(tbl_hdl); \ 71 }\ 72 return -1;\ 73 } 74#endif 75 76#define IPADBG(fmt, args...) printf(" %s:%d " fmt, __FUNCTION__, __LINE__, ## args) 77#define IPAERR(fmt, args...) printf(" %s:%d " fmt, __FUNCTION__, __LINE__, ## args) 78 79#define NAT_DUMP 80int ipa_nat_validate_ipv4_table(u32); 81 82int ipa_nat_test000(int, u32, u8); 83int ipa_nat_test001(int, u32, u8); 84int ipa_nat_test002(int, u32, u8); 85int ipa_nat_test003(int, u32, u8); 86int ipa_nat_test004(int, u32, u8); 87int ipa_nat_test005(int, u32, u8); 88int ipa_nat_test006(int, u32, u8); 89int ipa_nat_test007(int, u32, u8); 90int ipa_nat_test008(int, u32, u8); 91int ipa_nat_test009(int, u32, u8); 92int ipa_nat_test010(int, u32, u8); 93int ipa_nat_test011(int, u32, u8); 94int ipa_nat_test012(int, u32, u8); 95int ipa_nat_test013(int, u32, u8); 96int ipa_nat_test014(int, u32, u8); 97int ipa_nat_test015(int, u32, u8); 98int ipa_nat_test016(int, u32, u8); 99int ipa_nat_test017(int, u32, u8); 100int ipa_nat_test018(int, u32, u8); 101int ipa_nat_test019(int, u32, u8); 102int ipa_nat_test020(int, u32, u8); 103int ipa_nat_test021(int, int); 104int ipa_nat_test022(int, u32, u8); 105