projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1
[tinc]
/
src
/
bsd
/
device.c
diff --git
a/src/bsd/device.c
b/src/bsd/device.c
index
5a60ab7
..
9c3009d
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
09
Guus Sliepen <guus@tinc-vpn.org>
+ 2001-20
11
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
@@
-22,6
+22,7
@@
#include "system.h"
#include "conf.h"
#include "system.h"
#include "conf.h"
+#include "device.h"
#include "logger.h"
#include "net.h"
#include "route.h"
#include "logger.h"
#include "net.h"
#include "route.h"
@@
-51,7
+52,7
@@
static uint64_t device_total_in = 0;
static uint64_t device_total_out = 0;
#if defined(TUNEMU)
static device_type_t device_type = DEVICE_TYPE_TUNEMU;
static uint64_t device_total_out = 0;
#if defined(TUNEMU)
static device_type_t device_type = DEVICE_TYPE_TUNEMU;
-#elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD)
+#elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD)
|| defined(HAVE_DRAGONFLY)
static device_type_t device_type = DEVICE_TYPE_TUNIFHEAD;
#else
static device_type_t device_type = DEVICE_TYPE_TUN;
static device_type_t device_type = DEVICE_TYPE_TUNIFHEAD;
#else
static device_type_t device_type = DEVICE_TYPE_TUN;
@@
-190,19
+191,19
@@
void close_device(void) {
}
bool read_packet(vpn_packet_t *packet) {
}
bool read_packet(vpn_packet_t *packet) {
- int
leni
n;
+ int
inle
n;
switch(device_type) {
case DEVICE_TYPE_TUN:
#ifdef HAVE_TUNEMU
case DEVICE_TYPE_TUNEMU:
if(device_type == DEVICE_TYPE_TUNEMU)
switch(device_type) {
case DEVICE_TYPE_TUN:
#ifdef HAVE_TUNEMU
case DEVICE_TYPE_TUNEMU:
if(device_type == DEVICE_TYPE_TUNEMU)
-
leni
n = tunemu_read(device_fd, packet->data + 14, MTU - 14);
+
inle
n = tunemu_read(device_fd, packet->data + 14, MTU - 14);
else
#endif
else
#endif
-
leni
n = read(device_fd, packet->data + 14, MTU - 14);
+
inle
n = read(device_fd, packet->data + 14, MTU - 14);
- if(
leni
n <= 0) {
+ if(
inle
n <= 0) {
logger(LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
logger(LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
@@
-224,14
+225,14
@@
bool read_packet(vpn_packet_t *packet) {
return false;
}
return false;
}
- packet->len =
leni
n + 14;
+ packet->len =
inle
n + 14;
break;
case DEVICE_TYPE_TUNIFHEAD: {
u_int32_t type;
break;
case DEVICE_TYPE_TUNIFHEAD: {
u_int32_t type;
- struct iovec vector[2] = {{&type, sizeof
(type)
}, {packet->data + 14, MTU - 14}};
+ struct iovec vector[2] = {{&type, sizeof
type
}, {packet->data + 14, MTU - 14}};
- if((
leni
n = readv(device_fd, vector, 2)) <= 0) {
+ if((
inle
n = readv(device_fd, vector, 2)) <= 0) {
logger(LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
logger(LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
@@
-255,18
+256,18
@@
bool read_packet(vpn_packet_t *packet) {
return false;
}
return false;
}
- packet->len =
leni
n + 10;
+ packet->len =
inle
n + 10;
break;
}
case DEVICE_TYPE_TAP:
break;
}
case DEVICE_TYPE_TAP:
- if((
leni
n = read(device_fd, packet->data, MTU)) <= 0) {
+ if((
inle
n = read(device_fd, packet->data, MTU)) <= 0) {
logger(LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
}
logger(LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
}
- packet->len =
leni
n;
+ packet->len =
inle
n;
break;
default:
break;
default:
@@
-296,7
+297,7
@@
bool write_packet(vpn_packet_t *packet) {
case DEVICE_TYPE_TUNIFHEAD: {
u_int32_t type;
case DEVICE_TYPE_TUNIFHEAD: {
u_int32_t type;
- struct iovec vector[2] = {{&type, sizeof
(type)
}, {packet->data + 14, packet->len - 14}};
+ struct iovec vector[2] = {{&type, sizeof
type
}, {packet->data + 14, packet->len - 14}};
int af;
af = (packet->data[12] << 8) + packet->data[13];
int af;
af = (packet->data[12] << 8) + packet->data[13];