Changeset 5978

Show
Ignore:
Timestamp:
03/28/10 21:42:09 (3 years ago)
Author:
Cyrus
Message:

nixio: Fix interface data for layer 3+ interfaces

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/nixio/src/address.c

    r5494 r5978  
    392392        lua_setfield(L, -2, "flags"); 
    393393 
    394         if (c->ifa_addr && !nixio__addr_parse(&addr, c->ifa_addr)) { 
    395             lua_pushstring(L, addr.host); 
    396             lua_setfield(L, -2, "addr"); 
     394        if (c->ifa_addr) { 
     395            if (!nixio__addr_parse(&addr, c->ifa_addr)) { 
     396                lua_pushstring(L, addr.host); 
     397                lua_setfield(L, -2, "addr"); 
     398            } 
    397399 
    398400            if (c->ifa_addr->sa_family == AF_INET) { 
     
    416418                lua_pushinteger(L, addr.prefix); 
    417419                lua_setfield(L, -2, "hatype"); 
    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 
    459469 
    460470        if (c->ifa_netmask && !nixio__addr_parse(&addr, c->ifa_netmask)) {