This variable is never used outside of setup_device(), therefore there is no
reason to declare it in global scope.
} device_type = DEVICE_TYPE_TUN;
int device_fd = -1;
} device_type = DEVICE_TYPE_TUN;
int device_fd = -1;
static int ip_fd = -1;
char *device = NULL;
char *iface = NULL;
static int ip_fd = -1;
char *device = NULL;
char *iface = NULL;
if((if_fd = open(device, O_RDWR, 0)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s\n", device, strerror(errno));
return false;
if((if_fd = open(device, O_RDWR, 0)) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s\n", device, strerror(errno));
return false;