projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
61b9022
)
nixio: Fix interface data for layer 3+ interfaces
author
Steven Barth
<steven@midlink.org>
Sun, 28 Mar 2010 19:42:09 +0000
(19:42 +0000)
committer
Steven Barth
<steven@midlink.org>
Sun, 28 Mar 2010 19:42:09 +0000
(19:42 +0000)
libs/nixio/src/address.c
patch
|
blob
|
history
diff --git
a/libs/nixio/src/address.c
b/libs/nixio/src/address.c
index
41c6b8a
..
eff05e3
100644
(file)
--- a/
libs/nixio/src/address.c
+++ b/
libs/nixio/src/address.c
@@
-391,9
+391,11
@@
static int nixio_getifaddrs(lua_State *L) {
lua_setfield(L, -2, "multicast");
lua_setfield(L, -2, "flags");
lua_setfield(L, -2, "multicast");
lua_setfield(L, -2, "flags");
- if (c->ifa_addr && !nixio__addr_parse(&addr, c->ifa_addr)) {
- lua_pushstring(L, addr.host);
- lua_setfield(L, -2, "addr");
+ if (c->ifa_addr) {
+ if (!nixio__addr_parse(&addr, c->ifa_addr)) {
+ lua_pushstring(L, addr.host);
+ lua_setfield(L, -2, "addr");
+ }
if (c->ifa_addr->sa_family == AF_INET) {
lua_pushliteral(L, "inet");
if (c->ifa_addr->sa_family == AF_INET) {
lua_pushliteral(L, "inet");
@@
-415,47
+417,55
@@
static int nixio_getifaddrs(lua_State *L) {
lua_pushinteger(L, addr.prefix);
lua_setfield(L, -2, "hatype");
lua_pushinteger(L, addr.prefix);
lua_setfield(L, -2, "hatype");
+ }
+#endif
+ }
- if (c->ifa_data) {
- lua_createtable(L, 0, 10);
- struct nixio__nds *stats = c->ifa_data;
+#ifdef __linux__
+ if (c->ifa_data && (!c->ifa_addr
+ || c->ifa_addr->sa_family == AF_PACKET)) {
+ if (!c->ifa_addr) {
+ lua_pushliteral(L, "packet");
+ lua_setfield(L, -2, "family");
+ }
-
lua_pushnumber(L, stats->rx_packets
);
-
lua_setfield(L, -2, "rx_packets")
;
+
lua_createtable(L, 0, 10
);
+
struct nixio__nds *stats = c->ifa_data
;
-
lua_pushnumber(L, stats->t
x_packets);
-
lua_setfield(L, -2, "t
x_packets");
+
lua_pushnumber(L, stats->r
x_packets);
+
lua_setfield(L, -2, "r
x_packets");
-
lua_pushnumber(L, stats->rx_byte
s);
-
lua_setfield(L, -2, "rx_byte
s");
+
lua_pushnumber(L, stats->tx_packet
s);
+
lua_setfield(L, -2, "tx_packet
s");
-
lua_pushnumber(L, stats->t
x_bytes);
-
lua_setfield(L, -2, "t
x_bytes");
+
lua_pushnumber(L, stats->r
x_bytes);
+
lua_setfield(L, -2, "r
x_bytes");
-
lua_pushnumber(L, stats->rx_error
s);
-
lua_setfield(L, -2, "rx_error
s");
+
lua_pushnumber(L, stats->tx_byte
s);
+
lua_setfield(L, -2, "tx_byte
s");
-
lua_pushnumber(L, stats->t
x_errors);
-
lua_setfield(L, -2, "t
x_errors");
+
lua_pushnumber(L, stats->r
x_errors);
+
lua_setfield(L, -2, "r
x_errors");
-
lua_pushnumber(L, stats->rx_dropped
);
-
lua_setfield(L, -2, "rx_dropped
");
+
lua_pushnumber(L, stats->tx_errors
);
+
lua_setfield(L, -2, "tx_errors
");
-
lua_pushnumber(L, stats->t
x_dropped);
-
lua_setfield(L, -2, "t
x_dropped");
+
lua_pushnumber(L, stats->r
x_dropped);
+
lua_setfield(L, -2, "r
x_dropped");
-
lua_pushnumber(L, stats->multicast
);
-
lua_setfield(L, -2, "multicast
");
+
lua_pushnumber(L, stats->tx_dropped
);
+
lua_setfield(L, -2, "tx_dropped
");
- lua_pushnumber(L, stats->collisions);
- lua_setfield(L, -2, "collisions");
- } else {
- lua_newtable(L);
- }
- lua_setfield(L, -2, "data");
- }
-#endif
+ lua_pushnumber(L, stats->multicast);
+ lua_setfield(L, -2, "multicast");
+
+ lua_pushnumber(L, stats->collisions);
+ lua_setfield(L, -2, "collisions");
+ } else {
+ lua_newtable(L);
}
}
+ lua_setfield(L, -2, "data");
+#endif
if (c->ifa_netmask && !nixio__addr_parse(&addr, c->ifa_netmask)) {
lua_pushstring(L, addr.host);
if (c->ifa_netmask && !nixio__addr_parse(&addr, c->ifa_netmask)) {
lua_pushstring(L, addr.host);