123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439 |
- /*
- * Copyright (c) 2018 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 <stdint.h>
- #include <cstring> // for memcpy
- #include "hton.h" // for htonl
- #include "InterfaceAbstraction.h"
- #include "Constants.h"
- #include "Logger.h"
- #include "TestsUtils.h"
- #include "Filtering.h"
- #include "RoutingDriverWrapper.h"
- #include "IPAFilteringTable.h"
- extern "C" {
- #include "ipa_ipv6ct.h"
- }
- #define IPV6_SRC_PORT_OFFSET (40)
- #define IPV6_SRC_ADDRESS_MSB_OFFSET (8)
- #define IPV6_SRC_ADDRESS_LSB_OFFSET (16)
- #define IPV6_DST_ADDRESS_MSB_OFFSET (24)
- #define IPV6_DST_ADDRESS_LSB_OFFSET (32)
- #define IPV6_DST_PORT_OFFSET (40+2)
- #define IPV6_LOW_32_MASK (0xFFFFFFFF)
- #define IPV6_HIGH_32_MASK (0xFFFFFFFF00000000)
- #define IPV6_BITS_IN_BYTE 8
- inline uint32_t GetHigh32(uint64_t in)
- {
- return static_cast<uint32_t>((in & IPV6_HIGH_32_MASK) >> 32);
- }
- inline uint32_t GetLow32(uint64_t in)
- {
- return static_cast<uint32_t>(in & IPV6_LOW_32_MASK);
- }
- template <typename T>
- T HostToNetwork(T in)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- if (1 == htons(1))
- {
- return in;
- }
- static const T mask = 0xff;
- T ret;
- uint8_t* p = reinterpret_cast<uint8_t*>(&ret + 1);
- while (in)
- {
- *--p = static_cast<uint8_t>(in & mask);
- in >>= IPV6_BITS_IN_BYTE;
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return ret;
- }
- extern Logger g_Logger;
- class IpaIPv6CTBlockTestFixture : public TestBase
- {
- public:
- IpaIPv6CTBlockTestFixture() :
- m_sendSize(BUFF_MAX_SIZE),
- m_sendSize2(BUFF_MAX_SIZE),
- m_sendSize3(BUFF_MAX_SIZE),
- m_outbound_dst_addr_msb(0XFF02000000000000),
- m_outbound_dst_addr_lsb(0x11223344556677AA),
- m_outbound_dst_port(1000),
- m_outbound_src_addr_msb(m_outbound_dst_addr_msb),
- m_outbound_src_addr_lsb(0x11223344556677CC),
- m_outbound_src_port(1001),
- m_direction_settings(IPA_IPV6CT_DIRECTION_ALLOW_ALL),
- m_tableHandle(0)
- {
- memset(m_sendBuffer, 0, sizeof(m_sendBuffer)); // First input file / IP packet
- memset(m_sendBuffer2, 0, sizeof(m_sendBuffer2)); // Second input file / IP packet
- memset(m_sendBuffer3, 0, sizeof(m_sendBuffer3)); // Third input file (default) / IP packet
- m_minIPAHwType = IPA_HW_v4_0;
- m_testSuiteName.push_back("IPv6CT");
- }
- static int SetupKernelModule(bool en_status = false, bool ct_suppress = false)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- int retval;
- struct ipa_channel_config from_ipa_channels[3];
- struct test_ipa_ep_cfg from_ipa_cfg[3];
- struct ipa_channel_config to_ipa_channels[1];
- struct test_ipa_ep_cfg to_ipa_cfg[1];
- struct ipa_test_config_header header = { 0 };
- struct ipa_channel_config *to_ipa_array[1];
- struct ipa_channel_config *from_ipa_array[3];
- /* From ipa configurations - 3 pipes */
- memset(&from_ipa_cfg[0], 0, sizeof(from_ipa_cfg[0]));
- prepare_channel_struct(&from_ipa_channels[0],
- header.from_ipa_channels_num++,
- IPA_CLIENT_TEST2_CONS,
- (void *)&from_ipa_cfg[0],
- sizeof(from_ipa_cfg[0]),
- en_status);
- from_ipa_array[0] = &from_ipa_channels[0];
- memset(&from_ipa_cfg[1], 0, sizeof(from_ipa_cfg[1]));
- prepare_channel_struct(&from_ipa_channels[1],
- header.from_ipa_channels_num++,
- IPA_CLIENT_TEST3_CONS,
- (void *)&from_ipa_cfg[1],
- sizeof(from_ipa_cfg[1]),
- en_status);
- from_ipa_array[1] = &from_ipa_channels[1];
- memset(&from_ipa_cfg[2], 0, sizeof(from_ipa_cfg[2]));
- prepare_channel_struct(&from_ipa_channels[2],
- header.from_ipa_channels_num++,
- IPA_CLIENT_TEST4_CONS,
- (void *)&from_ipa_cfg[2],
- sizeof(from_ipa_cfg[2]),
- en_status);
- from_ipa_array[2] = &from_ipa_channels[2];
- /* To ipa configurations - 1 pipes */
- memset(&to_ipa_cfg[0], 0, sizeof(to_ipa_cfg[0]));
- to_ipa_cfg[0].nat.nat_exc_suppress = ct_suppress;
- prepare_channel_struct(&to_ipa_channels[0],
- header.to_ipa_channels_num++,
- IPA_CLIENT_TEST_PROD,
- (void *)&to_ipa_cfg[0],
- sizeof(to_ipa_cfg[0]));
- to_ipa_array[0] = &to_ipa_channels[0];
- prepare_header_struct(&header, from_ipa_array, to_ipa_array);
- retval = GenericConfigureScenario(&header);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return retval;
- }
- bool Setup(bool en_status = false, bool ct_suppress = false)
- {
- bool bRetVal = true;
- if (SetupKernelModule(en_status,ct_suppress) != true)
- return bRetVal;
- m_producer.Open(INTERFACE0_TO_IPA_DATA_PATH, INTERFACE0_FROM_IPA_DATA_PATH);
- m_consumer.Open(INTERFACE1_TO_IPA_DATA_PATH, INTERFACE1_FROM_IPA_DATA_PATH);
- m_consumer2.Open(INTERFACE2_TO_IPA_DATA_PATH, INTERFACE2_FROM_IPA_DATA_PATH);
- m_defaultConsumer.Open(INTERFACE3_TO_IPA_DATA_PATH, INTERFACE3_FROM_IPA_DATA_PATH);
- if (!m_routing.DeviceNodeIsOpened())
- {
- printf("Routing block is not ready for immediate commands!\n");
- return false;
- }
- if (!m_filtering.DeviceNodeIsOpened())
- {
- printf("Filtering block is not ready for immediate commands!\n");
- return false;
- }
- m_routing.Reset(IPA_IP_v4); // This will issue a Reset command to the Filtering as well
- m_routing.Reset(IPA_IP_v6); // This will issue a Reset command to the Filtering as well
- return true;
- } // Setup()
- bool Teardown()
- {
- ipa_ipv6ct_dump_table(m_tableHandle);
- ipa_ipv6ct_del_tbl(m_tableHandle);
- m_producer.Close();
- m_consumer.Close();
- m_consumer2.Close();
- m_defaultConsumer.Close();
- return true;
- } // Teardown()
- bool LoadFiles()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- if (!LoadDefaultPacket(IPA_IP_v6, m_extHdrType, m_sendBuffer, m_sendSize))
- {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf("Loaded %zu Bytes to Buffer 1\n", m_sendSize);
- if (!LoadDefaultPacket(IPA_IP_v6, m_extHdrType, m_sendBuffer2, m_sendSize2))
- {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf("Loaded %zu Bytes to Buffer 2\n", m_sendSize2);
- if (!LoadDefaultPacket(IPA_IP_v6, m_extHdrType, m_sendBuffer3, m_sendSize3))
- {
- LOG_MSG_ERROR("Failed default Packet\n");
- return false;
- }
- printf("Loaded %zu Bytes to Buffer 3\n", m_sendSize3);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }
- // This function creates three IPv6 bypass routing entries and commits them.
- bool CreateThreeIPv6BypassRoutingTables(const char * bypass0, const char * bypass1, const char * bypass2)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- struct ipa_ioc_add_rt_rule *rt_rule0 = 0, *rt_rule1 = 0, *rt_rule2 = 0;
- struct ipa_rt_rule_add *rt_rule_entry;
- rt_rule0 = (struct ipa_ioc_add_rt_rule *)
- calloc(1,
- sizeof(struct ipa_ioc_add_rt_rule) +
- 1 * sizeof(struct ipa_rt_rule_add)
- );
- if (!rt_rule0) {
- printf("calloc failed to allocate rt_rule0 in %s\n", __FUNCTION__);
- return false;
- }
- rt_rule1 = (struct ipa_ioc_add_rt_rule *)
- calloc(1,
- sizeof(struct ipa_ioc_add_rt_rule) +
- 1 * sizeof(struct ipa_rt_rule_add)
- );
- if (!rt_rule1) {
- printf("calloc failed to allocate rt_rule1 in %s\n", __FUNCTION__);
- Free(rt_rule0);
- return false;
- }
- rt_rule2 = (struct ipa_ioc_add_rt_rule *)
- calloc(1,
- sizeof(struct ipa_ioc_add_rt_rule) +
- 1 * sizeof(struct ipa_rt_rule_add)
- );
- if (!rt_rule2) {
- printf("calloc failed to allocate rt_rule2 in %s\n", __FUNCTION__);
- Free(rt_rule0);
- Free(rt_rule1);
- return false;
- }
- rt_rule0->num_rules = 1;
- rt_rule0->ip = IPA_IP_v6;
- rt_rule0->commit = true;
- strlcpy(rt_rule0->rt_tbl_name, bypass0, sizeof(rt_rule0->rt_tbl_name));
- rt_rule_entry = &rt_rule0->rules[0];
- rt_rule_entry->at_rear = false;
- rt_rule_entry->rule.dst = IPA_CLIENT_TEST2_CONS;
- rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0xaabbccdd;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0xeeff0011;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x22334455;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0x66778899;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;// All Packets will get a "Hit"
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
- if (false == m_routing.AddRoutingRule(rt_rule0))
- {
- printf("Routing rule addition(rt_rule0) failed!\n");
- Free(rt_rule2);
- Free(rt_rule1);
- Free(rt_rule0);
- return false;
- }
- rt_rule1->num_rules = 1;
- rt_rule1->ip = IPA_IP_v6;
- rt_rule1->commit = true;
- strlcpy(rt_rule1->rt_tbl_name, bypass1, sizeof(rt_rule1->rt_tbl_name));
- rt_rule_entry = &rt_rule1->rules[0];
- rt_rule_entry->at_rear = false;
- rt_rule_entry->rule.dst = IPA_CLIENT_TEST3_CONS;
- rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0xaabbccdd;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0xeeff0011;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x22334455;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0x66778899;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;// All Packets will get a "Hit"
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
- if (false == m_routing.AddRoutingRule(rt_rule1))
- {
- printf("Routing rule addition(rt_rule1) failed!\n");
- Free(rt_rule2);
- Free(rt_rule1);
- Free(rt_rule0);
- return false;
- }
- rt_rule2->num_rules = 1;
- rt_rule2->ip = IPA_IP_v6;
- rt_rule2->commit = true;
- strlcpy(rt_rule2->rt_tbl_name, bypass2, sizeof(rt_rule2->rt_tbl_name));
- rt_rule_entry = &rt_rule2->rules[0];
- rt_rule_entry->at_rear = false;
- rt_rule_entry->rule.dst = IPA_CLIENT_TEST4_CONS;
- rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0xaabbccdd;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0xeeff0011;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = 0x22334455;
- rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = 0x66778899;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0x00000000;// All Packets will get a "Hit"
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0x00000000;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0x00000000;
- rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0x00000000;
- if (false == m_routing.AddRoutingRule(rt_rule2))
- {
- printf("Routing rule addition(rt_rule2) failed!\n");
- Free(rt_rule2);
- Free(rt_rule1);
- Free(rt_rule0);
- return false;
- }
- Free(rt_rule2);
- Free(rt_rule1);
- Free(rt_rule0);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }
- bool GetThreeIPv6BypassRoutingTables(uint32_t *Hndl0, uint32_t *Hndl1, uint32_t *Hndl2)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- const char bypass0[20] = "Bypass0";
- const char bypass1[20] = "Bypass1";
- const char bypass2[20] = "Bypass2";
- struct ipa_ioc_get_rt_tbl routing_table0, routing_table1, routing_table2;
- if (!CreateThreeIPv6BypassRoutingTables(bypass0, bypass1, bypass2))
- {
- printf("CreateThreeBypassRoutingTables Failed\n");
- return false;
- }
- printf("CreateThreeBypassRoutingTables completed successfully\n");
- routing_table0.ip = IPA_IP_v6;
- strlcpy(routing_table0.name, bypass0, sizeof(routing_table0.name));
- if (!m_routing.GetRoutingTable(&routing_table0))
- {
- printf("m_routing.GetRoutingTable(&routing_table0=0x%pK) Failed.\n", &routing_table0);
- return false;
- }
- routing_table1.ip = IPA_IP_v6;
- strlcpy(routing_table1.name, bypass1, sizeof(routing_table1.name));
- if (!m_routing.GetRoutingTable(&routing_table1))
- {
- printf("m_routing.GetRoutingTable(&routing_table1=0x%pK) Failed.\n", &routing_table1);
- return false;
- }
- routing_table2.ip = IPA_IP_v6;
- strlcpy(routing_table2.name, bypass2, sizeof(routing_table2.name));
- if (!m_routing.GetRoutingTable(&routing_table2))
- {
- printf("m_routing.GetRoutingTable(&routing_table2=0x%pK) Failed.\n", &routing_table2);
- return false;
- }
- *Hndl0 = routing_table0.hdl;
- *Hndl1 = routing_table1.hdl;
- *Hndl2 = routing_table2.hdl;
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }
- bool AddIpv6ctTable()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- const int total_entries = 20;
- int result = ipa_ipv6ct_add_tbl(total_entries, &m_tableHandle);
- if (result)
- {
- printf("Leaving %s, %s(), failed creating IPvC6T table with result %d\n", __FUNCTION__, __FILE__, result);
- return false;
- }
- printf("IPv6CT table added, hdl %d\n", m_tableHandle);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }
- bool AddIpv6ctRule(ipa_ipv6ct_rule& rule, uint32_t& rule_hdl) const
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- int result = ipa_ipv6ct_add_rule(m_tableHandle, &rule, &rule_hdl);
- if (result)
- {
- printf("Leaving %s, %s(), failed creating IPvC6T rule with result %d\n", __FUNCTION__, __FILE__, result);
- return false;
- }
- printf("IPv6CT rule added:\ndest lsb %llX, dest msb %llX, dest port %d\ndir %d, proto %d\nsrc lsb 0x%llX, src msb 0x%llX, src port %d\n",
- (long long unsigned int)rule.dest_ipv6_lsb, (long long unsigned int)rule.dest_ipv6_msb,
- rule.dest_port, rule.direction_settings,
- rule.protocol, (long long unsigned int)rule.src_ipv6_lsb, (long long unsigned int)rule.src_ipv6_msb,
- rule.src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }
- void InitIpv6ctRule(ipa_ipv6ct_rule& rule, uint64_t change_bit) const
- {
- rule.dest_ipv6_lsb = m_outbound_dst_addr_lsb ^ change_bit;
- rule.dest_ipv6_msb = m_outbound_dst_addr_msb;
- rule.dest_port = m_outbound_dst_port;
- rule.direction_settings = m_direction_settings;
- rule.protocol = IPPROTO_TCP;
- rule.src_ipv6_lsb = m_outbound_src_addr_lsb ^ change_bit;
- rule.src_ipv6_msb = m_outbound_src_addr_msb;
- rule.src_port = m_outbound_src_port;
- }
- virtual bool AddIpv6ctRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- ipa_ipv6ct_rule rule;
- InitIpv6ctRule(rule, 0);
- uint32_t rule_hdl;
- bool result = AddIpv6ctRule(rule, rule_hdl);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- virtual bool ModifyPackets() = 0;
- virtual bool AddRoutingFilteringRules() = 0;
- virtual bool ReceivePacketsAndCompare() = 0;
- bool Run()
- {
- bool res = false;
- bool isSuccess = false;
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- res = AddRoutingFilteringRules();
- if (false == res) {
- printf("Failed adding routing and filtering rules.\n");
- return false;
- }
- res = AddIpv6ctTable();
- if (false == res)
- {
- printf("Failed adding IPv6 connection tracking table.\n");
- return false;
- }
- res = AddIpv6ctRules();
- if (false == res)
- {
- printf("Failed adding IPv6 connection tracking rules.\n");
- return false;
- }
- res = LoadFiles();
- if (false == res) {
- printf("Failed loading files.\n");
- return false;
- }
- res = ModifyPackets();
- if (false == res) {
- printf("Failed to modify packets.\n");
- return false;
- }
- // Send first packet
- isSuccess = m_producer.SendData(m_sendBuffer, m_sendSize);
- if (false == isSuccess)
- {
- printf("SendData failure.\n");
- return false;
- }
- // Receive packets from the channels and compare results
- isSuccess = ReceivePacketsAndCompare();
- printf("Leaving %s, %s(), Returning %d\n", __FUNCTION__, __FILE__, isSuccess);
- return isSuccess;
- } // Run()
- void ModifyPackets(uint64_t dstAddrLsb, uint64_t dstAddrMsb, uint16_t dstPort,
- uint64_t srcAddrLsb, uint64_t srcAddrMsb, uint16_t srcPort)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- // destination
- uint64_t address = HostToNetwork(dstAddrLsb);
- memcpy(&m_sendBuffer[IPV6_DST_ADDRESS_LSB_OFFSET], &address, sizeof(address));
- address = HostToNetwork(dstAddrMsb);
- memcpy(&m_sendBuffer[IPV6_DST_ADDRESS_MSB_OFFSET], &address, sizeof(address));
- uint16_t port = ntohs(dstPort);
- memcpy(&m_sendBuffer[IPV6_DST_PORT_OFFSET], &port, sizeof(port));
- // source
- address = HostToNetwork(srcAddrLsb);
- memcpy(&m_sendBuffer[IPV6_SRC_ADDRESS_LSB_OFFSET], &address, sizeof(address));
- address = HostToNetwork(srcAddrMsb);
- memcpy(&m_sendBuffer[IPV6_SRC_ADDRESS_MSB_OFFSET], &address, sizeof(address));
- port = ntohs(srcPort);
- memcpy(&m_sendBuffer[IPV6_SRC_PORT_OFFSET], &port, sizeof(port));
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- }// ModifyPacktes ()
- virtual bool AddRoutingFilteringRules(enum ipa_flt_action flt_action, uint64_t dst_addr_msb, uint64_t dst_addr_lsb)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- const char bypass0[20] = "Bypass0";
- const char bypass1[20] = "Bypass1";
- const char bypass2[20] = "Bypass2";
- if (!CreateThreeIPv6BypassRoutingTables(bypass0, bypass1, bypass2))
- {
- printf("CreateThreeBypassRoutingTables Failed\n");
- return false;
- }
- printf("CreateThreeBypassRoutingTables completed successfully\n");
- ipa_ioc_get_rt_tbl routing_table0;
- routing_table0.ip = IPA_IP_v6;
- strlcpy(routing_table0.name, bypass0, sizeof(routing_table0.name));
- if (!m_routing.GetRoutingTable(&routing_table0))
- {
- printf("m_routing.GetRoutingTable(&routing_table0=0x%pK) Failed.\n", &routing_table0);
- return false;
- }
- ipa_ioc_get_rt_tbl routing_table1;
- routing_table1.ip = IPA_IP_v6;
- strlcpy(routing_table1.name, bypass1, sizeof(routing_table1.name));
- if (!m_routing.GetRoutingTable(&routing_table1))
- {
- printf("m_routing.GetRoutingTable(&routing_table1=0x%pK) Failed.\n", &routing_table1);
- return false;
- }
- IPAFilteringTable FilterTable0;
- ipa_flt_rule_add flt_rule_entry;
- FilterTable0.Init(IPA_IP_v6, IPA_CLIENT_TEST_PROD, false, 1);
- // Configuring Filtering Rule No.0
- FilterTable0.GeneratePresetRule(1, flt_rule_entry);
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1; // return Value
- flt_rule_entry.status = -1; // return value
- flt_rule_entry.rule.action = flt_action;
- flt_rule_entry.rule.rt_tbl_hdl = routing_table0.hdl; //put here the handle corresponding to Routing Rule 1
- flt_rule_entry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = GetHigh32(dst_addr_msb); // Filter DST_IP
- flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = GetLow32(dst_addr_msb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = GetHigh32(dst_addr_lsb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = GetLow32(dst_addr_lsb);
- printf("flt_rule_entry was set successfully, preparing for insertion....\n");
- if (((uint8_t)-1 == FilterTable0.AddRuleToTable(flt_rule_entry)) ||
- !m_filtering.AddFilteringRule(FilterTable0.GetFilteringTable()))
- {
- printf("%s::Error Adding Rule to Filter Table, aborting...\n", __FUNCTION__);
- return false;
- }
- else
- {
- printf("flt rule hdl0=0x%x, status=0x%x\n",
- FilterTable0.ReadRuleFromTable(0)->flt_rule_hdl, FilterTable0.ReadRuleFromTable(0)->status);
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// AddRoutingFilteringRules()
- virtual bool ReceivePacketsAndCompare(bool packetPassExpected)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- // Receive results
- Byte rxBuff1[0x400];
- size_t receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
- printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
- bool isSuccess = true;
- if (packetPassExpected)
- {
- // Compare results
- if (!CompareResultVsGolden(m_sendBuffer, m_sendSize, rxBuff1, receivedSize))
- {
- printf("Comparison of Buffer0 Failed!\n");
- isSuccess = false;
- }
- }
- else
- {
- if (receivedSize)
- {
- isSuccess = false;
- printf("got data while expected packet to be blocked, failing\n");
- }
- }
- char recievedBuffer[256] = {0};
- char SentBuffer[256] = {0};
- size_t j;
- for (j = 0; j < m_sendSize; j++)
- {
- snprintf(&SentBuffer[3 * j], sizeof(SentBuffer)-(3 * j + 1), " %02X", m_sendBuffer[j]);
- }
- for (j = 0; j < receivedSize; j++)
- {
- snprintf(&recievedBuffer[3 * j], sizeof(recievedBuffer)-(3 * j + 1), " %02X", rxBuff1[j]);
- }
- printf("Expected Value1 (%zu)\n%s\n, Received Value1(%zu)\n%s\n",
- m_sendSize, SentBuffer, receivedSize, recievedBuffer);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return isSuccess;
- }
- protected:
- static Filtering m_filtering;
- static RoutingDriverWrapper m_routing;
- InterfaceAbstraction m_producer;
- InterfaceAbstraction m_consumer;
- InterfaceAbstraction m_consumer2;
- InterfaceAbstraction m_defaultConsumer;
- static const size_t BUFF_MAX_SIZE = 1024;
- Byte m_sendBuffer[BUFF_MAX_SIZE]; // First input file / IP packet
- Byte m_sendBuffer2[BUFF_MAX_SIZE]; // Second input file / IP packet
- Byte m_sendBuffer3[BUFF_MAX_SIZE]; // Third input file (default) / IP packet
- size_t m_sendSize;
- size_t m_sendSize2;
- size_t m_sendSize3;
- static const ipv6_ext_hdr_type m_extHdrType = NONE;
- uint64_t m_outbound_dst_addr_msb;
- uint64_t m_outbound_dst_addr_lsb;
- uint16_t m_outbound_dst_port;
- uint64_t m_outbound_src_addr_msb;
- uint64_t m_outbound_src_addr_lsb;
- uint16_t m_outbound_src_port;
- ipa_ipv6_ct_direction_settings_type m_direction_settings;
- uint32_t m_tableHandle;
- };
- RoutingDriverWrapper IpaIPv6CTBlockTestFixture::m_routing;
- Filtering IpaIPv6CTBlockTestFixture::m_filtering;
- /*---------------------------------------------------------------------------------------------*/
- /* Test001: IPv6CT send outbound packet */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest001 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest001()
- {
- m_name = "IpaIPV6CTBlockTest001";
- m_description =
- "IPv6CT block test 001 - IPv6CT passes successfully one packet in outbound direction\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test002: IPv6CT send inbound packet */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest002 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest002()
- {
- m_name = "IpaIPV6CTBlockTest002";
- m_description =
- "IPv6CT block test 002 - IPv6CT passes successfully one packet in inbound direction\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test003: IPv6CT send outbound packet - without IPV6CT rule */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest003 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest003()
- {
- m_name = "IpaIPV6CTBlockTest003";
- m_description =
- "IPv6CT block test 003 - IPv6CT blocks one packet in outbound direction due to rule absence\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n";
- Register(*this);
- }
- virtual bool AddIpv6ctRules()
- {
- printf("not adding IPv6CT rule for packet - blocking expected %s %s\n", __FUNCTION__, __FILE__);
- return true;
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test004: IPv6CT send inbound packet - without IPV6CT rule */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest004 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest004()
- {
- m_name = "IpaIPV6CTBlockTest004";
- m_description =
- "IPv6CT block test 004 - IPv6CT blocks one packet in inbound direction due to rule absence\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n";
- Register(*this);
- }
- virtual bool AddIpv6ctRules()
- {
- printf("not adding IPv6CT rule for packet - blocking expected %s %s\n", __FUNCTION__, __FILE__);
- return true;
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test005: IPv6CT send outbound packet with inbound filtering rule */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest005 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest005()
- {
- m_name = "IpaIPV6CTBlockTest005";
- m_description =
- "IPv6CT block test 005 - IPv6CT blocks one packet in outbound direction, because the filtering rule\n"
- " action is inbound\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test006: IPv6CT send inbound packet with outbound filtering rule */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest006 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest006()
- {
- m_name = "IpaIPV6CTBlockTest006";
- m_description =
- "IPv6CT block test 006 - IPv6CT blocks one packet in inbound direction, because the filtering rule\n"
- " action is outbound\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test007: IPv6CT block outbound packet while disabled outbound direction */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest007 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest007()
- {
- m_name = "IpaIPV6CTBlockTest007";
- m_description =
- "IPv6CT block test 007 - IPv6CT blocks one packet in outbound direction, because the outbound direction\n"
- " is disabled\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet with disabled outbound direction\n";
- m_direction_settings = IPA_IPV6CT_DIRECTION_ALLOW_IN;
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test008: IPv6CT block inbound packet with disabled inbound direction */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest008 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest008()
- {
- m_name = "IpaIPV6CTBlockTest008";
- m_description =
- "IPv6CT block test 008 - IPv6CT blocks one packet in inbound direction, because the inbound direction\n"
- " is disabled\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet with disabled inbound direction\n";
- m_direction_settings = IPA_IPV6CT_DIRECTION_ALLOW_OUT;
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- class IpaIPv6CTBlockExpansionTableTestFixture : public IpaIPv6CTBlockTestFixture
- {
- public:
- virtual bool AddIpv6ctRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- ipa_ipv6ct_rule rule;
- InitIpv6ctRule(rule, 8);
- uint32_t rule_hdl;
- if (!AddIpv6ctRule(rule, rule_hdl))
- {
- return false;
- }
- bool result = IpaIPv6CTBlockTestFixture::AddIpv6ctRules();
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test009: IPv6CT send outbound packet with rule in expansion table */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest009 : public IpaIPv6CTBlockExpansionTableTestFixture
- {
- public:
- IpaIPV6CTBlockTest009()
- {
- m_name = "IpaIPV6CTBlockTest009";
- m_description =
- "IPv6CT block test 009 - IPv6CT passes successfully one packet in outbound direction with rule in\n"
- " expansion table\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add an IPv6CT rule to occupy base table. This rule is not supposed to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test010: IPv6CT send inbound packet with rule in expansion table */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest010 : public IpaIPv6CTBlockExpansionTableTestFixture
- {
- public:
- IpaIPV6CTBlockTest010()
- {
- m_name = "IpaIPV6CTBlockTest010";
- m_description =
- "IPv6CT block test 010 - IPv6CT passes successfully one packet in inbound direction with rule in\n"
- " expansion table\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add an IPv6CT rule to occupy base table. This rule is not supposed to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- class IpaIPv6CTBlockRuleDeleteTestFixture : public IpaIPv6CTBlockTestFixture
- {
- public:
- virtual bool AddIpv6ctRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- ipa_ipv6ct_rule rule;
- InitIpv6ctRule(rule, 0);
- uint32_t rule_hdl;
- if (!AddIpv6ctRule(rule, rule_hdl))
- {
- return false;
- }
- int result = ipa_ipv6ct_del_rule(m_tableHandle, rule_hdl);
- if (result)
- {
- printf("Leaving %s, %s(), failed delete IPvC6T rule %d with result %d\n", __FUNCTION__, __FILE__,
- rule_hdl, result);
- return false;
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test011: IPv6CT block outbound packet while the rule was deleted */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest011 : public IpaIPv6CTBlockRuleDeleteTestFixture
- {
- public:
- IpaIPV6CTBlockTest011()
- {
- m_name = "IpaIPV6CTBlockTest011";
- m_description =
- "IPv6CT block test 011 - IPv6CT blocks one packet in outbound direction due to the rule deletion\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n"
- "4. Delete IPv6CT rule for the packet\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test012: IPv6CT block inbound packet while the rule was deleted */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest012 : public IpaIPv6CTBlockRuleDeleteTestFixture
- {
- public:
- IpaIPV6CTBlockTest012()
- {
- m_name = "IpaIPV6CTBlockTest012";
- m_description =
- "IPv6CT block test 012 - IPv6CT blocks one packet in inbound direction due to the rule deletion\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n"
- "4. Delete IPv6CT rule for the packet\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- class IpaIPv6CTBlockRuleDeleteExpansionTableTestFixture : public IpaIPv6CTBlockRuleDeleteTestFixture
- {
- public:
- virtual bool AddIpv6ctRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- ipa_ipv6ct_rule rule;
- InitIpv6ctRule(rule, 8);
- uint32_t rule_hdl;
- if (!AddIpv6ctRule(rule, rule_hdl))
- {
- return false;
- }
- bool result = IpaIPv6CTBlockRuleDeleteTestFixture::AddIpv6ctRules();
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test013: IPv6CT block outbound packet while the rule in expansion table was deleted */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest013 : public IpaIPv6CTBlockRuleDeleteExpansionTableTestFixture
- {
- public:
- IpaIPV6CTBlockTest013()
- {
- m_name = "IpaIPV6CTBlockTest013";
- m_description =
- "IPv6CT block test 013 - IPv6CT blocks one packet in outbound direction due to the rule deletion from\n"
- " the expansion table\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add an IPv6CT rule to occupy base table. This rule is not supposed to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n"
- "5. Delete IPv6CT rule for the packet from the expansion table\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test014: IPv6CT block inbound packet while the rule in expansion table was deleted */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest014 : public IpaIPv6CTBlockRuleDeleteExpansionTableTestFixture
- {
- public:
- IpaIPV6CTBlockTest014()
- {
- m_name = "IpaIPV6CTBlockTest014";
- m_description =
- "IPv6CT block test 014 - IPv6CT blocks one packet in inbound direction due to the rule deletion from\n"
- " the expansion table\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add an IPv6CT rule to occupy base table. This rule is not supposed to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n"
- "5. Delete IPv6CT rule for the packet from the expansion table\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(false);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- class IpaIPv6CTBlockHeadRuleDeleteTestFixture : public IpaIPv6CTBlockTestFixture
- {
- public:
- virtual bool AddIpv6ctRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- ipa_ipv6ct_rule rule;
- InitIpv6ctRule(rule, 8);
- uint32_t rule_hdl;
- if (!AddIpv6ctRule(rule, rule_hdl))
- {
- return false;
- }
- if (!IpaIPv6CTBlockTestFixture::AddIpv6ctRules())
- {
- return false;
- }
- int result = ipa_ipv6ct_del_rule(m_tableHandle, rule_hdl);
- if (result)
- {
- printf("Leaving %s, %s(), failed delete IPvC6T rule %d with result %d\n", __FUNCTION__, __FILE__,
- rule_hdl, result);
- return false;
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }
- };
- /*---------------------------------------------------------------------------------------------------------------*/
- /* Test015: IPv6CT send outbound packet with rule in expansion table while the rule in the list head was deleted */
- /*---------------------------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest015 : public IpaIPv6CTBlockHeadRuleDeleteTestFixture
- {
- public:
- IpaIPV6CTBlockTest015()
- {
- m_name = "IpaIPV6CTBlockTest015";
- m_description =
- "IPv6CT block test 015 - IPv6CT passes successfully one packet in outbound direction with rule in\n"
- " expansion table, while the list head was deleted\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add an IPv6CT rule to occupy base table. This rule is not supposed to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n"
- "5. Delete IPv6CT rule in the list head\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------------------------*/
- /* Test016: IPv6CT send inbound packet with rule in expansion table while the rule in the list head was deleted */
- /*---------------------------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest016 : public IpaIPv6CTBlockHeadRuleDeleteTestFixture
- {
- public:
- IpaIPV6CTBlockTest016()
- {
- m_name = "IpaIPV6CTBlockTest016";
- m_description =
- "IPv6CT block test 016 - IPv6CT passes successfully one packet in inbound direction with rule in\n"
- " expansion table, while the list head was deleted\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add an IPv6CT rule to occupy base table. This rule is not supposed to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n"
- "5. Delete IPv6CT rule in the list head\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- class IpaIPv6CTBlockMiddleRuleDeleteTestFixture : public IpaIPv6CTBlockHeadRuleDeleteTestFixture
- {
- public:
- virtual bool AddIpv6ctRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- ipa_ipv6ct_rule rule;
- InitIpv6ctRule(rule, 1);
- uint32_t rule_hdl;
- if (!AddIpv6ctRule(rule, rule_hdl))
- {
- return false;
- }
- bool result = IpaIPv6CTBlockHeadRuleDeleteTestFixture::AddIpv6ctRules();
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*------------------------------------------------------------------------------------------------------------*/
- /* Test017: IPv6CT send outbound packet with rule in expansion table while the rule in the middle of the list */
- /* was deleted */
- /*------------------------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest017 : public IpaIPv6CTBlockMiddleRuleDeleteTestFixture
- {
- public:
- IpaIPV6CTBlockTest017()
- {
- m_name = "IpaIPV6CTBlockTest017";
- m_description =
- "IPv6CT block test 017 - IPv6CT passes successfully one packet in outbound direction with rule in\n"
- " expansion table, while the rule in the middle of the list was deleted\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add two IPv6CT rules: one to base table and other to expansion table. These rules are not supposed\n"
- " to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n"
- "5. Delete IPv6CT rule in the middle of the list\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*------------------------------------------------------------------------------------------------------------*/
- /* Test018: IPv6CT send inbound packet with rule in expansion table while the rule in the middle of the list */
- /* was deleted */
- /*------------------------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest018 : public IpaIPv6CTBlockMiddleRuleDeleteTestFixture
- {
- public:
- IpaIPV6CTBlockTest018()
- {
- m_name = "IpaIPV6CTBlockTest018";
- m_description =
- "IPv6CT block test 018 - IPv6CT passes successfully one packet in inbound direction with rule in\n"
- " expansion table, while the rule in the middle of the list was deleted\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add two IPv6CT rules to occupy base table and the middle of the list. These rules are not supposed\n"
- " to match a packet\n"
- "4. Add IPv6CT rule for the packet to the expansion table\n"
- "5. Delete IPv6CT rule in the middle of the list\n";
- Register(*this);
- }
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test019: IPv6CT send outbound packet, suppression test */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest019 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest019()
- {
- m_name = "IpaIPV6CTBlockTest019";
- m_description =
- "IPv6CT block test 019 - IPv6CT passes successfully one packet in outbound direction\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet which doesn't match\n"
- "4. Expect NAT supporession to kick in and packet is routed correctly\n";
- Register(*this);
- }
- virtual bool Setup()
- {
- /* we want statuses on this test */
- return IpaIPv6CTBlockTestFixture::Setup(false, true);
- }
- virtual bool AddRoutingFilteringRules(enum ipa_flt_action flt_action, uint64_t dst_addr_msb, uint64_t dst_addr_lsb)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- const char bypass0[20] = "Bypass0";
- const char bypass1[20] = "Bypass1";
- const char bypass2[20] = "Bypass2";
- if (!CreateThreeIPv6BypassRoutingTables(bypass0, bypass1, bypass2))
- {
- printf("CreateThreeBypassRoutingTables Failed\n");
- return false;
- }
- printf("CreateThreeBypassRoutingTables completed successfully\n");
- ipa_ioc_get_rt_tbl routing_table0;
- routing_table0.ip = IPA_IP_v6;
- strlcpy(routing_table0.name, bypass0, sizeof(routing_table0.name));
- if (!m_routing.GetRoutingTable(&routing_table0))
- {
- printf("m_routing.GetRoutingTable(&routing_table0=0x%pK) Failed.\n", &routing_table0);
- return false;
- }
- /* Setup conntrack exception routing table. */
- if (!m_routing.SetNatConntrackExcRoutingTable(routing_table0.hdl, false))
- {
- LOG_MSG_ERROR("m_routing.SetNatConntrackExcRoutingTable(routing_table0 hdl=%d) Failed.\n",
- routing_table0.hdl);
- return false;
- }
- ipa_ioc_get_rt_tbl routing_table1;
- routing_table1.ip = IPA_IP_v6;
- strlcpy(routing_table1.name, bypass1, sizeof(routing_table1.name));
- if (!m_routing.GetRoutingTable(&routing_table1))
- {
- printf("m_routing.GetRoutingTable(&routing_table1=0x%pK) Failed.\n", &routing_table1);
- return false;
- }
- IPAFilteringTable FilterTable0;
- ipa_flt_rule_add flt_rule_entry;
- FilterTable0.Init(IPA_IP_v6, IPA_CLIENT_TEST_PROD, false, 1);
- // Configuring Filtering Rule No.0
- FilterTable0.GeneratePresetRule(1, flt_rule_entry);
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1; // return Value
- flt_rule_entry.status = -1; // return value
- flt_rule_entry.rule.action = flt_action;
- flt_rule_entry.rule.rt_tbl_hdl = routing_table0.hdl; //put here the handle corresponding to Routing Rule 1
- flt_rule_entry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = GetHigh32(dst_addr_msb); // Filter DST_IP
- flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = GetLow32(dst_addr_msb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = GetHigh32(dst_addr_lsb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = GetLow32(dst_addr_lsb);
- printf("flt_rule_entry was set successfully, preparing for insertion....\n");
- if (((uint8_t)-1 == FilterTable0.AddRuleToTable(flt_rule_entry)) ||
- !m_filtering.AddFilteringRule(FilterTable0.GetFilteringTable()))
- {
- printf("%s::Error Adding Rule to Filter Table, aborting...\n", __FUNCTION__);
- return false;
- }
- else
- {
- printf("flt rule hdl0=0x%x, status=0x%x\n",
- FilterTable0.ReadRuleFromTable(0)->flt_rule_hdl, FilterTable0.ReadRuleFromTable(0)->status);
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// AddRoutingFilteringRules()
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port+1);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test020: IPv6CT send inbound packet for NAT suppression test */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest020 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest020()
- {
- m_name = "IpaIPV6CTBlockTest020";
- m_description =
- "IPv6CT block test 020 - IPv6CT passes successfully one packet in inbound direction on NAT suppression\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n";
- Register(*this);
- }
- virtual bool Setup()
- {
- /* we want statuses on this test */
- return IpaIPv6CTBlockTestFixture::Setup(false, true);
- }
- virtual bool AddRoutingFilteringRules(enum ipa_flt_action flt_action, uint64_t dst_addr_msb, uint64_t dst_addr_lsb)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- const char bypass0[20] = "Bypass0";
- const char bypass1[20] = "Bypass1";
- const char bypass2[20] = "Bypass2";
- if (!CreateThreeIPv6BypassRoutingTables(bypass0, bypass1, bypass2))
- {
- printf("CreateThreeBypassRoutingTables Failed\n");
- return false;
- }
- printf("CreateThreeBypassRoutingTables completed successfully\n");
- ipa_ioc_get_rt_tbl routing_table0;
- routing_table0.ip = IPA_IP_v6;
- strlcpy(routing_table0.name, bypass0, sizeof(routing_table0.name));
- if (!m_routing.GetRoutingTable(&routing_table0))
- {
- printf("m_routing.GetRoutingTable(&routing_table0=0x%pK) Failed.\n", &routing_table0);
- return false;
- }
- /* Setup conntrack exception routing table. */
- if (!m_routing.SetNatConntrackExcRoutingTable(routing_table0.hdl, false))
- {
- LOG_MSG_ERROR("m_routing.SetNatConntrackExcRoutingTable(routing_table0 hdl=%d) Failed.\n",
- routing_table0.hdl);
- return false;
- }
- ipa_ioc_get_rt_tbl routing_table1;
- routing_table1.ip = IPA_IP_v6;
- strlcpy(routing_table1.name, bypass1, sizeof(routing_table1.name));
- if (!m_routing.GetRoutingTable(&routing_table1))
- {
- printf("m_routing.GetRoutingTable(&routing_table1=0x%pK) Failed.\n", &routing_table1);
- return false;
- }
- IPAFilteringTable FilterTable0;
- ipa_flt_rule_add flt_rule_entry;
- FilterTable0.Init(IPA_IP_v6, IPA_CLIENT_TEST_PROD, false, 1);
- // Configuring Filtering Rule No.0
- FilterTable0.GeneratePresetRule(1, flt_rule_entry);
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1; // return Value
- flt_rule_entry.status = -1; // return value
- flt_rule_entry.rule.action = flt_action;
- flt_rule_entry.rule.rt_tbl_hdl = routing_table0.hdl; //put here the handle corresponding to Routing Rule 1
- flt_rule_entry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = GetHigh32(dst_addr_msb); // Filter DST_IP
- flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = GetLow32(dst_addr_msb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = GetHigh32(dst_addr_lsb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = GetLow32(dst_addr_lsb);
- printf("flt_rule_entry was set successfully, preparing for insertion....\n");
- if (((uint8_t)-1 == FilterTable0.AddRuleToTable(flt_rule_entry)) ||
- !m_filtering.AddFilteringRule(FilterTable0.GetFilteringTable()))
- {
- printf("%s::Error Adding Rule to Filter Table, aborting...\n", __FUNCTION__);
- return false;
- }
- else
- {
- printf("flt rule hdl0=0x%x, status=0x%x\n",
- FilterTable0.ReadRuleFromTable(0)->flt_rule_hdl, FilterTable0.ReadRuleFromTable(0)->status);
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// AddRoutingFilteringRules()
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port+1);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test021: IPv6CT send outbound packet, suppression test with status enabled */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest021 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest021()
- {
- m_name = "IpaIPV6CTBlockTest021";
- m_description =
- "IPv6CT block test 021 - IPv6CT passes successfully one packet in outbound direction\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one outbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet which doesn't match\n"
- "4. Expect NAT suppression to kick in and packet is routed correctly\n"
- "5. Compare status and check if NAT suppression kicked in.\n";
- Register(*this);
- }
- virtual bool Setup()
- {
- /* we want statuses on this test */
- return IpaIPv6CTBlockTestFixture::Setup(true, true);
- }
- virtual bool AddRoutingFilteringRules(enum ipa_flt_action flt_action, uint64_t dst_addr_msb, uint64_t dst_addr_lsb)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- const char bypass0[20] = "Bypass0";
- const char bypass1[20] = "Bypass1";
- const char bypass2[20] = "Bypass2";
- if (!CreateThreeIPv6BypassRoutingTables(bypass0, bypass1, bypass2))
- {
- printf("CreateThreeBypassRoutingTables Failed\n");
- return false;
- }
- printf("CreateThreeBypassRoutingTables completed successfully\n");
- ipa_ioc_get_rt_tbl routing_table0;
- routing_table0.ip = IPA_IP_v6;
- strlcpy(routing_table0.name, bypass0, sizeof(routing_table0.name));
- if (!m_routing.GetRoutingTable(&routing_table0))
- {
- printf("m_routing.GetRoutingTable(&routing_table0=0x%pK) Failed.\n", &routing_table0);
- return false;
- }
- /* Setup conntrack exception routing table. */
- if (!m_routing.SetNatConntrackExcRoutingTable(routing_table0.hdl, false))
- {
- LOG_MSG_ERROR("m_routing.SetNatConntrackExcRoutingTable(routing_table0 hdl=%d) Failed.\n",
- routing_table0.hdl);
- return false;
- }
- ipa_ioc_get_rt_tbl routing_table1;
- routing_table1.ip = IPA_IP_v6;
- strlcpy(routing_table1.name, bypass1, sizeof(routing_table1.name));
- if (!m_routing.GetRoutingTable(&routing_table1))
- {
- printf("m_routing.GetRoutingTable(&routing_table1=0x%pK) Failed.\n", &routing_table1);
- return false;
- }
- IPAFilteringTable FilterTable0;
- ipa_flt_rule_add flt_rule_entry;
- FilterTable0.Init(IPA_IP_v6, IPA_CLIENT_TEST_PROD, false, 1);
- // Configuring Filtering Rule No.0
- FilterTable0.GeneratePresetRule(1, flt_rule_entry);
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1; // return Value
- flt_rule_entry.status = -1; // return value
- flt_rule_entry.rule.action = flt_action;
- flt_rule_entry.rule.rt_tbl_hdl = routing_table0.hdl; //put here the handle corresponding to Routing Rule 1
- flt_rule_entry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = GetHigh32(dst_addr_msb); // Filter DST_IP
- flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = GetLow32(dst_addr_msb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = GetHigh32(dst_addr_lsb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = GetLow32(dst_addr_lsb);
- printf("flt_rule_entry was set successfully, preparing for insertion....\n");
- if (((uint8_t)-1 == FilterTable0.AddRuleToTable(flt_rule_entry)) ||
- !m_filtering.AddFilteringRule(FilterTable0.GetFilteringTable()))
- {
- printf("%s::Error Adding Rule to Filter Table, aborting...\n", __FUNCTION__);
- return false;
- }
- else
- {
- printf("flt rule hdl0=0x%x, status=0x%x\n",
- FilterTable0.ReadRuleFromTable(0)->flt_rule_hdl, FilterTable0.ReadRuleFromTable(0)->status);
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// AddRoutingFilteringRules()
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = AddRoutingFilteringRules(IPA_PASS_TO_SRC_NAT,
- m_outbound_dst_addr_msb, m_outbound_dst_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port,
- m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port+1);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare(bool packetPassExpected)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- // Receive results
- struct ipa3_hw_pkt_status_hw_v5_5 *status = NULL;
- Byte rxBuff1[0x400];
- size_t receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
- printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
- bool isSuccess = true;
- if (packetPassExpected)
- {
- // Compare results
- if (!CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize))
- {
- printf("Comparison of Buffer0 Failed!\n");
- isSuccess = false;
- }
- }
- else
- {
- if (receivedSize)
- {
- isSuccess = false;
- printf("got data while expected packet to be blocked, failing\n");
- }
- }
- status = (struct ipa3_hw_pkt_status_hw_v5_5 *)rxBuff1;
- if (!status->nat_exc_suppress)
- {
- printf("NAT Suppression not hit!\n");
- isSuccess = false;
- }
- char recievedBuffer[256] = {0};
- char SentBuffer[256] = {0};
- size_t j;
- for (j = 0; j < m_sendSize; j++)
- {
- snprintf(&SentBuffer[3 * j], sizeof(SentBuffer)-(3 * j + 1), " %02X", m_sendBuffer[j]);
- }
- for (j = 0; j < receivedSize; j++)
- {
- snprintf(&recievedBuffer[3 * j], sizeof(recievedBuffer)-(3 * j + 1), " %02X", rxBuff1[j]);
- }
- printf("Expected Value1 (%zu)\n%s\n, Received Value1(%zu)\n%s\n",
- m_sendSize, SentBuffer, receivedSize, recievedBuffer);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return isSuccess;
- }
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- /*---------------------------------------------------------------------------------------------*/
- /* Test022: IPv6CT send inbound packet for NAT suppression test with status enabled */
- /*---------------------------------------------------------------------------------------------*/
- class IpaIPV6CTBlockTest022 : public IpaIPv6CTBlockTestFixture
- {
- public:
- IpaIPV6CTBlockTest022()
- {
- m_name = "IpaIPV6CTBlockTest022";
- m_description =
- "IPv6CT block test 022 - IPv6CT passes successfully one packet in inbound direction on NAT suppression\n"
- "1. Generate and commit three routing tables.\n"
- " Each table contains a single \"bypass\" rule (all data goes to output pipe 0, 1 and 2 (accordingly))\n"
- "2. Generate and commit one inbound filtering rule: Destination IP Exactly Match.\n"
- "3. Add IPv6CT rule for the packet\n"
- "4. Send packet which doesn't match CT and expect NAT suppression to kick in.\n"
- "5. Compare status and check if NAT suppression kicked in.\n";
- Register(*this);
- }
- virtual bool Setup()
- {
- /* we want statuses on this test */
- return IpaIPv6CTBlockTestFixture::Setup(true, true);
- }
- virtual bool AddRoutingFilteringRules(enum ipa_flt_action flt_action, uint64_t dst_addr_msb, uint64_t dst_addr_lsb)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- const char bypass0[20] = "Bypass0";
- const char bypass1[20] = "Bypass1";
- const char bypass2[20] = "Bypass2";
- if (!CreateThreeIPv6BypassRoutingTables(bypass0, bypass1, bypass2))
- {
- printf("CreateThreeBypassRoutingTables Failed\n");
- return false;
- }
- printf("CreateThreeBypassRoutingTables completed successfully\n");
- ipa_ioc_get_rt_tbl routing_table0;
- routing_table0.ip = IPA_IP_v6;
- strlcpy(routing_table0.name, bypass0, sizeof(routing_table0.name));
- if (!m_routing.GetRoutingTable(&routing_table0))
- {
- printf("m_routing.GetRoutingTable(&routing_table0=0x%pK) Failed.\n", &routing_table0);
- return false;
- }
- /* Setup conntrack exception routing table. */
- if (!m_routing.SetNatConntrackExcRoutingTable(routing_table0.hdl, false))
- {
- LOG_MSG_ERROR("m_routing.SetNatConntrackExcRoutingTable(routing_table0 hdl=%d) Failed.\n",
- routing_table0.hdl);
- return false;
- }
- ipa_ioc_get_rt_tbl routing_table1;
- routing_table1.ip = IPA_IP_v6;
- strlcpy(routing_table1.name, bypass1, sizeof(routing_table1.name));
- if (!m_routing.GetRoutingTable(&routing_table1))
- {
- printf("m_routing.GetRoutingTable(&routing_table1=0x%pK) Failed.\n", &routing_table1);
- return false;
- }
- IPAFilteringTable FilterTable0;
- ipa_flt_rule_add flt_rule_entry;
- FilterTable0.Init(IPA_IP_v6, IPA_CLIENT_TEST_PROD, false, 1);
- // Configuring Filtering Rule No.0
- FilterTable0.GeneratePresetRule(1, flt_rule_entry);
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1; // return Value
- flt_rule_entry.status = -1; // return value
- flt_rule_entry.rule.action = flt_action;
- flt_rule_entry.rule.rt_tbl_hdl = routing_table0.hdl; //put here the handle corresponding to Routing Rule 1
- flt_rule_entry.rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;// Exact Match
- flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = GetHigh32(dst_addr_msb); // Filter DST_IP
- flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = GetLow32(dst_addr_msb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = GetHigh32(dst_addr_lsb);
- flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = GetLow32(dst_addr_lsb);
- printf("flt_rule_entry was set successfully, preparing for insertion....\n");
- if (((uint8_t)-1 == FilterTable0.AddRuleToTable(flt_rule_entry)) ||
- !m_filtering.AddFilteringRule(FilterTable0.GetFilteringTable()))
- {
- printf("%s::Error Adding Rule to Filter Table, aborting...\n", __FUNCTION__);
- return false;
- }
- else
- {
- printf("flt rule hdl0=0x%x, status=0x%x\n",
- FilterTable0.ReadRuleFromTable(0)->flt_rule_hdl, FilterTable0.ReadRuleFromTable(0)->status);
- }
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// AddRoutingFilteringRules()
- virtual bool AddRoutingFilteringRules()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = IpaIPv6CTBlockTestFixture::AddRoutingFilteringRules(IPA_PASS_TO_DST_NAT,
- m_outbound_src_addr_msb, m_outbound_src_addr_lsb);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }// AddRoutingFilteringRules()
- virtual bool ModifyPackets()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- IpaIPv6CTBlockTestFixture::ModifyPackets(m_outbound_src_addr_lsb, m_outbound_src_addr_msb, m_outbound_src_port,
- m_outbound_dst_addr_lsb, m_outbound_dst_addr_msb, m_outbound_dst_port+1);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return true;
- }// ModifyPackets()
- virtual bool ReceivePacketsAndCompare(bool packetPassExpected)
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- // Receive results
- struct ipa3_hw_pkt_status_hw_v5_5 *status = NULL;
- Byte rxBuff1[0x400];
- size_t receivedSize = m_consumer.ReceiveData(rxBuff1, 0x400);
- printf("Received %zu bytes on %s.\n", receivedSize, m_consumer.m_fromChannelName.c_str());
- bool isSuccess = true;
- if (packetPassExpected)
- {
- // Compare results
- if (!CompareResultVsGolden_w_Status(m_sendBuffer, m_sendSize, rxBuff1, receivedSize))
- {
- printf("Comparison of Buffer0 Failed!\n");
- isSuccess = false;
- }
- }
- else
- {
- if (receivedSize)
- {
- isSuccess = false;
- printf("got data while expected packet to be blocked, failing\n");
- }
- }
- status = (struct ipa3_hw_pkt_status_hw_v5_5 *)rxBuff1;
- if (!status->nat_exc_suppress)
- {
- printf("NAT Suppression not hit!\n");
- isSuccess = false;
- }
- char recievedBuffer[256] = {0};
- char SentBuffer[256] = {0};
- size_t j;
- for (j = 0; j < m_sendSize; j++)
- {
- snprintf(&SentBuffer[3 * j], sizeof(SentBuffer)-(3 * j + 1), " %02X", m_sendBuffer[j]);
- }
- for (j = 0; j < receivedSize; j++)
- {
- snprintf(&recievedBuffer[3 * j], sizeof(recievedBuffer)-(3 * j + 1), " %02X", rxBuff1[j]);
- }
- printf("Expected Value1 (%zu)\n%s\n, Received Value1(%zu)\n%s\n",
- m_sendSize, SentBuffer, receivedSize, recievedBuffer);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return isSuccess;
- }
- virtual bool ReceivePacketsAndCompare()
- {
- printf("Entering %s, %s()\n", __FUNCTION__, __FILE__);
- bool result = ReceivePacketsAndCompare(true);
- printf("Leaving %s, %s()\n", __FUNCTION__, __FILE__);
- return result;
- }
- };
- // IPv6CT outbound packet test
- static class IpaIPV6CTBlockTest001 IpaIPV6CTBlockTest001;
- // IPv6CT inbound packet test
- static class IpaIPV6CTBlockTest002 IpaIPV6CTBlockTest002;
- // IPv6CT block outbound packet test
- static class IpaIPV6CTBlockTest003 IpaIPV6CTBlockTest003;
- // IPv6CT block inbound packet test
- static class IpaIPV6CTBlockTest004 IpaIPV6CTBlockTest004;
- // IPv6CT block outbound packet on inbound filtering rule test
- static class IpaIPV6CTBlockTest005 IpaIPV6CTBlockTest005;
- // IPv6CT block inbound packet on outbound filtering rule test
- static class IpaIPV6CTBlockTest006 IpaIPV6CTBlockTest006;
- // IPv6CT block outbound packet while disabled outbound direction
- static class IpaIPV6CTBlockTest007 IpaIPV6CTBlockTest007;
- // IPv6CT block inbound packet with disabled inbound direction
- static class IpaIPV6CTBlockTest008 IpaIPV6CTBlockTest008;
- // IPv6CT send outbound packet with rule in expansion table
- static class IpaIPV6CTBlockTest009 IpaIPV6CTBlockTest009;
- // IPv6CT send inbound packet with rule in expansion table
- static class IpaIPV6CTBlockTest010 IpaIPV6CTBlockTest010;
- // IPv6CT block outbound packet while the rule was deleted
- static class IpaIPV6CTBlockTest011 IpaIPV6CTBlockTest011;
- // IPv6CT block inbound packet while the rule was deleted
- static class IpaIPV6CTBlockTest012 IpaIPV6CTBlockTest012;
- // IPv6CT block outbound packet while the rule in expansion table was deleted
- static class IpaIPV6CTBlockTest013 IpaIPV6CTBlockTest013;
- // IPv6CT block inbound packet while the rule in expansion table was deleted
- static class IpaIPV6CTBlockTest014 IpaIPV6CTBlockTest014;
- // IPv6CT send outbound packet with rule in expansion table while the rule in list head was deleted
- static class IpaIPV6CTBlockTest015 IpaIPV6CTBlockTest015;
- // IPv6CT send inbound packet with rule in expansion table while the rule in list head was deleted
- static class IpaIPV6CTBlockTest016 IpaIPV6CTBlockTest016;
- // IPv6CT send outbound packet with rule in expansion table while the rule in the middle of the list was deleted
- static class IpaIPV6CTBlockTest017 IpaIPV6CTBlockTest017;
- // IPv6CT send inbound packet with rule in expansion table while the rule in the middle of the list was deleted
- static class IpaIPV6CTBlockTest018 IpaIPV6CTBlockTest018;
- // IPv6CT suppression test Outbound traffic
- static class IpaIPV6CTBlockTest019 IpaIPV6CTBlockTest019;
- // IPv6CT suppression test Inbound traffic
- static class IpaIPV6CTBlockTest020 IpaIPV6CTBlockTest020;
- // IPv6CT suppression test Outbound traffic with status
- static class IpaIPV6CTBlockTest021 IpaIPV6CTBlockTest021;
- // IPv6CT suppression test Inbound traffic with status
- static class IpaIPV6CTBlockTest022 IpaIPV6CTBlockTest022;
|