diff options
author | emax <emax@FreeBSD.org> | 2005-11-23 00:56:18 +0000 |
---|---|---|
committer | emax <emax@FreeBSD.org> | 2005-11-23 00:56:18 +0000 |
commit | 60d4f5be38e011c1b667df82b85d266fbc0930db (patch) | |
tree | f44940b106a98e64d68b8a0f036a050cca418608 /usr.bin | |
parent | 760a197f7dccc166ae51ad40d57d71ca14311251 (diff) | |
download | FreeBSD-src-60d4f5be38e011c1b667df82b85d266fbc0930db.zip FreeBSD-src-60d4f5be38e011c1b667df82b85d266fbc0930db.tar.gz |
Teach rfcomm_sppd(1) about service names, so it is possible to specify
service name instead of channel number with -c command option. Supported
service names are: DUN (Dial-Up Networking), FAX (Fax) and SP (Serial Port).
MFC after: 1 week
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 | 13 | ||||
-rw-r--r-- | usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c | 34 |
2 files changed, 39 insertions, 8 deletions
diff --git a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 index 21c921c..b2b4dea 100644 --- a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 +++ b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.1 @@ -81,11 +81,18 @@ utility will attempt to resolve the name via Detach from the controlling terminal, i.e., run in background. .It Fl c Ar channel This option specifies RFCOMM channel to connect to. -The channel must provide Serial Port service. +RFCOMM channel could either be a number between 1 and 30 or a service name. +Supported service names are: +.Cm DUN +(for DialUp Networking service), +.Cm FAX +(for Fax service) and +.Cm SP +(for Serial Port service). If channel was not specified then .Nm -utility will try to obtain RFCOMM channel via Service Discovery Protocol from -the server. +utility will try to obtain RFCOMM channel for Serial Port service via Service +Discovery Protocol from the server. .It Fl h Display usage message and exit. .It Fl t Ar tty diff --git a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c index 40ad502..d5f0bf5 100644 --- a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c +++ b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c @@ -31,6 +31,7 @@ #include <sys/stat.h> #include <bluetooth.h> +#include <ctype.h> #include <err.h> #include <errno.h> #include <fcntl.h> @@ -70,12 +71,14 @@ main(int argc, char *argv[]) struct sigaction sa; struct sockaddr_rfcomm ra; bdaddr_t addr; - int n, background, channel, s, amaster, aslave, fd; + int n, background, channel, service, + s, amaster, aslave, fd; fd_set rfd; - char *tty = NULL, buf[SPPD_BUFFER_SIZE]; + char *tty = NULL, *ep = NULL, buf[SPPD_BUFFER_SIZE]; memcpy(&addr, NG_HCI_BDADDR_ANY, sizeof(addr)); background = channel = 0; + service = SDP_SERVICE_CLASS_SERIAL_PORT; /* Parse command line options */ while ((n = getopt(argc, argv, "a:bc:t:h")) != -1) { @@ -92,7 +95,28 @@ main(int argc, char *argv[]) break; case 'c': /* RFCOMM channel */ - channel = atoi(optarg); + channel = strtoul(optarg, &ep, 10); + if (*ep != '\0') { + channel = 0; + switch (tolower(optarg[0])) { + case 'd': /* DialUp Networking */ + service = SDP_SERVICE_CLASS_DIALUP_NETWORKING; + break; + + case 'f': /* Fax */ + service = SDP_SERVICE_CLASS_FAX; + break; + + case 's': /* Serial Port */ + service = SDP_SERVICE_CLASS_SERIAL_PORT; + break; + + default: + errx(1, "Unknown service name: %s", + optarg); + /* NOT REACHED */ + } + } break; case 'b': /* Run in background */ @@ -138,9 +162,9 @@ main(int argc, char *argv[]) err(1, "Could not sigaction(SIGCHLD)"); /* Check channel, if was not set then obtain it via SDP */ - if (channel == 0) + if (channel == 0 && service != 0) if (rfcomm_channel_lookup(NULL, &addr, - SDP_SERVICE_CLASS_SERIAL_PORT, &channel, &n) != 0) + service, &channel, &n) != 0) errc(1, n, "Could not obtain RFCOMM channel"); if (channel <= 0 || channel > 30) errx(1, "Invalid RFCOMM channel number %d", channel); |