TestFramework.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef TestFramework_H
  16. #define TestFramework_H
  17. #include "switch/EncodingScheme.h"
  18. #include "net/NetCore.h"
  19. #include "util/Linker.h"
  20. Linker_require("test/TestFramework.c");
  21. struct TestFramework
  22. {
  23. struct Allocator* alloc;
  24. struct Random* rand;
  25. struct EventBase* eventBase;
  26. struct Log* logger;
  27. #ifndef SUBNODE
  28. struct Pathfinder* pathfinder;
  29. #endif
  30. struct SubnodePathfinder* subnodePathfinder;
  31. struct Iface* tunIf;
  32. struct NetCore* nc;
  33. struct EncodingScheme* scheme;
  34. /** The last message which this node sent. */
  35. struct Message* lastMsg;
  36. /**
  37. * A backup of the last message which this node sent.
  38. * Used to check if the framework alters the message after sending it.
  39. */
  40. struct Message* lastMsgBackup;
  41. uint8_t* publicKey;
  42. uint8_t* ip;
  43. Identity
  44. };
  45. #define TestFramework_KEY_SIZE 8
  46. struct TestFramework* TestFramework_setUp(char* privateKey,
  47. struct Allocator* allocator,
  48. struct EventBase* base,
  49. struct Random* rand,
  50. struct Log* logger);
  51. void TestFramework_linkNodes(struct TestFramework* client,
  52. struct TestFramework* server,
  53. bool beacon);
  54. void TestFramework_craftIPHeader(struct Message* msg, uint8_t srcAddr[16], uint8_t destAddr[16]);
  55. /** Check if the last message sent was altered after having been sent. */
  56. void TestFramework_assertLastMessageUnaltered(struct TestFramework* tf);
  57. int TestFramework_peerCount(struct TestFramework* node);
  58. int TestFramework_sessionCount(struct TestFramework* node);
  59. #endif