tor-fw-helper.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
  2. * Copyright (c) 2010-2011, The Tor Project, Inc. */
  3. /* See LICENSE for licensing information */
  4. /**
  5. * \file tor-fw-helper.h
  6. * \brief The main header for our firewall helper.
  7. **/
  8. #ifndef _TOR_FW_HELPER_H
  9. #define _TOR_FW_HELPER_H
  10. #include <stdint.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <getopt.h>
  14. #include <time.h>
  15. /** The current version of tor-fw-helper. */
  16. #define tor_fw_version "0.1"
  17. /** This is an arbitrary hard limit - We currently have two (NAT-PMP and UPnP).
  18. We're likely going to add the Intel UPnP library but nothing else comes to
  19. mind at the moment. */
  20. #define MAX_BACKENDS 23
  21. /** This is where we store parsed commandline options. */
  22. typedef struct {
  23. int verbose;
  24. int help;
  25. int test_commandline;
  26. uint16_t private_dir_port;
  27. uint16_t private_or_port;
  28. uint16_t public_dir_port;
  29. uint16_t public_or_port;
  30. uint16_t internal_port;
  31. uint16_t external_port;
  32. int fetch_public_ip;
  33. int nat_pmp_status;
  34. int upnp_status;
  35. int public_ip_status;
  36. } tor_fw_options_t;
  37. /** This is our main structure that defines our backend helper API; each helper
  38. * must conform to these public methods if it expects to be handled in a
  39. * non-special way. */
  40. typedef struct tor_fw_backend_t {
  41. const char *name;
  42. size_t state_len;
  43. int (*init)(tor_fw_options_t *options, void *backend_state);
  44. int (*cleanup)(tor_fw_options_t *options, void *backend_state);
  45. int (*fetch_public_ip)(tor_fw_options_t *options, void *backend_state);
  46. int (*add_tcp_mapping)(tor_fw_options_t *options, void *backend_state);
  47. } tor_fw_backend_t;
  48. #endif