Linux 3.7.1
[linux/fpc-iii.git] / Documentation / usb / wusb-cbaf
blob8b3d43efce900020fb36c364835fc3b9cf256286
1 #! /bin/bash
4 set -e
6 progname=$(basename $0)
7 function help
9 cat <<EOF
10 Usage: $progname COMMAND DEVICEs [ARGS]
12 Command for manipulating the pairing/authentication credentials of a
13 Wireless USB device that supports wired-mode Cable-Based-Association.
15 Works in conjunction with the wusb-cba.ko driver from http://linuxuwb.org.
18 DEVICE
20 sysfs path to the device to authenticate; for example, both this
21 guys are the same:
23 /sys/devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4.4/1-4.4:1.1
24 /sys/bus/usb/drivers/wusb-cbaf/1-4.4:1.1
26 COMMAND/ARGS are
28 start
30 Start a WUSB host controller (by setting up a CHID)
32 set-chid DEVICE HOST-CHID HOST-BANDGROUP HOST-NAME
34 Sets host information in the device; after this you can call the
35 get-cdid to see how does this device report itself to us.
37 get-cdid DEVICE
39 Get the device ID associated to the HOST-CHID we sent with
40 'set-chid'. We might not know about it.
42 set-cc DEVICE
44 If we allow the device to connect, set a random new CDID and CK
45 (connection key). Device saves them for the next time it wants to
46 connect wireless. We save them for that next time also so we can
47 authenticate the device (when we see the CDID he uses to id
48 itself) and the CK to crypto talk to it.
50 CHID is always 16 hex bytes in 'XX YY ZZ...' form
51 BANDGROUP is almost always 0001
53 Examples:
55 You can default most arguments to '' to get a sane value:
57 $ $progname set-chid '' '' '' "My host name"
59 A full sequence:
61 $ $progname set-chid '' '' '' "My host name"
62 $ $progname get-cdid ''
63 $ $progname set-cc ''
65 EOF
69 # Defaults
70 # FIXME: CHID should come from a database :), band group from the host
71 host_CHID="00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"
72 host_band_group="0001"
73 host_name=$(hostname)
75 devs="$(echo /sys/bus/usb/drivers/wusb-cbaf/[0-9]*)"
76 hdevs="$(for h in /sys/class/uwb_rc/*/wusbhc; do readlink -f $h; done)"
78 result=0
79 case $1 in
80 start)
81 for dev in ${2:-$hdevs}
83 echo $host_CHID > $dev/wusb_chid
84 echo I: started host $(basename $dev) >&2
85 done
87 stop)
88 for dev in ${2:-$hdevs}
90 echo 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > $dev/wusb_chid
91 echo I: stopped host $(basename $dev) >&2
92 done
94 set-chid)
95 shift
96 for dev in ${2:-$devs}; do
97 echo "${4:-$host_name}" > $dev/wusb_host_name
98 echo "${3:-$host_band_group}" > $dev/wusb_host_band_groups
99 echo ${2:-$host_CHID} > $dev/wusb_chid
100 done
102 get-cdid)
103 for dev in ${2:-$devs}
105 cat $dev/wusb_cdid
106 done
108 set-cc)
109 for dev in ${2:-$devs}; do
110 shift
111 CDID="$(head --bytes=16 /dev/urandom | od -tx1 -An)"
112 CK="$(head --bytes=16 /dev/urandom | od -tx1 -An)"
113 echo "$CDID" > $dev/wusb_cdid
114 echo "$CK" > $dev/wusb_ck
116 echo I: CC set >&2
117 echo "CHID: $(cat $dev/wusb_chid)"
118 echo "CDID:$CDID"
119 echo "CK: $CK"
120 done
122 help|h|--help|-h)
123 help
126 echo "E: Unknown usage" 1>&2
127 help 1>&2
128 result=1
129 esac
130 exit $result