Update all device.c files.
This commit is contained in:
parent
271d3537fe
commit
00ddbf5723
8 changed files with 60 additions and 138 deletions
|
@ -17,30 +17,20 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.8 2003/07/15 16:27:39 guus Exp $
|
||||
$Id: device.c,v 1.1.2.9 2003/07/18 13:41:35 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <w32api/windows.h>
|
||||
#include <w32api/winioctl.h>
|
||||
|
||||
// #include <utils.h>
|
||||
#include "conf.h"
|
||||
#include "net.h"
|
||||
#include "logger.h"
|
||||
#include "net.h"
|
||||
#include "route.h"
|
||||
|
||||
#include "system.h"
|
||||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
/* Definitions from CIPE */
|
||||
|
||||
|
|
|
@ -17,35 +17,22 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.8 2003/07/12 17:41:47 guus Exp $
|
||||
$Id: device.c,v 1.1.2.9 2003/07/18 13:41:36 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <net/if.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils.h>
|
||||
#include "conf.h"
|
||||
#include "net.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "logger.h"
|
||||
#include "net.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/tun0"
|
||||
|
||||
int device_fd = -1;
|
||||
int device_type;
|
||||
char *device;
|
||||
char *interface;
|
||||
char *iface;
|
||||
char *device_info;
|
||||
int device_total_in = 0;
|
||||
int device_total_out = 0;
|
||||
|
@ -57,8 +44,8 @@ int setup_device(void)
|
|||
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
|
||||
device = DEFAULT_DEVICE;
|
||||
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
|
||||
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||
iface = 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));
|
||||
|
|
|
@ -17,35 +17,22 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.11 2003/07/12 17:41:47 guus Exp $
|
||||
$Id: device.c,v 1.1.2.12 2003/07/18 13:41:36 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <net/if.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils.h>
|
||||
#include "conf.h"
|
||||
#include "net.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "logger.h"
|
||||
#include "net.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/tap0"
|
||||
|
||||
int device_fd = -1;
|
||||
int device_type;
|
||||
char *device;
|
||||
char *interface;
|
||||
char *iface;
|
||||
char *device_info;
|
||||
int device_total_in = 0;
|
||||
int device_total_out = 0;
|
||||
|
@ -57,8 +44,8 @@ int setup_device(void)
|
|||
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
|
||||
device = DEFAULT_DEVICE;
|
||||
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
|
||||
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||
iface = 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));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.18 2003/07/17 15:06:27 guus Exp $
|
||||
$Id: device.c,v 1.1.2.19 2003/07/18 13:41:36 guus Exp $
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
@ -48,7 +48,7 @@ enum {
|
|||
int device_fd = -1;
|
||||
int device_type;
|
||||
char *device;
|
||||
char *interface;
|
||||
char *iface;
|
||||
char ifrname[IFNAMSIZ];
|
||||
char *device_info;
|
||||
|
||||
|
@ -64,11 +64,11 @@ int setup_device(void)
|
|||
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
|
||||
device = DEFAULT_DEVICE;
|
||||
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||
#ifdef HAVE_TUNTAP
|
||||
interface = netname;
|
||||
iface = netname;
|
||||
#else
|
||||
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
#endif
|
||||
device_fd = open(device, O_RDWR | O_NONBLOCK);
|
||||
|
||||
|
@ -91,16 +91,16 @@ int setup_device(void)
|
|||
device_info = _("Linux tun/tap device (tap mode)");
|
||||
}
|
||||
|
||||
if(interface)
|
||||
strncpy(ifr.ifr_name, interface, IFNAMSIZ);
|
||||
if(iface)
|
||||
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
|
||||
|
||||
if(!ioctl(device_fd, TUNSETIFF, (void *) &ifr)) {
|
||||
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
|
||||
interface = ifrname;
|
||||
iface = ifrname;
|
||||
} else if(!ioctl(device_fd, (('T' << 8) | 202), (void *) &ifr)) {
|
||||
logger(LOG_WARNING, _("Old ioctl() request was needed for %s"), device);
|
||||
strncpy(ifrname, ifr.ifr_name, IFNAMSIZ);
|
||||
interface = ifrname;
|
||||
iface = ifrname;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ int setup_device(void)
|
|||
overwrite_mac = 1;
|
||||
device_info = _("Linux ethertap device");
|
||||
device_type = DEVICE_TYPE_ETHERTAP;
|
||||
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
}
|
||||
|
||||
logger(LOG_INFO, _("%s is a %s"), device, device_info);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: net_socket.c,v 1.1.2.27 2003/07/17 15:06:26 guus Exp $
|
||||
$Id: net_socket.c,v 1.1.2.28 2003/07/18 13:41:35 guus Exp $
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
@ -48,10 +48,8 @@ int setup_listen_socket(sockaddr_t *sa)
|
|||
int nfd, flags;
|
||||
char *addrstr;
|
||||
int option;
|
||||
#if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE)
|
||||
char *interface;
|
||||
struct ifreq ifr;
|
||||
#endif
|
||||
|
||||
cp();
|
||||
|
||||
|
|
|
@ -17,30 +17,16 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.10 2003/07/12 17:41:48 guus Exp $
|
||||
$Id: device.c,v 1.1.2.11 2003/07/18 13:41:36 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <net/if.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils.h>
|
||||
#include "conf.h"
|
||||
#include "net.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "logger.h"
|
||||
#include "net.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/tun0"
|
||||
|
||||
#define DEVICE_TYPE_ETHERTAP 0
|
||||
|
@ -49,7 +35,7 @@
|
|||
int device_fd = -1;
|
||||
int device_type;
|
||||
char *device;
|
||||
char *interface;
|
||||
char *iface;
|
||||
char *device_info;
|
||||
|
||||
int device_total_in = 0;
|
||||
|
@ -62,8 +48,8 @@ int setup_device(void)
|
|||
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
|
||||
device = DEFAULT_DEVICE;
|
||||
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
|
||||
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||
iface = 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));
|
||||
return -1;
|
||||
|
|
|
@ -17,30 +17,16 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.15 2003/07/12 17:41:48 guus Exp $
|
||||
$Id: device.c,v 1.1.2.16 2003/07/18 13:41:36 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <net/if.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils.h>
|
||||
#include "conf.h"
|
||||
#include "net.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "conf.h"
|
||||
#include "logger.h"
|
||||
#include "net.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/tun0"
|
||||
|
||||
#define DEVICE_TYPE_ETHERTAP 0
|
||||
|
@ -49,7 +35,7 @@
|
|||
int device_fd = -1;
|
||||
int device_type;
|
||||
char *device;
|
||||
char *interface;
|
||||
char *iface;
|
||||
char *device_info;
|
||||
|
||||
int device_total_in = 0;
|
||||
|
@ -62,8 +48,8 @@ int setup_device(void)
|
|||
if(!get_config_string(lookup_config(config_tree, "Device"), &device))
|
||||
device = DEFAULT_DEVICE;
|
||||
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
|
||||
interface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||
iface = 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));
|
||||
return -1;
|
||||
|
|
|
@ -17,39 +17,27 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.14 2003/07/12 17:41:48 guus Exp $
|
||||
$Id: device.c,v 1.1.2.15 2003/07/18 13:41:37 guus Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stropts.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <net/if_tun.h>
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/tun"
|
||||
|
||||
#include <utils.h>
|
||||
#include "conf.h"
|
||||
#include "net.h"
|
||||
#include "logger.h"
|
||||
#include "net.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "system.h"
|
||||
#define DEFAULT_DEVICE "/dev/tun"
|
||||
|
||||
int device_fd = -1;
|
||||
int device_type;
|
||||
char *device = NULL;
|
||||
char *interface = NULL;
|
||||
char *iface = NULL;
|
||||
char ifrname[IFNAMSIZ];
|
||||
char *device_info = NULL;
|
||||
|
||||
|
@ -112,8 +100,8 @@ int setup_device(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &interface))
|
||||
asprintf(&interface, "tun%d", ppa);
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||
asprintf(&iface, "tun%d", ppa);
|
||||
|
||||
device_info = _("Solaris tun device");
|
||||
|
||||
|
|
Loading…
Reference in a new issue