How does rrm work?

In /etc/init.d/neighbor_report:

#!/bin/sh /etc/rc.common

START=90

USE_PROCD=1

radios=$(ubus list | grep hostapd.wlan)

start_service() {
	local rrm_own
	
	OIFS=$IFS
	IFS=$'\n'

	for value in ${radios}
	do
		rrm_own=${rrm_own}",$(ubus call ${value} rrm_nr_get_own | jsonfilter -e '$.value')"
	done

	IFS=$OIFS

	procd_open_instance
	procd_set_param command /bin/sh "/usr/bin/rrm"
	procd_add_mdns "rrm" "udp" "" "${rrm_own:1}"
	procd_close_instance
}

service_triggers()
{
	procd_add_reload_trigger wireless
}

In /usr/bin/rrm

#!/bin/sh

radios=$(ubus list | grep hostapd.wlan)

_discover_neighbors() {
	local rrm_neighbors

	ubus call umdns update
	sleep 2

	rrm_neighbors=$(ubus call umdns browse | jsonfilter -e '@["_rrm._udp"][*].txt')

	for value in ${rrm_neighbors}
	do
		rrm_nr_lists=${rrm_nr_lists}",${value}"
	done
}

_append_own() {
	for value in ${radios}
	do
		rrm_nr_lists=${rrm_nr_lists}",$(ubus call ${value} rrm_nr_get_own | jsonfilter -e '$.value')"
	done
}

while true
do
	OIFS=$IFS
	IFS=$'\n'

	rrm_nr_lists=""

	_discover_neighbors
	_append_own

	for value in ${radios}
	do
		ubus call ${value} bss_mgmt_enable '{"neighbor_report": true}'
		eval "ubus call ${value} rrm_nr_set '{ \"list\": [ ${rrm_nr_lists:1} ] }'"
	done

	sleep 60

	IFS=$OIFS
done

exit 0

These scripts would probably fare better if they were (1) integrated as easily as 802.11r is now enabled via mac80211.sh and (2) lives as a hotplud.d script watching the wlan0/wlan1 interface(s). Right now, I don't really have the time to figure this out myself and this script from @sotux and @muddyfeet does what it needs to do albeit a few caveats if something is shut down/rebooted.

Additionally, umdns is a requirement.

2 Likes