- cp();
-
- if(device_type == DEVICE_TYPE_TUNTAP) {
- lenin = read(device_fd, packet->data, MTU);
-
- if(lenin <= 0) {
- syslog(LOG_ERR, _("Error while reading from %s %s: %s"),
- device_info, device, strerror(errno));
- return -1;
- }
-
- packet->len = lenin;
- } else { /* ethertap */
-
- lenin = read(device_fd, packet->data - 2, MTU + 2);
-
- if(lenin <= 0) {
- syslog(LOG_ERR, _("Error while reading from %s %s: %s"),
- device_info, device, strerror(errno));
- return -1;
- }
-
- packet->len = lenin - 2;
+ switch(device_type) {
+ case DEVICE_TYPE_TUN:
+ lenin = read(device_fd, packet->data + 10, MTU - 10);
+
+ if(lenin <= 0) {
+ logger(LOG_ERR, "Error while reading from %s %s: %s",
+ device_info, device, strerror(errno));
+ return false;
+ }
+
+ memset(packet->data, 0, 12);
+ packet->len = lenin + 10;
+ break;
+ case DEVICE_TYPE_TAP:
+ lenin = read(device_fd, packet->data, MTU);
+
+ if(lenin <= 0) {
+ logger(LOG_ERR, "Error while reading from %s %s: %s",
+ device_info, device, strerror(errno));
+ return false;
+ }
+
+ packet->len = lenin;
+ break;
+ case DEVICE_TYPE_ETHERTAP:
+ lenin = read(device_fd, packet->data - 2, MTU + 2);
+
+ if(lenin <= 0) {
+ logger(LOG_ERR, "Error while reading from %s %s: %s",
+ device_info, device, strerror(errno));
+ return false;
+ }
+
+ packet->len = lenin - 2;
+ break;