libiwinfo: add restricted flag for freqlist
[project/luci.git] / contrib / package / iwinfo / src / iwinfo_lualib.c
index 1377ffe..95600c8 100644 (file)
@@ -308,6 +308,21 @@ static int iwinfo_L_type(lua_State *L)
        return 1;
 }
 
+/* Shutdown backends */
+static int iwinfo_L__gc(lua_State *L)
+{
+#ifdef USE_WL
+       wl_close();
+#endif
+#ifdef USE_MADWIFI
+       madwifi_close();
+#endif
+#ifdef USE_NL80211
+       nl80211_close();
+#endif
+       wext_close();
+}
+
 /*
  * Build a short textual description of the crypto info
  */
@@ -656,6 +671,10 @@ static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int
                        lua_pushinteger(L, e->channel);
                        lua_setfield(L, -2, "channel");
 
+                       /* Restricted (DFS/TPC/Radar) */
+                       lua_pushboolean(L, e->restricted);
+                       lua_setfield(L, -2, "restricted");
+
                        lua_rawseti(L, -2, x);
                }
        }
@@ -930,6 +949,7 @@ static const luaL_reg R_wext[] = {
 /* Common */
 static const luaL_reg R_common[] = {
        { "type", iwinfo_L_type },
+       { "__gc", iwinfo_L__gc  },
        { NULL, NULL }
 };