- int lenin;
-cp
- if(device_type == DEVICE_TYPE_TUNTAP)
- {
- if((lenin = read(device_fd, packet->data, MTU)) <= 0)
- {
- syslog(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, device, strerror(errno));
- return -1;
- }
-
- packet->len = lenin;
- }
- else /* ethertap */
- {
- if((lenin = read(device_fd, packet->data - 2, MTU + 2)) <= 0)
- {
- syslog(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, device, strerror(errno));
- return -1;
- }
-
- packet->len = lenin - 2;
- }
-
- device_total_in += packet->len;
-
- if(debug_lvl >= DEBUG_TRAFFIC)
- {
- syslog(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len, device_info);
- }
-
- return 0;
-cp
+ int lenin;
+
+ cp();
+
+ 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 -1;
+ }
+
+ 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 -1;
+ }
+
+ 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 -1;
+ }
+
+ packet->len = lenin - 2;
+ break;
+ }
+
+ device_total_in += packet->len;
+
+ ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
+ device_info);
+
+ return 0;