summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/raycontrol/Makefile9
-rw-r--r--usr.sbin/raycontrol/raycontrol.8310
-rw-r--r--usr.sbin/raycontrol/raycontrol.c488
3 files changed, 807 insertions, 0 deletions
diff --git a/usr.sbin/raycontrol/Makefile b/usr.sbin/raycontrol/Makefile
new file mode 100644
index 0000000..8fd1eef
--- /dev/null
+++ b/usr.sbin/raycontrol/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+PROG= raycontrol
+SRCS= raycontrol.c
+
+MAN8= raycontrol.8
+
+CFLAGS+=-I${.CURDIR}/../../sys
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/raycontrol/raycontrol.8 b/usr.sbin/raycontrol/raycontrol.8
new file mode 100644
index 0000000..1020bf4
--- /dev/null
+++ b/usr.sbin/raycontrol/raycontrol.8
@@ -0,0 +1,310 @@
+'\"
+'\"Copyright (C) 2000
+'\"Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
+'\"
+'\" All rights reserved.
+'\"
+'\"Redistribution and use in source and binary forms, with or without
+'\"modification, are permitted provided that the following conditions
+'\"are met:
+'\"1. Redistributions of source code must retain the above copyright
+'\" notice, this list of conditions and the following disclaimer.
+'\"2. Redistributions in binary form must reproduce the above copyright
+'\" notice, this list of conditions and the following disclaimer in the
+'\" documentation and/or other materials provided with the distribution.
+'\"3. Neither the name of the author nor the names of any co-contributors
+'\" may be used to endorse or promote products derived from this software
+'\" without specific prior written permission.
+'\"
+'\"THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY AND CONTRIBUTORS ``AS IS'' AND
+'\"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+'\"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+'\"ARE DISCLAIMED. IN NO EVENT SHALL DUNCAN BARCLAY OR CONTRIBUTORS BE LIABLE
+'\"FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+'\"DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+'\"OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+'\"HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+'\"LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+'\"OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+'\"SUCH DAMAGE.
+'\"
+'\" $FreeBSD$
+'\"
+
+'\"
+.\" Copyright (c) 1997, 1998, 1999
+.\" Bill Paul <wpaul@ctr.columbia.edu> All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Bill Paul.
+.\" 4. Neither the name of the author nor the names of any co-contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+.\" THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 21, 2000
+.Dt RAYCONTROL 8
+.Os FreeBSD 3.3
+.Sh NAME
+.Nm raycontrol
+.Nd configure Raytheon Raylink/Webgear Aviator devices
+.Sh SYNOPSIS
+.Nm raycontrol
+.Fl i Ar iface Op Fl o
+.Nm raycontrol
+.Fl i Ar iface Fl t Ar tx rate
+.Nm raycontrol
+.Fl i Ar iface Fl n Ar network name
+.Nm raycontrol
+.Fl i Ar iface Fl c Ar ap status
+.Nm raycontrol
+.Fl i Ar iface Fl p Ar port type
+.Nm raycontrol
+.Fl i Ar iface Fl m Ar mac address
+.Nm raycontrol
+.Fl i Ar iface Fl d Ar max data length
+.Nm raycontrol
+.Fl i Ar iface Fl r Ar RTS threshold
+.Nm raycontrol
+.Fl i Ar iface Fl f Ar hopset
+.Nm raycontrol
+.Fl i Ar iface Fl P Ar 0|1
+.Nm raycontrol
+.Fl i Ar iface Fl S Ar max_sleep_duration
+.Nm raycontrol
+.Fl i Ar iface Fl Z Ar zero signal cache
+.Nm raycontrol
+.Fl i Ar iface Fl C Ar display signal cache
+.Sh DESCRIPTION
+The
+.Nm
+command controls the operation of Raylink/Webgear wireless networking
+devices via the
+.Xr ray 4
+driver.
+Most of the parameters that can be changed relate to the
+IEEE 802.11 protocol which the card implements.
+This includes
+the station name, whether the station is operating in ad-hoc
+or infrastructure mode, and the network name of a service
+set to join - the BSS in ad-hoc mode or ESS if infrastructure mode is enabled.
+The
+.Nm
+command can also be used to view the current settings of these parameters
+and to dump out the values of the card's statistics counters.
+.Pp
+The
+.Ar iface
+argument given to
+.Nm
+should be the logical interface name associated with the Raylink/Webgear
+device (ray0, ray1, etc...).
+.Sh OPTIONS
+The options are as follows:
+.Bl -tag -width Fl
+.It Fl i Ar iface Op Fl o
+Display the current settings of the specified Raylink/Webgear interface.
+This retrieves the current card settings from the driver and prints them
+out. The results from this command are a snapshot of the card settings.
+Using the additional
+.Fl o
+flag will cause
+.Nm
+to print out the statistics counters instead of the card settings.
+.It Fl i Ar iface Fl t Ar tx rate
+Set the transmit rate of the specified interface.
+The
+NICs support a maximum transmit rate of 2Mbps.
+The following table shows the
+legal transmit rate settings and the corresponding transmit speeds:
+.Bd -filled -offset indent
+.Bl -column "TX rate " "NIC speed "
+.Em "TX rate NIC speed"
+1 Very Low (0.5Mbps)
+2 Low (1Mbps)
+3 Medium (1.5Mbps)
+4 High (2Mbps)
+.El
+.Ed
+.Pp
+The version 4 firmware may ignore this setting. Note, that the IEEE802.11
+standard
+only allows 1Mbps or 2Mbps operation, and that the generally accepted
+reading of the IEEE802.11 standard is that 2Mbps is only allowed in
+infrastructure mode.
+.It Fl i Ar iface Fl n Ar network name
+Set the name of the service set that this station wishes to
+join. The
+.Ar network name
+can be any text string up to 32 characters in length.
+The default name
+is the string "NETWORK_NAME" which should allow the station to connect to
+the default Webgear ad-hoc network.
+.It Fl i Ar iface Fl p Ar port type
+Set the
+.Ar port type
+for a specified interface.
+The legal values for
+.Ar port type
+are 0 (ad-hoc mode) and 1 (infrastructure) mode.
+In ad-hoc mode, the station can
+communicate directly with any other stations within direct radio range
+(provided that they are also operating in ad-hoc mode). In inrastructure mode,
+hosts must associate with a service set controlled by an access point,
+that relays traffic between end stations.
+The default setting is 0
+(ad-hoc mode).
+.Pp
+When in ad-hoc mode the station will create a BSS with the network name
+specified by the
+.Fl n
+option if it cannot find an existing network of that name on the
+currently configured hopset (see the
+.Fl f
+option.)
+.It Fl i Ar iface Fl m Ar mac address
+Set the station address for the specified interface.
+The
+.Ar mac address
+is specified as a series of six hexadecimal values separated by colons,
+e.g.: 00:60:1d:12:34:56.
+This programs the new address into the card
+and updates the interface as well.
+.It Fl i Ar iface Fl d Ar max_data_length
+Set the maximum transmit frame size for a specified interface.
+The
+.Ar max data length
+can be any number from 350 to 2304 or -1 to disable fragmentation.
+The default is -1.
+.It Fl i Ar iface Fl r Ar RTS threshold
+Set the RTS/CTS threshold for a given interface.
+This controls the
+number of bytes used for the RTS/CTS handshake boundary.
+The
+.Ar RTS threshold
+can be any value between -1 and 2047.
+The default is -1 (disable.)
+.It Fl i Ar iface Fl f Ar hopset
+Set the radio hopset of a given interface.
+The
+.Ar hopset
+should be specified as a country code as shown in the table below.
+The
+hopset varies both the number of RF channels and their frequencies
+and is dependent on radio regulations specified
+by regional authorities.
+.Bd -filled -offset indent
+.Bl -column "Hopset ID " "Country "
+.Em "Hopset ID Country"
+1 USA
+2 Europe
+3 Japan
+4 Korea
+5 Spain
+6 France
+7 Israel
+8 Australia
+9 Japan Test
+.El
+.Ed
+.Pp
+Whilst the card can be programmed to work with any hopset it makes
+sense to use the hopset for your own region to avoid interference from
+and interfering with other users of the RF spectrum (in places like
+France this is the military.)
+.Pp
+Note that all stations must be set to the same hopset in order to
+communicate.
+.It Fl i Ar iface Fl P Ar 0|1
+Enable or disable power management on a given interface.
+Enabling
+power management uses an alternating sleep/wake protocol to help
+conserve power on mobile stations, at the cost of some increased
+receive latency.
+Power management is off by default.
+.Pp
+Note that power
+management requires the cooperation of an access point in order to
+function; it is not functional in ad-hoc mode.
+Legal
+values for this parameter are 0 (off) and 1 (on).
+.It Fl i Ar iface Fl S Ar max_sleep_interval
+Specify the sleep interval to use when power management is enabled.
+The
+.Are max sleep interval
+is specified in milliseconds.
+The default is 100.
+.It Fl i Ar iface Fl Z
+Clear the signal strength cache maintained internally by the
+.Nm ray
+driver.
+.It Fl i Ar iface Fl C
+Display the cached signal strength information maintained by the
+.Nm ray
+driver.
+The driver retains information about signal strength and
+noise level for packets received from different hosts. For
+infrastructure networks the cache stores the signal strength of the
+access point.
+.Pp
+The driver also uses the cache to pick the best antenna when
+transmitting.
+.El
+.Sh SEE ALSO
+.Xr ray 4 ,
+.Xr ifconfig 8
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Fx 4.0 .
+.Sh AUTHORS
+The
+.Nm
+command was written by
+.An Duncan Barclay Aq dmlb@ragnet.demon.co.uk
+and based on the
+.Nm wicontrol
+command by
+.An Bill Paul Aq wpaul@ctr.columbia.edu .
+.Sh BUGS
+The
+.Fl m
+,
+.Fl P
+,
+.Fl S
+and
+.Fl Z
+options aren't implmented yet. No access point was available for testing
+against.
+.Pp
+Not tested with Version 5 firmware.
+.Pp
+Hopset changing may not work with version 4 firmware.
+.Pp
+The
+.Fl W
+option is un-documented on purpose.
diff --git a/usr.sbin/raycontrol/raycontrol.c b/usr.sbin/raycontrol/raycontrol.c
new file mode 100644
index 0000000..604960f
--- /dev/null
+++ b/usr.sbin/raycontrol/raycontrol.c
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 1999, 2000
+ * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL DUNCAN BARCLAY OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_ieee80211.h>
+
+#include <dev/ray/if_rayreg.h>
+#include <dev/ray/if_raymib.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <err.h>
+
+static char * ray_printhex (u_int8_t *d, char *s, int len);
+static void ray_getval (char *iface, struct ray_param_req *rreq);
+static void ray_getstats (char *iface, struct ray_stats_req *sreq);
+static int ray_version (char *iface);
+static void ray_dumpstats (char *iface);
+static void ray_dumpinfo (char *iface);
+static void ray_setstr (char *iface, u_int8_t mib, char *s);
+static void ray_setword (char *iface, u_int8_t mib, u_int16_t v);
+static void ray_setval (char *iface, struct ray_param_req *rreq);
+static void usage (char *p);
+
+static char *mib_strings[] = RAY_MIB_STRINGS;
+static char *mib_help_strings[] = RAY_MIB_HELP_STRINGS;
+static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO;
+
+static char *
+ray_printhex(u_int8_t *d, char *s, int len)
+{
+ static char buf[3*256];
+ char *p;
+ int i;
+
+ if (len > 256)
+ err(1, "Byte string too long");
+
+ sprintf(buf, "%02x", *d);
+ for (p = buf + 2, i = 1; i < len; i++) {
+ sprintf(p, "%s%02x", s, *(d+i));
+ p = p + 2 + strlen(s);
+ }
+
+ return(buf);
+}
+
+static void
+ray_getval(char *iface, struct ray_param_req *rreq)
+{
+ struct ifreq ifr;
+ int s;
+
+ bzero((char *)&ifr, sizeof(ifr));
+
+ strcpy(ifr.ifr_name, iface);
+ ifr.ifr_data = (caddr_t)rreq;
+
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (s == -1)
+ err(1, "socket");
+
+ if (ioctl(s, SIOCGRAYPARAM, &ifr) == -1)
+ warn("SIOCGRAYPARAM failed with failcode 0x%02x",
+ rreq->r_failcause);
+
+ close(s);
+}
+
+static void
+ray_getsiglev(char *iface, struct ray_siglev *siglev)
+{
+ struct ifreq ifr;
+ int s;
+
+ bzero((char *)&ifr, sizeof(ifr));
+
+ strcpy(ifr.ifr_name, iface);
+ ifr.ifr_data = (caddr_t)siglev;
+
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (s == -1)
+ err(1, "socket");
+
+ if (ioctl(s, SIOCGRAYSIGLEV, &ifr) == -1)
+ err(1, "SIOCGRAYSIGLEV failed");
+
+ close(s);
+}
+
+static void
+ray_getstats(char *iface, struct ray_stats_req *sreq)
+{
+ struct ifreq ifr;
+ int s;
+
+ bzero((char *)&ifr, sizeof(ifr));
+
+ strcpy(ifr.ifr_name, iface);
+ ifr.ifr_data = (caddr_t)sreq;
+
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (s == -1)
+ err(1, "socket");
+
+ if (ioctl(s, SIOCGRAYSTATS, &ifr) == -1)
+ err(1, "SIOCGRAYSTATS failed");
+
+ close(s);
+}
+
+static int
+ray_version(char *iface)
+{
+ struct ray_param_req rreq;
+
+ if (iface == NULL)
+ errx(1, "must specify interface name");
+
+ bzero((char *)&rreq, sizeof(rreq));
+ rreq.r_paramid = RAY_MIB_VERSION;
+ ray_getval(iface, &rreq);
+ return(*rreq.r_data);
+}
+
+static void
+ray_dumpinfo(char *iface)
+{
+ struct ray_param_req rreq;
+ u_int8_t mib, version;
+
+ if (iface == NULL)
+ errx(1, "must specify interface name");
+
+ bzero((char *)&rreq, sizeof(rreq));
+
+ version = ray_version(iface);
+ printf("%-26s\t", mib_strings[RAY_MIB_VERSION]);
+ printf("%d\n", 3+version);
+
+ for (mib = RAY_MIB_NET_TYPE; mib < RAY_MIB_MAX; mib++) {
+
+ if ((mib_info[mib][0] & version) == 0)
+ continue;
+ if (mib == RAY_MIB_VERSION)
+ continue;
+
+ rreq.r_paramid = mib;
+ ray_getval(iface, &rreq);
+ printf("%-26s\t", mib_strings[mib]);
+ switch (rreq.r_len) {
+
+ case 2:
+ printf("0x%02x%02x", *rreq.r_data, *(rreq.r_data+1));
+ break;
+
+ case ETHER_ADDR_LEN:
+ printf("%s",
+ ray_printhex(rreq.r_data, ":", rreq.r_len));
+ break;
+
+ case IEEE80211_NWID_LEN:
+ printf("%-32s", (char *)rreq.r_data);
+ break;
+
+
+ case 1:
+ default:
+ printf("0x%02x", *rreq.r_data);
+ break;
+ }
+ printf("\t%s\n", mib_help_strings[mib]);
+ }
+}
+
+static void
+ray_dumpsiglev(char *iface)
+{
+ struct ray_siglev siglevs[RAY_NSIGLEVRECS];
+ int i;
+
+ if (iface == NULL)
+ errx(1, "must specify interface name");
+
+ bzero((char *)siglevs, sizeof(siglevs));
+
+ ray_getsiglev(iface, siglevs);
+
+ for (i = 0; i < RAY_NSIGLEVRECS; i++) {
+ printf("Slot %d: %s", i,
+ ray_printhex(siglevs[i].rsl_host, ":", ETHER_ADDR_LEN));
+ printf(" %s",
+ ray_printhex(siglevs[i].rsl_siglevs, ",", RAY_NSIGLEV));
+ printf(" %s\n",
+ ray_printhex(siglevs[i].rsl_antennas, "", RAY_NANTENNA));
+ }
+
+}
+
+static void
+ray_dumpstats(char *iface)
+{
+ struct ray_stats_req sreq;
+
+ if (iface == NULL)
+ errx(1, "must specify interface name");
+
+ bzero((char *)&sreq, sizeof(sreq));
+
+ ray_getstats(iface, &sreq);
+
+ printf("Receiver overflows %lu\n",
+ (unsigned long int)sreq.rxoverflow);
+ printf("Receiver checksum errors %lu\n",
+ (unsigned long int)sreq.rxcksum);
+ printf("Header checksum errors %lu\n",
+ (unsigned long int)sreq.rxhcksum);
+ printf("Clear channel noise level %u\n", sreq.rxnoise);
+}
+
+static void
+ray_setval(char *iface, struct ray_param_req *rreq)
+{
+ struct ifreq ifr;
+ int s;
+
+ bzero((char *)&ifr, sizeof(ifr));
+
+ strcpy(ifr.ifr_name, iface);
+ ifr.ifr_data = (caddr_t)rreq;
+
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (s == -1)
+ err(1, "socket");
+
+ if (ioctl(s, SIOCSRAYPARAM, &ifr) == -1) {
+ err(1, "SIOCSRAYPARAM failed with failcode 0x%02x",
+ rreq->r_failcause);
+ }
+
+ close(s);
+}
+
+static void
+ray_setword(char *iface, u_int8_t mib, u_int16_t v)
+{
+ struct ray_param_req rreq;
+
+ if (iface == NULL)
+ errx(1, "must specify interface name");
+
+ bzero((char *)&rreq, sizeof(rreq));
+
+ rreq.r_paramid = mib;
+ rreq.r_len = RAY_MIB_SIZE(mib_info, mib, ray_version(iface));
+ switch (rreq.r_len) {
+
+ case 1:
+ *rreq.r_data = (u_int8_t)(v & 0xff);
+ break;
+
+ case 2:
+ *rreq.r_data = (u_int8_t)((v & 0xff00) >> 8);
+ *(rreq.r_data+1) = (u_int8_t)(v & 0xff);
+ break;
+
+ default:
+ break;
+ }
+
+ ray_setval(iface, &rreq);
+}
+
+static void
+ray_setstr(char *iface, u_int8_t mib, char *s)
+{
+ struct ray_param_req rreq;
+
+ if (iface == NULL)
+ errx(1, "must specify interface name");
+ if (s == NULL)
+ errx(1, "must specify string");
+ if (strlen(s) > RAY_MIB_SIZE(mib_info, mib, ray_version(iface)))
+ errx(1, "string too long");
+
+ bzero((char *)&rreq, sizeof(rreq));
+
+ rreq.r_paramid = mib;
+ rreq.r_len = RAY_MIB_SIZE(mib_info, mib, ray_version(iface));
+ bcopy(s, (char *)rreq.r_data, strlen(s));
+
+ ray_setval(iface, &rreq);
+}
+
+static void
+usage(char *p)
+{
+ fprintf(stderr, "usage: %s -i iface\n", p);
+ fprintf(stderr, "\t%s -i iface -o\n", p);
+ fprintf(stderr, "\t%s -i iface -t tx rate\n", p);
+ fprintf(stderr, "\t%s -i iface -n network name\n", p);
+ fprintf(stderr, "\t%s -i iface -p port type\n", p);
+ fprintf(stderr, "\t%s -i iface -m mac address\n", p);
+ fprintf(stderr, "\t%s -i iface -d max data length\n", p);
+ fprintf(stderr, "\t%s -i iface -r RTS threshold\n", p);
+ fprintf(stderr, "\t%s -i iface -f hopset\n", p);
+ fprintf(stderr, "\t%s -i iface -P 0|1\n", p);
+ fprintf(stderr, "\t%s -i iface -S max sleep duration\n", p);
+ fprintf(stderr, "\t%s -i iface -C print signal cache\n", p);
+
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ char *iface, *p;
+ int ch, val;
+
+ iface = NULL;
+ p = argv[0];
+
+ /* Get the interface name */
+ opterr = 0;
+ ch = getopt(argc, argv, "i:");
+ if (ch == 'i') {
+ iface = optarg;
+ } else {
+ if (argc > 1 && *argv[1] != '-') {
+ iface = argv[1];
+ optind = 2;
+ } else {
+ iface = "ray0";
+ optind = 1;
+ }
+ optreset = 1;
+ }
+ opterr = 1;
+
+ while ((ch = getopt(argc, argv, "hoCi:d:f:n:p:r:t:W:")) != -1) {
+ switch (ch) {
+
+ case 'i':
+ iface = optarg;
+ break;
+
+ case 'd':
+ val = atoi(optarg);
+ if (((val < 350) &&
+ (val != -1)) || (val > RAY_MIB_FRAG_THRESH_MAXIMUM))
+ usage(p);
+ if (val == -1)
+ val = 0x7fff;
+ ray_setword(iface, RAY_MIB_FRAG_THRESH, val);
+ exit(0);
+ break;
+
+ case 'f':
+ val = atoi(optarg);
+ if ((val < RAY_MIB_COUNTRY_CODE_MIMIMUM) ||
+ (val > RAY_MIB_COUNTRY_CODE_MAXIMUM))
+ usage(p);
+ ray_setword(iface, RAY_MIB_COUNTRY_CODE, val);
+ exit(0);
+ break;
+
+ case 'n':
+ ray_setstr(iface, RAY_MIB_SSID, optarg);
+ exit(0);
+ break;
+
+ case 'o':
+ ray_dumpstats(iface);
+ exit(0);
+ break;
+
+ case 'p':
+ val = atoi(optarg);
+ if ((val < 0) || (val > 1))
+ usage(p);
+ ray_setword(iface, RAY_MIB_NET_TYPE, val);
+ exit(0);
+ break;
+
+
+ case 'r':
+ val = atoi(optarg);
+ if ((val < -1) || (val > RAY_MIB_RTS_THRESH_MAXIMUM))
+ usage(p);
+ if (val == -1)
+ val = 0x7fff;
+ ray_setword(iface, RAY_MIB_RTS_THRESH, val);
+ exit(0);
+ break;
+
+ case 't':
+ val = atoi(optarg);
+ if ((val < RAY_MIB_BASIC_RATE_SET_MINIMUM) ||
+ (val > RAY_MIB_BASIC_RATE_SET_MAXIMUM))
+ usage(p);
+ ray_setword(iface, RAY_MIB_BASIC_RATE_SET, val);
+ exit(0);
+ break;
+
+ case 'C':
+ ray_dumpsiglev(iface);
+ exit(0);
+ break;
+
+ case 'W':
+ {
+ char *stringp, **ap, *av[5];
+ u_int8_t mib;
+
+ stringp = optarg;
+ ap = av;
+ *ap = strsep(&stringp, ":");
+ ap++;
+ *ap = strsep(&stringp, ":");
+ mib = atoi(av[0]);
+ sscanf(av[1], "%x", &val);
+ printf("mib %d, val 0x%02x\n", mib, val);
+ ray_setword(iface, mib, val);
+ }
+ exit(0);
+ break;
+
+ case 'h':
+ default:
+ usage(p);
+
+ }
+ }
+
+ if (iface == NULL)
+ usage(p);
+
+ ray_dumpinfo(iface);
+
+ exit(0);
+}
OpenPOWER on IntegriCloud