projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Assign more suitable types and fix narrowing conversion warns.
[tinc]
/
src
/
bsd
/
device.c
diff --git
a/src/bsd/device.c
b/src/bsd/device.c
index
0eeee6e
..
57029d5
100644
(file)
--- a/
src/bsd/device.c
+++ b/
src/bsd/device.c
@@
-1,7
+1,7
@@
/*
device.c -- Interaction BSD tun/tap device
Copyright (C) 2001-2005 Ivo Timmermans,
/*
device.c -- Interaction BSD tun/tap device
Copyright (C) 2001-2005 Ivo Timmermans,
- 2001-20
17
Guus Sliepen <guus@tinc-vpn.org>
+ 2001-20
21
Guus Sliepen <guus@tinc-vpn.org>
2009 Grzegorz Dymarek <gregd72002@googlemail.com>
This program is free software; you can redistribute it and/or modify
2009 Grzegorz Dymarek <gregd72002@googlemail.com>
This program is free software; you can redistribute it and/or modify
@@
-24,10
+24,7
@@
#include "../conf.h"
#include "../device.h"
#include "../logger.h"
#include "../conf.h"
#include "../device.h"
#include "../logger.h"
-#include "../names.h"
-#include "../net.h"
#include "../route.h"
#include "../route.h"
-#include "../utils.h"
#include "../xalloc.h"
#ifdef ENABLE_TUNEMU
#include "../xalloc.h"
#ifdef ENABLE_TUNEMU
@@
-40,8
+37,13
@@
#include <net/if_utun.h>
#endif
#include <net/if_utun.h>
#endif
+#if defined(HAVE_FREEBSD) || defined(HAVE_DRAGONFLY)
+#define DEFAULT_TUN_DEVICE "/dev/tun" // Use the autoclone device
+#define DEFAULT_TAP_DEVICE "/dev/tap"
+#else
#define DEFAULT_TUN_DEVICE "/dev/tun0"
#define DEFAULT_TAP_DEVICE "/dev/tap0"
#define DEFAULT_TUN_DEVICE "/dev/tun0"
#define DEFAULT_TAP_DEVICE "/dev/tap0"
+#endif
typedef enum device_type {
DEVICE_TYPE_TUN,
typedef enum device_type {
DEVICE_TYPE_TUN,
@@
-83,7
+85,7
@@
static bool setup_utun(void) {
return false;
}
return false;
}
-
int
unit = -1;
+
long
unit = -1;
char *p = strstr(device, "utun"), *e = NULL;
if(p) {
char *p = strstr(device, "utun"), *e = NULL;
if(p) {
@@
-349,7
+351,7
@@
static void close_device(void) {
}
static bool read_packet(vpn_packet_t *packet) {
}
static bool read_packet(vpn_packet_t *packet) {
-
in
t inlen;
+
ssize_
t inlen;
switch(device_type) {
case DEVICE_TYPE_TUN:
switch(device_type) {
case DEVICE_TYPE_TUN:
@@
-498,7
+500,7
@@
static bool write_packet(vpn_packet_t *packet) {
#ifdef ENABLE_TUNEMU
case DEVICE_TYPE_TUNEMU:
#ifdef ENABLE_TUNEMU
case DEVICE_TYPE_TUNEMU:
- if(tunemu_write(
device_fd,
DATA(packet) + 14, packet->len - 14) < 0) {
+ if(tunemu_write(DATA(packet) + 14, packet->len - 14) < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to %s %s: %s", device_info,
device, strerror(errno));
return false;
logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to %s %s: %s", device_info,
device, strerror(errno));
return false;