Changeset 7810 for luci/branches/luci-0.10/contrib/package
- Timestamp:
- 10/28/11 16:15:27 (19 months ago)
- Location:
- luci/branches/luci-0.10/contrib/package
- Files:
-
- 2 removed
- 30 modified
- 95 copied
-
. (modified) (1 prop)
-
community-profiles (copied) (copied from luci/trunk/contrib/package/community-profiles)
-
community-profiles/files (copied) (copied from luci/trunk/contrib/package/community-profiles/files)
-
community-profiles/files/etc (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc)
-
community-profiles/files/etc/config (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config)
-
community-profiles/files/etc/config/profile_aachen (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_aachen)
-
community-profiles/files/etc/config/profile_augsburg (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_augsburg)
-
community-profiles/files/etc/config/profile_bayreuth (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_bayreuth)
-
community-profiles/files/etc/config/profile_bensheim (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_bensheim)
-
community-profiles/files/etc/config/profile_bergischesland (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_bergischesland)
-
community-profiles/files/etc/config/profile_berlin (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_berlin)
-
community-profiles/files/etc/config/profile_carbodebit (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_carbodebit)
-
community-profiles/files/etc/config/profile_dresden (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_dresden)
-
community-profiles/files/etc/config/profile_duesseldorf (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_duesseldorf)
-
community-profiles/files/etc/config/profile_evernet (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_evernet)
-
community-profiles/files/etc/config/profile_Freifunk (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_Freifunk)
-
community-profiles/files/etc/config/profile_gadow (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_gadow)
-
community-profiles/files/etc/config/profile_guifibages (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_guifibages)
-
community-profiles/files/etc/config/profile_halle (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_halle)
-
community-profiles/files/etc/config/profile_hamburg (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_hamburg)
-
community-profiles/files/etc/config/profile_hannover (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_hannover)
-
community-profiles/files/etc/config/profile_heppenheim (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_heppenheim)
-
community-profiles/files/etc/config/profile_jena (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_jena)
-
community-profiles/files/etc/config/profile_kiberpipa (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_kiberpipa)
-
community-profiles/files/etc/config/profile_l59 (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_l59)
-
community-profiles/files/etc/config/profile_leipzig (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_leipzig)
-
community-profiles/files/etc/config/profile_mainz (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_mainz)
-
community-profiles/files/etc/config/profile_marburg (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_marburg)
-
community-profiles/files/etc/config/profile_neuss (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_neuss)
-
community-profiles/files/etc/config/profile_oldenburg (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_oldenburg)
-
community-profiles/files/etc/config/profile_openwireless_bern (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_openwireless_bern)
-
community-profiles/files/etc/config/profile_pberg (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_pberg)
-
community-profiles/files/etc/config/profile_piraten_dresden (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_piraten_dresden)
-
community-profiles/files/etc/config/profile_potsdam (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_potsdam)
-
community-profiles/files/etc/config/profile_rosbach (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_rosbach)
-
community-profiles/files/etc/config/profile_seefeld (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_seefeld)
-
community-profiles/files/etc/config/profile_wlanljubljana (copied) (copied from luci/trunk/contrib/package/community-profiles/files/etc/config/profile_wlanljubljana)
-
community-profiles/Makefile (copied) (copied from luci/trunk/contrib/package/community-profiles/Makefile)
-
freifunk-common (copied) (copied from luci/trunk/contrib/package/freifunk-common)
-
freifunk-common/files (copied) (copied from luci/trunk/contrib/package/freifunk-common/files)
-
freifunk-common/files/etc (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc)
-
freifunk-common/files/etc/config (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/config)
-
freifunk-common/files/etc/config/freifunk (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/config/freifunk)
-
freifunk-common/files/etc/init.d (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/init.d)
-
freifunk-common/files/etc/init.d/freifunk (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/init.d/freifunk)
-
freifunk-common/files/etc/rc.local.d (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/rc.local.d)
-
freifunk-common/files/etc/rc.local.d/01-config-migration (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/rc.local.d/01-config-migration)
-
freifunk-common/files/etc/uci-defaults (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/uci-defaults)
-
freifunk-common/files/etc/uci-defaults/freifunk (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/etc/uci-defaults/freifunk)
-
freifunk-common/files/usr (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/usr)
-
freifunk-common/files/usr/bin (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/usr/bin)
-
freifunk-common/files/usr/bin/ffdzero (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/usr/bin/ffdzero)
-
freifunk-common/files/usr/bin/neigh.sh (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/usr/bin/neigh.sh)
-
freifunk-common/files/usr/sbin (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/usr/sbin)
-
freifunk-common/files/usr/sbin/ff_olsr_watchdog (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog)
-
freifunk-common/files/usr/sbin/ff_rdate (copied) (copied from luci/trunk/contrib/package/freifunk-common/files/usr/sbin/ff_rdate)
-
freifunk-common/ipkg (copied) (copied from luci/trunk/contrib/package/freifunk-common/ipkg)
-
freifunk-common/ipkg/postinst (copied) (copied from luci/trunk/contrib/package/freifunk-common/ipkg/postinst)
-
freifunk-common/Makefile (copied) (copied from luci/trunk/contrib/package/freifunk-common/Makefile)
-
freifunk-firewall/files/etc/firewall.freifunk (modified) (1 diff)
-
freifunk-firewall/files/etc/hotplug.d/firewall/23-restricted-wan (modified) (1 prop)
-
freifunk-firewall/files/etc/hotplug.d/iface (deleted)
-
freifunk-firewall/Makefile (modified) (1 diff)
-
freifunk-gwcheck (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck)
-
freifunk-gwcheck/files (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/files)
-
freifunk-gwcheck/files/etc (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/files/etc)
-
freifunk-gwcheck/files/etc/config (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/files/etc/config)
-
freifunk-gwcheck/files/etc/config/freifunk-gwcheck (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/files/etc/config/freifunk-gwcheck)
-
freifunk-gwcheck/files/usr (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/files/usr)
-
freifunk-gwcheck/files/usr/sbin (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/files/usr/sbin)
-
freifunk-gwcheck/files/usr/sbin/ff_olsr_test_gw.sh (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/files/usr/sbin/ff_olsr_test_gw.sh)
-
freifunk-gwcheck/ipkg (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/ipkg)
-
freifunk-gwcheck/ipkg/postinst (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/ipkg/postinst)
-
freifunk-gwcheck/ipkg/postrm (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/ipkg/postrm)
-
freifunk-gwcheck/Makefile (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/Makefile)
-
freifunk-gwcheck/root (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/root)
-
freifunk-gwcheck/root/etc (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/root/etc)
-
freifunk-gwcheck/root/etc/uci-defaults (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/root/etc/uci-defaults)
-
freifunk-gwcheck/root/etc/uci-defaults/freifunk-gwcheck (copied) (copied from luci/trunk/contrib/package/freifunk-gwcheck/root/etc/uci-defaults/freifunk-gwcheck)
-
freifunk-mapupdate (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate)
-
freifunk-mapupdate/files (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/files)
-
freifunk-mapupdate/files/etc (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/files/etc)
-
freifunk-mapupdate/files/etc/config (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/files/etc/config)
-
freifunk-mapupdate/files/etc/config/freifunk-mapupdate (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/files/etc/config/freifunk-mapupdate)
-
freifunk-mapupdate/files/usr (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/files/usr)
-
freifunk-mapupdate/files/usr/sbin (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/files/usr/sbin)
-
freifunk-mapupdate/files/usr/sbin/ff_mapupdate.sh (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/files/usr/sbin/ff_mapupdate.sh)
-
freifunk-mapupdate/ipkg (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/ipkg)
-
freifunk-mapupdate/ipkg/postinst (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/ipkg/postinst)
-
freifunk-mapupdate/ipkg/postrm (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/ipkg/postrm)
-
freifunk-mapupdate/Makefile (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/Makefile)
-
freifunk-mapupdate/root (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/root)
-
freifunk-mapupdate/root/etc (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/root/etc)
-
freifunk-mapupdate/root/etc/uci-defaults (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/root/etc/uci-defaults)
-
freifunk-mapupdate/root/etc/uci-defaults/freifunk-mapupdate (copied) (copied from luci/trunk/contrib/package/freifunk-mapupdate/root/etc/uci-defaults/freifunk-mapupdate)
-
freifunk-p2pblock (modified) (1 prop)
-
freifunk-p2pblock/Makefile (modified) (1 diff)
-
freifunk-policyrouting (modified) (1 prop)
-
freifunk-policyrouting/Makefile (modified) (1 diff)
-
freifunk-watchdog/Makefile (modified) (1 diff)
-
iwinfo (modified) (1 prop)
-
iwinfo/Makefile (modified) (2 diffs)
-
iwinfo/src/iwinfo_nl80211.c (modified) (69 diffs)
-
iwinfo/src/iwinfo_nl80211.h (modified) (2 diffs)
-
luci/Makefile (modified) (22 diffs)
-
meshwizard/files/usr/bin/meshwizard/functions.sh (modified) (2 diffs)
-
meshwizard/files/usr/bin/meshwizard/helpers/gen_bssid.sh (modified) (1 diff)
-
meshwizard/files/usr/bin/meshwizard/helpers/initial_config.sh (modified) (2 diffs)
-
meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh (modified) (1 diff)
-
meshwizard/files/usr/bin/meshwizard/helpers/rename-wifi.sh (modified) (2 diffs)
-
meshwizard/files/usr/bin/meshwizard/helpers/restore_default_config.sh (copied) (copied from luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/restore_default_config.sh)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh (modified) (2 diffs)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh (modified) (1 diff)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh (modified) (3 diffs)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh (copied) (copied from luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall_interface.sh)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_lan_static.sh (copied) (copied from luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_lan_static.sh)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh (modified) (4 diffs)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh (modified) (3 diffs)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd_interface.sh (copied) (copied from luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd_interface.sh)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh (modified) (1 diff)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh (modified) (1 diff)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_wan_static.sh (copied) (copied from luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wan_static.sh)
-
meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh (modified) (3 diffs)
-
meshwizard/files/usr/bin/meshwizard/wizard.sh (modified) (2 diffs)
-
meshwizard/Makefile (modified) (2 diffs)
-
remote-update/Makefile (modified) (1 diff)
-
zoneinfo (deleted)
Legend:
- Unmodified
- Added
- Removed
-
luci/branches/luci-0.10/contrib/package
- Property svn:mergeinfo deleted
-
luci/branches/luci-0.10/contrib/package/freifunk-firewall/files/etc/firewall.freifunk
r7038 r7810 37 37 config_foreach apply_advanced advanced 38 38 39 40 #41 # Apply fixes for masquerading rules42 #43 apply_nat_fix() {44 local up45 local ifname46 config_get up $1 up47 [ -n "$up" ] || return 048 (ACTION="ifup" INTERFACE="$1" . /etc/hotplug.d/iface/22-firewall-nat-fix )49 }50 51 uci_set_state firewall core loaded 152 config_foreach fw_addif interface53 config_foreach apply_nat_fix interface54 55 39 [ -x /etc/init.d/luci_splash ] && ( sleep 3; /etc/init.d/luci_splash restart )& 56 40 -
luci/branches/luci-0.10/contrib/package/freifunk-firewall/files/etc/hotplug.d/firewall/23-restricted-wan
- Property svn:mergeinfo deleted
-
luci/branches/luci-0.10/contrib/package/freifunk-firewall/Makefile
r5310 r7810 17 17 SECTION:=luci 18 18 CATEGORY:=LuCI 19 SUBMENU:= Freifunk19 SUBMENU:=9. Freifunk 20 20 TITLE:=Freifunk Firewall Addon 21 21 DEPENDS:=+firewall -
luci/branches/luci-0.10/contrib/package/freifunk-p2pblock
- Property svn:mergeinfo deleted
-
luci/branches/luci-0.10/contrib/package/freifunk-p2pblock/Makefile
r7243 r7810 18 18 SECTION:=luci 19 19 CATEGORY:=LuCI 20 SUBMENU:= Freifunk20 SUBMENU:=9. Freifunk 21 21 TITLE:=Freifunk p2pblock Addon 22 22 DEPENDS:=+iptables-mod-filter +iptables-mod-ipp2p +l7-protocols +iptables-mod-conntrack-extra -
luci/branches/luci-0.10/contrib/package/freifunk-policyrouting
- Property svn:mergeinfo deleted
-
luci/branches/luci-0.10/contrib/package/freifunk-policyrouting/Makefile
r7038 r7810 14 14 SECTION:=luci 15 15 CATEGORY:=LuCI 16 SUBMENU:= Freifunk16 SUBMENU:=9. Freifunk 17 17 TITLE:=Freifunk policy routing addon 18 18 DEPENDS:=+firewall +ip -
luci/branches/luci-0.10/contrib/package/freifunk-watchdog/Makefile
r5359 r7810 19 19 SECTION:=luci 20 20 CATEGORY:=LuCI 21 SUBMENU:= Freifunk21 SUBMENU:=9. Freifunk 22 22 TITLE:=Freifunk Ad-Hoc watchdog daemon 23 23 DEPENDS:=libuci -
luci/branches/luci-0.10/contrib/package/iwinfo
- Property svn:mergeinfo deleted
-
luci/branches/luci-0.10/contrib/package/iwinfo/Makefile
r7248 r7810 8 8 9 9 PKG_NAME:=libiwinfo 10 PKG_RELEASE:=1 510 PKG_RELEASE:=16 11 11 12 12 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) … … 18 18 SECTION:=luci 19 19 CATEGORY:=LuCI 20 SUBMENU:= Libraries20 SUBMENU:=8. Libraries 21 21 TITLE:=Generalized Wireless Information Library (iwinfo) 22 22 DEPENDS:=+PACKAGE_kmod-mac80211:libnl-tiny +liblua +lua -
luci/branches/luci-0.10/contrib/package/iwinfo/src/iwinfo_nl80211.c
r7335 r7810 35 35 int err, fd; 36 36 37 if ( !nls)37 if (!nls) 38 38 { 39 39 nls = malloc(sizeof(struct nl80211_state)); 40 if ( !nls) {40 if (!nls) { 41 41 err = -ENOMEM; 42 42 goto err; … … 44 44 45 45 nls->nl_sock = nl_socket_alloc(); 46 if ( !nls->nl_sock) {46 if (!nls->nl_sock) { 47 47 err = -ENOMEM; 48 48 goto err; … … 55 55 56 56 fd = nl_socket_get_fd(nls->nl_sock); 57 if ( fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) < 0)57 if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) < 0) 58 58 { 59 59 err = -EINVAL; … … 67 67 68 68 nls->nl80211 = genl_ctrl_search_by_name(nls->nl_cache, "nl80211"); 69 if ( !nls->nl80211)69 if (!nls->nl80211) 70 70 { 71 71 err = -ENOENT; … … 106 106 static int nl80211_msg_response(struct nl_msg *msg, void *arg) 107 107 { 108 struct nl80211_msg_conveyor *cv = arg;109 110 nlmsg_get(msg);111 112 cv->msg = msg;113 cv->hdr = nlmsg_data(nlmsg_hdr(cv->msg));114 115 nla_parse(cv->attr, NL80211_ATTR_MAX,116 genlmsg_attrdata(cv->hdr, 0),117 genlmsg_attrlen(cv->hdr, 0), NULL);118 119 108 return NL_SKIP; 120 109 } … … 122 111 static void nl80211_free(struct nl80211_msg_conveyor *cv) 123 112 { 124 if ( cv)125 { 126 if ( cv->cb)113 if (cv) 114 { 115 if (cv->cb) 127 116 nl_cb_put(cv->cb); 128 117 129 if ( cv->msg)118 if (cv->msg) 130 119 nlmsg_free(cv->msg); 131 120 … … 143 132 struct nl_cb *cb = NULL; 144 133 145 if ( nl80211_init() < 0)134 if (nl80211_init() < 0) 146 135 goto err; 147 136 148 if ( !strncmp(ifname, "phy", 3))137 if (!strncmp(ifname, "phy", 3)) 149 138 phyidx = atoi(&ifname[3]); 150 else if ( !strncmp(ifname, "radio", 5))139 else if (!strncmp(ifname, "radio", 5)) 151 140 phyidx = atoi(&ifname[5]); 152 else if ( !strncmp(ifname, "mon.", 4))141 else if (!strncmp(ifname, "mon.", 4)) 153 142 ifidx = if_nametoindex(&ifname[4]); 154 143 else 155 144 ifidx = if_nametoindex(ifname); 156 145 157 if ( (ifidx < 0) && (phyidx < 0))146 if ((ifidx < 0) && (phyidx < 0)) 158 147 return NULL; 159 148 160 149 req = nlmsg_alloc(); 161 if ( !req)150 if (!req) 162 151 goto err; 163 152 164 153 cb = nl_cb_alloc(NL_CB_DEFAULT); 165 if ( !cb)154 if (!cb) 166 155 goto err; 167 156 … … 169 158 flags, cmd, 0); 170 159 171 if ( ifidx > -1)160 if (ifidx > -1) 172 161 NLA_PUT_U32(req, NL80211_ATTR_IFINDEX, ifidx); 173 162 174 if ( phyidx > -1)163 if (phyidx > -1) 175 164 NLA_PUT_U32(req, NL80211_ATTR_WIPHY, phyidx); 176 165 177 nlmsg_get(req); 178 179 cv.msg = req; 180 cv.cb = cb; 181 cv.custom_cb = 0; 166 cv.msg = req; 167 cv.cb = cb; 182 168 183 169 return &cv; … … 185 171 err: 186 172 nla_put_failure: 187 if ( cb)173 if (cb) 188 174 nl_cb_put(cb); 189 175 190 if ( req)176 if (req) 191 177 nlmsg_free(req); 192 178 … … 194 180 } 195 181 196 static void nl80211_cb(struct nl80211_msg_conveyor *cv, 197 int (*cb)(struct nl_msg *, void *), void *arg) 198 { 199 cv->custom_cb = 1; 200 nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, cb, arg); 201 } 202 203 static struct nl80211_msg_conveyor * nl80211_send(struct nl80211_msg_conveyor *cv) 204 { 182 static struct nl80211_msg_conveyor * nl80211_send( 183 struct nl80211_msg_conveyor *cv, 184 int (*cb_func)(struct nl_msg *, void *), void *cb_arg 185 ) { 205 186 static struct nl80211_msg_conveyor rcv; 206 187 int err = 1; 207 188 208 if( !cv->custom_cb ) 189 if (cb_func) 190 nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, cb_func, cb_arg); 191 else 209 192 nl_cb_set(cv->cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_msg_response, &rcv); 210 193 211 if ( nl_send_auto_complete(nls->nl_sock, cv->msg) < 0)194 if (nl_send_auto_complete(nls->nl_sock, cv->msg) < 0) 212 195 goto err; 213 196 … … 226 209 227 210 return NULL; 211 } 212 213 static struct nlattr ** nl80211_parse(struct nl_msg *msg) 214 { 215 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 216 static struct nlattr *attr[NL80211_ATTR_MAX + 1]; 217 218 nla_parse(attr, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 219 genlmsg_attrlen(gnlh, 0), NULL); 220 221 return attr; 228 222 } 229 223 … … 251 245 for( i = 0, len = strlen(buf); i < len; i++ ) 252 246 { 253 if ( !lkey[0] && (buf[i] == ' ' || buf[i] == '\t'))247 if (!lkey[0] && (buf[i] == ' ' || buf[i] == '\t')) 254 248 { 255 249 ln++; 256 250 } 257 else if ( !lkey[0] && (buf[i] == '='))258 { 259 if ( (&buf[i] - ln) > 0)251 else if (!lkey[0] && (buf[i] == '=')) 252 { 253 if ((&buf[i] - ln) > 0) 260 254 memcpy(lkey, ln, min(sizeof(lkey) - 1, &buf[i] - ln)); 261 255 } 262 else if ( buf[i] == '\n')263 { 264 if ( lkey[0])256 else if (buf[i] == '\n') 257 { 258 if (lkey[0]) 265 259 { 266 260 memcpy(lval, ln + strlen(lkey) + 1, 267 261 min(sizeof(lval) - 1, &buf[i] - ln - strlen(lkey) - 1)); 268 262 269 if ( (ifname != NULL) &&263 if ((ifname != NULL) && 270 264 (!strcmp(lkey, "interface") || !strcmp(lkey, "bss")) ) 271 265 { 272 266 matched_if = !strcmp(lval, ifname); 273 267 } 274 else if ( matched_if && !strcmp(lkey, key))268 else if (matched_if && !strcmp(lkey, key)) 275 269 { 276 270 return lval; … … 287 281 } 288 282 283 static int nl80211_ifname2phy_cb(struct nl_msg *msg, void *arg) 284 { 285 char *buf = arg; 286 struct nlattr **attr = nl80211_parse(msg); 287 288 if (attr[NL80211_ATTR_WIPHY_NAME]) 289 sprintf(buf, "%s", nla_data(attr[NL80211_ATTR_WIPHY_NAME])); 290 else 291 buf[0] = 0; 292 293 return NL_SKIP; 294 } 295 289 296 static char * nl80211_ifname2phy(const char *ifname) 290 297 { 291 298 static char phy[32] = { 0 }; 292 struct nl80211_msg_conveyor *req , *res;299 struct nl80211_msg_conveyor *req; 293 300 294 301 req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0); 295 if( req ) 296 { 297 res = nl80211_send(req); 298 if( res ) 299 { 300 if( res->attr[NL80211_ATTR_WIPHY_NAME] ) 301 { 302 snprintf(phy, sizeof(phy), "%s", 303 nla_get_string(res->attr[NL80211_ATTR_WIPHY_NAME])); 304 } 305 nl80211_free(res); 306 } 302 if (req) 303 { 304 nl80211_send(req, nl80211_ifname2phy_cb, phy); 307 305 nl80211_free(req); 308 306 } … … 318 316 FILE *conf; 319 317 320 if ( (phy = nl80211_ifname2phy(ifname)) != NULL)318 if ((phy = nl80211_ifname2phy(ifname)) != NULL) 321 319 { 322 320 snprintf(path, sizeof(path), "/var/run/hostapd-%s.conf", phy); 323 321 324 if ( (conf = fopen(path, "r")) != NULL)322 if ((conf = fopen(path, "r")) != NULL) 325 323 { 326 324 fread(buf, sizeof(buf) - 1, 1, conf); … … 345 343 346 344 347 if ( select(sock + 1, &rfds, NULL, NULL, &tv) < 0)345 if (select(sock + 1, &rfds, NULL, NULL, &tv) < 0) 348 346 return -1; 349 347 350 if ( !FD_ISSET(sock, &rfds))348 if (!FD_ISSET(sock, &rfds)) 351 349 return -1; 352 350 … … 368 366 369 367 sock = socket(PF_UNIX, SOCK_DGRAM, 0); 370 if ( sock < 0)368 if (sock < 0) 371 369 return NULL; 372 370 … … 375 373 "/var/run/wpa_supplicant-%s/%s", ifname, ifname); 376 374 377 if ( fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC) < 0)375 if (fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC) < 0) 378 376 goto out; 379 377 380 if ( connect(sock, (struct sockaddr *) &remote, remote_length))378 if (connect(sock, (struct sockaddr *) &remote, remote_length)) 381 379 goto out; 382 380 … … 385 383 "/var/run/iwinfo-%s-%d", ifname, getpid()); 386 384 387 if ( bind(sock, (struct sockaddr *) &local, local_length))385 if (bind(sock, (struct sockaddr *) &local, local_length)) 388 386 goto out; 389 387 … … 391 389 send(sock, "ATTACH", 6, 0); 392 390 393 if ( nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)391 if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0) 394 392 goto out; 395 393 … … 399 397 while( numtry++ < 5 ) 400 398 { 401 if ( nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0)402 { 403 if ( event)399 if (nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0) 400 { 401 if (event) 404 402 continue; 405 403 … … 407 405 } 408 406 409 if ( (!event && buffer[0] != '<') || strstr(buffer, event))407 if ((!event && buffer[0] != '<') || strstr(buffer, event)) 410 408 break; 411 409 } … … 416 414 close(sock); 417 415 418 if ( local.sun_family)416 if (local.sun_family) 419 417 unlink(local.sun_path); 420 418 … … 428 426 char buffer[16]; 429 427 430 if ( (fd = open(path, O_RDONLY)) > -1)431 { 432 if ( read(fd, buffer, sizeof(buffer)) > 0)428 if ((fd = open(path, O_RDONLY)) > -1) 429 { 430 if (read(fd, buffer, sizeof(buffer)) > 0) 433 431 rv = atoi(buffer); 434 432 … … 448 446 struct dirent *e; 449 447 450 if ( !ifname)448 if (!ifname) 451 449 return NULL; 452 else if ( !strncmp(ifname, "phy", 3))450 else if (!strncmp(ifname, "phy", 3)) 453 451 phyidx = atoi(&ifname[3]); 454 else if ( !strncmp(ifname, "radio", 5))452 else if (!strncmp(ifname, "radio", 5)) 455 453 phyidx = atoi(&ifname[5]); 456 454 457 if ( phyidx > -1)458 { 459 if ( (d = opendir("/sys/class/net")) != NULL)455 if (phyidx > -1) 456 { 457 if ((d = opendir("/sys/class/net")) != NULL) 460 458 { 461 459 while( (e = readdir(d)) != NULL ) … … 464 462 "/sys/class/net/%s/phy80211/index", e->d_name); 465 463 466 if ( nl80211_readint(buffer) == phyidx)464 if (nl80211_readint(buffer) == phyidx) 467 465 { 468 466 snprintf(buffer, sizeof(buffer), … … 493 491 494 492 req = nl80211_msg(ifname, NL80211_CMD_NEW_INTERFACE, 0); 495 if ( req)493 if (req) 496 494 { 497 495 snprintf(nif, sizeof(nif), "tmp.%s", ifname); … … 500 498 NLA_PUT_U32(req->msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_STATION); 501 499 502 res = nl80211_send(req); 503 if( res ) 504 { 505 rv = nif; 506 nl80211_free(res); 507 } 500 nl80211_send(req, NULL, NULL); 501 502 rv = nif; 508 503 509 504 nla_put_failure: … … 519 514 520 515 req = nl80211_msg(ifname, NL80211_CMD_DEL_INTERFACE, 0); 521 if ( req)516 if (req) 522 517 { 523 518 NLA_PUT_STRING(req->msg, NL80211_ATTR_IFNAME, ifname); 524 519 525 nl80211_ free(nl80211_send(req));520 nl80211_send(req, NULL, NULL); 526 521 527 522 nla_put_failure: … … 536 531 char *phy = nl80211_ifname2phy(ifname); 537 532 538 if ( phy)533 if (phy) 539 534 { 540 535 snprintf(buf, sizeof(buf), "/var/run/wifi-%s.pid", phy); 541 if ( (fd = open(buf, O_RDONLY)) > 0)542 { 543 if ( read(fd, buf, sizeof(buf)) > 0)536 if ((fd = open(buf, O_RDONLY)) > 0) 537 { 538 if (read(fd, buf, sizeof(buf)) > 0) 544 539 pid = atoi(buf); 545 540 … … 547 542 } 548 543 549 if ( pid > 0)544 if (pid > 0) 550 545 kill(pid, 1); 551 546 } … … 560 555 void nl80211_close(void) 561 556 { 562 if ( nls)563 { 564 if ( nls->nl_sock)557 if (nls) 558 { 559 if (nls->nl_sock) 565 560 nl_socket_free(nls->nl_sock); 566 561 567 if ( nls->nl_cache)562 if (nls->nl_cache) 568 563 nl_cache_free(nls->nl_cache); 569 564 … … 582 577 char *ssid; 583 578 584 if ( !wext_get_ssid(ifname, buf))579 if (!wext_get_ssid(ifname, buf)) 585 580 { 586 581 return 0; … … 601 596 unsigned char mac[6]; 602 597 603 if ( !wext_get_bssid(ifname, buf))598 if (!wext_get_bssid(ifname, buf)) 604 599 { 605 600 return 0; 606 601 } 607 else if( (bssid = nl80211_hostapd_info(ifname)) &&608 (bssid = nl80211_getval(ifname, bssid, "bssid")) )602 else if((bssid = nl80211_hostapd_info(ifname)) && 603 (bssid = nl80211_getval(ifname, bssid, "bssid"))) 609 604 { 610 605 mac[0] = strtol(&bssid[0], NULL, 16); … … 628 623 char *first; 629 624 630 if ( !wext_get_channel(ifname, buf))625 if (!wext_get_channel(ifname, buf)) 631 626 return 0; 632 627 633 else if ( (first = nl80211_phy2ifname(nl80211_ifname2phy(ifname))) != NULL)628 else if ((first = nl80211_phy2ifname(nl80211_ifname2phy(ifname))) != NULL) 634 629 return wext_get_channel(first, buf); 635 630 … … 641 636 char *first; 642 637 643 if ( !wext_get_frequency(ifname, buf))638 if (!wext_get_frequency(ifname, buf)) 644 639 return 0; 645 640 646 else if ( (first = nl80211_phy2ifname(nl80211_ifname2phy(ifname))) != NULL)641 else if ((first = nl80211_phy2ifname(nl80211_ifname2phy(ifname))) != NULL) 647 642 return wext_get_frequency(first, buf); 648 643 … … 661 656 int16_t mbit; 662 657 struct nl80211_rssi_rate *rr = arg; 663 664 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 665 struct nlattr *attr[NL80211_ATTR_MAX + 1]; 658 struct nlattr **attr = nl80211_parse(msg); 666 659 struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1]; 667 660 struct nlattr *rinfo[NL80211_RATE_INFO_MAX + 1]; … … 687 680 }; 688 681 689 nla_parse(attr, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 690 genlmsg_attrlen(gnlh, 0), NULL); 691 692 if( attr[NL80211_ATTR_STA_INFO] ) 682 if (attr[NL80211_ATTR_STA_INFO]) 693 683 { 694 684 if( !nla_parse_nested(sinfo, NL80211_STA_INFO_MAX, 695 685 attr[NL80211_ATTR_STA_INFO], stats_policy) ) 696 686 { 697 if ( sinfo[NL80211_STA_INFO_SIGNAL])687 if (sinfo[NL80211_STA_INFO_SIGNAL]) 698 688 { 699 689 dbm = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]); … … 701 691 } 702 692 703 if ( sinfo[NL80211_STA_INFO_TX_BITRATE])693 if (sinfo[NL80211_STA_INFO_TX_BITRATE]) 704 694 { 705 695 if( !nla_parse_nested(rinfo, NL80211_RATE_INFO_MAX, 706 696 sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy) ) 707 697 { 708 if ( rinfo[NL80211_RATE_INFO_BITRATE])698 if (rinfo[NL80211_RATE_INFO_BITRATE]) 709 699 { 710 700 mbit = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]); … … 742 732 if (req) 743 733 { 744 nl80211_cb(req, nl80211_fill_signal_cb, r); 745 nl80211_send(req); 734 nl80211_send(req, nl80211_fill_signal_cb, r); 746 735 nl80211_free(req); 747 736 } … … 757 746 struct nl80211_rssi_rate rr; 758 747 759 if ( !wext_get_bitrate(ifname, buf))748 if (!wext_get_bitrate(ifname, buf)) 760 749 return 0; 761 750 … … 775 764 struct nl80211_rssi_rate rr; 776 765 777 if ( !wext_get_signal(ifname, buf))766 if (!wext_get_signal(ifname, buf)) 778 767 return 0; 779 768 … … 792 781 { 793 782 int8_t *noise = arg; 794 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 795 struct nlattr *tb[NL80211_ATTR_MAX + 1]; 783 struct nlattr **tb = nl80211_parse(msg); 796 784 struct nlattr *si[NL80211_SURVEY_INFO_MAX + 1]; 797 785 … … 801 789 }; 802 790 803 nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),804 genlmsg_attrlen(gnlh, 0), NULL);805 806 791 if (!tb[NL80211_ATTR_SURVEY_INFO]) 807 792 return NL_SKIP; … … 831 816 noise = 0; 832 817 833 nl80211_cb(req, nl80211_get_noise_cb, &noise); 834 nl80211_send(req); 818 nl80211_send(req, nl80211_get_noise_cb, &noise); 835 819 nl80211_free(req); 836 820 … … 849 833 int signal; 850 834 851 if ( wext_get_quality(ifname, buf))835 if (wext_get_quality(ifname, buf)) 852 836 { 853 837 *buf = 0; 854 838 855 if ( !nl80211_get_signal(ifname, &signal))839 if (!nl80211_get_signal(ifname, &signal)) 856 840 { 857 841 /* A positive signal level is usually just a quality 858 842 * value, pass through as-is */ 859 if ( signal >= 0)843 if (signal >= 0) 860 844 { 861 845 *buf = signal; … … 867 851 else 868 852 { 869 if ( signal < -110)853 if (signal < -110) 870 854 signal = -110; 871 else if ( signal > -40)855 else if (signal > -40) 872 856 signal = -40; 873 857 … … 882 866 int nl80211_get_quality_max(const char *ifname, int *buf) 883 867 { 884 if ( wext_get_quality_max(ifname, buf))868 if (wext_get_quality_max(ifname, buf)) 885 869 /* The cfg80211 wext compat layer assumes a maximum 886 870 * quality of 70 */ … … 897 881 struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf; 898 882 883 /* WPA supplicant */ 884 if( (res = nl80211_wpactl_info(ifname, "STATUS", NULL)) && 885 (val = nl80211_getval(NULL, res, "pairwise_cipher")) ) 886 { 887 /* WEP */ 888 if (strstr(val, "WEP")) 889 { 890 if (strstr(val, "WEP-40")) 891 c->pair_ciphers |= IWINFO_CIPHER_WEP40; 892 893 else if (strstr(val, "WEP-104")) 894 c->pair_ciphers |= IWINFO_CIPHER_WEP104; 895 896 c->enabled = 1; 897 c->group_ciphers = c->pair_ciphers; 898 899 c->auth_suites |= IWINFO_KMGMT_NONE; 900 c->auth_algs |= IWINFO_AUTH_OPEN; /* XXX: assumption */ 901 } 902 903 /* WPA */ 904 else 905 { 906 if (strstr(val, "TKIP")) 907 c->pair_ciphers |= IWINFO_CIPHER_TKIP; 908 909 else if (strstr(val, "CCMP")) 910 c->pair_ciphers |= IWINFO_CIPHER_CCMP; 911 912 else if (strstr(val, "NONE")) 913 c->pair_ciphers |= IWINFO_CIPHER_NONE; 914 915 else if (strstr(val, "WEP-40")) 916 c->pair_ciphers |= IWINFO_CIPHER_WEP40; 917 918 else if (strstr(val, "WEP-104")) 919 c->pair_ciphers |= IWINFO_CIPHER_WEP104; 920 921 922 if ((val = nl80211_getval(NULL, res, "group_cipher"))) 923 { 924 if (strstr(val, "TKIP")) 925 c->group_ciphers |= IWINFO_CIPHER_TKIP; 926 927 else if (strstr(val, "CCMP")) 928 c->group_ciphers |= IWINFO_CIPHER_CCMP; 929 930 else if (strstr(val, "NONE")) 931 c->group_ciphers |= IWINFO_CIPHER_NONE; 932 933 else if (strstr(val, "WEP-40")) 934 c->group_ciphers |= IWINFO_CIPHER_WEP40; 935 936 else if (strstr(val, "WEP-104")) 937 c->group_ciphers |= IWINFO_CIPHER_WEP104; 938 } 939 940 941 if ((val = nl80211_getval(NULL, res, "key_mgmt"))) 942 { 943 if (strstr(val, "WPA2")) 944 c->wpa_version = 2; 945 946 else if (strstr(val, "WPA")) 947 c->wpa_version = 1; 948 949 950 if (strstr(val, "PSK")) 951 c->auth_suites |= IWINFO_KMGMT_PSK; 952 953 else if (strstr(val, "EAP") || strstr(val, "802.1X")) 954 c->auth_suites |= IWINFO_KMGMT_8021x; 955 956 else if (strstr(val, "NONE")) 957 c->auth_suites |= IWINFO_KMGMT_NONE; 958 } 959 960 c->enabled = (c->wpa_version && c->auth_suites) ? 1 : 0; 961 } 962 963 return 0; 964 } 965 899 966 /* Hostapd */ 900 if( (res = nl80211_hostapd_info(ifname)))901 { 902 if ( (val = nl80211_getval(ifname, res, "wpa")) != NULL)967 else if ((res = nl80211_hostapd_info(ifname))) 968 { 969 if ((val = nl80211_getval(ifname, res, "wpa")) != NULL) 903 970 c->wpa_version = atoi(val); 904 971 905 972 val = nl80211_getval(ifname, res, "wpa_key_mgmt"); 906 973 907 if ( !val || strstr(val, "PSK"))974 if (!val || strstr(val, "PSK")) 908 975 c->auth_suites |= IWINFO_KMGMT_PSK; 909 976 910 if ( val && strstr(val, "EAP"))977 if (val && strstr(val, "EAP")) 911 978 c->auth_suites |= IWINFO_KMGMT_8021x; 912 979 913 if ( val && strstr(val, "NONE"))980 if (val && strstr(val, "NONE")) 914 981 c->auth_suites |= IWINFO_KMGMT_NONE; 915 982 916 if ( (val = nl80211_getval(ifname, res, "wpa_pairwise")) != NULL)917 { 918 if ( strstr(val, "TKIP"))983 if ((val = nl80211_getval(ifname, res, "wpa_pairwise")) != NULL) 984 { 985 if (strstr(val, "TKIP")) 919 986 c->pair_ciphers |= IWINFO_CIPHER_TKIP; 920 987 921 if ( strstr(val, "CCMP"))988 if (strstr(val, "CCMP")) 922 989 c->pair_ciphers |= IWINFO_CIPHER_CCMP; 923 990 924 if ( strstr(val, "NONE"))991 if (strstr(val, "NONE")) 925 992 c->pair_ciphers |= IWINFO_CIPHER_NONE; 926 993 } 927 994 928 if ( (val = nl80211_getval(ifname, res, "auth_algs")) != NULL)995 if ((val = nl80211_getval(ifname, res, "auth_algs")) != NULL) 929 996 { 930 997 switch(atoi(val)) { … … 950 1017 snprintf(k, sizeof(k), "wep_key%d", i); 951 1018 952 if ( (val = nl80211_getval(ifname, res, k)))1019 if ((val = nl80211_getval(ifname, res, k))) 953 1020 { 954 if ( (strlen(val) == 5) || (strlen(val) == 10))1021 if ((strlen(val) == 5) || (strlen(val) == 10)) 955 1022 c->pair_ciphers |= IWINFO_CIPHER_WEP40; 956 1023 957 else if ( (strlen(val) == 13) || (strlen(val) == 26))1024 else if ((strlen(val) == 13) || (strlen(val) == 26)) 958 1025 c->pair_ciphers |= IWINFO_CIPHER_WEP104; 959 1026 } … … 967 1034 } 968 1035 969 /* WPA supplicant */970 else if( (res = nl80211_wpactl_info(ifname, "STATUS", NULL)) &&971 (val = nl80211_getval(NULL, res, "pairwise_cipher")) )972 {973 /* WEP */974 if( strstr(val, "WEP") )975 {976 if( strstr(val, "WEP-40") )977 c->pair_ciphers |= IWINFO_CIPHER_WEP40;978 979 else if( strstr(val, "WEP-104") )980 c->pair_ciphers |= IWINFO_CIPHER_WEP104;981 982 c->enabled = 1;983 c->group_ciphers = c->pair_ciphers;984 985 c->auth_suites |= IWINFO_KMGMT_NONE;986 c->auth_algs |= IWINFO_AUTH_OPEN; /* XXX: assumption */987 }988 989 /* WPA */990 else991 {992 if( strstr(val, "TKIP") )993 c->pair_ciphers |= IWINFO_CIPHER_TKIP;994 995 else if( strstr(val, "CCMP") )996 c->pair_ciphers |= IWINFO_CIPHER_CCMP;997 998 else if( strstr(val, "NONE") )999 c->pair_ciphers |= IWINFO_CIPHER_NONE;1000 1001 else if( strstr(val, "WEP-40") )1002 c->pair_ciphers |= IWINFO_CIPHER_WEP40;1003 1004 else if( strstr(val, "WEP-104") )1005 c->pair_ciphers |= IWINFO_CIPHER_WEP104;1006 1007 1008 if( (val = nl80211_getval(NULL, res, "group_cipher")) )1009 {1010 if( strstr(val, "TKIP") )1011 c->group_ciphers |= IWINFO_CIPHER_TKIP;1012 1013 else if( strstr(val, "CCMP") )1014 c->group_ciphers |= IWINFO_CIPHER_CCMP;1015 1016 else if( strstr(val, "NONE") )1017 c->group_ciphers |= IWINFO_CIPHER_NONE;1018 1019 else if( strstr(val, "WEP-40") )1020 c->group_ciphers |= IWINFO_CIPHER_WEP40;1021 1022 else if( strstr(val, "WEP-104") )1023 c->group_ciphers |= IWINFO_CIPHER_WEP104;1024 }1025 1026 1027 if( (val = nl80211_getval(NULL, res, "key_mgmt")) )1028 {1029 if( strstr(val, "WPA2") )1030 c->wpa_version = 2;1031 1032 else if( strstr(val, "WPA") )1033 c->wpa_version = 1;1034 1035 1036 if( strstr(val, "PSK") )1037 c->auth_suites |= IWINFO_KMGMT_PSK;1038 1039 else if( strstr(val, "EAP") || strstr(val, "802.1X") )1040 c->auth_suites |= IWINFO_KMGMT_8021x;1041 1042 else if( strstr(val, "NONE") )1043 c->auth_suites |= IWINFO_KMGMT_NONE;1044 }1045 1046 c->enabled = (c->wpa_version && c->auth_suites) ? 1 : 0;1047 }1048 1049 return 0;1050 }1051 1052 1036 return -1; 1053 1037 } … … 1056 1040 static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) 1057 1041 { 1058 struct nl80211_a ssoc_count *ac= arg;1059 struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));1060 struct nlattr * attr[NL80211_ATTR_MAX + 1];1042 struct nl80211_array_buf *arr = arg; 1043 struct iwinfo_assoclist_entry *e = arr->buf; 1044 struct nlattr **attr = nl80211_parse(msg); 1061 1045 struct nlattr *sinfo[NL80211_STA_INFO_MAX + 1]; 1062 1046 … … 1074 1058 }; 1075 1059 1076 nla_parse(attr, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 1077 genlmsg_attrlen(gnlh, 0), NULL); 1078 1079 if( attr[NL80211_ATTR_MAC] ) 1080 memcpy(ac->entry->mac, nla_data(attr[NL80211_ATTR_MAC]), 6); 1081 1082 if( attr[NL80211_ATTR_STA_INFO] ) 1083 { 1084 if( !nla_parse_nested(sinfo, NL80211_STA_INFO_MAX, 1085 attr[NL80211_ATTR_STA_INFO], stats_policy) ) 1086 { 1087 if( sinfo[NL80211_STA_INFO_SIGNAL] ) 1088 ac->entry->signal = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]); 1089 } 1090 } 1091 1092 ac->entry->noise = ac->noise; 1093 ac->entry++; 1094 ac->count++; 1060 /* advance to end of array */ 1061 e += arr->count; 1062 1063 if (attr[NL80211_ATTR_MAC]) 1064 memcpy(e->mac, nla_data(attr[NL80211_ATTR_MAC]), 6); 1065 1066 if (attr[NL80211_ATTR_STA_INFO]) 1067 { 1068 if (!nla_parse_nested(sinfo, NL80211_STA_INFO_MAX, 1069 attr[NL80211_ATTR_STA_INFO], stats_policy)) 1070 { 1071 if (sinfo[NL80211_STA_INFO_SIGNAL]) 1072 e->signal = nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]); 1073 } 1074 } 1075 1076 e->noise = 0; /* filled in by caller */ 1077 arr->count++; 1095 1078 1096 1079 return NL_SKIP; … … 1100 1083 { 1101 1084 DIR *d; 1085 int i, noise = 0; 1102 1086 struct dirent *de; 1103 struct nl80211_assoc_count ac;1104 1087 struct nl80211_msg_conveyor *req; 1088 struct nl80211_array_buf arr = { .buf = buf, .count = 0 }; 1089 struct iwinfo_assoclist_entry *e; 1105 1090 1106 1091 if ((d = opendir("/sys/class/net")) != NULL) 1107 1092 { 1108 ac.count = 0;1109 ac.entry = (struct iwinfo_assoclist_entry *)buf;1110 1111 nl80211_get_noise(ifname, &ac.noise);1112 1113 1093 while ((de = readdir(d)) != NULL) 1114 1094 { … … 1122 1102 if (req) 1123 1103 { 1124 nl80211_cb(req, nl80211_get_assoclist_cb, &ac); 1125 nl80211_send(req); 1104 nl80211_send(req, nl80211_get_assoclist_cb, &arr); 1126 1105 nl80211_free(req); 1127 1106 } 1107 1108 break; 1128 1109 } 1129 1110 } … … 1131 1112 closedir(d); 1132 1113 1133 *len = (ac.count * sizeof(struct iwinfo_assoclist_entry)); 1114 if (!nl80211_get_noise(ifname, &noise)) 1115 for (i = 0, e = arr.buf; i < arr.count; i++, e++) 1116 e->noise = noise; 1117 1118 *len = (arr.count * sizeof(struct iwinfo_assoclist_entry)); 1134 1119 return 0; 1135 1120 } … … 1138 1123 } 1139 1124 1140 int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len) 1141 { 1125 static int nl80211_get_txpwrlist_cb(struct nl_msg *msg, void *arg) 1126 { 1127 int *dbm_max = arg; 1142 1128 int ch_cur, ch_cmp, bands_remain, freqs_remain; 1143 int dbm_max = -1, dbm_cur, dbm_cnt; 1144 struct nl 80211_msg_conveyor *req, *res;1129 1130 struct nlattr **attr = nl80211_parse(msg); 1145 1131 struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1]; 1146 1132 struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1]; 1147 1133 struct nlattr *band, *freq; 1148 struct iwinfo_txpwrlist_entry entry;1149 1134 1150 1135 static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { … … 1157 1142 }; 1158 1143 1159 if( nl80211_get_channel(ifname, &ch_cur) ) 1144 ch_cur = *dbm_max; /* value int* is initialized with channel by caller */ 1145 *dbm_max = -1; 1146 1147 nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain) 1148 { 1149 nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band), 1150 nla_len(band), NULL); 1151 1152 nla_for_each_nested(freq, 1153 bands[NL80211_BAND_ATTR_FREQS], freqs_remain) 1154 { 1155 nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, 1156 nla_data(freq), nla_len(freq), freq_policy); 1157 1158 ch_cmp = nl80211_freq2channel( 1159 nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ])); 1160 1161 if( (!ch_cur || (ch_cmp == ch_cur)) && 1162 freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] ) 1163 { 1164 *dbm_max = (int)(0.01 * nla_get_u32( 1165 freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])); 1166 1167 break; 1168 } 1169 } 1170 } 1171 1172 return NL_SKIP; 1173 } 1174 1175 int nl80211_get_txpwrlist(const char *ifname, char *buf, int *len) 1176 { 1177 int ch_cur; 1178 int dbm_max = -1, dbm_cur, dbm_cnt; 1179 struct nl80211_msg_conveyor *req; 1180 struct iwinfo_txpwrlist_entry entry; 1181 1182 if (nl80211_get_channel(ifname, &ch_cur)) 1160 1183 ch_cur = 0; 1161 1184 1162 1185 req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0); 1163 if( req ) 1164 { 1165 res = nl80211_send(req); 1166 if( res ) 1167 { 1168 nla_for_each_nested(band, 1169 res->attr[NL80211_ATTR_WIPHY_BANDS], bands_remain) 1170 { 1171 nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band), 1172 nla_len(band), NULL); 1173 1174 nla_for_each_nested(freq, 1175 bands[NL80211_BAND_ATTR_FREQS], freqs_remain) 1176 { 1177 nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, 1178 nla_data(freq), nla_len(freq), freq_policy); 1179 1180 ch_cmp = nl80211_freq2channel( 1181 nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ])); 1182 1183 if( (!ch_cur || (ch_cmp == ch_cur)) && 1184 freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] ) 1185 { 1186 dbm_max = (int)(0.01 * nla_get_u32( 1187 freqs[NL80211_FREQUENCY_ATTR_MAX_TX_POWER])); 1188 1189 break; 1190 } 1191 } 1192 } 1193 1194 nl80211_free(res); 1195 } 1186 if (req) 1187 { 1188 /* initialize the value pointer with channel for callback */ 1189 dbm_max = ch_cur; 1190 1191 nl80211_send(req, nl80211_get_txpwrlist_cb, &dbm_max); 1196 1192 nl80211_free(req); 1197 1193 } 1198 1194 1199 if ( dbm_max > -1)1200 { 1201 for (dbm_cur = 0, dbm_cnt = 0;1195 if (dbm_max > -1) 1196 { 1197 for (dbm_cur = 0, dbm_cnt = 0; 1202 1198 dbm_cur < dbm_max; 1203 dbm_cur++, dbm_cnt++ )1199 dbm_cur++, dbm_cnt++) 1204 1200 { 1205 1201 entry.dbm = dbm_cur; … … 1225 1221 struct iwinfo_crypto_entry *c) 1226 1222 { 1227 if ( strstr(spec, "WPA") || strstr(spec, "WEP"))1223 if (strstr(spec, "WPA") || strstr(spec, "WEP")) 1228 1224 { 1229 1225 c->enabled = 1; 1230 1226 1231 if ( strstr(spec, "WPA2-") && strstr(spec, "WPA-"))1227 if (strstr(spec, "WPA2-") && strstr(spec, "WPA-")) 1232 1228 c->wpa_version = 3; 1233 1229 1234 else if ( strstr(spec, "WPA2"))1230 else if (strstr(spec, "WPA2")) 1235 1231 c->wpa_version = 2; 1236 1232 1237 else if ( strstr(spec, "WPA"))1233 else if (strstr(spec, "WPA")) 1238 1234 c->wpa_version = 1; 1239 1235 1240 else if ( strstr(spec, "WEP"))1236 else if (strstr(spec, "WEP")) 1241 1237 c->auth_algs = IWINFO_AUTH_OPEN | IWINFO_AUTH_SHARED; 1242 1238 1243 1239 1244 if ( strstr(spec, "PSK"))1240 if (strstr(spec, "PSK")) 1245 1241 c->auth_suites |= IWINFO_KMGMT_PSK; 1246 1242 1247 if ( strstr(spec, "802.1X") || strstr(spec, "EAP"))1243 if (strstr(spec, "802.1X") || strstr(spec, "EAP")) 1248 1244 c->auth_suites |= IWINFO_KMGMT_8021x; 1249 1245 1250 if ( strstr(spec, "WPA-NONE"))1246 if (strstr(spec, "WPA-NONE")) 1251 1247 c->auth_suites |= IWINFO_KMGMT_NONE; 1252 1248 1253 1249 1254 if ( strstr(spec, "TKIP"))1250 if (strstr(spec, "TKIP")) 1255 1251 c->pair_ciphers |= IWINFO_CIPHER_TKIP; 1256 1252 1257 if ( strstr(spec, "CCMP"))1253 if (strstr(spec, "CCMP")) 1258 1254 c->pair_ciphers |= IWINFO_CIPHER_CCMP; 1259 1255 1260 if ( strstr(spec, "WEP-40"))1256 if (strstr(spec, "WEP-40")) 1261 1257 c->pair_ciphers |= IWINFO_CIPHER_WEP40; 1262 1258 1263 if ( strstr(spec, "WEP-104"))1259 if (strstr(spec, "WEP-104")) 1264 1260 c->pair_ciphers |= IWINFO_CIPHER_WEP104; 1265 1261 … … 1281 1277 1282 1278 /* Got a radioX pseudo interface, find some interface on it or create one */ 1283 if ( !strncmp(ifname, "radio", 5))1279 if (!strncmp(ifname, "radio", 5)) 1284 1280 { 1285 1281 /* Reuse existing interface */ 1286 if ( (res = nl80211_phy2ifname(ifname)) != NULL)1282 if ((res = nl80211_phy2ifname(ifname)) != NULL) 1287 1283 { 1288 1284 return nl80211_get_scanlist(res, buf, len); … … 1290 1286 1291 1287 /* Need to spawn a temporary iface for scanning */ 1292 else if ( (res = nl80211_ifadd(ifname)) != NULL)1288 else if ((res = nl80211_ifadd(ifname)) != NULL) 1293 1289 { 1294 1290 count = nl80211_get_scanlist(res, buf, len); … … 1301 1297 1302 1298 /* WPA supplicant */ 1303 if ( (res = nl80211_wpactl_info(ifname, "SCAN", "CTRL-EVENT-SCAN-RESULTS")))1304 { 1305 if ( (res = nl80211_wpactl_info(ifname, "SCAN_RESULTS", NULL)))1299 if ((res = nl80211_wpactl_info(ifname, "SCAN", "CTRL-EVENT-SCAN-RESULTS"))) 1300 { 1301 if ((res = nl80211_wpactl_info(ifname, "SCAN_RESULTS", NULL))) 1306 1302 { 1307 1303 nl80211_get_quality_max(ifname, &qmax); … … 1337 1333 1338 1334 /* Quality */ 1339 if ( rssi < 0)1335 if (rssi < 0) 1340 1336 { 1341 1337 /* The cfg80211 wext compat layer assumes a signal range 1342 1338 * of -110 dBm to -40 dBm, the quality value is derived 1343 1339 * by adding 110 to the signal level */ 1344 if ( rssi < -110)1340 if (rssi < -110) 1345 1341 rssi = -110; 1346 else if ( rssi > -40)1342 else if (rssi > -40) 1347 1343 rssi = -40; 1348 1344 … … 1380 1376 { 1381 1377 /* Got a temp interface, don't create yet another one */ 1382 if ( !strncmp(ifname, "tmp.", 4))1383 { 1384 if ( !iwinfo_ifup(ifname))1378 if (!strncmp(ifname, "tmp.", 4)) 1379 { 1380 if (!iwinfo_ifup(ifname)) 1385 1381 return -1; 1386 1382 … … 1393 1389 else 1394 1390 { 1395 if ( !(res = nl80211_ifadd(ifname)))1391 if (!(res = nl80211_ifadd(ifname))) 1396 1392 goto out; 1397 1393 1398 if ( !iwinfo_ifmac(res))1394 if (!iwinfo_ifmac(res)) 1399 1395 goto out; 1400 1396 1401 1397 /* if we can take the new interface up, the driver supports an 1402 1398 * additional interface and there's no need to tear down the ap */ 1403 if ( iwinfo_ifup(res))1399 if (iwinfo_ifup(res)) 1404 1400 { 1405 1401 wext_get_scanlist(res, buf, len); … … 1409 1405 /* driver cannot create secondary interface, take down ap 1410 1406 * during scan */ 1411 else if ( iwinfo_ifdown(ifname) && iwinfo_ifup(res))1407 else if (iwinfo_ifdown(ifname) && iwinfo_ifup(res)) 1412 1408 { 1413 1409 wext_get_scanlist(res, buf, len); … … 1426 1422 } 1427 1423 1428 int nl80211_get_freqlist(const char *ifname, char *buf, int *len) 1429 { 1430 int count = 0, bands_remain, freqs_remain; 1431 struct nl80211_msg_conveyor *req, *res; 1424 static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg) 1425 { 1426 int bands_remain, freqs_remain; 1427 1428 struct nl80211_array_buf *arr = arg; 1429 struct iwinfo_freqlist_entry *e = arr->buf; 1430 1431 struct nlattr **attr = nl80211_parse(msg); 1432 1432 struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1]; 1433 1433 struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1]; 1434 1434 struct nlattr *band, *freq; 1435 struct iwinfo_freqlist_entry *e = (struct iwinfo_freqlist_entry *)buf; 1435 1436 static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { 1437 [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 }, 1438 [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG }, 1439 [NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG }, 1440 [NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG }, 1441 [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG }, 1442 [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, 1443 }; 1444 1445 nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain) 1446 { 1447 nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band), 1448 nla_len(band), NULL); 1449 1450 nla_for_each_nested(freq, 1451 bands[NL80211_BAND_ATTR_FREQS], freqs_remain) 1452 { 1453 nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, 1454 nla_data(freq), nla_len(freq), NULL); 1455 1456 if( !freqs[NL80211_FREQUENCY_ATTR_FREQ] || 1457 freqs[NL80211_FREQUENCY_ATTR_DISABLED] ) 1458 continue; 1459 1460 e->mhz = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]); 1461 e->channel = nl80211_freq2channel(e->mhz); 1462 1463 e->restricted = ( 1464 freqs[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] || 1465 freqs[NL80211_FREQUENCY_ATTR_NO_IBSS] || 1466 freqs[NL80211_FREQUENCY_ATTR_RADAR] 1467 ) ? 1 : 0; 1468 1469 e++; 1470 arr->count++; 1471 } 1472 } 1473 1474 return NL_SKIP; 1475 } 1476 1477 int nl80211_get_freqlist(const char *ifname, char *buf, int *len) 1478 { 1479 struct nl80211_msg_conveyor *req; 1480 struct nl80211_array_buf arr = { .buf = buf, .count = 0 }; 1436 1481 1437 1482 req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0); 1438 if( req ) 1439 { 1440 res = nl80211_send(req); 1441 if( res && res->attr[NL80211_ATTR_WIPHY_BANDS] ) 1442 { 1443 nla_for_each_nested(band, 1444 res->attr[NL80211_ATTR_WIPHY_BANDS], bands_remain) 1445 { 1446 nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band), 1447 nla_len(band), NULL); 1448 1449 nla_for_each_nested(freq, 1450 bands[NL80211_BAND_ATTR_FREQS], freqs_remain) 1451 { 1452 nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, 1453 nla_data(freq), nla_len(freq), NULL); 1454 1455 if( !freqs[NL80211_FREQUENCY_ATTR_FREQ] || 1456 freqs[NL80211_FREQUENCY_ATTR_DISABLED] ) 1457 continue; 1458 1459 e->mhz = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]); 1460 e->channel = nl80211_freq2channel(e->mhz); 1461 1462 e->restricted = ( 1463 freqs[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] || 1464 freqs[NL80211_FREQUENCY_ATTR_NO_IBSS] || 1465 freqs[NL80211_FREQUENCY_ATTR_RADAR] 1466 ) ? 1 : 0; 1467 1468 e++; 1469 count++; 1470 } 1471 } 1472 nl80211_free(res); 1473 } 1483 if (req) 1484 { 1485 nl80211_send(req, nl80211_get_freqlist_cb, &arr); 1474 1486 nl80211_free(req); 1475 1487 } 1476 1488 1477 if ( count > 0)1478 { 1479 *len = count * sizeof(struct iwinfo_freqlist_entry);1489 if (arr.count > 0) 1490 { 1491 *len = arr.count * sizeof(struct iwinfo_freqlist_entry); 1480 1492 return 0; 1481 1493 } … … 1484 1496 } 1485 1497 1498 static int nl80211_get_country_cb(struct nl_msg *msg, void *arg) 1499 { 1500 char *buf = arg; 1501 struct nlattr **attr = nl80211_parse(msg); 1502 1503 if (attr[NL80211_ATTR_REG_ALPHA2]) 1504 memcpy(buf, nla_data(attr[NL80211_ATTR_REG_ALPHA2]), 2); 1505 else 1506 buf[0] = 0; 1507 1508 return NL_SKIP; 1509 } 1510 1486 1511 int nl80211_get_country(const char *ifname, char *buf) 1487 1512 { 1488 1513 int rv = -1; 1489 struct nl80211_msg_conveyor *req , *res;1514 struct nl80211_msg_conveyor *req; 1490 1515 1491 1516 req = nl80211_msg(ifname, NL80211_CMD_GET_REG, 0); 1492 if( req ) 1493 { 1494 res = nl80211_send(req); 1495 if( res ) 1496 { 1497 if( res->attr[NL80211_ATTR_REG_ALPHA2] ) 1498 { 1499 memcpy(buf, nla_data(res->attr[NL80211_ATTR_REG_ALPHA2]), 2); 1500 rv = 0; 1501 } 1502 nl80211_free(res); 1503 } 1517 if (req) 1518 { 1519 nl80211_send(req, nl80211_get_country_cb, buf); 1504 1520 nl80211_free(req); 1521 1522 if (buf[0]) 1523 rv = 0; 1505 1524 } 1506 1525 … … 1525 1544 } 1526 1545 1527 int nl80211_get_hwmodelist(const char *ifname, int *buf) 1528 { 1546 static int nl80211_get_hwmodelist_cb(struct nl_msg *msg, void *arg) 1547 { 1548 int *modes = arg; 1529 1549 int bands_remain, freqs_remain; 1530 struct nl80211_msg_conveyor *req, *res; 1550 uint16_t caps = 0; 1551 struct nlattr **attr = nl80211_parse(msg); 1531 1552 struct nlattr *bands[NL80211_BAND_ATTR_MAX + 1]; 1532 1553 struct nlattr *freqs[NL80211_FREQUENCY_ATTR_MAX + 1]; 1533 1554 struct nlattr *band, *freq; 1534 uint16_t caps = 0; 1535 1536 req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0); 1537 if( req ) 1538 { 1539 res = nl80211_send(req); 1540 if( res && res->attr[NL80211_ATTR_WIPHY_BANDS] ) 1541 { 1542 nla_for_each_nested(band, 1543 res->attr[NL80211_ATTR_WIPHY_BANDS], bands_remain) 1555 1556 *modes = 0; 1557 1558 if (attr[NL80211_ATTR_WIPHY_BANDS]) 1559 { 1560 nla_for_each_nested(band, attr[NL80211_ATTR_WIPHY_BANDS], bands_remain) 1561 { 1562 nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band), 1563 nla_len(band), NULL); 1564 1565 if (bands[NL80211_BAND_ATTR_HT_CAPA]) 1566 caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]); 1567 1568 /* Treat any nonzero capability as 11n */ 1569 if (caps > 0) 1570 *modes |= IWINFO_80211_N; 1571 1572 nla_for_each_nested(freq, 1573 bands[NL80211_BAND_ATTR_FREQS], freqs_remain) 1544 1574 { 1545 nla_parse(bands, NL80211_BAND_ATTR_MAX, nla_data(band), 1546 nla_len(band), NULL); 1547 1548 if( bands[NL80211_BAND_ATTR_HT_CAPA] ) 1549 caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]); 1550 1551 /* Treat any nonzero capability as 11n */ 1552 if( caps > 0 ) 1553 *buf |= IWINFO_80211_N; 1554 1555 nla_for_each_nested(freq, 1556 bands[NL80211_BAND_ATTR_FREQS], freqs_remain) 1575 nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, 1576 nla_data(freq), nla_len(freq), NULL); 1577 1578 if (!freqs[NL80211_FREQUENCY_ATTR_FREQ]) 1579 continue; 1580 1581 if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) < 2485) 1557 1582 { 1558 nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, 1559 nla_data(freq), nla_len(freq), NULL); 1560 1561 if( !freqs[NL80211_FREQUENCY_ATTR_FREQ] ) 1562 continue; 1563 1564 if( nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) < 2485 ) 1565 { 1566 *buf |= IWINFO_80211_B; 1567 *buf |= IWINFO_80211_G; 1568 } 1569 else 1570 { 1571 *buf |= IWINFO_80211_A; 1572 } 1583 *modes |= IWINFO_80211_B; 1584 *modes |= IWINFO_80211_G; 1585 } 1586 else 1587 { 1588 *modes |= IWINFO_80211_A; 1573 1589 } 1574 1590 } 1575 nl80211_free(res); 1576 } 1591 } 1592 } 1593 1594 return NL_SKIP; 1595 } 1596 1597 int nl80211_get_hwmodelist(const char *ifname, int *buf) 1598 { 1599 struct nl80211_msg_conveyor *req; 1600 1601 req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0); 1602 if (req) 1603 { 1604 nl80211_send(req, nl80211_get_hwmodelist_cb, buf); 1577 1605 nl80211_free(req); 1578 1606 } … … 1586 1614 char *nif = nl80211_ifadd(ifname); 1587 1615 1588 if ( nif)1616 if (nif) 1589 1617 { 1590 1618 *buf = (iwinfo_ifmac(nif) && iwinfo_ifup(nif)); -
luci/branches/luci-0.10/contrib/package/iwinfo/src/iwinfo_nl80211.h
r6334 r7810 43 43 44 44 struct nl80211_msg_conveyor { 45 int custom_cb;46 45 struct nl_msg *msg; 47 46 struct nl_cb *cb; 48 struct genlmsghdr *hdr;49 struct nlattr *attr[NL80211_ATTR_MAX + 1];50 47 }; 51 48 … … 55 52 }; 56 53 57 struct nl80211_assoc_count { 58 struct iwinfo_assoclist_entry *entry; 59 int noise; 54 struct nl80211_array_buf { 55 void *buf; 60 56 int count; 61 57 }; -
luci/branches/luci-0.10/contrib/package/luci/Makefile
r7228 r7810 54 54 URL:=http://luci.subsignal.org/ 55 55 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 56 SUBMENU:= Libraries56 SUBMENU:=8. Libraries 57 57 DEPENDS:=+lua +libuci-lua 58 58 TITLE:=LuCI core libraries … … 115 115 URL:=http://luci.subsignal.org/ 116 116 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 117 SUBMENU:= Libraries117 SUBMENU:=8. Libraries 118 118 TITLE:=$(if $(2),$(2),LuCI $(1) library) 119 119 $(if $(3),DEPENDS:=+luci-lib-core $(3)) … … 188 188 189 189 190 ### Protocols ### 191 define protocol 192 define Package/luci-proto-$(1) 193 SECTION:=luci 194 CATEGORY:=LuCI 195 TITLE:=LuCI - Lua Configuration Interface 196 URL:=http://luci.subsignal.org/ 197 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 198 SUBMENU:=6. Protocols 199 TITLE:=$(if $(2),$(2),LuCI $(1) protocol support) 200 DEPENDS:=$(3) 201 endef 202 203 define Package/luci-proto-$(1)/install 204 $(call Package/luci/install/template,$$(1),protocols/$(1)) 205 endef 206 207 ifneq ($(CONFIG_PACKAGE_luci-proto-$(1)),) 208 LUCI_SELECTED_MODULES+=protocols/$(1) 209 endif 210 211 LUCI_BUILD_PACKAGES += luci-proto-$(1) 212 endef 213 214 $(eval $(call protocol,core,Support for static/dhcp/none)) 215 $(eval $(call protocol,ppp,Support for PPP/PPPoE/PPPoA)) 216 $(eval $(call protocol,pptp,Support for PPtP,+pptp)) 217 $(eval $(call protocol,6x4,Support for 6in4/6to4,+6in4 +6to4)) 218 $(eval $(call protocol,3g,Support for 3G,+comgt)) 219 $(eval $(call protocol,relay,Support for relayd pseudo bridges,+relayd)) 220 221 190 222 ### Community Packages ### 191 223 define Package/luci-mod-freifunk-community … … 195 227 URL:=http://luci.subsignal.org/ 196 228 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 197 SUBMENU:= Freifunk229 SUBMENU:=9. Freifunk 198 230 TITLE:=Freifunk Community Meta-Package 199 231 DEPENDS+= \ … … 202 234 +PACKAGE_luci-mod-freifunk-community:olsrd-mod-txtinfo +PACKAGE_luci-mod-freifunk-community:olsrd-mod-nameservice \ 203 235 +PACKAGE_luci-mod-freifunk-community:olsrd-mod-watchdog +PACKAGE_luci-mod-freifunk-community:kmod-tun \ 204 +PACKAGE_luci-mod-freifunk-community:ip +PACKAGE_luci-mod-freifunk-community:freifunk-watchdog +luci-app-olsr +luci-app-olsr-services 236 +PACKAGE_luci-mod-freifunk-community:ip +PACKAGE_luci-mod-freifunk-community:freifunk-watchdog +luci-app-olsr \ 237 +luci-app-olsr-services +freifunk-gwcheck +freifunk-mapupdate 205 238 endef 206 239 … … 224 257 URL:=http://luci.subsignal.org/ 225 258 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 226 SUBMENU:= Modules259 SUBMENU:=2. Modules 227 260 TITLE:=$(if $(2),$(2),LuCI $(1) module) 228 261 $(if $(3),DEPENDS+=$(3)) … … 246 279 endef 247 280 248 define Package/luci-mod-freifunk/conffiles 249 /etc/config/freifunk 250 endef 251 252 $(eval $(call module,admin-core,Web UI Core module,+luci-lib-web +luci-i18n-english)) 281 $(eval $(call module,admin-core,Web UI Core module,+luci-lib-web +luci-proto-core +luci-i18n-english)) 253 282 $(eval $(call module,admin-mini,LuCI Essentials - stripped down and user-friendly,+luci-mod-admin-core @BROKEN)) 254 283 $(eval $(call module,admin-full,LuCI Administration - full-featured for full control,+luci-mod-admin-core +luci-lib-ipkg)) 255 284 $(eval $(call module,rpc,LuCI RPC - JSON-RPC API,+luci-lib-json)) 256 $(eval $(call module,freifunk,LuCI Freifunk module,+luci-mod-admin-full +luci-lib-json +PACKAGE_luci-mod-freifunk:freifunk-firewall ))285 $(eval $(call module,freifunk,LuCI Freifunk module,+luci-mod-admin-full +luci-lib-json +PACKAGE_luci-mod-freifunk:freifunk-firewall +freifunk-common +community-profiles)) 257 286 $(eval $(call module,niu,NIU - Next Generation Interface,+luci-mod-admin-core @BROKEN)) 258 287 … … 266 295 URL:=http://luci.subsignal.org/ 267 296 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 268 SUBMENU:= Applications297 SUBMENU:=3. Applications 269 298 TITLE:=$(if $(2),$(2),LuCI $(1) application) 270 DEPENDS:= +luci-mod-admin-core$(3)299 DEPENDS:=$(3) 271 300 endef 272 301 … … 296 325 297 326 298 $(eval $(call application,ffwizard,Freifunk configuration wizard,\299 +luci-mod-freifunk))300 301 327 $(eval $(call application,siitwizard,SIIT IPv4-over-IPv6 configuration wizard,\ 302 328 +PACKAGE_luci-app-siitwizard:kmod-siit)) … … 306 332 307 333 $(eval $(call application,freifunk-policyrouting,Policy routing for mesh traffic,\ 308 +PACKAGE_luci-app-freifunk-policyrouting:freifunk-policyrouting +luci-mod-freifunk))334 +PACKAGE_luci-app-freifunk-policyrouting:freifunk-policyrouting)) 309 335 310 336 $(eval $(call application,meshwizard, Shellscript based wizard to setup mesh networks,\ 311 + meshwizard +luci-mod-freifunk))337 +PACKAGE_luci-app-freifunk-meshwizard:meshwizard)) 312 338 313 339 $(eval $(call application,olsr,OLSR configuration and status module,\ 314 + luci-mod-admin-full +PACKAGE_luci-app-olsr:olsrd +PACKAGE_luci-app-olsr:olsrd-mod-txtinfo))340 +olsrd-mod-txtinfo)) 315 341 316 342 $(eval $(call application,olsr-viz,OLSR Visualisation,\ 317 +PACKAGE_luci-app-olsr-viz:luci-app-olsr +PACKAGE_luci-app-olsr-viz:olsrd-mod-txtinfo))343 luci-app-olsr +olsrd-mod-txtinfo)) 318 344 319 345 $(eval $(call application,olsr-services,Show services announced with the nameservice plugin,\ 320 +PACKAGE_luci-app-olsr-services:olsrd-mod-nameservice +luci-mod-freifunk +PACKAGE_luci-app-olsr-services:luci-app-olsr))346 luci-app-olsr +olsrd-mod-nameservice)) 321 347 322 348 $(eval $(call application,qos,Quality of Service configuration module,\ … … 324 350 325 351 $(eval $(call application,splash,Freifunk DHCP-Splash application,\ 326 +luci-lib-nixio +PACKAGE_luci-app-splash:tc \ 327 +PACKAGE_luci-app-splash:kmod-sched +PACKAGE_luci-app-splash:iptables-mod-nat-extra \ 328 +PACKAGE_luci-app-splash:iptables-mod-ipopt)) 352 +luci-lib-nixio +tc +kmod-sched +iptables-mod-nat-extra +iptables-mod-ipopt)) 329 353 330 354 $(eval $(call application,statistics,LuCI Statistics Application,\ 331 + luci-mod-admin-full +PACKAGE_luci-app-statistics:collectd \355 +PACKAGE_luci-app-statistics:collectd \ 332 356 +PACKAGE_luci-app-statistics:rrdtool1 \ 333 357 +PACKAGE_luci-app-statistics:collectd-mod-rrdtool \ … … 351 375 352 376 $(eval $(call application,voice-diag,LuCI Voice Software (Diagnostics),\ 353 +luci-app-voice-core +luci-app-diag-devinfo))377 luci-app-diag-devinfo)) 354 378 355 379 $(eval $(call application,upnp,Universal Plug & Play configuration module,\ … … 363 387 364 388 $(eval $(call application,samba,Network Shares - Samba SMB/CIFS module,\ 365 + luci-mod-admin-full +PACKAGE_luci-app-samba:samba3))389 +PACKAGE_luci-app-samba:samba3)) 366 390 367 391 $(eval $(call application,mmc-over-gpio,MMC-over-GPIO configuration module,\ 368 + luci-mod-admin-full +PACKAGE_luci-app-mmc-over-gpio:kmod-mmc-over-gpio))392 +PACKAGE_luci-app-mmc-over-gpio:kmod-mmc-over-gpio)) 369 393 370 394 $(eval $(call application,p910nd,p910nd - Printer server module,\ 371 + luci-mod-admin-full +PACKAGE_luci-app-p910nd:p910nd))395 +PACKAGE_luci-app-p910nd:p910nd)) 372 396 373 397 $(eval $(call application,ushare,uShare - UPnP A/V & DLNA Media Server,\ 374 + luci-mod-admin-full +PACKAGE_luci-app-ushare:ushare))398 +PACKAGE_luci-app-ushare:ushare)) 375 399 376 400 $(eval $(call application,hd-idle,Hard Disk Idle Spin-Down module,\ 377 + luci-mod-admin-full +PACKAGE_luci-app-hd-idle:hd-idle))401 +PACKAGE_luci-app-hd-idle:hd-idle)) 378 402 379 403 $(eval $(call application,tinyproxy,Tinyproxy - HTTP(S)-Proxy configuration,\ 380 + luci-mod-admin-full +PACKAGE_luci-app-tinyproxy:tinyproxy))404 +PACKAGE_luci-app-tinyproxy:tinyproxy)) 381 405 382 406 $(eval $(call application,polipo,LuCI Support for the Polipo Proxy,\ … … 387 411 388 412 $(eval $(call application,p2pblock,LuCI Support for the Freifunk P2P-Block addon,\ 389 +luci-app-firewall +PACKAGE_luci-app-p2pblock:freifunk-p2pblock))413 luci-app-firewall +PACKAGE_luci-app-p2pblock:freifunk-p2pblock)) 390 414 391 415 $(eval $(call application,multiwan,LuCI Support for the OpenWrt MultiWAN agent,\ 392 +luci-app-firewall +PACKAGE_luci-app-multiwan:multiwan))416 luci-app-firewall +PACKAGE_luci-app-multiwan:multiwan)) 393 417 394 418 $(eval $(call application,wol,LuCI Support for Wake-on-LAN,\ … … 400 424 401 425 $(eval $(call application,radvd,LuCI Support for Radvd,\ 402 + luci-mod-admin-full +PACKAGE_luci-app-radvd:radvd))426 +PACKAGE_luci-app-radvd:radvd)) 403 427 404 428 $(eval $(call application,ahcp,LuCI Support for AHCPd,\ 405 +luci-mod-admin-full +PACKAGE_luci-app-ahcp:ahcpd)) 429 +PACKAGE_luci-app-ahcp:ahcpd)) 430 431 $(eval $(call application,wshaper,LuCI Support for wshaper,\ 432 +PACKAGE_luci-app-wshaper:wshaper)) 406 433 407 434 $(eval $(call application,lqtapifoss,Lantiq voip)) … … 415 442 URL:=http://luci.subsignal.org/ 416 443 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 417 SUBMENU:= Server Interfaces444 SUBMENU:=7. Server Interfaces 418 445 TITLE:=$(if $(2),$(2),LuCI $(1) server gateway interface) 419 $(if $(3),DEPENDS:=$(3))446 DEPENDS:=$(3) 420 447 endef 421 448 … … 442 469 TITLE:=LuCI - Lua Configuration Interface 443 470 URL:=http://luci.subsignal.org/ 444 SUBMENU:= Themes471 SUBMENU:=4. Themes 445 472 TITLE:=$(if $(2),$(2),LuCI $(1) theme) 446 473 MAINTAINER:=$(if $(3),$(3),LuCI Development Team <luci@lists.subsignal.org>) … … 460 487 endef 461 488 462 $(eval $(call theme,base,Common base for all themes ,,+luci-lib-web))489 $(eval $(call theme,base,Common base for all themes)) 463 490 $(eval $(call theme,openwrt,OpenWrt.org (default),,,1)) 464 491 $(eval $(call theme,fledermaus,Fledermaus Theme)) … … 484 511 URL:=http://luci.subsignal.org/ 485 512 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 486 SUBMENU:= Translations513 SUBMENU:=5. Translations 487 514 TITLE:=$(if $(2),$(2),$(1)) 488 515 endef … … 515 542 $(eval $(call translation,norwegian,Norwegian (by Lars Hardy))) 516 543 $(eval $(call translation,hebrew,Hebrew)) 544 $(eval $(call translation,romanian,Romanian)) 517 545 518 546 … … 525 553 URL:=http://luci.subsignal.org/ 526 554 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org> 527 SUBMENU:= Collections555 SUBMENU:=1. Collections 528 556 TITLE:=$(if $(2),$(2),LuCI $(if $(1),$(1),general) collection) 529 557 $(if $(3),DEPENDS:=$(3)) … … 538 566 539 567 $(eval $(call collection,,\ 540 Standard OpenWrt set including full and mini admin and the standard theme,\ 568 Standard OpenWrt set including full admin with ppp support and the \ 569 default OpenWrt theme,\ 541 570 +uhttpd +luci-mod-admin-full +luci-theme-openwrt +luci-app-firewall \ 542 +l ibiwinfo))571 +luci-proto-core +luci-proto-ppp +libiwinfo)) 543 572 544 573 $(eval $(call collection,ssl,\ 545 574 Standard OpenWrt set with HTTPS support,\ 546 +uhttpd +uhttpd-mod-tls +px5g +luci-mod-admin-full +luci-theme-openwrt \ 547 +luci-app-firewall +libiwinfo)) 575 +luci +uhttpd-mod-tls +px5g)) 548 576 549 577 $(eval $(call collection,light,\ -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/functions.sh
r7228 r7810 13 13 } 14 14 15 set_defaults() { 16 for def in $(env |grep "^$1"); do 17 option=${def/$1/} 18 uci set $2.$option 19 echo " ${option/=/: }" 15 # Takes 2 arguments 16 # $1 = text to be displayed in the output for this section 17 # $2 = section (optional) 18 uci_commitverbose() { 19 echo "+ $1" 20 uci changes $2 | while read line; do 21 echo " $line" 20 22 done 23 uci commit $2 21 24 } 22 25 23 # 1 argument: section to remove 24 section_cleanup() { 25 uci -q delete $1 && msg_cleanup $1 || msg_cleanup_error $1 26 set_defaults() { 27 for def in $(env |grep "^$1" | sed 's/ /_/g'); do 28 option="${def/$1/}" 29 a="$(echo $option |cut -d '=' -f1)" 30 b="$(echo $option |cut -d '=' -f2)" 31 b="${b//_/ }" 32 uci set $2.$a="$b" 33 done 26 34 } 27 35 … … 29 37 section_rename() { 30 38 uci -q rename $1.$2=$3 && msg_rename $1.$2 $1.$3 || msg_rename_error $1.2 $1.$3 31 }32 33 msg_start() {34 echo " Starting configuration of $1"35 }36 37 msg_cleanup() {38 echo " Cleanup: Removed section $1."39 }40 41 msg_cleanup_error() {42 echo -e " \033[1mWarning:\033[0m Cleanup of $1 failed."43 39 } 44 40 -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/gen_bssid.sh
r7228 r7810 12 12 config_load profile_$community 13 13 config_get bssid bssidscheme $channel 14 if [ -z "$bssid" ]; then 15 config_get bssid bssidscheme "all" 16 fi 14 17 15 18 if [ -z "$bssid" ]; then -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/initial_config.sh
r7228 r7810 3 3 # It sets up the initial config for this node. 4 4 5 6 5 . /etc/functions.sh 7 6 . $dir/functions.sh 8 9 ### System config10 7 11 8 config_load system … … 19 16 config_foreach handle_system system 20 17 21 if [ -n "$(uci -q get meshwizard.system)" ]; then 22 echo " + Setup system" 23 uci show meshwizard.system | sed 's/^meshwizard/uci set system/g' | while read line; do 24 eval $line 25 echo " $line" 26 done 27 uci -q delete meshwizard.system 18 if [ -n "$(uci -q get meshwizard.community)" ]; then 19 set_defaults "community_" freifunk.community 20 uci -q delete meshwizard.community 21 fi 22 [ -n "$profile_homepage" ] && uci set freifunk.community.homepage="$profile_homepage" 23 uci_commitverbose "Setup community" freifunk 24 25 if [ -n "$(uci -q get meshwizard.contact)" ]; then 26 set_defaults "contact_" freifunk.contact 27 uci -q delete meshwizard.contact && uci_commitverbose "Setup contact" freifunk 28 28 fi 29 29 30 if [ -n "$(uci -q get meshwizard.community)" ]; then 31 echo " + Setup community" 32 uci show meshwizard.community | sed 's/^meshwizard/freifunk/g' | while read line; do 33 eval uci set $line 34 echo " $line" 35 done 36 uci -q delete meshwizard.community 30 if [ "$has_luci" == TRUE ]; then 31 set_defaults "luci_main_" luci.main 32 uci -q delete meshwizard.luci_main && uci_commitverbose "Setup luci" luci 37 33 fi 38 39 if [ -n "$(uci -q get meshwizard.contact)" ]; then40 echo " + Setup contact"41 uci show meshwizard.contact | sed 's/^meshwizard/freifunk/g' | while read line; do42 eval uci set $line43 echo " $line"44 done45 uci -q delete meshwizard.contact46 fi47 48 if [ -n "$(uci -q get meshwizard.luci_main)" ]; then49 echo " + Setup luci"50 uci show meshwizard.luci_main |sed -e 's/^meshwizard/luci/g' -e 's/luci_main/main/' | while read line; do51 eval uci set $line52 echo " $line"53 done54 uci -q delete meshwizard.luci_main55 fi56 57 uci commit58 59 -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh
r7228 r7810 19 19 get_var profile_$community.$v 20 20 done 21 22 # read values from meshwizard 23 for v in system luci_main contact community wan lan; do 24 get_var meshwizard.$v 25 done -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/rename-wifi.sh
r7228 r7810 3 3 # E.g. wireless.IB_wifi0 would become wireless.wifi0 on madwifi and wireless.radio0 on mac80211 4 4 5 . $dir/functions.sh 6 5 7 posIB=-1 6 8 7 9 IBwifis="$(uci show meshwizard.netconfig | grep -v 'netconfig=netconfig' | sed 's/meshwizard.netconfig\.\(IB_wifi.*\)_.*/\1/' |uniq)" 10 [ -z "$(echo $IBwifis |grep IB_wifi)" ] && exit 8 11 9 12 for w in $IBwifis; do … … 41 44 done 42 45 43 uci commit46 uci_commitverbose "Renaming wifi-devices in /etc/config/meshwizard" meshwizard -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh
r7228 r7810 10 10 config_get interface "$1" interface 11 11 if [ "$interface" == "${netrenamed}dhcp" ]; then 12 if [ "$cleanup" == 1 ]; then 13 section_cleanup dhcp.$1 14 else 15 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 16 section_rename dhcp $1 ${netrenamed}dhcp 17 fi 18 fi 19 fi 12 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 13 section_rename dhcp $1 ${netrenamed}dhcp 14 fi 15 fi 20 16 } 21 17 config_load dhcp … … 23 19 24 20 uci batch << EOF 25 set dhcp.${netrenamed}dhcp="dhcp" 26 set dhcp.${netrenamed}dhcp.leasetime="${dhcp_leasetime}" 27 set dhcp.${netrenamed}dhcp.force="1" 28 set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp" 21 set dhcp.${netrenamed}dhcp="dhcp" 22 set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp" 29 23 EOF 30 24 31 echo " leasetime: ${dhcp_leasetime} 32 interface: ${netrenamed}dhcp" 25 set_defaults "dhcp_" dhcp.${netrenamed}dhcp 33 26 27 uci_commitverbose "Setup DHCP for $netrenamed" dhcp 28 -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh
r7228 r7810 14 14 config_foreach handle_dhcp dnsmasq 15 15 16 echo " + Setup dnsmasq" 17 18 uci set dhcp.dnsmasq.local="/$profile_suffix/" 19 uci set dhcp.dnsmasq.domain="$profile_suffix" 20 21 echo " local: /$profile_suffix/ 22 domain: $profile_suffix" 16 uci batch << EOF 17 set dhcp.dnsmasq.local="/$profile_suffix/" 18 set dhcp.dnsmasq.domain="$profile_suffix" 19 EOF 23 20 24 21 config_get addnhosts dnsmasq addnhosts 25 22 if [ -z "${addnhosts/\var\/etc\/hosts.olsr/}" ]; then 26 23 uci add_list dhcp.dnsmasq.addnhosts="/var/etc/hosts.olsr" 27 echo " addnhosts: /var/etc/hosts.olsr"28 24 fi 29 25 30 uci commit 31 26 uci_commitverbose "Setup dnsmasq" dhcp -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh
r7291 r7810 1 1 #!/bin/sh 2 # This will add $net to the zone firewall (and remove it from other zones where it is referenced)3 # I t will also setup rules defined in /etc/config/freifunk and /etc/config/profile_<community>4 # A rg $1 = $net2 # Add "freifunk" firewall zone 3 # If wan/lan is used for olsr then remove these networks from wan/lan zones 4 # Also setup rules defined in /etc/config/freifunk and /etc/config/profile_<community> 5 5 6 net=$17 6 . /etc/functions.sh 8 7 . $dir/functions.sh 8 9 wan_is_olsr=$(uci -q get meshwizard.netconfig.wan_config) 10 lan_is_olsr=$(uci -q get meshwizard.netconfig.lan_config) 11 9 12 config_load firewall 10 13 11 # Get some variables12 type="$(uci -q get wireless.$net.type)" 13 vap="$(uci -q get meshwizard.netconfig.$net\_vap)" 14 # Rename firewall zone for freifunk if unnamed 15 # If wan is used for olsr then set network for the firewall zone wan to ' ' to remove the wan interface from it, else add local restrict to it 16 # If lan is used for olsr then set network for the firewall zone lan to ' ' to remove the lan interface from it 14 17 15 # Add local_restrict to wan firewall zone16 handle_zonewan() {17 config_get name "$1" name18 if [ "$name" == "wan" ]; then19 uci set firewall.$1.local_restrict=120 fi21 }22 config_foreach handle_zonewan zone && echo " + Enable local_restrict for zone wan"23 24 # Delete old firewall zone for freifunk25 18 handle_fwzone() { 26 19 config_get name "$1" name 27 20 config_get network "$1" network 28 21 29 if [ "$2" == "zoneconf" ]; then 30 # clean zone 31 if [ "$name" == "freifunk" ]; then 32 if [ "$cleanup" == 1 ]; then 33 section_cleanup firewall.$1 34 else 35 # rename section if unnamed 36 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 37 section_rename firewall $1 zone_freifunk 38 fi 39 fi 22 if [ "$name" == "freifunk" ]; then 23 # rename section if unnamed 24 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 25 section_rename firewall $1 zone_freifunk 26 fi 27 fi 28 29 if [ "$name" == "wan" ]; then 30 if [ "$wan_is_olsr" == 1 ]; then 31 uci set firewall.$1.network=' ' && uci_commitverbose "WAN is used for olsr, removed the wan interface from zone wan" firewall 40 32 else 33 uci set firewall.$1.local_restrict=1 && uci_commitverbose "Enable local_restrict for zone wan" firewall 34 fi 35 fi 41 36 42 if [ "$name" == "$netrenamed" ]; then 43 section_cleanup firewall.$1 44 fi 45 if [ -n "$netrenamed" -a -n "$(echo $network | grep $netrenamed)" ] && [ ! "$name" == "freifunk" ]; then 46 echo " Removed $netrenamed from firewall zone $name." 47 network_new=$(echo $network | sed -e 's/'$netrenamed'//' -e 's/^ //' -e 's/ / /' -e 's/ $//') 48 uci set firewall.$1.network="$network_new" 49 fi 50 fi 51 else 52 # clean fw_rule, fw_forwarding, include and advanced 53 for option in src tcp_ecn path; do 54 config_get $option $1 $option 55 done 56 if [ "$src" == "freifunk" -o "$path" == "/etc/firewall.freifunk" -o -n "$tcpecn" ]; then 57 section_cleanup firewall.$1 58 fi 37 if [ "$name" == "lan" ] && [ "$lan_is_olsr" == 1 ]; then 38 uci set firewall.$1.network=' ' && uci_commitverbose "LAN is used for olsr, removed the lan interface from zone lan" firewall 59 39 fi 60 40 } 61 41 62 config_foreach handle_fwzone zone zoneconf 63 64 if [ "$cleanup" == 1 ]; then 65 for target in include advanced rule forwarding; do 66 config_foreach handle_fwzone $target 67 done 68 fi 69 70 # setup freifunk firewall zone 71 72 echo " + Setup firewall zone." 73 74 # add $netrenamed and if needed ${netrenamed}dhcp to the networks for this zone 75 config_get network zone_freifunk network 76 77 # remove ${netrenamed}dhcp from networks list 78 [ -n "$network" -a -n "$net" ] && network="${network/${netrenamed}dhcp/}" 79 network=$(echo $network) # Removes leading and trailing whitespaces 80 81 [ -n "$netrenamed" ] && [ -z "$(echo $network | grep $netrenamed)" ] && network="$network $netrenamed" 82 83 if [ "$type" == "atheros" -a "$vap" == 1 ]; then 84 [ -n "$netrenamed" ] && [ "$network" == "${network/${netrenamed}dhcp/}" ] && network="$network ${netrenamed}dhcp" 85 fi 42 config_foreach handle_fwzone zone 86 43 87 44 uci batch << EOF 88 set firewall.zone_freifunk="zone" 89 set firewall.zone_freifunk.name="freifunk" 90 set firewall.zone_freifunk.network="$network" 91 set firewall.zone_freifunk.input="$zone_freifunk_input" 92 set firewall.zone_freifunk.forward="$zone_freifunk_forward" 93 set firewall.zone_freifunk.output="$zone_freifunk_output" 45 set firewall.zone_freifunk="zone" 46 set firewall.zone_freifunk.name="freifunk" 47 set firewall.zone_freifunk.input="$zone_freifunk_input" 48 set firewall.zone_freifunk.forward="$zone_freifunk_forward" 49 set firewall.zone_freifunk.output="$zone_freifunk_output" 94 50 EOF 95 51 96 echo " network: $network 97 input: $zone_freifunk_input 98 forward: $zone_freifunk_forward 99 output: $zone_freifunk_output" 52 uci_commitverbose "Setup firewall zones" firewall 100 53 101 # Usually we need to setup masquerading for lan, except lan is an olsr interface or has an olsr hna 102 103 echo " + Setup masquerading rules" 54 # Usually we need to setup masquerading for lan, except lan is an olsr interface or has an olsr hna-entry 104 55 105 56 handle_interface() { … … 112 63 config_foreach handle_interface Interface 113 64 114 handle_hna() { 115 config_get netaddr "$1" netaddr 116 if [ "$NETWORK" == "$netaddr" ]; then 117 no_masq_lan=1 118 fi 119 } 120 config_foreach handle_hna Hna4 65 LANIP="$(uci -q get network.lan.ipaddr)" 66 if [ -n "$LANIP" ]; then 67 handle_hna() { 68 config_get netaddr "$1" netaddr 69 if [ "$LANIP" == "$netaddr" ]; then 70 no_masq_lan=1 71 fi 72 } 73 config_foreach handle_hna Hna4 74 fi 121 75 122 76 currms=$(uci -q get firewall.zone_freifunk.masq_src) 123 if [ ! "$no_masq_lan" == "1" ] ; then124 uci set firewall.zone_freifunk.masq="1" && echo " Enabled masquerading." || echo -e "\033[1mWarning:\033[0m: Could not enable masquerading."77 if [ ! "$no_masq_lan" == "1" ] && [ ! "$(uci -q get meshwizard.netconfig.lan_config)" == 1 ]; then 78 uci set firewall.zone_freifunk.masq="1" 125 79 [ -z "$(echo $currms |grep lan)" ] && uci add_list firewall.zone_freifunk.masq_src="lan" 126 80 fi 127 81 128 # If wifi-interfaces are outside of the mesh network they should be natted129 for i in $networks; do130 # Get dhcprange and meshnet131 dhcprange=$(uci get meshwizard.netconfig.$i\_dhcprange)132 meshnet="$(uci get profile_$community.profile.mesh_network)"133 # check if the dhcprange is inside meshnet134 dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"135 if [ ! "$dhcpinmesh" == 1 ]; then136 [ -z "$(echo $currms |grep ${netrenamed}dhcp)" ] && uci add_list firewall.zone_freifunk.masq_src="${netrenamed}dhcp"137 fi138 done139 82 140 83 # Rules, Forwardings, advanced config and includes 141 # Clear firewall configuration142 143 echo " + Setup rules, forwardings, advanced config and includes."144 84 145 85 for config in freifunk profile_$community; do … … 158 98 done 159 99 done 160 161 uci commit 100 uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
r7228 r7810 1 1 # setup entry in /etc/config/network for a interface 2 2 # Argument $1: network interface 3 3 4 4 net="$1" 5 5 . /etc/functions.sh 6 6 . $dir/functions.sh 7 8 # Delete the network interface section for $net9 if [ "$cleanup" == 1 ]; then10 section_cleanup network.$netrenamed11 fi12 7 13 8 # Setup a (new) interface section for $net … … 16 11 [ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr 17 12 18 [ -z "$interface_netmask" ] && interface netmask="255.255.0.0" 13 netmask=$(uci -q get meshwizard.netconfig.$net\_netmask) 14 [ -z "$netmask" ] && netmask="$interface_netmask" 15 [ -z "$netmask" ] && netmask="255.255.0.0" 16 17 uci set network.$netrenamed="interface" 18 set_defaults "interface_" network.$netrenamed 19 19 20 20 uci batch << EOF 21 set network.$netrenamed="interface" 22 set network.$netrenamed.proto="static" 23 set network.$netrenamed.ipaddr="$ipaddr" 24 set network.$netrenamed.netmask="$interface_netmask" 25 set network.$netrenamed.dns="$interface_dns" 21 set network.$netrenamed.proto="static" 22 set network.$netrenamed.ipaddr="$ipaddr" 23 set network.$netrenamed.netmask="$netmask" 26 24 EOF 27 25 28 echo " IP address: $ipaddr" 29 echo " Netmask : $interface_netmask" 26 uci_commitverbose "Setup interface $netrenamed" network 30 27 31 28 # setup dhcp alias/interface … … 39 36 vap=$(uci -q get meshwizard.netconfig.${net}_vap) 40 37 41 # Clean/rename config38 # Rename config 42 39 handle_dhcpalias() { 43 40 config_get interface "$1" interface 44 41 if [ "$interface" == "$netrenamed" ]; then 45 if [ "$cleanup" == 1 ]; then 46 section_cleanup network.$1 47 else 48 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 49 section_rename network $1 ${netrenamed}dhcp 50 fi 42 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 43 section_rename network $1 ${netrenamed}dhcp 51 44 fi 52 45 fi … … 69 62 70 63 if [ "$vap" == 1 ]; then 71 echo " + Setup interface ${netrenamed}dhcp."72 64 uci set network.${netrenamed}dhcp=interface 73 65 else 74 echo " + Setup alias interface ${netrenamed}dhcp."75 66 uci set network.${netrenamed}dhcp=alias 76 67 uci set network.${netrenamed}dhcp.interface="$netrenamed" 77 68 fi 78 69 79 uci batch << EOF 80 set network.${netrenamed}dhcp.proto=static 81 set network.${netrenamed}dhcp.ipaddr="$START" 82 set network.${netrenamed}dhcp.netmask="$NETMASK" 83 EOF 84 85 echo " interface: $net 86 ipaddr: $START 87 netmask: $NETMASK" 70 uci batch <<- EOF 71 set network.${netrenamed}dhcp.proto=static 72 set network.${netrenamed}dhcp.ipaddr="$START" 73 set network.${netrenamed}dhcp.netmask="$NETMASK" 74 EOF 75 uci_commitverbose "Setup interface for ${netrenamed}dhcp" network 88 76 89 77 fi 90 91 uci commit -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh
r7228 r7810 1 1 #!/bin/sh 2 2 # Sets up olsrd 3 # arg $1 = net4 5 net=$16 3 7 4 . /etc/functions.sh 8 9 5 . $dir/functions.sh 10 6 11 # Clean or delete interface defaults 7 # Rename interface defaults 8 12 9 handle_interfacedefaults() { 13 if [ "$cleanup" == 1 ]; then 14 section_cleanup olsrd.$1 15 else 16 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 17 section_rename olsrd $1 InterfaceDefaults 18 fi 10 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 11 section_rename olsrd $1 InterfaceDefaults 19 12 fi 20 13 } 21 22 14 config_load olsrd 23 15 config_foreach handle_interfacedefaults InterfaceDefaults 24 16 25 17 # Setup new InterfaceDefaults 26 27 echo " + Setup InterfaceDefaults"28 18 uci set olsrd.InterfaceDefaults=InterfaceDefaults 29 19 set_defaults "olsr_interfacedefaults_" olsrd.InterfaceDefaults 20 uci_commitverbose "Setup olsr interface defaults" olsrd 30 21 31 # Delete old interface for $netrenamed 32 handle_interface() { 33 config_get interface "$1" Interface 34 if [ "$interface" == "$netrenamed" ]; then 35 if [ "$cleanup" == 1 ]; then 36 section_cleanup olsrd.$1 37 elif [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 38 section_rename olsrd $1 $netrenamed 39 fi 40 fi 41 } 22 # Rename nameservice, dyngw and httpinfo plugins 42 23 43 config_foreach handle_interface Interface44 45 # Setup new interface for $netrenamed46 47 echo " + Setup Interface"48 49 uci set olsrd.$netrenamed=Interface50 51 set_defaults "olsr_interface_" olsrd.$net52 53 uci set olsrd.$netrenamed.interface="$netrenamed"54 echo " interface: $netrenamed"55 56 # If dhcp-network is inside the mesh_network then add HNA for it57 dhcprange=$(uci get meshwizard.netconfig.$net\_dhcprange)58 meshnet="$(uci get profile_$community.profile.mesh_network)"59 60 uci -q delete olsrd.${netrenamed}clients61 62 # check if the dhcprange is inside meshnet63 dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"64 65 if [ "$dhcpinmesh" == 1 ]; then66 echo " + Setting up HNA"67 uci set olsrd.${netrenamed}clients="Hna4"68 eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange)69 uci set olsrd.${netrenamed}clients.netaddr="$NETWORK"70 uci set olsrd.${netrenamed}clients.netmask="$NETMASK"71 echo " netaddr: $NETWORK"72 echo " natmask: $NETMASK"73 fi74 75 76 # Delete nameservice, dyngw and httpinfo plugins77 78 echo " + Configure Plugins"79 24 handle_plugin() { 80 config_get library "$1" library 81 if [ "$cleanup" == 1 ]; then 82 case library in 83 olsrd_*) 84 section_cleanup olsrd.$1 85 esac 86 elif [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 25 config_get library "$1" library 26 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 87 27 new="$(echo $library | cut -d '.' -f 1)" 88 28 section_rename olsrd $1 $new 89 fi 29 fi 90 30 } 91 31 config_foreach handle_plugin LoadPlugin … … 98 38 fi 99 39 uci batch << EOF 100 set olsrd.olsrd_nameservice=LoadPlugin101 set olsrd.olsrd_nameservice.library="olsrd_nameservice.so.0.3"102 set olsrd.olsrd_nameservice.latlon_file="/var/run/latlon.js"103 set olsrd.olsrd_nameservice.hosts_file="/var/etc/hosts.olsr"104 set olsrd.olsrd_nameservice.sighup_pid_file="/var/run/dnsmasq.pid"105 set olsrd.olsrd_nameservice.suffix="$suffix"40 set olsrd.olsrd_nameservice=LoadPlugin 41 set olsrd.olsrd_nameservice.library="olsrd_nameservice.so.0.3" 42 set olsrd.olsrd_nameservice.latlon_file="/var/run/latlon.js" 43 set olsrd.olsrd_nameservice.hosts_file="/var/etc/hosts.olsr" 44 set olsrd.olsrd_nameservice.sighup_pid_file="/var/run/dnsmasq.pid" 45 set olsrd.olsrd_nameservice.suffix="$suffix" 106 46 EOF 107 47 108 echo " Nameservice Plugin configured." 48 uci_commitverbose "Setup olsr nameservice plugin" olsrd 109 49 110 50 # Setup dyngw_plain … … 113 53 sharenet=$(uci -q get meshwizard.general.sharenet) 114 54 115 if [ -n "$(uci -q get olsrd.dyngw_plain.library)" ]; then116 section_cleanup olsrd.dyngw_plain117 fi118 119 55 if [ "$sharenet" == 1 ]; then 120 echo " + Setup dyngw_plain"121 56 uci set olsrd.dyngw_plain=LoadPlugin 122 57 uci set olsrd.dyngw_plain.ignore=0 123 58 uci set olsrd.dyngw_plain.library="olsrd_dyn_gw_plain.so.0.4" 59 60 uci_commitverbose "Setup olsrd_dyngw_plain plugin" olsrd 124 61 fi 125 126 uci commit -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh
r7291 r7810 7 7 net=$1 8 8 9 handle_splash() { 10 config_get network "$1" network 11 if [ "$network" == "${netrenamed}dhcp" ]; then 12 if [ "$cleanup" == 1 ]; then 13 section_cleanup luci_splash.$1 14 else 9 if [ ! "$has_luci_splash" == TRUE ]; then 10 echo " Luci Splash is not installed, skipping setup of it." 11 exit 12 fi 13 14 dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange) 15 16 if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then 17 handle_splash() { 18 config_get network "$1" network 19 if [ "$network" == "${netrenamed}dhcp" ]; then 15 20 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 16 21 section_rename luci_splash $1 ${netrenamed}dhcp 17 22 fi 18 23 fi 19 fi 20 } 21 config_load luci_splash 22 config_foreach handle_splash iface 24 } 25 config_load luci_splash 26 config_foreach handle_splash iface 23 27 24 uci batch <<EOF25 set luci_splash.${netrenamed}dhcp="iface"26 set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp"27 set luci_splash.${netrenamed}dhcp.zone="freifunk"28 EOF28 uci batch <<- EOF 29 set luci_splash.${netrenamed}dhcp="iface" 30 set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp" 31 set luci_splash.${netrenamed}dhcp.zone="freifunk" 32 EOF 29 33 30 echo " network: ${netrenamed}dhcp" 34 uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash 35 /etc/init.d/luci_splash enable 36 fi 31 37 32 uci commit33 34 /etc/init.d/luci_splash enable35 -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh
r7291 r7810 1 1 #!/bin/sh 2 # Sets values from /etc/config/freifunk and/or the community profile in /etc/config/system3 2 4 if [ -n "$(env | grep '^system_')" ]; then 5 echo "++++ Setup system" 6 env | grep "^system_" | sed "s/system_/uci set system.system./g" | while read line; do 7 eval $line 8 echo " $line" 9 done 10 fi 3 . $dir/functions.sh 11 4 12 uci commit system 5 set_defaults "system_" system.system 6 uci -q delete meshwizard.system && uci commit meshwizard 7 uci_commitverbose "System config" system -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh
r7228 r7810 9 9 ##### wifi-device ##### 10 10 11 echo " + Setup wifi-device"12 13 11 # Get the type before we delete the wifi-device 14 12 config_load wireless 15 13 config_get type $net type 16 14 17 # Delete oldwifi-device for $net15 # Rename wifi-device for $net 18 16 19 17 handle_wifidevice() { 20 if [ "$1" == "$net" -a "$cleanup" == 1 ]; then 21 section_cleanup wireless.${net} 22 else 23 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 24 section_rename wireless $1 $net 25 fi 18 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 19 section_rename wireless $1 $net 26 20 fi 27 21 } … … 42 36 43 37 uci batch << EOF 44 set wireless.${net}.type="$type"45 set wireless.${net}.channel="$channel"38 set wireless.${net}.type="$type" 39 set wireless.${net}.channel="$channel" 46 40 EOF 47 41 48 echo " Type: $type" 49 echo " Channel: $channel" 42 uci_commitverbose "Setup wifi device for $netrenamed" wireless 50 43 51 44 ##### wifi iface 52 45 53 echo " + Setup wifi-iface" 54 55 # Delete old wifi-iface for $net 46 # Rename wifi-iface for $net 56 47 handle_interface() { 57 48 config_get device "$1" device 58 49 if [ "$device" == "$net" ]; then 59 if [ "$cleanup" == 1 ]; then 60 section_cleanup wireless.${net}_iface 61 else 62 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 63 section_rename wireless $1 ${net}_iface 64 fi 50 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 51 section_rename wireless $1 ${net}_iface 65 52 fi 66 53 fi … … 76 63 # overwrite defaults 77 64 bssid="$($dir/helpers/gen_bssid.sh $channel $community)" 65 66 ssid="$profile_ssid" 67 if [ "$profile_ssid_scheme" == "addchannel" ]; then 68 ssid="$ssid - ch$channel" 69 fi 70 78 71 uci batch << EOF 79 set wireless.$net\_iface.device="${net}"80 set wireless.$net\_iface.network="$netrenamed"81 set wireless.$net\_iface.ssid="$profile_ssid - ch$channel"82 set wireless.$net\_iface.bssid="$bssid"72 set wireless.$net\_iface.device="${net}" 73 set wireless.$net\_iface.network="$netrenamed" 74 set wireless.$net\_iface.ssid="$ssid" 75 set wireless.$net\_iface.bssid="$bssid" 83 76 EOF 84 77 85 echo " device: $net 86 network: $netrenamed 87 ssid: $profile_ssid - ch$channel 88 bssid: $bssid" 78 uci_commitverbose "Setup wifi interface for $netrenamed" wireless 89 79 90 80 ## VAP 91 81 ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)" 92 82 if [ "$type" == "atheros" -a "$vap" == 1 ]; then 93 uci batch << EOF 94 set wireless.$net\_iface_dhcp="wifi-iface" 95 set wireless.$net\_iface_dhcp.device="$net" 96 set wireless.$net\_iface_dhcp.mode="ap" 97 set wireless.$net\_iface_dhcp.encryption="none" 98 set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp" 99 set wireless.$net\_iface_dhcp.ssid="FF-AP-$ip4addr" 100 EOF 101 echo " + Setting up VAP interface for $net 102 device: $net 103 network: ${netrenamed}dhcp 104 ssid: AP-$profile_ssid-$ip4addr" 83 uci batch <<- EOF 84 set wireless.$net\_iface_dhcp="wifi-iface" 85 set wireless.$net\_iface_dhcp.device="$net" 86 set wireless.$net\_iface_dhcp.mode="ap" 87 set wireless.$net\_iface_dhcp.encryption="none" 88 set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp" 89 set wireless.$net\_iface_dhcp.ssid="FF-AP-$ip4addr" 90 EOF 91 uci_commitverbose "Setup VAP interface for $netrenamed" wireless 105 92 fi 106 93 107 uci commit -
luci/branches/luci-0.10/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh
r7291 r7810 1 1 #!/bin/sh 2 # This script will take settings from /etc/config/meshwizard, /etc/config/freifunk and /etc/config/profile_<selected in freifunk> 3 # and setup the router to participate in wireless mesh networks 2 3 # This collection of scripts will take settings from /etc/config/meshwizard, /etc/config/freifunk 4 # and /etc/config/profile_<community> and setup the router to participate in wireless mesh networks 5 6 # Copyright 2011 Manuel Munz <freifunk at somakoma dot de> 7 8 # Licensed under the Apache License, Version 2.0 (the "License") 9 # You may not use this file except in compliance with the License. 10 # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 4 11 5 12 . /etc/functions.sh 13 14 echo " 15 /* Meshwizard 0.0.4 */ 16 " 6 17 7 18 # config 8 19 export dir="/usr/bin/meshwizard" 9 20 . $dir/functions.sh 10 debug=1 21 22 # Check which packages we have installed 23 export has_luci=FALSE 24 opkg list_installed |grep luci-mod-admin > /dev/null && export has_luci=TRUE 25 export has_luci_splash=FALSE 26 opkg list_installed |grep luci-app-splash > /dev/null && export has_luci_splash=TRUE 27 28 # Check whether we want to cleanup/restore uci config before setting new options 29 cleanup=$(uci -q get meshwizard.general.cleanup) 30 [ "$cleanup" == 1 ] && $dir/helpers/restore_default_config.sh 11 31 12 32 # Rename wifi interfaces 13 echo "++++ Renaming wifi-devices in /etc/config/meshwizard" 14 $dir/helpers/rename-wifi.sh 15 16 # Firstboot/initial config 17 echo "++++ Initial config" 18 $dir/helpers/initial_config.sh 33 $dir/helpers/rename-wifi.sh 19 34 20 35 # Get community 21 export community=$(uciget freifunk.community.name)36 community=$(uci -q get meshwizard.community.name || uci -q get freifunk.community.name) 22 37 [ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1 23 24 # Check whether we want to cleanup uci config before setting new options or not 25 cleanup=$(uci -q get meshwizard.general.cleanup) 26 27 [ "$cleanup" == 1 ] && export cleanup=1 38 export community="$community" 39 echo $community 28 40 29 41 # Get a list of networks we need to setup 30 42 networks=$(uci show meshwizard.netconfig | grep -v "netconfig=" | sed -e 's/meshwizard.netconfig\.\(.*\)\_.*/\1/' |sort|uniq) 31 43 export networks 32 33 44 [ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1 34 45 35 echo "+++ wizard 0.0.2 +++ 36 Community=$community 37 Network(s)=$networks" 38 39 # Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community, 46 # Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community 47 # then /etc/config/meshwizard 40 48 # last will overwrite first 41 42 49 43 50 $dir/helpers/read_defaults.sh $community > /tmp/meshwizard.tmp … … 46 53 done < /tmp/meshwizard.tmp 47 54 48 # dnsmasq 49 echo "++++ dnsmasq config" 50 $dir/helpers/setup_dnsmasq.sh 55 # Do config 56 $dir/helpers/initial_config.sh 57 $dir/helpers/setup_dnsmasq.sh 58 $dir/helpers/setup_system.sh 59 $dir/helpers/setup_olsrd.sh 60 $dir/helpers/setup_firewall.sh 51 61 52 # system 53 $dir/helpers/setup_system.sh 62 if [ "$wan_proto" == "static" ] && [ -n "$wan_ip4addr" ] && [ -n "$wan_netmask" ]; then 63 $dir/helpers/setup_wan_static.sh 64 fi 65 66 if [ "$lan_proto" == "static" ] && [ -n "$lan_ip4addr" ] && [ -n "$lan_netmask" ]; then 67 $dir/helpers/setup_lan_static.sh 68 fi 54 69 55 70 # Configure found networks 56 71 for net in $networks; do 57 72 # radioX devices need to be renamed 58 73 netrenamed="${net/radio/wireless}" 59 74 export netrenamed 60 61 echo "++++ Configure interface $net"62 63 config="network"64 echo "$(msg_start $config)"65 75 $dir/helpers/setup_network.sh $net 66 67 config="wireless" 68 echo "$(msg_start $config)" 69 $dir/helpers/setup_wifi.sh $net 70 71 config="OLSRd" 72 echo "$(msg_start $config)" 73 $dir/helpers/setup_olsrd.sh $net 76 if [ ! "$net" == "wan" ] && [ ! "$net" == "lan" ]; then 77 $dir/helpers/setup_wifi.sh $net 78 fi 79 $dir/helpers/setup_olsrd_interface.sh $net 74 80 75 81 net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp) 76 82 if [ "$net_dhcp" == 1 ]; then 77 config="DHCP"78 echo "$(msg_start $config)"79 83 $dir/helpers/setup_dhcp.sh $net 80 84 fi 81 85 82 config="luci_splash"83 echo "$(msg_start $config)"84 86 $dir/helpers/setup_splash.sh $net 85 86 config="firewall" 87 echo "$(msg_start $config)" 88 $dir/helpers/setup_firewall.sh $net 89 90 echo " Configuration of $net finished." 87 $dir/helpers/setup_firewall_interface.sh $net 91 88 done 92 89 -
luci/branches/luci-0.10/contrib/package/meshwizard/Makefile
r7228 r7810 5 5 6 6 PKG_NAME:=meshwizard 7 PKG_RELEASE:= 17 PKG_RELEASE:=0.0.5 8 8 9 9 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) … … 14 14 SECTION:=luci 15 15 CATEGORY:=LuCI 16 SUBMENU:= Freifunk16 SUBMENU:=9. Freifunk 17 17 TITLE:=Shell script based wizard for Mesh networks 18 18 DEPENDS:=+firewall -
luci/branches/luci-0.10/contrib/package/remote-update/Makefile
r5572 r7810 17 17 SECTION:=luci 18 18 CATEGORY:=LuCI 19 SUBMENU:= Freifunk19 SUBMENU:=9. Freifunk 20 20 TITLE:=Freifunk remote update utility. 21 21 DEPENDS:=@TARGET_atheros||@TARGET_ar71xx||@TARGET_brcm_2_4
