#include "net.h"
#include "route.h"
#include "utils.h"
+#include "xalloc.h"
#define DEFAULT_DEVICE "/dev/tun0"
} device_type_t;
int device_fd = -1;
-char *device;
-char *iface;
-char *device_info;
+char *device = NULL;
+char *iface = NULL;
+static char *device_info = NULL;
static int device_total_in = 0;
static int device_total_out = 0;
#if defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD)
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
- device = DEFAULT_DEVICE;
+ device = xstrdup(DEFAULT_DEVICE);
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
- iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
+ iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device);
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
static HANDLE device_handle = INVALID_HANDLE_VALUE;
char *device = NULL;
char *iface = NULL;
-char *device_info = NULL;
+static char *device_info = NULL;
static int device_total_in = 0;
static int device_total_out = 0;
#include "net.h"
#include "route.h"
#include "utils.h"
+#include "xalloc.h"
typedef enum device_type_t {
DEVICE_TYPE_ETHERTAP,
static device_type_t device_type;
char *device;
char *iface;
-char ifrname[IFNAMSIZ];
-char *device_info;
+static char ifrname[IFNAMSIZ];
+static char *device_info;
static int device_total_in = 0;
static int device_total_out = 0;
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
- device = DEFAULT_DEVICE;
+ device = xstrdup(DEFAULT_DEVICE);
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
#ifdef HAVE_LINUX_IF_TUN_H
- iface = netname;
+ iface = xstrdup(netname);
#else
- iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
+ iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device);
#endif
device_fd = open(device, O_RDWR | O_NONBLOCK);
static HANDLE device_handle = INVALID_HANDLE_VALUE;
char *device = NULL;
char *iface = NULL;
-char *device_info = NULL;
+static char *device_info = NULL;
static int device_total_in = 0;
static int device_total_out = 0;
static int nbufs = 64;
-DWORD WINAPI tapreader(void *bla) {
+static DWORD WINAPI tapreader(void *bla) {
int sock, err, status;
struct addrinfo *ai;
struct addrinfo hint = {
#include "logger.h"
#include "utils.h"
#include "route.h"
+#include "xalloc.h"
int device_fd = -1;
char *device;
char *iface;
-char ifrname[IFNAMSIZ];
-char *device_info;
+static char ifrname[IFNAMSIZ];
+static char *device_info;
static int device_total_in = 0;
static int device_total_out = 0;
cp();
- if(!get_config_string
- (lookup_config(config_tree, "Interface"), &iface))
- iface = "eth0";
+ if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
+ iface = xstrdup("eth0");
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
- device = iface;
+ device = xstrdup(iface);
device_info = _("raw socket");
#include "logger.h"
#include "net.h"
#include "utils.h"
+#include "xalloc.h"
#define DEFAULT_DEVICE "/dev/tun"
int device_fd = -1;
char *device = NULL;
char *iface = NULL;
-char *device_info = NULL;
+static char *device_info = NULL;
static int device_total_in = 0;
static int device_total_out = 0;
cp();
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
- device = DEFAULT_DEVICE;
+ device = xstrdup(DEFAULT_DEVICE);
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
static int data_fd = -1;
static int write_fd = -1;
static int state = 0;
-char *device;
+char *device = NULL;
char *iface = NULL;
-char *device_info;
+static char *device_info;
extern char *identname;
extern bool running;