ExceptionTests.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. /*
  2. * Copyright (c) 2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above
  10. * copyright notice, this list of conditions and the following
  11. * disclaimer in the documentation and/or other materials provided
  12. * with the distribution.
  13. * * Neither the name of The Linux Foundation nor the names of its
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  21. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  24. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  26. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  27. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * Changes from Qualcomm Innovation Center are provided under the following license:
  30. *
  31. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  32. *
  33. * Redistribution and use in source and binary forms, with or without
  34. * modification, are permitted (subject to the limitations in the
  35. * disclaimer below) provided that the following conditions are met:
  36. *
  37. * * Redistributions of source code must retain the above copyright
  38. * notice, this list of conditions and the following disclaimer.
  39. *
  40. * * Redistributions in binary form must reproduce the above
  41. * copyright notice, this list of conditions and the following
  42. * disclaimer in the documentation and/or other materials provided
  43. * with the distribution.
  44. *
  45. * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
  46. * contributors may be used to endorse or promote products derived
  47. * from this software without specific prior written permission.
  48. *
  49. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  50. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
  51. * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  52. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  53. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  54. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  55. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  56. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  57. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  58. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  59. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  60. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  61. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  62. */
  63. #include "TestsUtils.h"
  64. #include "RoutingDriverWrapper.h"
  65. #include "HeaderInsertion.h"
  66. #include "Filtering.h"
  67. #include "IPAFilteringTable.h"
  68. #include "IPv4Packet.h"
  69. #include <string.h>
  70. using namespace IPA;
  71. class IPAExceptionTestFixture: public TestBase {
  72. public:
  73. IPAExceptionTestFixture() :
  74. m_uBufferSize(0) {
  75. memset(m_aBuffer, 0, sizeof(m_aBuffer));
  76. m_testSuiteName.push_back("Exception");
  77. }
  78. virtual bool AddRules() = 0;
  79. virtual bool ModifyPackets() = 0;
  80. virtual bool TestLogic() = 0;
  81. bool Setup() {
  82. ConfigureScenario(PHASE_SEVEN_TEST_CONFIGURATION);
  83. m_producer.Open(INTERFACE0_TO_IPA_DATA_PATH,
  84. INTERFACE0_FROM_IPA_DATA_PATH);
  85. m_Consumer1.Open(INTERFACE1_TO_IPA_DATA_PATH,
  86. INTERFACE1_FROM_IPA_DATA_PATH);
  87. m_Consumer2.Open(INTERFACE2_TO_IPA_DATA_PATH,
  88. INTERFACE2_FROM_IPA_DATA_PATH);
  89. m_Consumer3.Open(INTERFACE3_TO_IPA_DATA_PATH,
  90. INTERFACE3_FROM_IPA_DATA_PATH);
  91. m_Exceptions.Open(INTERFACE_TO_IPA_EXCEPTION_PATH,
  92. INTERFACE_FROM_IPA_EXCEPTION_PATH);
  93. if (!m_Routing.DeviceNodeIsOpened()) {
  94. LOG_MSG_ERROR(
  95. "Routing block is not ready for immediate commands!\n");
  96. return false;
  97. }
  98. if (!m_Filtering.DeviceNodeIsOpened()) {
  99. LOG_MSG_ERROR(
  100. "Filtering block is not ready for immediate commands!\n");
  101. return false;
  102. }
  103. if (!m_HeaderInsertion.DeviceNodeIsOpened())
  104. {
  105. LOG_MSG_ERROR("Header Insertion block is not ready for immediate commands!\n");
  106. return false;
  107. }
  108. m_HeaderInsertion.Reset();
  109. return true;
  110. } // Setup()
  111. bool Run() {
  112. m_uBufferSize = BUFF_MAX_SIZE;
  113. LOG_MSG_STACK("Entering Function");
  114. // Configure the system by adding Routing / Filtering / HDR
  115. if (!AddRules()) {
  116. LOG_MSG_ERROR("Failed adding Routing / Filtering / HDR.");
  117. return false;
  118. }
  119. // Load input data (IP packet) from file
  120. if (!LoadDefaultPacket(m_eIP, m_aBuffer, m_uBufferSize)) {
  121. LOG_MSG_ERROR("Failed default Packet");
  122. return false;
  123. }
  124. if (!ModifyPackets()) {
  125. LOG_MSG_ERROR("Failed to modify packets.");
  126. return false;
  127. }
  128. if (!TestLogic()) {
  129. LOG_MSG_ERROR("Test failed, Input and expected output mismatch.");
  130. return false;
  131. }
  132. LOG_MSG_STACK("Leaving Function (Returning True)");
  133. return true;
  134. } // Run()
  135. bool Teardown() {
  136. m_producer.Close();
  137. m_Consumer1.Close();
  138. m_Consumer2.Close();
  139. m_Consumer3.Close();
  140. m_Exceptions.Close();
  141. return true;
  142. } // Teardown()
  143. ~IPAExceptionTestFixture() {
  144. }
  145. static RoutingDriverWrapper m_Routing;
  146. static Filtering m_Filtering;
  147. static HeaderInsertion m_HeaderInsertion;
  148. InterfaceAbstraction m_producer;
  149. InterfaceAbstraction m_Consumer1;
  150. InterfaceAbstraction m_Consumer2;
  151. InterfaceAbstraction m_Consumer3;
  152. InterfaceAbstraction m_Exceptions;
  153. protected:
  154. static const size_t BUFF_MAX_SIZE = 1024;
  155. static const uint8_t MAX_HEADER_SIZE = 64; // 64Bytes - Max Header Length
  156. enum ipa_ip_type m_eIP;
  157. uint8_t m_aBuffer[BUFF_MAX_SIZE]; // Input file \ IP packet
  158. size_t m_uBufferSize;
  159. };
  160. RoutingDriverWrapper IPAExceptionTestFixture::m_Routing;
  161. Filtering IPAExceptionTestFixture::m_Filtering;
  162. HeaderInsertion IPAExceptionTestFixture::m_HeaderInsertion;
  163. //----------------------------------------------------------------------------------------------------------------------------------------/
  164. // Test001: Test that when a packet with (IPVer != 4) && (IPVer Ver != 6) , an exception packet is created and received & exception_pipe /
  165. //----------------------------------------------------------------------------------------------------------------------------------------/
  166. class IPAExceptionPacketTest001: public IPAExceptionTestFixture {
  167. public:
  168. IPAExceptionPacketTest001() {
  169. m_name = "IPAExceptionPacketTest001";
  170. m_description = "\
  171. IPA Exception Test 001 - Test that when a packet with (IPVer != 4) && (IPVer Ver != 6) , an exception packet is created and received & exception_pipe \
  172. Test Generates send NUM_OF_EXCEPTION_PKTS packets with IP Version changing from 0 to 9.\
  173. First IP Version == 4, hence it is not considered as exception (same goes for IP Ver == 6) \
  174. ";
  175. m_eIP = IPA_IP_v4;
  176. Register(*this);
  177. }
  178. virtual bool AddRules() {
  179. // Clear All Rules
  180. bool bRetVal = true;
  181. LOG_MSG_STACK("Entering Function");
  182. const char bypass0[20] = "Bypass0";
  183. struct ipa_ioc_get_rt_tbl sRoutingTable;
  184. IPAFilteringTable cFilterTable;
  185. struct ipa_flt_rule_add sFilterRuleEntry;
  186. uint32_t nRTTableHdl=0;
  187. memset(&sRoutingTable, 0, sizeof(sRoutingTable));
  188. LOG_MSG_STACK("Entering Function");
  189. if (!CreateBypassRoutingTable(&m_Routing, m_eIP, bypass0, IPA_CLIENT_TEST2_CONS,
  190. 0,&nRTTableHdl)) {
  191. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  192. bRetVal = false;
  193. goto bail;
  194. }
  195. LOG_MSG_INFO("CreateBypassRoutingTable completed successfully");
  196. sRoutingTable.ip = m_eIP;
  197. strlcpy(sRoutingTable.name, bypass0, sizeof(sRoutingTable.name));
  198. if (!m_Routing.GetRoutingTable(&sRoutingTable)) {
  199. LOG_MSG_ERROR(
  200. "m_routing.GetRoutingTable(&sRoutingTable=0x%p) Failed.", &sRoutingTable);
  201. bRetVal = false;
  202. goto bail;
  203. }
  204. // Creating Filtering Rules
  205. cFilterTable.Init(m_eIP,IPA_CLIENT_TEST_PROD,true,1);
  206. LOG_MSG_INFO("Creation of filtering table completed successfully");
  207. // Configuring Filtering Rule No.1
  208. cFilterTable.GeneratePresetRule(0,sFilterRuleEntry);
  209. sFilterRuleEntry.at_rear = true;
  210. sFilterRuleEntry.flt_rule_hdl = -1; // return Value
  211. sFilterRuleEntry.status = -1; // return value
  212. sFilterRuleEntry.rule.action = IPA_PASS_TO_ROUTING;
  213. sFilterRuleEntry.rule.rt_tbl_hdl = nRTTableHdl;
  214. if (
  215. ((uint8_t)-1 == cFilterTable.AddRuleToTable(sFilterRuleEntry)) ||
  216. !m_Filtering.AddFilteringRule(cFilterTable.GetFilteringTable())
  217. )
  218. {
  219. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  220. bRetVal = false;
  221. goto bail;
  222. } else
  223. {
  224. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable.ReadRuleFromTable(0)->status);
  225. }
  226. bail:
  227. LOG_MSG_STACK(
  228. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  229. return bRetVal;
  230. } // AddRules()
  231. virtual bool ModifyPackets() {
  232. m_eIP = IPA_IP_v6;
  233. AddRules(); // Need to add Routing / Filtering rules for IPv6 as well.
  234. return true;
  235. } // ModifyPacktes ()
  236. virtual bool TestLogic() {
  237. int i = 0, nIPVer = 0;;
  238. memset(m_aExpectedBuffer, 0, sizeof(m_aExpectedBuffer));
  239. m_aExpectedBuffer[2] = 0x0b;
  240. m_aExpectedBuffer[3] = 0x80;
  241. memcpy(m_aExpectedBuffer+8, m_aBuffer, m_uBufferSize);
  242. m_aExpectedBufSize = m_uBufferSize+8;
  243. for (i=0;i<NUM_OF_EXCEPTION_PKTS;i++)
  244. {
  245. LOG_MSG_INFO("Packet %d\n",i);
  246. nIPVer = i+4 % 10;
  247. m_aBuffer[0] = (m_aBuffer[0] & 0x0F)+0x10*nIPVer;// Change to Invalid IP version
  248. m_aExpectedBuffer[8] = (m_aExpectedBuffer[8] & 0x0F)+0x10*nIPVer;
  249. if (4 == nIPVer || 6 == nIPVer)
  250. {
  251. if (!SendReceiveAndCompare(&m_producer, m_aBuffer, m_uBufferSize,
  252. &m_Consumer1, m_aExpectedBuffer+8, m_aExpectedBufSize-8))
  253. {
  254. LOG_MSG_ERROR("SendReceiveAndCompare failed. IPVer = %d",nIPVer);
  255. return false;
  256. }
  257. } else
  258. {
  259. if (!SendReceiveAndCompare(&m_producer, m_aBuffer, m_uBufferSize,
  260. &m_Exceptions, m_aExpectedBuffer, m_aExpectedBufSize))
  261. {
  262. LOG_MSG_ERROR("SendReceiveAndCompare failed. IPVer = %d",nIPVer);
  263. return false;
  264. }
  265. }
  266. }
  267. return true;
  268. }
  269. private:
  270. static const int NUM_OF_EXCEPTION_PKTS = 9;
  271. uint8_t m_aExpectedBuffer[BUFF_MAX_SIZE];
  272. size_t m_aExpectedBufSize;
  273. };
  274. //------------------------------------------------------------------------------------------------------------------------------------------/
  275. // Test003: Test that when Filtering Routes the Packet to the Exception Pipe, an exception packet is created and received & exception_pipe /
  276. //------------------------------------------------------------------------------------------------------------------------------------------/
  277. class IPAExceptionPacketTest003: public IPAExceptionTestFixture {
  278. public:
  279. IPAExceptionPacketTest003() {
  280. m_name = "IPAExceptionPacketTest003";
  281. m_description = "\
  282. IPA Exception Test 003 - Test that when Filtering Routes the Packet to the Exception Pipe, an exception packet is created and received & exception_pipe \
  283. Test Generates a Filtering Table that routes all packets to the Exception Pipe. \
  284. and verify that the packet is recieved @ the Exception Pipe. \
  285. ";
  286. m_eIP = IPA_IP_v4;
  287. Register(*this);
  288. }
  289. virtual bool AddRules() {
  290. // Clear All Rules
  291. bool bRetVal = true;
  292. LOG_MSG_STACK("Entering Function");
  293. const char bypass0[20] = "Bypass0";
  294. struct ipa_ioc_get_rt_tbl sRoutingTable;
  295. IPAFilteringTable cFilterTable;
  296. struct ipa_flt_rule_add sFilterRuleEntry;
  297. uint32_t nRTTableHdl=0;
  298. memset(&sRoutingTable, 0, sizeof(sRoutingTable));
  299. LOG_MSG_STACK("Entering Function");
  300. if (!CreateBypassRoutingTable(&m_Routing, m_eIP, bypass0, IPA_CLIENT_TEST2_CONS,
  301. 0,&nRTTableHdl)) {
  302. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  303. bRetVal = false;
  304. goto bail;
  305. }
  306. LOG_MSG_INFO("CreateBypassRoutingTable completed successfully");
  307. sRoutingTable.ip = m_eIP;
  308. strlcpy(sRoutingTable.name, bypass0, sizeof(sRoutingTable.name));
  309. if (!m_Routing.GetRoutingTable(&sRoutingTable)) {
  310. LOG_MSG_ERROR(
  311. "m_routing.GetRoutingTable(&sRoutingTable=0x%p) Failed.", &sRoutingTable);
  312. bRetVal = false;
  313. goto bail;
  314. }
  315. // Creating Filtering Rules
  316. cFilterTable.Init(m_eIP,IPA_CLIENT_TEST_PROD,true,1);
  317. LOG_MSG_INFO("Creation of filtering table completed successfully");
  318. // Configuring Filtering Rule No.1
  319. cFilterTable.GeneratePresetRule(0,sFilterRuleEntry);
  320. sFilterRuleEntry.at_rear = true;
  321. sFilterRuleEntry.flt_rule_hdl = -1; // return Value
  322. sFilterRuleEntry.status = -1; // return value
  323. sFilterRuleEntry.rule.action = IPA_PASS_TO_EXCEPTION;
  324. sFilterRuleEntry.rule.rt_tbl_hdl = nRTTableHdl;
  325. if (
  326. ((uint8_t)-1 == cFilterTable.AddRuleToTable(sFilterRuleEntry)) ||
  327. !m_Filtering.AddFilteringRule(cFilterTable.GetFilteringTable())
  328. )
  329. {
  330. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  331. bRetVal = false;
  332. goto bail;
  333. } else
  334. {
  335. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable.ReadRuleFromTable(0)->status);
  336. }
  337. bail:
  338. LOG_MSG_STACK(
  339. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  340. return bRetVal;
  341. } // AddRules()
  342. virtual bool ModifyPackets() {
  343. return true;
  344. } // ModifyPacktes ()
  345. virtual bool TestLogic() {
  346. memset(m_aExpectedBuffer, 0, sizeof(m_aExpectedBuffer));
  347. m_aExpectedBuffer[2] = 0x0b;
  348. m_aExpectedBuffer[3] = 0x20;
  349. memcpy(m_aExpectedBuffer+8, m_aBuffer, m_uBufferSize);
  350. m_aExpectedBufSize = m_uBufferSize+8;
  351. if (!SendReceiveAndCompare(&m_producer, m_aBuffer, m_uBufferSize,
  352. &m_Exceptions, m_aExpectedBuffer, m_aExpectedBufSize))
  353. {
  354. LOG_MSG_ERROR("SendReceiveAndCompare failed.");
  355. return false;
  356. }
  357. return true;
  358. }
  359. private:
  360. uint8_t m_aExpectedBuffer[BUFF_MAX_SIZE];
  361. size_t m_aExpectedBufSize;
  362. };
  363. //-----------------------------------------------------------------------------------------------------------------------------------------/
  364. // Test006: Test that when a packet with Internet Header Length < 5 Arrives, an exception packet is created and received & exception_pipe /
  365. //-----------------------------------------------------------------------------------------------------------------------------------------/
  366. class IPAExceptionPacketTest006: public IPAExceptionTestFixture {
  367. public:
  368. IPAExceptionPacketTest006() {
  369. m_name = "IPAExceptionPacketTest006";
  370. m_description = "\
  371. IPA Exception Test 006 - Test that when a packet with Internet Header Length < 5 Arrives, an exception packet is created and received & exception_pipe \
  372. Test Generates a Packet with Internet Header Length (IHL == 4). \
  373. and verifies that the packet is recieved @ the Exception Pipe. \
  374. ";
  375. m_eIP = IPA_IP_v4;
  376. Register(*this);
  377. }
  378. virtual bool AddRules() {
  379. // Clear All Rules
  380. bool bRetVal = true;
  381. LOG_MSG_STACK("Entering Function");
  382. const char bypass0[20] = "Bypass0";
  383. struct ipa_ioc_get_rt_tbl sRoutingTable;
  384. IPAFilteringTable cFilterTable;
  385. struct ipa_flt_rule_add sFilterRuleEntry;
  386. uint32_t nRTTableHdl=0;
  387. memset(&sRoutingTable, 0, sizeof(sRoutingTable));
  388. LOG_MSG_STACK("Entering Function");
  389. if (!CreateBypassRoutingTable(&m_Routing, m_eIP, bypass0, IPA_CLIENT_TEST2_CONS,
  390. 0,&nRTTableHdl)) {
  391. LOG_MSG_ERROR("CreateBypassRoutingTable Failed\n");
  392. bRetVal = false;
  393. goto bail;
  394. }
  395. LOG_MSG_INFO("CreateBypassRoutingTable completed successfully");
  396. sRoutingTable.ip = m_eIP;
  397. strlcpy(sRoutingTable.name, bypass0, sizeof(sRoutingTable.name));
  398. if (!m_Routing.GetRoutingTable(&sRoutingTable)) {
  399. LOG_MSG_ERROR(
  400. "m_routing.GetRoutingTable(&sRoutingTable=0x%p) Failed.", &sRoutingTable);
  401. bRetVal = false;
  402. goto bail;
  403. }
  404. // Creating Filtering Rules
  405. cFilterTable.Init(m_eIP,IPA_CLIENT_TEST_PROD,true,1);
  406. LOG_MSG_INFO("Creation of filtering table completed successfully");
  407. // Configuring Filtering Rule No.1
  408. cFilterTable.GeneratePresetRule(0,sFilterRuleEntry);
  409. sFilterRuleEntry.at_rear = true;
  410. sFilterRuleEntry.flt_rule_hdl = -1; // return Value
  411. sFilterRuleEntry.status = -1; // return value
  412. sFilterRuleEntry.rule.action = IPA_PASS_TO_ROUTING;
  413. sFilterRuleEntry.rule.rt_tbl_hdl = nRTTableHdl;
  414. if (
  415. ((uint8_t)-1 == cFilterTable.AddRuleToTable(sFilterRuleEntry)) ||
  416. !m_Filtering.AddFilteringRule(cFilterTable.GetFilteringTable())
  417. )
  418. {
  419. LOG_MSG_ERROR ("Adding Rule (0) to Filtering block Failed.");
  420. bRetVal = false;
  421. goto bail;
  422. } else
  423. {
  424. LOG_MSG_DEBUG("flt rule hdl0=0x%x, status=0x%x\n", cFilterTable.ReadRuleFromTable(0)->flt_rule_hdl,cFilterTable.ReadRuleFromTable(0)->status);
  425. }
  426. bail:
  427. LOG_MSG_STACK(
  428. "Leaving Function (Returning %s)", bRetVal?"True":"False");
  429. return bRetVal;
  430. } // AddRules()
  431. virtual bool ModifyPackets() {
  432. m_aBuffer[0] =(m_aBuffer[0] & 0xF0)+0x04;// Change the IHL to 4
  433. return true;
  434. } // ModifyPacktes ()
  435. virtual bool TestLogic() {
  436. memset(m_aExpectedBuffer, 0, sizeof(m_aExpectedBuffer));
  437. m_aExpectedBuffer[2] = 0x0b;
  438. m_aExpectedBuffer[3] = 0x04;
  439. memcpy(m_aExpectedBuffer+8, m_aBuffer, m_uBufferSize);
  440. m_aExpectedBufSize = m_uBufferSize+8;
  441. if (!SendReceiveAndCompare(&m_producer, m_aBuffer, m_uBufferSize,
  442. &m_Exceptions, m_aExpectedBuffer, m_aExpectedBufSize))
  443. {
  444. LOG_MSG_ERROR("SendReceiveAndCompare failed.");
  445. return false;
  446. }
  447. return true;
  448. }
  449. private:
  450. uint8_t m_aExpectedBuffer[BUFF_MAX_SIZE];
  451. size_t m_aExpectedBufSize;
  452. };
  453. static IPAExceptionPacketTest001 ipaExceptionPacketTest001;
  454. static IPAExceptionPacketTest003 ipaExceptionPacketTest003;
  455. static IPAExceptionPacketTest006 ipaExceptionPacketTest006;