mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-11-01 02:48:18 +00:00 
			
		
		
		
	uspot: accounting: setup interim only when needed
There is no point in setting up the interim timer if the relevant radius data is not available. Furthermore, the return value check would only fail if the client was unknown to spotfilter at the query time, which isn't a failure to *send* data. 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
						
							45def78972
						
					
				
				
					commit
					4c272fe5f5
				
			| @@ -33,10 +33,6 @@ function debug(interface, mac, msg) { | |||||||
| 		syslog(interface, mac, msg); | 		syslog(interface, mac, msg); | ||||||
| } | } | ||||||
|  |  | ||||||
| function radius_available(interface,mac) { |  | ||||||
| 	return !!clients[interface][mac]?.radius; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function radius_init(interface, mac, payload) { | function radius_init(interface, mac, payload) { | ||||||
| 	for (let key in [ 'server', 'acct_server', 'acct_session', 'client_ip', 'called_station', 'calling_station', 'nas_ip', 'nas_id', 'username', 'location_name' ]) | 	for (let key in [ 'server', 'acct_server', 'acct_session', 'client_ip', 'called_station', 'calling_station', 'nas_ip', 'nas_id', 'username', 'location_name' ]) | ||||||
| 		if (clients[interface][mac].radius[key]) | 		if (clients[interface][mac].radius[key]) | ||||||
| @@ -65,9 +61,8 @@ function radius_acct(interface, mac, payload) { | |||||||
| 		interface, | 		interface, | ||||||
| 		address: mac | 		address: mac | ||||||
| 	}); | 	}); | ||||||
| 	if (!state) { | 	if (!state) | ||||||
| 		return false; | 		return; | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	payload = radius_init(interface, mac, payload); | 	payload = radius_init(interface, mac, payload); | ||||||
| 	payload.acct = true; | 	payload.acct = true; | ||||||
| @@ -82,7 +77,6 @@ function radius_acct(interface, mac, payload) { | |||||||
| 		payload.class = state.data.radius.reply.Class; | 		payload.class = state.data.radius.reply.Class; | ||||||
|  |  | ||||||
| 	radius_call(interface, mac, payload); | 	radius_call(interface, mac, payload); | ||||||
| 	return true; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // RADIUS Acct-Terminate-Cause attributes | // RADIUS Acct-Terminate-Cause attributes | ||||||
| @@ -106,15 +100,12 @@ function radius_terminate(interface, mac, cause) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function radius_interim(interface, mac) { | function radius_interim(interface, mac) { | ||||||
| 	if (!radius_available(interface, mac)) | 	const acct_type_interim = 3; | ||||||
| 		return; |  | ||||||
| 	let payload = { | 	let payload = { | ||||||
| 		acct_type: 3, | 		acct_type: acct_type_interim, | ||||||
| 	}; | 	}; | ||||||
| 	if (radius_acct(interface, mac, payload)) | 	radius_acct(interface, mac, payload); | ||||||
| 	debug(interface, mac, 'iterim acct call'); | 	debug(interface, mac, 'iterim acct call'); | ||||||
| 	else |  | ||||||
| 		syslog(interface, mac, 'failed to send interim accounting frame\n'); |  | ||||||
| 	clients[interface][mac].timeout.set(clients[interface][mac].interval); | 	clients[interface][mac].timeout.set(clients[interface][mac].interval); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -148,11 +139,12 @@ function client_add(interface, mac, state) { | |||||||
| 		clients[interface][mac].ip4addr = state.ip4addr; | 		clients[interface][mac].ip4addr = state.ip4addr; | ||||||
| 	if (state.ip6addr) | 	if (state.ip6addr) | ||||||
| 		clients[interface][mac].ip6addr = state.ip6addr; | 		clients[interface][mac].ip6addr = state.ip6addr; | ||||||
| 	if (state.data?.radius?.request) | 	if (state.data?.radius?.request) { | ||||||
| 		clients[interface][mac].radius = state.data.radius.request; | 		clients[interface][mac].radius = state.data.radius.request; | ||||||
| 	syslog(interface, mac, 'adding client'); |  | ||||||
| 		if (accounting) | 		if (accounting) | ||||||
| 			clients[interface][mac].timeout = uloop.timer(interval, () => radius_interim(interface, mac)); | 			clients[interface][mac].timeout = uloop.timer(interval, () => radius_interim(interface, mac)); | ||||||
|  | 	} | ||||||
|  | 	syslog(interface, mac, 'adding client'); | ||||||
| } | } | ||||||
|  |  | ||||||
| function client_kick(interface, mac, remove) { | function client_kick(interface, mac, remove) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user