TunDevice_PT.cc: Properly report tun device write errors

This commit is contained in:
Harald Welte 2017-07-06 19:37:08 +01:00
parent 5224db9da9
commit 65e28822be
1 changed files with 7 additions and 3 deletions

View File

@ -2,6 +2,7 @@
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@ -103,10 +104,9 @@ TunDevice__PT_PROVIDER::~TunDevice__PT_PROVIDER()
}
/* setting a port parameter via config file */
void TunDevice__PT_PROVIDER::set_parameter(const char *parameter_name,
const char *parameter_value)
void TunDevice__PT_PROVIDER::set_parameter(const char *parameter_name, const char *parameter_value)
{
printf("%s(%s, %s)\n", __func__, parameter_name, parameter_value);
//printf("%s(%s, %s)\n", __func__, parameter_name, parameter_value);
if (!strcmp(parameter_name, "device_name"))
tun_data.dev = strdup(parameter_value);
if (!strcmp(parameter_name, "debugging"))
@ -175,6 +175,10 @@ void TunDevice__PT_PROVIDER::outgoing_send(const TunDevice__Types::Tun__send& se
rc = write(tun_data.fd, (const char*)(const unsigned char*)send_par.msg(),
send_par.msg().lengthof());
if (rc < 0) {
TTCN_error("writing to tun");
return;
}
log("Nr of bytes sent = %d", rc);
log("leaving %s", __func__);
}