TUNInterface_ipv6_root_test.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 <http://www.gnu.org/licenses/>.
  14. */
  15. #include "interface/tuntap/TUNInterface.h"
  16. #include "interface/tuntap/TUNMessageType.h"
  17. #include "memory/Allocator.h"
  18. #include "memory/MallocAllocator.h"
  19. #include "util/Assert.h"
  20. #include "util/log/Log.h"
  21. #include "util/log/FileWriterLog.h"
  22. #include "util/events/Timeout.h"
  23. #include "wire/Ethernet.h"
  24. #include "wire/Headers.h"
  25. #include "util/platform/netdev/NetDev.h"
  26. #include "test/RootTest.h"
  27. #include "interface/tuntap/test/TUNTools.h"
  28. int main(int argc, char** argv)
  29. {
  30. struct Allocator* alloc = MallocAllocator_new(1<<20);
  31. struct EventBase* base = EventBase_new(alloc);
  32. struct Log* logger = FileWriterLog_new(stdout, alloc);
  33. struct Sockaddr* addrA = Sockaddr_fromBytes(TUNTools_testIP6AddrA, Sockaddr_AF_INET6, alloc);
  34. struct Sockaddr* addrB = Sockaddr_fromBytes(TUNTools_testIP6AddrB, Sockaddr_AF_INET6, alloc);
  35. char assignedIfName[TUNInterface_IFNAMSIZ];
  36. struct Iface* tun = TUNInterface_new(NULL, assignedIfName, 0, base, logger, NULL, alloc);
  37. addrA->flags |= Sockaddr_flags_PREFIX;
  38. addrA->prefix = 126;
  39. NetDev_addAddress(assignedIfName, addrA, logger, NULL);
  40. TUNTools_echoTest(addrA, addrB, TUNTools_genericIP6Echo, tun, base, logger, alloc);
  41. Allocator_free(alloc);
  42. return 0;
  43. }