tor-fw-helper.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
  2. * Copyright (c) 2010-2015, 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_TOR_FW_HELPER_H
  9. #define TOR_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.2"
  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. /** Forward traffic received in port <b>external_port</b> in the
  22. * external side of our NAT to <b>internal_port</b> in this host. */
  23. typedef struct {
  24. uint16_t external_port;
  25. uint16_t internal_port;
  26. } port_to_forward_t;
  27. /** This is where we store parsed commandline options. */
  28. typedef struct {
  29. int verbose;
  30. int help;
  31. int test_commandline;
  32. struct smartlist_t *ports_to_forward;
  33. int fetch_public_ip;
  34. int nat_pmp_status;
  35. int upnp_status;
  36. int public_ip_status;
  37. } tor_fw_options_t;
  38. /** This is our main structure that defines our backend helper API; each helper
  39. * must conform to these public methods if it expects to be handled in a
  40. * non-special way. */
  41. typedef struct tor_fw_backend_t {
  42. const char *name;
  43. size_t state_len;
  44. int (*init)(tor_fw_options_t *options, void *backend_state);
  45. int (*cleanup)(tor_fw_options_t *options, void *backend_state);
  46. int (*fetch_public_ip)(tor_fw_options_t *options, void *backend_state);
  47. int (*add_tcp_mapping)(uint16_t internal_port, uint16_t external_port,
  48. int is_verbose, void *backend_state);
  49. } tor_fw_backend_t;
  50. #endif