#include "device.h"
#include "net.h"
#include "logger.h"
-#include "utils.h"
-#include "route.h"
#include "xalloc.h"
#if defined(PF_PACKET) && defined(ETH_P_ALL) && defined(AF_PACKET) && defined(SIOCGIFINDEX)
struct ifreq ifr;
struct sockaddr_ll sa;
- if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) {
+ if(!get_config_string(lookup_config(&config_tree, "Interface"), &iface)) {
iface = xstrdup("eth0");
}
- if(!get_config_string(lookup_config(config_tree, "Device"), &device)) {
+ if(!get_config_string(lookup_config(&config_tree, "Device"), &device)) {
device = xstrdup(iface);
}
#endif
strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ);
+ ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0;
if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) {
close(device_fd);
}
static bool read_packet(vpn_packet_t *packet) {
- int inlen;
+ ssize_t inlen;
if((inlen = read(device_fd, DATA(packet), MTU)) <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info,