1149629Ssam#! /bin/sh
2149629Ssam#
3149629Ssam# Set the IFS parameters for an interface configured for
4149629Ssam# point-to-point use at a specific distance.  Based on a
5149629Ssam# program by Gunter Burchardt.
6149629Ssam#
7149629Ssam# $FreeBSD$
8149629Ssam#
9149629SsamDEV=ath0
10149629Ssamd=0
11149629Ssam
12149629Ssamusage()
13149629Ssam{
14149629Ssam	echo "Usage: $0 [-i athX] [-d meters]"
15149629Ssam	exit 2
16149629Ssam}
17149629Ssam
18149629Ssamargs=`getopt d:i: $*`
19149629Ssamtest $? -ne 0 && usage
20149629Ssam
21149629Ssamset -- $args
22149629Ssamfor i; do
23149629Ssam	case "$i" in
24149629Ssam	-i)	DEV="$2"; shift; shift;;
25149629Ssam	-d)	d="$2"; shift; shift;;
26149629Ssam	--)	shift; break;
27149629Ssam	esac
28149629Ssamdone
29149629Ssam
30149629Ssamtest $d -eq 0 && usage
31149629Ssam
32149629Ssamslottime=`expr 9 + \( $d / 300 \)`
33149629Ssamif expr \( $d % 300 \) != 0 >/dev/null 2>&1; then
34149629Ssam	slottime=`expr $slottime + 1`
35149629Ssamfi
36149629Ssamtimeout=`expr $slottime \* 2 + 3`
37149629Ssam
38149629Ssamprintf "Setup IFS parameters on interface ${DEV} for %i meter p-2-p link\n" $d
39149629SsamATHN=`echo $DEV | sed 's/ath//'`
40149629Ssamsysctl dev.ath.$ATHN.slottime=$slottime
41149629Ssamsysctl dev.ath.$ATHN.acktimeout=$timeout
42149629Ssamsysctl dev.ath.$ATHN.ctstimeout=$timeout
43