- int lenin;
- u_int32_t type;
- struct iovec vector[2] = {{&type, sizeof(type)}, {packet->data + 14, MTU - 14}};
-cp
-
- if((lenin = readv(device_fd, vector, 2)) <= 0)
- {
- syslog(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, device, strerror(errno));
- return -1;
- }
-
- memcpy(packet->data, mymac.net.mac.address.x, 6);
- memcpy(packet->data + 6, mymac.net.mac.address.x, 6);
-
- switch(ntohl(type))
- {
- case AF_INET:
- packet->data[12] = 0x8;
- packet->data[13] = 0x0;
- break;
- case AF_INET6:
- packet->data[12] = 0x86;
- packet->data[13] = 0xDD;
- break;
- default:
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_ERR, _("Unknown address family %d while reading packet from %s %s"), ntohl(type), device_info, device);
- return -1;
- }
-
- packet->len = lenin + 10;
-
- 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;
+ u_int32_t type;
+ struct iovec vector[2] = {{&type, sizeof(type)}, {packet->data + 14, MTU - 14}};
+
+ cp();
+
+ if((lenin = readv(device_fd, vector, 2)) <= 0) {
+ logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
+ device, strerror(errno));
+ return false;
+ }
+
+ switch (ntohl(type)) {
+ case AF_INET:
+ packet->data[12] = 0x8;
+ packet->data[13] = 0x0;
+ break;
+
+ case AF_INET6:
+ packet->data[12] = 0x86;
+ packet->data[13] = 0xDD;
+ break;
+
+ default:
+ ifdebug(TRAFFIC) logger(LOG_ERR,
+ _ ("Unknown address family %d while reading packet from %s %s"),
+ ntohl(type), device_info, device);
+ return false;
+ }
+
+ packet->len = lenin + 10;
+
+ device_total_in += packet->len;
+
+ ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
+ device_info);
+
+ return true;