aboutsummaryrefslogtreecommitdiff
path: root/src/tools/tor-fw-helper/tor-fw-helper-natpmp.h
blob: 2d924ce750b2fbf14104f3849c9b937a54225086 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
 * Copyright (c) 2010-2013, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
  * \file tor-fw-helper-natpmp.h
  **/

#ifdef NAT_PMP
#ifndef TOR_TOR_FW_HELPER_NATPMP_H
#define TOR_TOR_FW_HELPER_NATPMP_H

#include <natpmp.h>

/** This is the default NAT-PMP lease time in seconds. */
#define NATPMP_DEFAULT_LEASE 3600
/** NAT-PMP has many codes for success; this is one of them. */
#define NATPMP_SUCCESS 0

/** This is our NAT-PMP meta structure - it holds our request data, responses,
 * various NAT-PMP parameters, and of course the status of the motion in the
 * NAT-PMP ocean. */
typedef struct natpmp_state_t {
  natpmp_t natpmp;
  natpmpresp_t response;
  int fetch_public_ip;
  int status;
  int init; /**< Have we been initialized? */
  int protocol; /**< This will only be TCP. */
  int lease;
} natpmp_state_t;

const tor_fw_backend_t *tor_fw_get_natpmp_backend(void);

int tor_natpmp_init(tor_fw_options_t *tor_fw_options, void *backend_state);

int tor_natpmp_cleanup(tor_fw_options_t *tor_fw_options, void *backend_state);

int tor_natpmp_add_tcp_mapping(uint16_t internal_port, uint16_t external_port,
                               int is_verbose, void *backend_state);

int tor_natpmp_fetch_public_ip(tor_fw_options_t *tor_fw_options,
                               void *backend_state);

#endif
#endif