| 418 | | |
| 419 | | if (c->ifa_data) { |
| 420 | | lua_createtable(L, 0, 10); |
| 421 | | struct nixio__nds *stats = c->ifa_data; |
| 422 | | |
| 423 | | lua_pushnumber(L, stats->rx_packets); |
| 424 | | lua_setfield(L, -2, "rx_packets"); |
| 425 | | |
| 426 | | lua_pushnumber(L, stats->tx_packets); |
| 427 | | lua_setfield(L, -2, "tx_packets"); |
| 428 | | |
| 429 | | lua_pushnumber(L, stats->rx_bytes); |
| 430 | | lua_setfield(L, -2, "rx_bytes"); |
| 431 | | |
| 432 | | lua_pushnumber(L, stats->tx_bytes); |
| 433 | | lua_setfield(L, -2, "tx_bytes"); |
| 434 | | |
| 435 | | lua_pushnumber(L, stats->rx_errors); |
| 436 | | lua_setfield(L, -2, "rx_errors"); |
| 437 | | |
| 438 | | lua_pushnumber(L, stats->tx_errors); |
| 439 | | lua_setfield(L, -2, "tx_errors"); |
| 440 | | |
| 441 | | lua_pushnumber(L, stats->rx_dropped); |
| 442 | | lua_setfield(L, -2, "rx_dropped"); |
| 443 | | |
| 444 | | lua_pushnumber(L, stats->tx_dropped); |
| 445 | | lua_setfield(L, -2, "tx_dropped"); |
| 446 | | |
| 447 | | lua_pushnumber(L, stats->multicast); |
| 448 | | lua_setfield(L, -2, "multicast"); |
| 449 | | |
| 450 | | lua_pushnumber(L, stats->collisions); |
| 451 | | lua_setfield(L, -2, "collisions"); |
| 452 | | } else { |
| 453 | | lua_newtable(L); |
| 454 | | } |
| 455 | | lua_setfield(L, -2, "data"); |
| 456 | | } |
| 457 | | #endif |
| 458 | | } |
| | 420 | } |
| | 421 | #endif |
| | 422 | } |
| | 423 | |
| | 424 | #ifdef __linux__ |
| | 425 | if (c->ifa_data && (!c->ifa_addr |
| | 426 | || c->ifa_addr->sa_family == AF_PACKET)) { |
| | 427 | if (!c->ifa_addr) { |
| | 428 | lua_pushliteral(L, "packet"); |
| | 429 | lua_setfield(L, -2, "family"); |
| | 430 | } |
| | 431 | |
| | 432 | lua_createtable(L, 0, 10); |
| | 433 | struct nixio__nds *stats = c->ifa_data; |
| | 434 | |
| | 435 | lua_pushnumber(L, stats->rx_packets); |
| | 436 | lua_setfield(L, -2, "rx_packets"); |
| | 437 | |
| | 438 | lua_pushnumber(L, stats->tx_packets); |
| | 439 | lua_setfield(L, -2, "tx_packets"); |
| | 440 | |
| | 441 | lua_pushnumber(L, stats->rx_bytes); |
| | 442 | lua_setfield(L, -2, "rx_bytes"); |
| | 443 | |
| | 444 | lua_pushnumber(L, stats->tx_bytes); |
| | 445 | lua_setfield(L, -2, "tx_bytes"); |
| | 446 | |
| | 447 | lua_pushnumber(L, stats->rx_errors); |
| | 448 | lua_setfield(L, -2, "rx_errors"); |
| | 449 | |
| | 450 | lua_pushnumber(L, stats->tx_errors); |
| | 451 | lua_setfield(L, -2, "tx_errors"); |
| | 452 | |
| | 453 | lua_pushnumber(L, stats->rx_dropped); |
| | 454 | lua_setfield(L, -2, "rx_dropped"); |
| | 455 | |
| | 456 | lua_pushnumber(L, stats->tx_dropped); |
| | 457 | lua_setfield(L, -2, "tx_dropped"); |
| | 458 | |
| | 459 | lua_pushnumber(L, stats->multicast); |
| | 460 | lua_setfield(L, -2, "multicast"); |
| | 461 | |
| | 462 | lua_pushnumber(L, stats->collisions); |
| | 463 | lua_setfield(L, -2, "collisions"); |
| | 464 | } else { |
| | 465 | lua_newtable(L); |
| | 466 | } |
| | 467 | lua_setfield(L, -2, "data"); |
| | 468 | #endif |