mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-30 18:07:52 +00:00 
			
		
		
		
	uspot: configure devices ifnames in section uspot
The current uspot config uses a single named section to assign ifnames to uspot interfaces like so: config devices 'devices' option wlanc0 'hotspot1' option wlanc1 'hotspot1' Where 'wlanc0' and 'wlanc1' are physical ifnames. Code in common.uc also hardcodes a check to match ifnames with 'wlanc*'. This comit gets rid of the "config device" sections and accepts in the "config uspot" sections e.g.: option ifname 'wlanc0' or list ifname 'wlanc0' list ifname 'wlanc1' The listed devices are then associated with the current uspot config exactly as they were with the previous configuration system. The hardcoded check in common.uc is also removed, allowing arbitrary ifnames to be used. Malformed sections are ignored with a warning. Subsequent duplicate entries for a given ifname are be ignored with a warning. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
		 Thibaut VARÈNE
					Thibaut VARÈNE
				
			
				
					committed by
					
						 John Crispin
						John Crispin
					
				
			
			
				
	
			
			
			 John Crispin
						John Crispin
					
				
			
						parent
						
							b44c7b09db
						
					
				
				
					commit
					74651831ef
				
			| @@ -1,2 +1 @@ | ||||
| config devices devices | ||||
| config webroot def_captive | ||||
|   | ||||
| @@ -10,10 +10,10 @@ function restart() { | ||||
|  | ||||
| function interfaces() { | ||||
| 	let interfaces = []; | ||||
| 	let devices = uci.get_all('uspot', 'devices'); | ||||
| 	for (let k, v in devices) | ||||
| 		if (substr(k, 0, 1) != '.') | ||||
| 			push(interfaces, v); | ||||
| 	uci.foreach('uspot', 'uspot', (d) => { | ||||
| 		if (!d[".anonymous"]) | ||||
| 			push(interfaces, d[".name"]); | ||||
| 	}); | ||||
| 	return uniq(interfaces); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -21,10 +21,10 @@ function session_timeout(interface) { | ||||
| 	return config[interface].session_timeout || 0; | ||||
| } | ||||
|  | ||||
| let devices = uci.get_all('uspot', 'devices'); | ||||
| for (let k, v in devices) | ||||
| 	if (substr(k, 0, 1) != '.') | ||||
| 		clients[v] = {};; | ||||
| uci.foreach('uspot', 'uspot', (d) => { | ||||
| 	if (!d[".anonymous"]) | ||||
| 		clients[d[".name"]] = {}; | ||||
| }); | ||||
|  | ||||
| function syslog(interface, mac, msg) { | ||||
| 	let log = sprintf('uspot: %s %s %s', interface, mac, msg); | ||||
|   | ||||
| @@ -29,12 +29,38 @@ if (file) { | ||||
| 	file.close(); | ||||
| } | ||||
|  | ||||
| let devices = uci.get_all('uspot', 'devices'); | ||||
| let devices = {}; | ||||
| uci.foreach('uspot', 'uspot', (d) => { | ||||
| 	function adddev(ifname, sname) { | ||||
| 		if (ifname in devices) | ||||
| 			warn('uspot: ignoring duplicate entry for ifname: "' + ifname + '"\n'); | ||||
| 		else | ||||
| 			devices[ifname] = sname; | ||||
| 	} | ||||
|  | ||||
| 	if (d[".anonymous"]) { | ||||
| 		warn('uspot: ignoring invalid anonymous section at index ' + d[".index"] + '\n'); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	let spotname = d[".name"]; | ||||
| 	if (!d.ifname) { | ||||
| 		warn('uspot: missing ifname in section "' + spotname + '"\n'); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (type(d.ifname) == "array") { | ||||
| 		for (let n in d.ifname) | ||||
| 			adddev(n, spotname); | ||||
| 	} | ||||
| 	else | ||||
| 		adddev(d.ifname, spotname); | ||||
| }); | ||||
|  | ||||
| function lookup_station(mac) { | ||||
| 	let wifs = nl.request(nl.const.NL80211_CMD_GET_INTERFACE, nl.const.NLM_F_DUMP); | ||||
| 	for (let wif in wifs) { | ||||
| 		if (substr(wif.ifname, 0, 5) != 'wlanc') | ||||
| 		if (!(wif.ifname in devices)) | ||||
| 			continue; | ||||
| 		let res = nl.request(nl.const.NL80211_CMD_GET_STATION, nl.const.NLM_F_DUMP, { dev: wif.ifname }); | ||||
| 		for (let sta in res) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user