network_sys.c 785 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Copyright (c) 2018-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file network_sys.c
  5. * \brief Subsystem object for networking setup.
  6. **/
  7. #include "orconfig.h"
  8. #include "lib/subsys/subsys.h"
  9. #include "lib/net/network_sys.h"
  10. #include "lib/net/resolve.h"
  11. #include "lib/net/socket.h"
  12. #ifdef _WIN32
  13. #include <winsock2.h>
  14. #include <windows.h>
  15. #endif
  16. static int
  17. subsys_network_initialize(void)
  18. {
  19. if (network_init() < 0)
  20. return -1;
  21. return 0;
  22. }
  23. static void
  24. subsys_network_shutdown(void)
  25. {
  26. #ifdef _WIN32
  27. WSACleanup();
  28. #endif
  29. tor_free_getaddrinfo_cache();
  30. }
  31. const subsys_fns_t sys_network = {
  32. .name = "network",
  33. .level = -90,
  34. .supported = true,
  35. .initialize = subsys_network_initialize,
  36. .shutdown = subsys_network_shutdown,
  37. };