Changeset 6332

Show
Ignore:
Timestamp:
10/23/10 02:37:05 (3 years ago)
Author:
jow
Message:

libiwinfo: probe for vap availability in mbssid_support(), fix return type, fix description string for no crypto

Location:
luci/trunk/contrib/package/iwinfo/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/contrib/package/iwinfo/src/iwinfo.lua

    r6320 r6332  
    6363 
    6464    printf("          Encryption: %s", 
    65         s(enc and enc.description)) 
     65        s(enc and enc.description or "None")) 
     66 
     67    printf("          Supports VAPs: %s", 
     68        iw.mbssid_support(dev) and "yes" or "no") 
    6669 
    6770    print("") 
     
    8689 
    8790            printf("          Encryption: %s", 
    88                 s(se.encryption.description)) 
     91                s(se.encryption.description or "None")) 
    8992 
    9093            print("") 
  • luci/trunk/contrib/package/iwinfo/src/iwinfo_lualib.c

    r6320 r6332  
    433433                } 
    434434            } 
     435            else 
     436            { 
     437                sprintf(desc, "None"); 
     438            } 
    435439        } 
    436440        else 
     
    695699    } 
    696700 
    697     return 0; 
     701    lua_pushnil(L); 
     702    return 1; 
    698703} 
    699704 
    700705/* Wrapper for hwmode list */ 
    701 static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char*, int *)) 
     706static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *)) 
    702707{ 
    703708    const char *ifname = luaL_checkstring(L, 1); 
     
    723728    } 
    724729 
    725     return 0; 
     730    lua_pushnil(L); 
     731    return 1; 
     732} 
     733 
     734/* Wrapper for mbbsid_support */ 
     735static int iwinfo_L_mbssid_support(lua_State *L, int (*func)(const char *, int *)) 
     736{ 
     737    const char *ifname = luaL_checkstring(L, 1); 
     738    int support = 0; 
     739 
     740    if( !(*func)(ifname, &support) ) 
     741    { 
     742        lua_pushboolean(L, support); 
     743        return 1; 
     744    } 
     745 
     746    lua_pushnil(L); 
     747    return 1; 
    726748} 
    727749 
     
    793815LUA_WRAP_INT(wl,quality) 
    794816LUA_WRAP_INT(wl,quality_max) 
    795 LUA_WRAP_INT(wl,mbssid_support) 
    796817LUA_WRAP_STRING(wl,mode) 
    797818LUA_WRAP_STRING(wl,ssid) 
     
    805826LUA_WRAP_LIST(wl,hwmodelist) 
    806827LUA_WRAP_LIST(wl,encryption) 
     828LUA_WRAP_LIST(wl,mbssid_support) 
    807829#endif 
    808830 
     
    817839LUA_WRAP_INT(madwifi,quality) 
    818840LUA_WRAP_INT(madwifi,quality_max) 
    819 LUA_WRAP_INT(madwifi,mbssid_support) 
    820841LUA_WRAP_STRING(madwifi,mode) 
    821842LUA_WRAP_STRING(madwifi,ssid) 
     
    829850LUA_WRAP_LIST(madwifi,hwmodelist) 
    830851LUA_WRAP_LIST(madwifi,encryption) 
     852LUA_WRAP_LIST(madwifi,mbssid_support) 
    831853#endif 
    832854 
     
    841863LUA_WRAP_INT(nl80211,quality) 
    842864LUA_WRAP_INT(nl80211,quality_max) 
    843 LUA_WRAP_INT(nl80211,mbssid_support) 
    844865LUA_WRAP_STRING(nl80211,mode) 
    845866LUA_WRAP_STRING(nl80211,ssid) 
     
    853874LUA_WRAP_LIST(nl80211,hwmodelist) 
    854875LUA_WRAP_LIST(nl80211,encryption) 
     876LUA_WRAP_LIST(nl80211,mbssid_support) 
    855877#endif 
    856878 
     
    864886LUA_WRAP_INT(wext,quality) 
    865887LUA_WRAP_INT(wext,quality_max) 
    866 LUA_WRAP_INT(wext,mbssid_support) 
    867888LUA_WRAP_STRING(wext,mode) 
    868889LUA_WRAP_STRING(wext,ssid) 
     
    876897LUA_WRAP_LIST(wext,hwmodelist) 
    877898LUA_WRAP_LIST(wext,encryption) 
     899LUA_WRAP_LIST(wext,mbssid_support) 
    878900 
    879901#ifdef USE_WL 
  • luci/trunk/contrib/package/iwinfo/src/iwinfo_nl80211.c

    r6330 r6332  
    160160        goto err; 
    161161 
    162     if( !strncmp(ifname, "radio", 5) ) 
     162    if( !strncmp(ifname, "phy", 3) ) 
     163        phyidx = atoi(&ifname[3]); 
     164    else if( !strncmp(ifname, "radio", 5) ) 
    163165        phyidx = atoi(&ifname[5]); 
    164166    else if( !strncmp(ifname, "mon.", 4) ) 
     
    415417static char * nl80211_phy2ifname(const char *ifname) 
    416418{ 
    417     int fd, phyidx = 0; 
     419    int fd, phyidx = -1; 
    418420    char buffer[64]; 
    419421    static char nif[IFNAMSIZ] = { 0 }; 
     
    422424    struct dirent *e; 
    423425 
    424     if( !strncmp(ifname, "radio", 5) ) 
    425     { 
     426    if( !strncmp(ifname, "phy", 3) ) 
     427        phyidx = atoi(&ifname[3]); 
     428    else if( !strncmp(ifname, "radio", 5) ) 
    426429        phyidx = atoi(&ifname[5]); 
    427430 
     431    if( phyidx > -1 ) 
     432    { 
    428433        if( (d = opendir("/sys/class/net")) != NULL ) 
    429434        { 
     
    547552    int fd, pid = 0; 
    548553    char buf[32]; 
    549     char *phy = strncmp(ifname, "phy", 3) ? nl80211_ifname2phy(ifname) : ifname; 
     554    char *phy = nl80211_ifname2phy(ifname); 
    550555 
    551556    if( phy ) 
     
    15091514                    caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]); 
    15101515 
    1511                 /* Treat HT20/HT40 as 11n */ 
    1512                 if( caps & (1 << 1) ) 
     1516                /* Treat any nonzero capability as 11n */ 
     1517                if( caps > 0 ) 
    15131518                    *buf |= IWINFO_80211_N; 
    15141519 
     
    15431548int nl80211_get_mbssid_support(const char *ifname, int *buf) 
    15441549{ 
    1545     /* We assume that multi bssid is always possible */ 
    1546     *buf = 1; 
    1547     return 0; 
    1548 } 
     1550    /* test whether we can create another interface */ 
     1551    char *nif = nl80211_ifadd(ifname); 
     1552 
     1553    if( nif ) 
     1554    { 
     1555        *buf = (nl80211_ifmac(nif) && nl80211_ifup(nif)); 
     1556 
     1557        nl80211_ifdown(nif); 
     1558        nl80211_ifdel(nif); 
     1559 
     1560        return 0; 
     1561    } 
     1562 
     1563    return -1; 
     1564}