the helper for exit nodes. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_common.h"
#include "gnunet_protocols.h"
Go to the source code of this file.
Macros | |
#define | DEBUG GNUNET_NO |
Need 'struct GNUNET_MessageHeader'. More... | |
#define | MAX_SIZE 65536 |
Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE) More... | |
#define | init_tun(dev) open (dev, O_RDWR) |
Creates a tun-interface called dev;. More... | |
Functions | |
static void | open_dev_null (int target_fd, int flags) |
Open '/dev/null' and make the result the given file descriptor. More... | |
static int | fork_and_exec (const char *file, const char *const cmd[]) |
Run the given command and wait for it to complete. More... | |
static void | set_address6 (const char *dev, const char *address, unsigned long prefix_len) |
Sets the IPv6-Address given in address on the interface dev. More... | |
static void | set_address4 (const char *dev, const char *address, const char *mask) |
Sets the IPv4-Address given in address on the interface dev. More... | |
static void | run (int fd_tun) |
Start forwarding to and from the tunnel. More... | |
int | main (int argc, char **argv) |
Open VPN tunnel interface. More... | |
Variables | |
static const char * | sbin_sysctl |
Path to 'sysctl' binary. More... | |
static const char * | sbin_iptables |
Path to 'iptables' binary. More... | |
the helper for exit nodes.
Opens a virtual network-interface, sends data received on the if to stdout, sends data received on stdin to the interface. The code also enables IPv4/IPv6 forwarding and NAT on the current system (the latter on an interface specified on the command-line); these changes to the network configuration are NOT automatically undone when the program is stopped (this is because we cannot be sure that some other application didn't enable them before or after us; also, these changes should be mostly harmless as it simply turns the system into a router).
The following list of people have reviewed this code and considered it safe since the last modification (if you reviewed it, please have your name added to the list):
Definition in file gnunet-helper-exit.c.
#define DEBUG GNUNET_NO |
Need 'struct GNUNET_MessageHeader'.
Need VPN message types. Should we print (interesting|debug) messages that can happen during normal operation?
Definition at line 70 of file gnunet-helper-exit.c.
#define MAX_SIZE 65536 |
Maximum size of a GNUnet message (GNUNET_MAX_MESSAGE_SIZE)
Definition at line 75 of file gnunet-helper-exit.c.
#define init_tun | ( | dev | ) | open (dev, O_RDWR) |
Creates a tun-interface called dev;.
dev | is assumed to point to a char[IFNAMSIZ] if *dev == '\0', uses the name supplied by the kernel; |
Definition at line 268 of file gnunet-helper-exit.c.
|
static |
Open '/dev/null' and make the result the given file descriptor.
target_fd | desired FD to point to /dev/null |
flags | open flags (O_RDONLY, O_WRONLY) |
Definition at line 111 of file gnunet-helper-exit.c.
Referenced by fork_and_exec().
|
static |
Run the given command and wait for it to complete.
file | name of the binary to run |
cmd | command line arguments (as given to 'execv') |
Definition at line 138 of file gnunet-helper-exit.c.
References open_dev_null(), pid, ret, and status.
Referenced by main().
|
static |
Sets the IPv6-Address given in address on the interface dev.
dev | the interface to configure |
address | the IPv6-Address |
prefix_len | the length of the network-prefix |
Definition at line 280 of file gnunet-helper-exit.c.
References address, in6_ifreq::ifr6_addr, in6_ifreq::ifr6_ifindex, and in6_ifreq::ifr6_prefixlen.
Referenced by main().
|
static |
Sets the IPv4-Address given in address on the interface dev.
dev | the interface to configure |
address | the IPv4-Address |
mask | the netmask |
Definition at line 372 of file gnunet-helper-exit.c.
References address.
Referenced by main().
|
static |
Start forwarding to and from the tunnel.
fd_tun | tunnel FD |
Definition at line 471 of file gnunet-helper-exit.c.
References GNUNET_MESSAGE_TYPE_VPN_HELPER, MAX_SIZE, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
Open VPN tunnel interface.
argc | must be 6 |
argv | 0: binary name ("gnunet-helper-exit") 1: tunnel interface name ("gnunet-exit") 2: "physical" interface name ("eth0"), or "-" to not setup NAT and routing 3: IPv6 address ("::1"), or "-" to skip IPv6 4: IPv6 netmask length in bits ("64") [ignored if #4 is "-"] 5: IPv4 address ("1.2.3.4"), or "-" to skip IPv4 6: IPv4 netmask ("255.255.0.0") [ignored if #4 is "-"] |
Definition at line 698 of file gnunet-helper-exit.c.
References address, cleanup(), fork_and_exec(), global_ret, init_tun, run(), sbin_iptables, sbin_sysctl, set_address4(), and set_address6().
|
static |
|
static |
Path to 'iptables' binary.
Definition at line 85 of file gnunet-helper-exit.c.
Referenced by main().