Add a port of the umb(4) driver from OpenBSD
The umb(4) driver provides support for USB MBIM (Mobile Broadband Interface Model) devices. MBIM devices establish connections via cellular networks such as GPRS, UMTS, and LTE. They appear as a regular point-to-point network interface, transporting raw IP frames. Required configuration parameters like PIN and APN have to be set with umbctl(8), a new tool specific to this driver. The IP address is configured automatically; the default route and DNS server information have to be set separately. The driver is not fully functional yet, it is therefore still marked as experimental and disabled by default. Any help welcome to complete it! Tested on NetBSD/amd64, with a Sierra Wireless EM7345 LTE modem on a Lenovo ThinkPad T440s. No functional change expected otherwise.
This commit is contained in:
parent
ad7c64535c
commit
d7f036be09
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.1181 2018/07/24 15:29:05 christos Exp $
|
||||
# $NetBSD: mi,v 1.1182 2018/07/31 16:44:28 khorben Exp $
|
||||
#
|
||||
# Note: Don't delete entries from here - mark them as "obsolete" instead,
|
||||
# unless otherwise stated below.
|
||||
@ -616,6 +616,7 @@
|
||||
./sbin/tbrconfig base-router-root
|
||||
./sbin/ttyflags base-sysutil-root
|
||||
./sbin/tunefs base-sysutil-root
|
||||
./sbin/umbctl base-netutil-root
|
||||
./sbin/umount base-sysutil-root
|
||||
./sbin/veriexecctl base-sysutil-root
|
||||
./sbin/verifiedexec_load base-obsolete obsolete
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: rescue.mi,v 1.41 2018/04/11 00:26:38 rin Exp $
|
||||
# $NetBSD: rescue.mi,v 1.42 2018/07/31 16:44:28 khorben Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
@ -152,6 +152,7 @@
|
||||
./rescue/tetris base-rescue-root
|
||||
./rescue/ttyflags base-rescue-root
|
||||
./rescue/tunefs base-rescue-root
|
||||
./rescue/umbctl base-rescue-root
|
||||
./rescue/umount base-rescue-root
|
||||
./rescue/veriexecctl base-rescue-root
|
||||
./rescue/vi base-rescue-root
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.2213 2018/07/31 13:04:10 rjs Exp $
|
||||
# $NetBSD: mi,v 1.2214 2018/07/31 16:44:28 khorben Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
./etc/mtree/set.comp comp-sys-root
|
||||
@ -736,6 +736,8 @@
|
||||
./usr/include/dev/tc/tcdsvar.h comp-obsolete obsolete
|
||||
./usr/include/dev/tc/tcreg.h comp-obsolete obsolete
|
||||
./usr/include/dev/tc/tcvar.h comp-obsolete obsolete
|
||||
./usr/include/dev/usb/if_umbreg.h comp-c-include
|
||||
./usr/include/dev/usb/mbim.h comp-c-include
|
||||
./usr/include/dev/usb/ukyopon.h comp-c-include
|
||||
./usr/include/dev/usb/urio.h comp-c-include
|
||||
./usr/include/dev/usb/usb.h comp-c-include
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.258 2018/07/24 15:29:05 christos Exp $
|
||||
# $NetBSD: mi,v 1.259 2018/07/31 16:44:29 khorben Exp $
|
||||
./etc/mtree/set.debug comp-sys-root
|
||||
./usr/lib comp-sys-usr compatdir
|
||||
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile
|
||||
@ -430,6 +430,7 @@
|
||||
./usr/libdata/debug/sbin/tbrconfig.debug comp-router-debug debug
|
||||
./usr/libdata/debug/sbin/ttyflags.debug comp-sysutil-debug debug
|
||||
./usr/libdata/debug/sbin/tunefs.debug comp-sysutil-debug debug
|
||||
./usr/libdata/debug/sbin/umbctl.debug comp-netutil-debug debug
|
||||
./usr/libdata/debug/sbin/umount.debug comp-sysutil-debug debug
|
||||
./usr/libdata/debug/sbin/veriexecctl.debug comp-sysutil-debug debug
|
||||
./usr/libdata/debug/sbin/wdogctl.debug comp-sysutil-debug debug
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.1602 2018/07/27 12:02:26 rkujawa Exp $
|
||||
# $NetBSD: mi,v 1.1603 2018/07/31 16:44:29 khorben Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
@ -1866,6 +1866,7 @@
|
||||
./usr/share/man/cat4/ukyopon.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/ulpt.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/umass.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/umb.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/umcs.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/umct.0 man-sys-catman .cat
|
||||
./usr/share/man/cat4/umidi.0 man-sys-catman .cat
|
||||
@ -3152,6 +3153,7 @@
|
||||
./usr/share/man/cat8/trsp.0 man-obsolete obsolete
|
||||
./usr/share/man/cat8/ttyflags.0 man-sysutil-catman .cat
|
||||
./usr/share/man/cat8/tunefs.0 man-sysutil-catman .cat
|
||||
./usr/share/man/cat8/umbctl.0 man-isdn-catman .cat
|
||||
./usr/share/man/cat8/umount.0 man-sysutil-catman .cat
|
||||
./usr/share/man/cat8/unbound-anchor.0 man-netutil-catman .cat,unbound
|
||||
./usr/share/man/cat8/unbound-checkconf.0 man-netutil-catman .cat,unbound
|
||||
@ -4937,6 +4939,7 @@
|
||||
./usr/share/man/html4/ukyopon.html man-sys-htmlman html
|
||||
./usr/share/man/html4/ulpt.html man-sys-htmlman html
|
||||
./usr/share/man/html4/umass.html man-sys-htmlman html
|
||||
./usr/share/man/html4/umb.html man-sys-htmlman html
|
||||
./usr/share/man/html4/umcs.html man-sys-htmlman html
|
||||
./usr/share/man/html4/umct.html man-sys-htmlman html
|
||||
./usr/share/man/html4/umidi.html man-sys-htmlman html
|
||||
@ -6010,6 +6013,7 @@
|
||||
./usr/share/man/html8/trpt.html man-netutil-htmlman html
|
||||
./usr/share/man/html8/ttyflags.html man-sysutil-htmlman html
|
||||
./usr/share/man/html8/tunefs.html man-sysutil-htmlman html
|
||||
./usr/share/man/html8/umbctl.html man-isdn-htmlman html
|
||||
./usr/share/man/html8/umount.html man-sysutil-htmlman html
|
||||
./usr/share/man/html8/unbound-anchor.html man-netutil-htmlman html,unbound
|
||||
./usr/share/man/html8/unbound-checkconf.html man-netutil-htmlman html,unbound
|
||||
@ -7932,6 +7936,7 @@
|
||||
./usr/share/man/man4/ukyopon.4 man-sys-man .man
|
||||
./usr/share/man/man4/ulpt.4 man-sys-man .man
|
||||
./usr/share/man/man4/umass.4 man-sys-man .man
|
||||
./usr/share/man/man4/umb.4 man-sys-man .man
|
||||
./usr/share/man/man4/umcs.4 man-sys-man .man
|
||||
./usr/share/man/man4/umct.4 man-sys-man .man
|
||||
./usr/share/man/man4/umidi.4 man-sys-man .man
|
||||
@ -9215,6 +9220,7 @@
|
||||
./usr/share/man/man8/trsp.8 man-obsolete obsolete
|
||||
./usr/share/man/man8/ttyflags.8 man-sysutil-man .man
|
||||
./usr/share/man/man8/tunefs.8 man-sysutil-man .man
|
||||
./usr/share/man/man8/umbctl.8 man-isdn-man .man
|
||||
./usr/share/man/man8/umount.8 man-sysutil-man .man
|
||||
./usr/share/man/man8/unbound-anchor.8 man-netutil-man .man,unbound
|
||||
./usr/share/man/man8/unbound-checkconf.8 man-netutil-man .man,unbound
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: list,v 1.49 2018/04/11 00:26:38 rin Exp $
|
||||
# $NetBSD: list,v 1.50 2018/07/31 16:44:29 khorben Exp $
|
||||
|
||||
SRCDIRS bin
|
||||
|
||||
@ -114,6 +114,7 @@ PROG swapctl swapon
|
||||
PROG sysctl
|
||||
PROG ttyflags
|
||||
PROG tunefs
|
||||
PROG umbctl
|
||||
PROG umount
|
||||
PROG wdogctl
|
||||
PROG veriexecctl
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.132 2018/01/14 22:44:04 christos Exp $
|
||||
# $NetBSD: Makefile,v 1.133 2018/07/31 16:44:29 khorben Exp $
|
||||
# @(#)Makefile 8.5 (Berkeley) 3/31/94
|
||||
|
||||
# Not ported: XNSrouted enpload scsiformat startslip
|
||||
@ -14,7 +14,7 @@ SUBDIR= amrctl apmlabel atactl badsect bioctl brconfig \
|
||||
newbtconf nologin nvmectl \
|
||||
ping pppoectl raidctl reboot rcorder rndctl route routed \
|
||||
savecore scan_ffs scsictl shutdown slattach svhlabel swapctl sysctl \
|
||||
ttyflags umount veriexecctl wdogctl wsconsctl
|
||||
ttyflags umbctl umount veriexecctl wdogctl wsconsctl
|
||||
|
||||
# support for various file systems
|
||||
SUBDIR+= newfs_ext2fs fsck_ext2fs
|
||||
|
6
sbin/umbctl/Makefile
Normal file
6
sbin/umbctl/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.1 2018/07/31 16:44:29 khorben Exp $
|
||||
|
||||
PROG= umbctl
|
||||
MAN= umbctl.8
|
||||
|
||||
.include <bsd.prog.mk>
|
165
sbin/umbctl/umbctl.8
Normal file
165
sbin/umbctl/umbctl.8
Normal file
@ -0,0 +1,165 @@
|
||||
.\" $NetBSD: umbctl.8,v 1.1 2018/07/31 16:44:29 khorben Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2018 by Pierre Pronchery <khorben@defora.org>
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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 THE AUTHOR(S) 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.
|
||||
.\"
|
||||
.\" From: pppoectl.8,v 1.30 2016/09/12 05:35:20 sevan Exp $
|
||||
.\"
|
||||
.\" $Id: umbctl.8,v 1.1 2018/07/31 16:44:29 khorben Exp $
|
||||
.\"
|
||||
.\" last edit-date: [Thu Aug 31 10:47:33 2000]
|
||||
.\"
|
||||
.Dd July 24, 2018
|
||||
.Dt UMBCTL 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm umbctl
|
||||
.Nd "display or set parameters for a MBIM interface (4G/LTE)"
|
||||
.Sh SYNOPSIS
|
||||
.Nm umbctl
|
||||
.Op Fl v
|
||||
.Ar ifname
|
||||
.Op Ar parameter Ns Op \&= Ns Ar value
|
||||
.Op Ar ...
|
||||
.Pp
|
||||
.Nm umbctl
|
||||
.Op Fl v
|
||||
.Op Fl f Ar config-file
|
||||
.Ar ifname
|
||||
.Op Ar parameter Ns Op \&= Ns Ar value
|
||||
.Op Ar ...
|
||||
.Pp
|
||||
.Sh DESCRIPTION
|
||||
.Bl -tag -width indent
|
||||
.It Fl v
|
||||
enables verbose mode.
|
||||
.It Fl f
|
||||
parse
|
||||
.Ar config-file
|
||||
for
|
||||
.Ar parameter Ns Op \&= Ns Ar value
|
||||
pairs, one per line, as if they had been specified on the command line.
|
||||
This allows the password or PIN codes to be not passed as command line
|
||||
arguments.
|
||||
Comments starting with # to the end of the current line are ignored.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Xr umb 4
|
||||
driver may require a number of additional arguments or optional
|
||||
parameters besides the settings that can be adjusted with
|
||||
.Xr ifconfig 8 .
|
||||
These may be credentials or other tunable connectivity variables.
|
||||
The
|
||||
.Nm
|
||||
utility can be used to display the current settings, or adjust these
|
||||
parameters as required.
|
||||
.Pp
|
||||
For whatever intent
|
||||
.Nm
|
||||
is being called, at least the parameter
|
||||
.Ar ifname
|
||||
needs to be specified, naming the interface for which the settings
|
||||
are to be performed or displayed.
|
||||
Use
|
||||
.Xr ifconfig 8
|
||||
or
|
||||
.Xr netstat 1
|
||||
to see which interfaces are available.
|
||||
.Pp
|
||||
If no other parameter is given,
|
||||
.Nm
|
||||
will just list the current status for
|
||||
.Ar ifname
|
||||
and exit.
|
||||
.Pp
|
||||
If any additional parameter is supplied, superuser privileges are
|
||||
required, and the command works in
|
||||
.Ql set
|
||||
mode.
|
||||
This is normally done quietly, unless the option
|
||||
.Fl v
|
||||
is also enabled, which will cause a final printout of the status as
|
||||
described above once all other actions have been taken.
|
||||
.Pp
|
||||
The parameters currently supported include:
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
.It Ar apn Ns \&= Ns Em access-point
|
||||
Set the APN to
|
||||
.Em access-point .
|
||||
.It Ar username Ns \&= Ns Em username
|
||||
Set the username to
|
||||
.Em username .
|
||||
.It Ar password Ns \&= Ns Em password
|
||||
Set the password to
|
||||
.Em password .
|
||||
.It Ar pin Ns \&= Ns Em pin-code
|
||||
Enter the PIN
|
||||
.Em pin-code .
|
||||
.It Ar puk Ns \&= Ns Em puk-code
|
||||
Enter the PUK
|
||||
.Em puk-code .
|
||||
.It Ar roaming
|
||||
Allow data connections when roaming.
|
||||
.It Ar -roaming
|
||||
Deny data connections when roaming.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
.Bd -literal
|
||||
# umbctl umb0
|
||||
umb0: state up, mode automatic, registration home network
|
||||
provider "BSD-Net", dataclass LTE, signal good
|
||||
phone number "+15554242", roaming "" (denied)
|
||||
APN "", TX 50000000, RX 100000000
|
||||
firmware "MBIM_FW_V1.0", hardware "MBIM_HW_V1.0"
|
||||
.Ed
|
||||
.Pp
|
||||
Display the settings for umb0.
|
||||
.Ed
|
||||
.Bd -literal
|
||||
# umbctl umb0 apn operator.internet username mobile password mobile
|
||||
.Ed
|
||||
.Pp
|
||||
Configure the connection parameters for umb0 from the command line.
|
||||
.Ed
|
||||
.Bd -literal
|
||||
# umbctl -f /dev/stdin umb0 << EOF
|
||||
pin=1234
|
||||
EOF
|
||||
.Ed
|
||||
.Pp
|
||||
Configure the connection parameters for umb0 from a file.
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr netstat 1 ,
|
||||
.Xr ifconfig 8 ,
|
||||
.Xr ifwatchd 8 ,
|
||||
.Xr umb 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility first appeared in
|
||||
.Nx 9.0 .
|
||||
.Sh AUTHORS
|
||||
The program was written by Pierre Pronchery.
|
482
sbin/umbctl/umbctl.c
Normal file
482
sbin/umbctl/umbctl.c
Normal file
@ -0,0 +1,482 @@
|
||||
/* $NetBSD: umbctl.c,v 1.1 2018/07/31 16:44:29 khorben Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2018 Pierre Pronchery <khorben@defora.org>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``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 THE DEVELOPERS 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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <sys/endian.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <dev/usb/mbim.h>
|
||||
#include <dev/usb/if_umbreg.h>
|
||||
|
||||
|
||||
/* constants */
|
||||
static const struct umb_valdescr _umb_regstate[] =
|
||||
MBIM_REGSTATE_DESCRIPTIONS;
|
||||
|
||||
static const struct umb_valdescr _umb_dataclass[] =
|
||||
MBIM_DATACLASS_DESCRIPTIONS;
|
||||
|
||||
static const struct umb_valdescr _umb_state[] =
|
||||
UMB_INTERNAL_STATE_DESCRIPTIONS;
|
||||
|
||||
static const struct umb_valdescr _umb_regmode[] =
|
||||
{
|
||||
{ MBIM_REGMODE_UNKNOWN, "unknown" },
|
||||
{ MBIM_REGMODE_AUTOMATIC, "automatic" },
|
||||
{ MBIM_REGMODE_MANUAL, "manual" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const struct umb_valdescr _umb_ber[] =
|
||||
{
|
||||
{ UMB_BER_EXCELLENT, "excellent" },
|
||||
{ UMB_BER_VERYGOOD, "very good" },
|
||||
{ UMB_BER_GOOD, "good" },
|
||||
{ UMB_BER_OK, "ok" },
|
||||
{ UMB_BER_MEDIUM, "medium" },
|
||||
{ UMB_BER_BAD, "bad" },
|
||||
{ UMB_BER_VERYBAD, "very bad" },
|
||||
{ UMB_BER_EXTREMELYBAD, "extremely bad" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static int _char_to_utf16(const char * in, uint16_t * out, size_t outlen);
|
||||
static int _error(int ret, char const * format, ...);
|
||||
static int _umbctl(char const * ifname, int verbose, int argc, char * argv[]);
|
||||
static int _umbctl_file(char const * ifname, char const * filename, int verbose,
|
||||
int argc, char * argv[]);
|
||||
static void _umbctl_info(char const * ifname, struct umb_info * umbi);
|
||||
static int _umbctl_ioctl(char const * ifname, int fd, unsigned long request,
|
||||
struct ifreq * ifr);
|
||||
static int _umbctl_set(char const * ifname, struct umb_parameter * umbp,
|
||||
int argc, char * argv[]);
|
||||
static int _umbctl_socket(void);
|
||||
static int _usage(void);
|
||||
static void _utf16_to_char(uint16_t *in, int inlen, char *out, size_t outlen);
|
||||
|
||||
|
||||
/* functions */
|
||||
/* char_to_utf16 */
|
||||
/* this function is from OpenBSD's ifconfig(8) */
|
||||
static int _char_to_utf16(const char * in, uint16_t * out, size_t outlen)
|
||||
{
|
||||
int n = 0;
|
||||
uint16_t c;
|
||||
|
||||
for (;;) {
|
||||
c = *in++;
|
||||
|
||||
if (c == '\0') {
|
||||
/*
|
||||
* NUL termination is not required, but zero out the
|
||||
* residual buffer
|
||||
*/
|
||||
memset(out, 0, outlen);
|
||||
return n;
|
||||
}
|
||||
if (outlen < sizeof(*out))
|
||||
return -1;
|
||||
|
||||
*out++ = htole16(c);
|
||||
n += sizeof(*out);
|
||||
outlen -= sizeof(*out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* error */
|
||||
static int _error(int ret, char const * format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
fputs("umbctl: ", stderr);
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
va_end(ap);
|
||||
fputs("\n", stderr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* umbctl */
|
||||
static int _umbctl(char const * ifname, int verbose, int argc, char * argv[])
|
||||
{
|
||||
int fd;
|
||||
struct ifreq ifr;
|
||||
struct umb_info umbi;
|
||||
struct umb_parameter umbp;
|
||||
|
||||
if((fd = _umbctl_socket()) < 0)
|
||||
return 2;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
if(argc != 0)
|
||||
{
|
||||
memset(&umbp, 0, sizeof(umbp));
|
||||
ifr.ifr_data = &umbp;
|
||||
if(_umbctl_ioctl(ifname, fd, SIOCGUMBPARAM, &ifr) != 0
|
||||
|| _umbctl_set(ifname, &umbp, argc, argv) != 0
|
||||
|| _umbctl_ioctl(ifname, fd, SIOCSUMBPARAM,
|
||||
&ifr) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
if(argc == 0 || verbose > 0)
|
||||
{
|
||||
ifr.ifr_data = &umbi;
|
||||
if(_umbctl_ioctl(ifname, fd, SIOCGUMBINFO, &ifr) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return 3;
|
||||
}
|
||||
_umbctl_info(ifname, &umbi);
|
||||
}
|
||||
if(close(fd) != 0)
|
||||
return _error(2, "%s: %s", ifname, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* umbctl_file */
|
||||
static int _umbctl_file(char const * ifname, char const * filename, int verbose,
|
||||
int argc, char * argv[])
|
||||
{
|
||||
int fd;
|
||||
struct ifreq ifr;
|
||||
struct umb_info umbi;
|
||||
struct umb_parameter umbp;
|
||||
FILE * fp;
|
||||
char buf[512];
|
||||
int eof;
|
||||
char * tokens[3] = { buf, NULL, NULL };
|
||||
char * p;
|
||||
|
||||
if((fp = fopen(filename, "r")) == NULL)
|
||||
return _error(2, "%s: %s", filename, strerror(errno));
|
||||
memset(&umbp, 0, sizeof(umbp));
|
||||
while(fgets(buf, sizeof(buf), fp) != NULL)
|
||||
{
|
||||
if(buf[0] == '#')
|
||||
continue;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
if((p = strstr(buf, "=")) != NULL)
|
||||
{
|
||||
tokens[1] = p + 1;
|
||||
*p = '\0';
|
||||
} else
|
||||
tokens[1] = NULL;
|
||||
if(_umbctl_set(ifname, &umbp, (p != NULL) ? 2 : 1, tokens) != 0)
|
||||
break;
|
||||
}
|
||||
eof = feof(fp);
|
||||
if(fclose(fp) != 0 || !eof)
|
||||
return _error(2, "%s: %s", filename, strerror(errno));
|
||||
if((fd = _umbctl_socket()) < 0)
|
||||
return 2;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_data = &umbp;
|
||||
if(_umbctl_ioctl(ifname, fd, SIOCGUMBPARAM, &ifr) != 0
|
||||
|| _umbctl_set(ifname, &umbp, argc, argv) != 0
|
||||
|| _umbctl_ioctl(ifname, fd, SIOCSUMBPARAM, &ifr) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return 2;
|
||||
}
|
||||
if(verbose > 0)
|
||||
{
|
||||
ifr.ifr_data = &umbi;
|
||||
if(_umbctl_ioctl(ifname, fd, SIOCGUMBINFO, &ifr) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return 3;
|
||||
}
|
||||
_umbctl_info(ifname, &umbi);
|
||||
}
|
||||
if(close(fd) != 0)
|
||||
return _error(2, "%s: %s", ifname, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* umbctl_info */
|
||||
static void _umbctl_info(char const * ifname, struct umb_info * umbi)
|
||||
{
|
||||
char provider[UMB_PROVIDERNAME_MAXLEN + 1];
|
||||
char pn[UMB_PHONENR_MAXLEN + 1];
|
||||
char roaming[UMB_ROAMINGTEXT_MAXLEN + 1];
|
||||
char apn[UMB_APN_MAXLEN + 1];
|
||||
char fwinfo[UMB_FWINFO_MAXLEN + 1];
|
||||
char hwinfo[UMB_HWINFO_MAXLEN + 1];
|
||||
|
||||
_utf16_to_char(umbi->provider, UMB_PROVIDERNAME_MAXLEN,
|
||||
provider, sizeof(provider));
|
||||
_utf16_to_char(umbi->pn, UMB_PHONENR_MAXLEN, pn, sizeof(pn));
|
||||
_utf16_to_char(umbi->roamingtxt, UMB_ROAMINGTEXT_MAXLEN,
|
||||
roaming, sizeof(roaming));
|
||||
_utf16_to_char(umbi->apn, UMB_APN_MAXLEN, apn, sizeof(apn));
|
||||
_utf16_to_char(umbi->fwinfo, UMB_FWINFO_MAXLEN, fwinfo, sizeof(fwinfo));
|
||||
_utf16_to_char(umbi->hwinfo, UMB_HWINFO_MAXLEN, hwinfo, sizeof(hwinfo));
|
||||
printf("%s: state %s, mode %s, registration %s\n"
|
||||
"\tprovider \"%s\", dataclass %s, signal %s\n"
|
||||
"\tphone number \"%s\", roaming \"%s\" (%s)\n"
|
||||
"\tAPN \"%s\", TX %" PRIu64 ", RX %" PRIu64 "\n"
|
||||
"\tfirmware \"%s\", hardware \"%s\"\n",
|
||||
ifname, umb_val2descr(_umb_state, umbi->state),
|
||||
umb_val2descr(_umb_regmode, umbi->regmode),
|
||||
umb_val2descr(_umb_regstate, umbi->regstate), provider,
|
||||
umb_val2descr(_umb_dataclass, umbi->cellclass),
|
||||
umb_val2descr(_umb_ber, umbi->ber), pn, roaming,
|
||||
umbi->enable_roaming ? "allowed" : "denied",
|
||||
apn, umbi->uplink_speed, umbi->downlink_speed,
|
||||
fwinfo, hwinfo);
|
||||
}
|
||||
|
||||
|
||||
/* umbctl_ioctl */
|
||||
static int _umbctl_ioctl(char const * ifname, int fd, unsigned long request,
|
||||
struct ifreq * ifr)
|
||||
{
|
||||
if(ioctl(fd, request, ifr) != 0)
|
||||
return _error(-1, "%s: %s", ifname, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* umbctl_set */
|
||||
/* callbacks */
|
||||
static int _set_apn(char const *, struct umb_parameter *, char const *);
|
||||
static int _set_username(char const *, struct umb_parameter *, char const *);
|
||||
static int _set_password(char const *, struct umb_parameter *, char const *);
|
||||
static int _set_pin(char const *, struct umb_parameter *, char const *);
|
||||
static int _set_puk(char const *, struct umb_parameter *, char const *);
|
||||
static int _set_roaming_allow(char const *, struct umb_parameter *,
|
||||
char const *);
|
||||
static int _set_roaming_deny(char const *, struct umb_parameter *,
|
||||
char const *);
|
||||
|
||||
static int _umbctl_set(char const * ifname, struct umb_parameter * umbp,
|
||||
int argc, char * argv[])
|
||||
{
|
||||
struct
|
||||
{
|
||||
char const * name;
|
||||
int (*callback)(char const *,
|
||||
struct umb_parameter *, char const *);
|
||||
int parameter;
|
||||
} callbacks[] =
|
||||
{
|
||||
{ "apn", _set_apn, 1 },
|
||||
{ "username", _set_username, 1 },
|
||||
{ "password", _set_password, 1 },
|
||||
{ "pin", _set_pin, 1 },
|
||||
{ "puk", _set_puk, 1 },
|
||||
{ "roaming", _set_roaming_allow, 0 },
|
||||
{ "-roaming", _set_roaming_deny, 0 },
|
||||
};
|
||||
int i;
|
||||
size_t j;
|
||||
|
||||
for(i = 0; i < argc; i++)
|
||||
{
|
||||
for(j = 0; j < sizeof(callbacks) / sizeof(*callbacks); j++)
|
||||
if(strcmp(argv[i], callbacks[j].name) == 0)
|
||||
{
|
||||
if(callbacks[j].parameter && i + 1 == argc)
|
||||
return _error(-1, "%s: Incomplete"
|
||||
" parameter", argv[i]);
|
||||
if(callbacks[j].callback(ifname, umbp,
|
||||
callbacks[j].parameter
|
||||
? argv[i + 1] : NULL))
|
||||
return -1;
|
||||
if(callbacks[j].parameter)
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
if(j == sizeof(callbacks) / sizeof(*callbacks))
|
||||
return _error(-1, "%s: Unknown parameter", argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set_apn(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * apn)
|
||||
{
|
||||
umbp->apnlen = _char_to_utf16(apn, umbp->apn, sizeof(umbp->apn));
|
||||
if(umbp->apnlen < 0 || (size_t)umbp->apnlen > sizeof(umbp->apn))
|
||||
return _error(-1, "%s: %s", ifname, "APN too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set_username(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * username)
|
||||
{
|
||||
umbp->usernamelen = _char_to_utf16(username, umbp->username,
|
||||
sizeof(umbp->username));
|
||||
if(umbp->usernamelen < 0
|
||||
|| (size_t)umbp->usernamelen > sizeof(umbp->username))
|
||||
return _error(-1, "%s: %s", ifname, "Username too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set_password(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * password)
|
||||
{
|
||||
umbp->passwordlen = _char_to_utf16(password, umbp->password,
|
||||
sizeof(umbp->password));
|
||||
if(umbp->passwordlen < 0
|
||||
|| (size_t)umbp->passwordlen > sizeof(umbp->password))
|
||||
return _error(-1, "%s: %s", ifname, "Password too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set_pin(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * pin)
|
||||
{
|
||||
umbp->is_puk = 0;
|
||||
umbp->op = MBIM_PIN_OP_ENTER;
|
||||
umbp->pinlen = _char_to_utf16(pin, umbp->pin, sizeof(umbp->pin));
|
||||
if(umbp->pinlen < 0 || (size_t)umbp->pinlen
|
||||
> sizeof(umbp->pin))
|
||||
return _error(-1, "%s: %s", ifname, "PIN code too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set_puk(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * puk)
|
||||
{
|
||||
umbp->is_puk = 1;
|
||||
umbp->op = MBIM_PIN_OP_ENTER;
|
||||
umbp->pinlen = _char_to_utf16(puk, umbp->pin, sizeof(umbp->pin));
|
||||
if(umbp->pinlen < 0 || (size_t)umbp->pinlen > sizeof(umbp->pin))
|
||||
return _error(-1, "%s: %s", ifname, "PUK code too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set_roaming_allow(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * unused)
|
||||
{
|
||||
(void) ifname;
|
||||
(void) unused;
|
||||
|
||||
umbp->roaming = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _set_roaming_deny(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * unused)
|
||||
{
|
||||
(void) ifname;
|
||||
(void) unused;
|
||||
|
||||
umbp->roaming = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* umbctl_socket */
|
||||
static int _umbctl_socket(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
return _error(-1, "socket: %s", strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: umbctl [-v] ifname [parameter[=value]] [...]\n"
|
||||
" umbctl -f config-file ifname [...]\n",
|
||||
stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* utf16_to_char */
|
||||
static void _utf16_to_char(uint16_t *in, int inlen, char *out, size_t outlen)
|
||||
{
|
||||
uint16_t c;
|
||||
|
||||
while (outlen > 0) {
|
||||
c = inlen > 0 ? htole16(*in) : 0;
|
||||
if (c == 0 || --outlen == 0) {
|
||||
/* always NUL terminate result */
|
||||
*out = '\0';
|
||||
break;
|
||||
}
|
||||
*out++ = isascii(c) ? (char)c : '?';
|
||||
in++;
|
||||
inlen--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* main */
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
int o;
|
||||
char const * filename = NULL;
|
||||
int verbose = 0;
|
||||
|
||||
while((o = getopt(argc, argv, "f:v")) != -1)
|
||||
switch(o)
|
||||
{
|
||||
case 'f':
|
||||
filename = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
default:
|
||||
return _usage();
|
||||
}
|
||||
if(optind == argc)
|
||||
return _usage();
|
||||
if(filename != NULL)
|
||||
return _umbctl_file(argv[optind], filename, verbose,
|
||||
argc - optind - 1, &argv[optind + 1]);
|
||||
return _umbctl(argv[optind], verbose, argc - optind - 1,
|
||||
&argv[optind + 1]);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.660 2018/07/27 16:12:40 gson Exp $
|
||||
# $NetBSD: Makefile,v 1.661 2018/07/31 16:44:29 khorben Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/18/93
|
||||
|
||||
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
|
||||
@ -64,7 +64,7 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
|
||||
tap.4 tc.4 tcds.4 tcp.4 tcu.4 tdvfb.4 tea5767radio.4 termios.4 tfb.4 \
|
||||
thinkpad.4 ti.4 tl.4 tlp.4 tlphy.4 tpm.4 tprof.4 tr.4 tra.4 \
|
||||
trm.4 tsllux.4 tty.4 tun.4 tqphy.4 twa.4 twe.4 txp.4 \
|
||||
uark.4 ubsec.4 udp.4 uep.4 ug.4 uha.4 uk.4 ukphy.4 unix.4 userconf.4 \
|
||||
uark.4 ubsec.4 udp.4 uep.4 ug.4 uha.4 uk.4 ukphy.4 umb.4 unix.4 userconf.4 \
|
||||
vald.4 valz.4 veriexec.4 vga.4 vge.4 viaide.4 video.4 vioif.4 viomb.4 \
|
||||
viornd.4 vioscsi.4 virt.4 \
|
||||
virtio.4 vlan.4 vmmon.4 vmnet.4 vnd.4 voodoofb.4 vr.4 vte.4 \
|
||||
|
91
share/man/man4/umb.4
Normal file
91
share/man/man4/umb.4
Normal file
@ -0,0 +1,91 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2016 genua mbH
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.\" $NetBSD: umb.4,v 1.1 2018/07/31 16:44:29 khorben Exp $
|
||||
.\"
|
||||
.Dd $Mdocdate: November 23 2017 $
|
||||
.Dt UMB 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm umb
|
||||
.Nd USB Mobile Broadband Interface Model (MBIM)
|
||||
.Sh SYNOPSIS
|
||||
.Cd "umb* at uhub? port?"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver provides support for USB MBIM devices.
|
||||
.Pp
|
||||
MBIM devices establish connections via cellular networks such as
|
||||
GPRS, UMTS, and LTE.
|
||||
They appear as a regular point-to-point network interface,
|
||||
transporting raw IP frames.
|
||||
.Pp
|
||||
Required configuration parameters like PIN and APN have to be set
|
||||
with
|
||||
.Xr umbctl 8 .
|
||||
Once the SIM card has been unlocked with the correct PIN, it
|
||||
will remain in this state until the MBIM device is power-cycled.
|
||||
In case the device is connected to an "always-on" USB port,
|
||||
it may be possible to connect to a provider without entering the
|
||||
PIN again even if the system was rebooted.
|
||||
.Sh HARDWARE
|
||||
The following devices should work:
|
||||
.Pp
|
||||
.Bl -tag -width Ds -offset indent -compact
|
||||
.It Ericsson H5321gw and N5321gw
|
||||
.It Fibocom L831-EAU
|
||||
.It Medion Mobile S4222 (MediaTek OEM)
|
||||
.It Sierra Wireless EM7345
|
||||
.It Sierra Wireless EM7455
|
||||
.It Sierra Wireless EM8805
|
||||
.It Sierra Wireless MC8305
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr intro 4 ,
|
||||
.Xr netintro 4 ,
|
||||
.Xr usb 4 ,
|
||||
.\" .Xr hostname.if 5 ,
|
||||
.Xr ifconfig 8 ,
|
||||
.Xr umbctl 8
|
||||
.Rs
|
||||
.%T "Universal Serial Bus Communications Class Subclass Specification for Mobile Broadband Interface Model"
|
||||
.%U http://www.usb.org/developers/docs/devclass_docs/MBIM10Errata1_073013.zip
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Ox 6.0
|
||||
and
|
||||
.Nx 9.0 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Gerhard Roth Aq Mt gerhard@openbsd.org
|
||||
and ported from
|
||||
.Ox
|
||||
by
|
||||
.An Pierre Pronchery Aq Mt khorben@defora.org .
|
||||
.Sh CAVEATS
|
||||
The
|
||||
.Nm
|
||||
driver does not support IPv6.
|
||||
.Pp
|
||||
Devices which fail to provide a conforming MBIM implementation will
|
||||
probably be attached as some other driver, such as
|
||||
.Xr u3g 4 .
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: GENERIC,v 1.496 2018/07/13 09:37:32 maxv Exp $
|
||||
# $NetBSD: GENERIC,v 1.497 2018/07/31 16:44:29 khorben Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
@ -22,7 +22,7 @@ include "arch/amd64/conf/std.amd64"
|
||||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.496 $"
|
||||
#ident "GENERIC-$Revision: 1.497 $"
|
||||
|
||||
maxusers 64 # estimated number of users
|
||||
|
||||
@ -997,6 +997,7 @@ cue* at uhub? port ? # CATC USB-EL1201A based adapters
|
||||
kue* at uhub? port ? # Kawasaki LSI KL5KUSB101B based adapters
|
||||
#mos* at uhub? port ? # Moschip MCS7730/MCS7830/MCS7832 based adapters
|
||||
udav* at uhub? port ? # Davicom DM9601 based adapters
|
||||
#umb* at uhub? port ? # Mobile Broadband Interface Model (EXPERIMENTAL)
|
||||
url* at uhub? port ? # Realtek RTL8150L based adapters
|
||||
urndis* at uhub? port ? # Microsoft RNDIS specification
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: GENERIC,v 1.1183 2018/07/13 09:37:32 maxv Exp $
|
||||
# $NetBSD: GENERIC,v 1.1184 2018/07/31 16:44:29 khorben Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386"
|
||||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.1183 $"
|
||||
#ident "GENERIC-$Revision: 1.1184 $"
|
||||
|
||||
maxusers 64 # estimated number of users
|
||||
|
||||
@ -1268,6 +1268,7 @@ cdce* at uhub? port ? # CDC, Ethernet Networking Control Model
|
||||
cue* at uhub? port ? # CATC USB-EL1201A based adapters
|
||||
kue* at uhub? port ? # Kawasaki LSI KL5KUSB101B based adapters
|
||||
udav* at uhub? port ? # Davicom DM9601 based adapters
|
||||
#umb* at uhub? port ? # Mobile Broadband Interface Model (EXPERIMENTAL)
|
||||
url* at uhub? port ? # Realtek RTL8150L based adapters
|
||||
urndis* at uhub? port ? # Microsoft RNDIS specification
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.9 2006/05/14 21:47:00 elad Exp $
|
||||
# $NetBSD: Makefile,v 1.10 2018/07/31 16:44:29 khorben Exp $
|
||||
|
||||
# use 'make -f Makefile.usbdevs' to make usbdevs.h and usbdevs_data.h
|
||||
# _after_ you committed usbdevs. See comment in Makefile.usbdevs
|
||||
@ -6,6 +6,6 @@
|
||||
INCSDIR= /usr/include/dev/usb
|
||||
|
||||
# Only install includes which are used by userland
|
||||
INCS= ukyopon.h urio.h usb.h usbhid.h utoppy.h
|
||||
INCS= if_umbreg.h mbim.h ukyopon.h urio.h usb.h usbhid.h utoppy.h
|
||||
|
||||
.include <bsd.kinc.mk>
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.usb,v 1.150 2018/03/05 09:35:01 ws Exp $
|
||||
# $NetBSD: files.usb,v 1.151 2018/07/31 16:44:29 khorben Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent USB code.
|
||||
# Included by ports that need it. Ports that use it must provide
|
||||
@ -379,6 +379,11 @@ device otus: arp, ether, firmload, ifnet, wlan
|
||||
attach otus at usbdevif
|
||||
file dev/usb/if_otus.c otus
|
||||
|
||||
# Mobile Broadband Interface Model
|
||||
device umb: ifnet
|
||||
attach umb at usbifif
|
||||
file dev/usb/if_umb.c umb
|
||||
|
||||
# Serial drivers
|
||||
# Modems
|
||||
define umodem_common
|
||||
|
2889
sys/dev/usb/if_umb.c
Normal file
2889
sys/dev/usb/if_umb.c
Normal file
File diff suppressed because it is too large
Load Diff
407
sys/dev/usb/if_umbreg.h
Normal file
407
sys/dev/usb/if_umbreg.h
Normal file
@ -0,0 +1,407 @@
|
||||
/* $NetBSD: if_umbreg.h,v 1.1 2018/07/31 16:44:29 khorben Exp $ */
|
||||
/* $OpenBSD: if_umb.h,v 1.4 2017/04/18 13:27:55 gerhard Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 genua mbH
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mobile Broadband Interface Model
|
||||
* http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
|
||||
*/
|
||||
#ifndef _IF_UMBREG_H_
|
||||
#define _IF_UMBREG_H_
|
||||
|
||||
struct umb_valdescr {
|
||||
int val;
|
||||
char const *descr;
|
||||
};
|
||||
|
||||
static const char *
|
||||
umb_val2descr(const struct umb_valdescr *vdp, int val)
|
||||
{
|
||||
static char sval[32];
|
||||
|
||||
while (vdp->descr != NULL) {
|
||||
if (vdp->val == val)
|
||||
return vdp->descr;
|
||||
vdp++;
|
||||
}
|
||||
snprintf(sval, sizeof (sval), "#%d", val);
|
||||
return sval;
|
||||
}
|
||||
|
||||
#define MBIM_REGSTATE_DESCRIPTIONS { \
|
||||
{ MBIM_REGSTATE_UNKNOWN, "unknown" }, \
|
||||
{ MBIM_REGSTATE_DEREGISTERED, "not registered" }, \
|
||||
{ MBIM_REGSTATE_SEARCHING, "searching" }, \
|
||||
{ MBIM_REGSTATE_HOME, "home network" }, \
|
||||
{ MBIM_REGSTATE_ROAMING, "roaming network" }, \
|
||||
{ MBIM_REGSTATE_PARTNER, "partner network" }, \
|
||||
{ MBIM_REGSTATE_DENIED, "access denied" }, \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_DATACLASS_DESCRIPTIONS { \
|
||||
{ MBIM_DATACLASS_NONE, "none" }, \
|
||||
{ MBIM_DATACLASS_GPRS, "GPRS" }, \
|
||||
{ MBIM_DATACLASS_EDGE, "EDGE" }, \
|
||||
{ MBIM_DATACLASS_UMTS, "UMTS" }, \
|
||||
{ MBIM_DATACLASS_HSDPA, "HSDPA" }, \
|
||||
{ MBIM_DATACLASS_HSUPA, "HSUPA" }, \
|
||||
{ MBIM_DATACLASS_HSDPA|MBIM_DATACLASS_HSUPA, "HSPA" }, \
|
||||
{ MBIM_DATACLASS_LTE, "LTE" }, \
|
||||
{ MBIM_DATACLASS_1XRTT, "CDMA2000" }, \
|
||||
{ MBIM_DATACLASS_1XEVDO, "CDMA2000" }, \
|
||||
{ MBIM_DATACLASS_1XEVDO_REV_A, "CDMA2000" }, \
|
||||
{ MBIM_DATACLASS_1XEVDV, "CDMA2000" }, \
|
||||
{ MBIM_DATACLASS_3XRTT, "CDMA2000" }, \
|
||||
{ MBIM_DATACLASS_1XEVDO_REV_B, "CDMA2000" }, \
|
||||
{ MBIM_DATACLASS_UMB, "CDMA2000" }, \
|
||||
{ MBIM_DATACLASS_CUSTOM, "custom" }, \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_1TO1_DESCRIPTION(m) { (m), #m }
|
||||
#define MBIM_MESSAGES_DESCRIPTIONS { \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_OPEN_MSG), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CLOSE_MSG), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_COMMAND_MSG), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_HOST_ERROR_MSG), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_OPEN_DONE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CLOSE_DONE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_COMMAND_DONE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_FUNCTION_ERROR_MSG), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_INDICATE_STATUS_MSG), \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_STATUS_DESCRIPTION(m) { MBIM_STATUS_ ## m, #m }
|
||||
#define MBIM_STATUS_DESCRIPTIONS { \
|
||||
MBIM_STATUS_DESCRIPTION(SUCCESS), \
|
||||
MBIM_STATUS_DESCRIPTION(BUSY), \
|
||||
MBIM_STATUS_DESCRIPTION(FAILURE), \
|
||||
MBIM_STATUS_DESCRIPTION(SIM_NOT_INSERTED), \
|
||||
MBIM_STATUS_DESCRIPTION(BAD_SIM), \
|
||||
MBIM_STATUS_DESCRIPTION(PIN_REQUIRED), \
|
||||
MBIM_STATUS_DESCRIPTION(PIN_DISABLED), \
|
||||
MBIM_STATUS_DESCRIPTION(NOT_REGISTERED), \
|
||||
MBIM_STATUS_DESCRIPTION(PROVIDERS_NOT_FOUND), \
|
||||
MBIM_STATUS_DESCRIPTION(NO_DEVICE_SUPPORT), \
|
||||
MBIM_STATUS_DESCRIPTION(PROVIDER_NOT_VISIBLE), \
|
||||
MBIM_STATUS_DESCRIPTION(DATA_CLASS_NOT_AVAILABLE), \
|
||||
MBIM_STATUS_DESCRIPTION(PACKET_SERVICE_DETACHED), \
|
||||
MBIM_STATUS_DESCRIPTION(MAX_ACTIVATED_CONTEXTS), \
|
||||
MBIM_STATUS_DESCRIPTION(NOT_INITIALIZED), \
|
||||
MBIM_STATUS_DESCRIPTION(VOICE_CALL_IN_PROGRESS), \
|
||||
MBIM_STATUS_DESCRIPTION(CONTEXT_NOT_ACTIVATED), \
|
||||
MBIM_STATUS_DESCRIPTION(SERVICE_NOT_ACTIVATED), \
|
||||
MBIM_STATUS_DESCRIPTION(INVALID_ACCESS_STRING), \
|
||||
MBIM_STATUS_DESCRIPTION(INVALID_USER_NAME_PWD), \
|
||||
MBIM_STATUS_DESCRIPTION(RADIO_POWER_OFF), \
|
||||
MBIM_STATUS_DESCRIPTION(INVALID_PARAMETERS), \
|
||||
MBIM_STATUS_DESCRIPTION(READ_FAILURE), \
|
||||
MBIM_STATUS_DESCRIPTION(WRITE_FAILURE), \
|
||||
MBIM_STATUS_DESCRIPTION(NO_PHONEBOOK), \
|
||||
MBIM_STATUS_DESCRIPTION(PARAMETER_TOO_LONG), \
|
||||
MBIM_STATUS_DESCRIPTION(STK_BUSY), \
|
||||
MBIM_STATUS_DESCRIPTION(OPERATION_NOT_ALLOWED), \
|
||||
MBIM_STATUS_DESCRIPTION(MEMORY_FAILURE), \
|
||||
MBIM_STATUS_DESCRIPTION(INVALID_MEMORY_INDEX), \
|
||||
MBIM_STATUS_DESCRIPTION(MEMORY_FULL), \
|
||||
MBIM_STATUS_DESCRIPTION(FILTER_NOT_SUPPORTED), \
|
||||
MBIM_STATUS_DESCRIPTION(DSS_INSTANCE_LIMIT), \
|
||||
MBIM_STATUS_DESCRIPTION(INVALID_DEVICE_SERVICE_OPERATION), \
|
||||
MBIM_STATUS_DESCRIPTION(AUTH_INCORRECT_AUTN), \
|
||||
MBIM_STATUS_DESCRIPTION(AUTH_SYNC_FAILURE), \
|
||||
MBIM_STATUS_DESCRIPTION(AUTH_AMF_NOT_SET), \
|
||||
MBIM_STATUS_DESCRIPTION(CONTEXT_NOT_SUPPORTED), \
|
||||
MBIM_STATUS_DESCRIPTION(SMS_UNKNOWN_SMSC_ADDRESS), \
|
||||
MBIM_STATUS_DESCRIPTION(SMS_NETWORK_TIMEOUT), \
|
||||
MBIM_STATUS_DESCRIPTION(SMS_LANG_NOT_SUPPORTED), \
|
||||
MBIM_STATUS_DESCRIPTION(SMS_ENCODING_NOT_SUPPORTED), \
|
||||
MBIM_STATUS_DESCRIPTION(SMS_FORMAT_NOT_SUPPORTED), \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_ERROR_DESCRIPTION(m) { MBIM_ERROR_ ## m, #m }
|
||||
#define MBIM_ERROR_DESCRIPTIONS { \
|
||||
MBIM_ERROR_DESCRIPTION(TIMEOUT_FRAGMENT), \
|
||||
MBIM_ERROR_DESCRIPTION(FRAGMENT_OUT_OF_SEQUENCE), \
|
||||
MBIM_ERROR_DESCRIPTION(LENGTH_MISMATCH), \
|
||||
MBIM_ERROR_DESCRIPTION(DUPLICATED_TID), \
|
||||
MBIM_ERROR_DESCRIPTION(NOT_OPENED), \
|
||||
MBIM_ERROR_DESCRIPTION(UNKNOWN), \
|
||||
MBIM_ERROR_DESCRIPTION(CANCEL), \
|
||||
MBIM_ERROR_DESCRIPTION(MAX_TRANSFER), \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_CID_DESCRIPTIONS { \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_DEVICE_CAPS), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_SUBSCRIBER_READY_STATUS), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_RADIO_STATE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_PIN), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_PIN_LIST), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_HOME_PROVIDER), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_PREFERRED_PROVIDERS), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_VISIBLE_PROVIDERS), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_REGISTER_STATE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_PACKET_SERVICE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_SIGNAL_STATE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_CONNECT), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_PROVISIONED_CONTEXTS), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_SERVICE_ACTIVATION), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_IP_CONFIGURATION), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_DEVICE_SERVICES), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_PACKET_STATISTICS), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_NETWORK_IDLE_HINT), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_EMERGENCY_MODE), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_IP_PACKET_FILTERS), \
|
||||
MBIM_1TO1_DESCRIPTION(MBIM_CID_MULTICARRIER_PROVIDERS), \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_SIMSTATE_DESCRIPTIONS { \
|
||||
{ MBIM_SIMSTATE_NOTINITIALIZED, "not initialized" }, \
|
||||
{ MBIM_SIMSTATE_INITIALIZED, "initialized" }, \
|
||||
{ MBIM_SIMSTATE_NOTINSERTED, "not inserted" }, \
|
||||
{ MBIM_SIMSTATE_BADSIM, "bad type" }, \
|
||||
{ MBIM_SIMSTATE_FAILURE, "failed" }, \
|
||||
{ MBIM_SIMSTATE_NOTACTIVATED, "not activated" }, \
|
||||
{ MBIM_SIMSTATE_LOCKED, "locked" }, \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_PINTYPE_DESCRIPTIONS { \
|
||||
{ MBIM_PIN_TYPE_NONE, "none" }, \
|
||||
{ MBIM_PIN_TYPE_CUSTOM, "custom" }, \
|
||||
{ MBIM_PIN_TYPE_PIN1, "PIN1" }, \
|
||||
{ MBIM_PIN_TYPE_PIN2, "PIN2" }, \
|
||||
{ MBIM_PIN_TYPE_DEV_SIM_PIN, "device PIN" }, \
|
||||
{ MBIM_PIN_TYPE_DEV_FIRST_SIM_PIN, "device 1st PIN" }, \
|
||||
{ MBIM_PIN_TYPE_NETWORK_PIN, "network PIN" }, \
|
||||
{ MBIM_PIN_TYPE_NETWORK_SUBSET_PIN, "network subset PIN" }, \
|
||||
{ MBIM_PIN_TYPE_SERVICE_PROVIDER_PIN, "provider PIN" }, \
|
||||
{ MBIM_PIN_TYPE_CORPORATE_PIN, "corporate PIN" }, \
|
||||
{ MBIM_PIN_TYPE_SUBSIDY_LOCK, "subsidy lock" }, \
|
||||
{ MBIM_PIN_TYPE_PUK1, "PUK" }, \
|
||||
{ MBIM_PIN_TYPE_PUK2, "PUK2" }, \
|
||||
{ MBIM_PIN_TYPE_DEV_FIRST_SIM_PUK, "device 1st PUK" }, \
|
||||
{ MBIM_PIN_TYPE_NETWORK_PUK, "network PUK" }, \
|
||||
{ MBIM_PIN_TYPE_NETWORK_SUBSET_PUK, "network subset PUK" }, \
|
||||
{ MBIM_PIN_TYPE_SERVICE_PROVIDER_PUK, "provider PUK" }, \
|
||||
{ MBIM_PIN_TYPE_CORPORATE_PUK, "corporate PUK" }, \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_PKTSRV_STATE_DESCRIPTIONS { \
|
||||
{ MBIM_PKTSERVICE_STATE_UNKNOWN, "unknown" }, \
|
||||
{ MBIM_PKTSERVICE_STATE_ATTACHING, "attaching" }, \
|
||||
{ MBIM_PKTSERVICE_STATE_ATTACHED, "attached" }, \
|
||||
{ MBIM_PKTSERVICE_STATE_DETACHING, "detaching" }, \
|
||||
{ MBIM_PKTSERVICE_STATE_DETACHED, "detached" }, \
|
||||
{ 0, NULL } }
|
||||
|
||||
#define MBIM_ACTIVATION_STATE_DESCRIPTIONS { \
|
||||
{ MBIM_ACTIVATION_STATE_UNKNOWN, "unknown" }, \
|
||||
{ MBIM_ACTIVATION_STATE_ACTIVATED, "activated" }, \
|
||||
{ MBIM_ACTIVATION_STATE_ACTIVATING, "activating" }, \
|
||||
{ MBIM_ACTIVATION_STATE_DEACTIVATED, "deactivated" }, \
|
||||
{ MBIM_ACTIVATION_STATE_DEACTIVATING, "deactivating" }, \
|
||||
{ 0, NULL } }
|
||||
|
||||
/*
|
||||
* Driver internal state
|
||||
*/
|
||||
enum umb_state {
|
||||
UMB_S_DOWN = 0, /* interface down */
|
||||
UMB_S_OPEN, /* MBIM device has been opened */
|
||||
UMB_S_CID, /* QMI client id allocated */
|
||||
UMB_S_RADIO, /* radio is on */
|
||||
UMB_S_SIMREADY, /* SIM is ready */
|
||||
UMB_S_ATTACHED, /* packet service is attached */
|
||||
UMB_S_CONNECTED, /* connected to provider */
|
||||
UMB_S_UP, /* have IP configuration */
|
||||
};
|
||||
|
||||
#define UMB_INTERNAL_STATE_DESCRIPTIONS { \
|
||||
{ UMB_S_DOWN, "down" }, \
|
||||
{ UMB_S_OPEN, "open" }, \
|
||||
{ UMB_S_CID, "CID allocated" }, \
|
||||
{ UMB_S_RADIO, "radio on" }, \
|
||||
{ UMB_S_SIMREADY, "SIM is ready" }, \
|
||||
{ UMB_S_ATTACHED, "attached" }, \
|
||||
{ UMB_S_CONNECTED, "connected" }, \
|
||||
{ UMB_S_UP, "up" }, \
|
||||
{ 0, NULL } }
|
||||
|
||||
/*
|
||||
* UMB parameters (SIOC[GS]UMBPARAM ioctls)
|
||||
*/
|
||||
struct umb_parameter {
|
||||
int op;
|
||||
int is_puk;
|
||||
uint16_t pin[MBIM_PIN_MAXLEN];
|
||||
int pinlen;
|
||||
|
||||
char newpin[MBIM_PIN_MAXLEN];
|
||||
int newpinlen;
|
||||
|
||||
#define UMB_APN_MAXLEN 100
|
||||
uint16_t apn[UMB_APN_MAXLEN];
|
||||
int apnlen;
|
||||
|
||||
#define UMB_USERNAME_MAXLEN 205
|
||||
uint16_t username[UMB_USERNAME_MAXLEN];
|
||||
int usernamelen;
|
||||
|
||||
#define UMB_PASSWORD_MAXLEN 205
|
||||
uint16_t password[UMB_PASSWORD_MAXLEN];
|
||||
int passwordlen;
|
||||
|
||||
int roaming;
|
||||
uint32_t preferredclasses;
|
||||
};
|
||||
|
||||
/*
|
||||
* UMB device status info (SIOCGUMBINFO ioctl)
|
||||
*/
|
||||
struct umb_info {
|
||||
enum umb_state state;
|
||||
int enable_roaming;
|
||||
#define UMB_PIN_REQUIRED 0
|
||||
#define UMB_PIN_UNLOCKED 1
|
||||
#define UMB_PUK_REQUIRED 2
|
||||
int pin_state;
|
||||
int pin_attempts_left;
|
||||
int activation;
|
||||
int sim_state;
|
||||
int regstate;
|
||||
int regmode;
|
||||
int nwerror;
|
||||
int packetstate;
|
||||
uint32_t supportedclasses; /* what the hw supports */
|
||||
uint32_t preferredclasses; /* what the user prefers */
|
||||
uint32_t highestclass; /* what the network offers */
|
||||
uint32_t cellclass;
|
||||
#define UMB_PROVIDERNAME_MAXLEN 20
|
||||
uint16_t provider[UMB_PROVIDERNAME_MAXLEN];
|
||||
#define UMB_PHONENR_MAXLEN 22
|
||||
uint16_t pn[UMB_PHONENR_MAXLEN];
|
||||
#define UMB_SUBSCRIBERID_MAXLEN 15
|
||||
uint16_t sid[UMB_SUBSCRIBERID_MAXLEN];
|
||||
#define UMB_ICCID_MAXLEN 20
|
||||
uint16_t iccid[UMB_ICCID_MAXLEN];
|
||||
#define UMB_ROAMINGTEXT_MAXLEN 63
|
||||
uint16_t roamingtxt[UMB_ROAMINGTEXT_MAXLEN];
|
||||
|
||||
#define UMB_DEVID_MAXLEN 18
|
||||
uint16_t devid[UMB_DEVID_MAXLEN];
|
||||
#define UMB_FWINFO_MAXLEN 30
|
||||
uint16_t fwinfo[UMB_FWINFO_MAXLEN];
|
||||
#define UMB_HWINFO_MAXLEN 30
|
||||
uint16_t hwinfo[UMB_HWINFO_MAXLEN];
|
||||
|
||||
uint16_t apn[UMB_APN_MAXLEN];
|
||||
int apnlen;
|
||||
|
||||
uint16_t username[UMB_USERNAME_MAXLEN];
|
||||
int usernamelen;
|
||||
|
||||
uint16_t password[UMB_PASSWORD_MAXLEN];
|
||||
int passwordlen;
|
||||
|
||||
#define UMB_VALUE_UNKNOWN -999
|
||||
int rssi;
|
||||
#define UMB_BER_EXCELLENT 0
|
||||
#define UMB_BER_VERYGOOD 1
|
||||
#define UMB_BER_GOOD 2
|
||||
#define UMB_BER_OK 3
|
||||
#define UMB_BER_MEDIUM 4
|
||||
#define UMB_BER_BAD 5
|
||||
#define UMB_BER_VERYBAD 6
|
||||
#define UMB_BER_EXTREMELYBAD 7
|
||||
int ber;
|
||||
|
||||
int hw_radio_on;
|
||||
int sw_radio_on;
|
||||
|
||||
uint64_t uplink_speed;
|
||||
uint64_t downlink_speed;
|
||||
|
||||
#define UMB_MAX_DNSSRV 2
|
||||
u_int32_t ipv4dns[UMB_MAX_DNSSRV];
|
||||
};
|
||||
|
||||
#if !defined(ifr_mtu)
|
||||
#define ifr_mtu ifr_ifru.ifru_metric
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* UMB device
|
||||
*/
|
||||
struct umb_softc {
|
||||
device_t sc_dev;
|
||||
struct ifnet sc_if;
|
||||
#define GET_IFP(sc) (&(sc)->sc_if)
|
||||
struct ifmedia sc_im;
|
||||
krndsource_t sc_rnd_source;
|
||||
struct usbd_device *sc_udev;
|
||||
|
||||
int sc_ver_maj;
|
||||
int sc_ver_min;
|
||||
int sc_ctrl_len;
|
||||
int sc_maxpktlen;
|
||||
int sc_maxsessions;
|
||||
|
||||
#define UMBFLG_FCC_AUTH_REQUIRED 0x0001
|
||||
uint32_t sc_flags;
|
||||
int sc_cid;
|
||||
|
||||
struct usb_task sc_umb_task;
|
||||
struct usb_task sc_get_response_task;
|
||||
int sc_nresp;
|
||||
callout_t sc_statechg_timer;
|
||||
char sc_dying;
|
||||
char sc_attached;
|
||||
|
||||
uint8_t sc_ctrl_ifaceno;
|
||||
struct usbd_pipe *sc_ctrl_pipe;
|
||||
usb_cdc_notification_t sc_intr_msg;
|
||||
struct usbd_interface *sc_data_iface;
|
||||
|
||||
void *sc_resp_buf;
|
||||
void *sc_ctrl_msg;
|
||||
|
||||
int sc_rx_ep;
|
||||
struct usbd_xfer *sc_rx_xfer;
|
||||
char *sc_rx_buf;
|
||||
int sc_rx_bufsz;
|
||||
struct usbd_pipe *sc_rx_pipe;
|
||||
unsigned sc_rx_nerr;
|
||||
|
||||
int sc_tx_ep;
|
||||
struct usbd_xfer *sc_tx_xfer;
|
||||
char *sc_tx_buf;
|
||||
int sc_tx_bufsz;
|
||||
struct usbd_pipe *sc_tx_pipe;
|
||||
struct mbuf *sc_tx_m;
|
||||
uint32_t sc_tx_seq;
|
||||
|
||||
uint32_t sc_tid;
|
||||
|
||||
#define sc_state sc_info.state
|
||||
#define sc_roaming sc_info.enable_roaming
|
||||
struct umb_info sc_info;
|
||||
};
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _IF_UMBREG_H_ */
|
697
sys/dev/usb/mbim.h
Normal file
697
sys/dev/usb/mbim.h
Normal file
@ -0,0 +1,697 @@
|
||||
/* $OpenBSD: mbim.h,v 1.4 2017/04/18 13:27:55 gerhard Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 genua mbH
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mobile Broadband Interface Model
|
||||
* http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
|
||||
*/
|
||||
#ifndef _MBIM_H_
|
||||
#define _MBIM_H_
|
||||
|
||||
#define UDESCSUB_MBIM 27
|
||||
#define MBIM_INTERFACE_ALTSETTING 1
|
||||
|
||||
#define MBIM_RESET_FUNCTION 0x05
|
||||
|
||||
/*
|
||||
* Registration state (MBIM_REGISTER_STATE)
|
||||
*/
|
||||
#define MBIM_REGSTATE_UNKNOWN 0
|
||||
#define MBIM_REGSTATE_DEREGISTERED 1
|
||||
#define MBIM_REGSTATE_SEARCHING 2
|
||||
#define MBIM_REGSTATE_HOME 3
|
||||
#define MBIM_REGSTATE_ROAMING 4
|
||||
#define MBIM_REGSTATE_PARTNER 5
|
||||
#define MBIM_REGSTATE_DENIED 6
|
||||
|
||||
/*
|
||||
* Data classes mask (MBIM_DATA_CLASS)
|
||||
*/
|
||||
#define MBIM_DATACLASS_NONE 0x00000000
|
||||
#define MBIM_DATACLASS_GPRS 0x00000001
|
||||
#define MBIM_DATACLASS_EDGE 0x00000002
|
||||
#define MBIM_DATACLASS_UMTS 0x00000004
|
||||
#define MBIM_DATACLASS_HSDPA 0x00000008
|
||||
#define MBIM_DATACLASS_HSUPA 0x00000010
|
||||
#define MBIM_DATACLASS_LTE 0x00000020
|
||||
#define MBIM_DATACLASS_1XRTT 0x00010000
|
||||
#define MBIM_DATACLASS_1XEVDO 0x00020000
|
||||
#define MBIM_DATACLASS_1XEVDO_REV_A 0x00040000
|
||||
#define MBIM_DATACLASS_1XEVDV 0x00080000
|
||||
#define MBIM_DATACLASS_3XRTT 0x00100000
|
||||
#define MBIM_DATACLASS_1XEVDO_REV_B 0x00200000
|
||||
#define MBIM_DATACLASS_UMB 0x00400000
|
||||
#define MBIM_DATACLASS_CUSTOM 0x80000000
|
||||
|
||||
/*
|
||||
* Cell classes mask (MBIM_CELLULAR_CLASS)
|
||||
*/
|
||||
#define MBIM_CELLCLASS_GSM 0x00000001
|
||||
#define MBIM_CELLCLASS_CDMA 0x00000002
|
||||
|
||||
/*
|
||||
* UUIDs
|
||||
*/
|
||||
#define MBIM_UUID_LEN 16
|
||||
|
||||
#define MBIM_UUID_BASIC_CONNECT { \
|
||||
0xa2, 0x89, 0xcc, 0x33, 0xbc, 0xbb, 0x8b, 0x4f, \
|
||||
0xb6, 0xb0, 0x13, 0x3e, 0xc2, 0xaa, 0xe6, 0xdf \
|
||||
}
|
||||
|
||||
#define MBIM_UUID_CONTEXT_INTERNET { \
|
||||
0x7e, 0x5e, 0x2a, 0x7e, 0x4e, 0x6f, 0x72, 0x72, \
|
||||
0x73, 0x6b, 0x65, 0x6e, 0x7e, 0x5e, 0x2a, 0x7e \
|
||||
}
|
||||
|
||||
#define MBIM_UUID_CONTEXT_VPN { \
|
||||
0x9b, 0x9f, 0x7b, 0xbe, 0x89, 0x52, 0x44, 0xb7, \
|
||||
0x83, 0xac, 0xca, 0x41, 0x31, 0x8d, 0xf7, 0xa0 \
|
||||
}
|
||||
|
||||
#define MBIM_UUID_QMI_MBIM { \
|
||||
0xd1, 0xa3, 0x0b, 0xc2, 0xf9, 0x7a, 0x6e, 0x43, \
|
||||
0xbf, 0x65, 0xc7, 0xe2, 0x4f, 0xb0, 0xf0, 0xd3 \
|
||||
}
|
||||
|
||||
#define MBIM_CTRLMSG_MINLEN 64
|
||||
#define MBIM_CTRLMSG_MAXLEN (4 * 1204)
|
||||
|
||||
#define MBIM_MAXSEGSZ_MINVAL (2 * 1024)
|
||||
|
||||
/*
|
||||
* Control messages (host to function)
|
||||
*/
|
||||
#define MBIM_OPEN_MSG 1U
|
||||
#define MBIM_CLOSE_MSG 2U
|
||||
#define MBIM_COMMAND_MSG 3U
|
||||
#define MBIM_HOST_ERROR_MSG 4U
|
||||
|
||||
/*
|
||||
* Control messages (function to host)
|
||||
*/
|
||||
#define MBIM_OPEN_DONE 0x80000001U
|
||||
#define MBIM_CLOSE_DONE 0x80000002U
|
||||
#define MBIM_COMMAND_DONE 0x80000003U
|
||||
#define MBIM_FUNCTION_ERROR_MSG 0x80000004U
|
||||
#define MBIM_INDICATE_STATUS_MSG 0x80000007U
|
||||
|
||||
/*
|
||||
* Generic status codes
|
||||
*/
|
||||
#define MBIM_STATUS_SUCCESS 0
|
||||
#define MBIM_STATUS_BUSY 1
|
||||
#define MBIM_STATUS_FAILURE 2
|
||||
#define MBIM_STATUS_SIM_NOT_INSERTED 3
|
||||
#define MBIM_STATUS_BAD_SIM 4
|
||||
#define MBIM_STATUS_PIN_REQUIRED 5
|
||||
#define MBIM_STATUS_PIN_DISABLED 6
|
||||
#define MBIM_STATUS_NOT_REGISTERED 7
|
||||
#define MBIM_STATUS_PROVIDERS_NOT_FOUND 8
|
||||
#define MBIM_STATUS_NO_DEVICE_SUPPORT 9
|
||||
#define MBIM_STATUS_PROVIDER_NOT_VISIBLE 10
|
||||
#define MBIM_STATUS_DATA_CLASS_NOT_AVAILABLE 11
|
||||
#define MBIM_STATUS_PACKET_SERVICE_DETACHED 12
|
||||
#define MBIM_STATUS_MAX_ACTIVATED_CONTEXTS 13
|
||||
#define MBIM_STATUS_NOT_INITIALIZED 14
|
||||
#define MBIM_STATUS_VOICE_CALL_IN_PROGRESS 15
|
||||
#define MBIM_STATUS_CONTEXT_NOT_ACTIVATED 16
|
||||
#define MBIM_STATUS_SERVICE_NOT_ACTIVATED 17
|
||||
#define MBIM_STATUS_INVALID_ACCESS_STRING 18
|
||||
#define MBIM_STATUS_INVALID_USER_NAME_PWD 19
|
||||
#define MBIM_STATUS_RADIO_POWER_OFF 20
|
||||
#define MBIM_STATUS_INVALID_PARAMETERS 21
|
||||
#define MBIM_STATUS_READ_FAILURE 22
|
||||
#define MBIM_STATUS_WRITE_FAILURE 23
|
||||
#define MBIM_STATUS_NO_PHONEBOOK 25
|
||||
#define MBIM_STATUS_PARAMETER_TOO_LONG 26
|
||||
#define MBIM_STATUS_STK_BUSY 27
|
||||
#define MBIM_STATUS_OPERATION_NOT_ALLOWED 28
|
||||
#define MBIM_STATUS_MEMORY_FAILURE 29
|
||||
#define MBIM_STATUS_INVALID_MEMORY_INDEX 30
|
||||
#define MBIM_STATUS_MEMORY_FULL 31
|
||||
#define MBIM_STATUS_FILTER_NOT_SUPPORTED 32
|
||||
#define MBIM_STATUS_DSS_INSTANCE_LIMIT 33
|
||||
#define MBIM_STATUS_INVALID_DEVICE_SERVICE_OPERATION 34
|
||||
#define MBIM_STATUS_AUTH_INCORRECT_AUTN 35
|
||||
#define MBIM_STATUS_AUTH_SYNC_FAILURE 36
|
||||
#define MBIM_STATUS_AUTH_AMF_NOT_SET 37
|
||||
#define MBIM_STATUS_CONTEXT_NOT_SUPPORTED 38
|
||||
#define MBIM_STATUS_SMS_UNKNOWN_SMSC_ADDRESS 100
|
||||
#define MBIM_STATUS_SMS_NETWORK_TIMEOUT 101
|
||||
#define MBIM_STATUS_SMS_LANG_NOT_SUPPORTED 102
|
||||
#define MBIM_STATUS_SMS_ENCODING_NOT_SUPPORTED 103
|
||||
#define MBIM_STATUS_SMS_FORMAT_NOT_SUPPORTED 104
|
||||
|
||||
/*
|
||||
* Message formats
|
||||
*/
|
||||
struct mbim_msghdr {
|
||||
/* Msg header */
|
||||
uint32_t type; /* message type */
|
||||
uint32_t len; /* message length */
|
||||
uint32_t tid; /* transaction id */
|
||||
} __packed;
|
||||
|
||||
struct mbim_fraghdr {
|
||||
uint32_t nfrag; /* total # of fragments */
|
||||
uint32_t currfrag; /* current fragment */
|
||||
} __packed;
|
||||
|
||||
struct mbim_fragmented_msg_hdr {
|
||||
struct mbim_msghdr hdr;
|
||||
struct mbim_fraghdr frag;
|
||||
} __packed;
|
||||
|
||||
struct mbim_h2f_openmsg {
|
||||
struct mbim_msghdr hdr;
|
||||
uint32_t maxlen;
|
||||
} __packed;
|
||||
|
||||
struct mbim_h2f_closemsg {
|
||||
struct mbim_msghdr hdr;
|
||||
} __packed;
|
||||
|
||||
struct mbim_h2f_cmd {
|
||||
struct mbim_msghdr hdr;
|
||||
struct mbim_fraghdr frag;
|
||||
uint8_t devid[MBIM_UUID_LEN];
|
||||
uint32_t cid; /* command id */
|
||||
#define MBIM_CMDOP_QRY 0
|
||||
#define MBIM_CMDOP_SET 1
|
||||
uint32_t op;
|
||||
uint32_t infolen;
|
||||
uint8_t info[];
|
||||
} __packed;
|
||||
|
||||
struct mbim_f2h_indicate_status {
|
||||
struct mbim_msghdr hdr;
|
||||
struct mbim_fraghdr frag;
|
||||
uint8_t devid[MBIM_UUID_LEN];
|
||||
uint32_t cid; /* command id */
|
||||
uint32_t infolen;
|
||||
uint8_t info[];
|
||||
} __packed;
|
||||
|
||||
struct mbim_f2h_hosterr {
|
||||
struct mbim_msghdr hdr;
|
||||
|
||||
#define MBIM_ERROR_TIMEOUT_FRAGMENT 1
|
||||
#define MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE 2
|
||||
#define MBIM_ERROR_LENGTH_MISMATCH 3
|
||||
#define MBIM_ERROR_DUPLICATED_TID 4
|
||||
#define MBIM_ERROR_NOT_OPENED 5
|
||||
#define MBIM_ERROR_UNKNOWN 6
|
||||
#define MBIM_ERROR_CANCEL 7
|
||||
#define MBIM_ERROR_MAX_TRANSFER 8
|
||||
uint32_t err;
|
||||
} __packed;
|
||||
|
||||
struct mbim_f2h_openclosedone {
|
||||
struct mbim_msghdr hdr;
|
||||
int32_t status;
|
||||
} __packed;
|
||||
|
||||
struct mbim_f2h_cmddone {
|
||||
struct mbim_msghdr hdr;
|
||||
struct mbim_fraghdr frag;
|
||||
uint8_t devid[MBIM_UUID_LEN];
|
||||
uint32_t cid; /* command id */
|
||||
int32_t status;
|
||||
uint32_t infolen;
|
||||
uint8_t info[];
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* Messages and commands for MBIM_UUID_BASIC_CONNECT
|
||||
*/
|
||||
#define MBIM_CID_DEVICE_CAPS 1
|
||||
#define MBIM_CID_SUBSCRIBER_READY_STATUS 2
|
||||
#define MBIM_CID_RADIO_STATE 3
|
||||
#define MBIM_CID_PIN 4
|
||||
#define MBIM_CID_PIN_LIST 5
|
||||
#define MBIM_CID_HOME_PROVIDER 6
|
||||
#define MBIM_CID_PREFERRED_PROVIDERS 7
|
||||
#define MBIM_CID_VISIBLE_PROVIDERS 8
|
||||
#define MBIM_CID_REGISTER_STATE 9
|
||||
#define MBIM_CID_PACKET_SERVICE 10
|
||||
#define MBIM_CID_SIGNAL_STATE 11
|
||||
#define MBIM_CID_CONNECT 12
|
||||
#define MBIM_CID_PROVISIONED_CONTEXTS 13
|
||||
#define MBIM_CID_SERVICE_ACTIVATION 14
|
||||
#define MBIM_CID_IP_CONFIGURATION 15
|
||||
#define MBIM_CID_DEVICE_SERVICES 16
|
||||
#define MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST 19
|
||||
#define MBIM_CID_PACKET_STATISTICS 20
|
||||
#define MBIM_CID_NETWORK_IDLE_HINT 21
|
||||
#define MBIM_CID_EMERGENCY_MODE 22
|
||||
#define MBIM_CID_IP_PACKET_FILTERS 23
|
||||
#define MBIM_CID_MULTICARRIER_PROVIDERS 24
|
||||
|
||||
struct mbim_cid_subscriber_ready_info {
|
||||
#define MBIM_SIMSTATE_NOTINITIALIZED 0
|
||||
#define MBIM_SIMSTATE_INITIALIZED 1
|
||||
#define MBIM_SIMSTATE_NOTINSERTED 2
|
||||
#define MBIM_SIMSTATE_BADSIM 3
|
||||
#define MBIM_SIMSTATE_FAILURE 4
|
||||
#define MBIM_SIMSTATE_NOTACTIVATED 5
|
||||
#define MBIM_SIMSTATE_LOCKED 6
|
||||
uint32_t ready;
|
||||
|
||||
uint32_t sid_offs;
|
||||
uint32_t sid_size;
|
||||
|
||||
uint32_t icc_offs;
|
||||
uint32_t icc_size;
|
||||
|
||||
#define MBIM_SIMUNIQEID_NONE 0
|
||||
#define MBIM_SIMUNIQEID_PROTECT 1
|
||||
uint32_t info;
|
||||
|
||||
uint32_t no_pn;
|
||||
struct {
|
||||
uint32_t offs;
|
||||
uint32_t size;
|
||||
}
|
||||
pn[];
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_radio_state {
|
||||
#define MBIM_RADIO_STATE_OFF 0
|
||||
#define MBIM_RADIO_STATE_ON 1
|
||||
uint32_t state;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_radio_state_info {
|
||||
uint32_t hw_state;
|
||||
uint32_t sw_state;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_pin {
|
||||
#define MBIM_PIN_TYPE_NONE 0
|
||||
#define MBIM_PIN_TYPE_CUSTOM 1
|
||||
#define MBIM_PIN_TYPE_PIN1 2
|
||||
#define MBIM_PIN_TYPE_PIN2 3
|
||||
#define MBIM_PIN_TYPE_DEV_SIM_PIN 4
|
||||
#define MBIM_PIN_TYPE_DEV_FIRST_SIM_PIN 5
|
||||
#define MBIM_PIN_TYPE_NETWORK_PIN 6
|
||||
#define MBIM_PIN_TYPE_NETWORK_SUBSET_PIN 7
|
||||
#define MBIM_PIN_TYPE_SERVICE_PROVIDER_PIN 8
|
||||
#define MBIM_PIN_TYPE_CORPORATE_PIN 9
|
||||
#define MBIM_PIN_TYPE_SUBSIDY_LOCK 10
|
||||
#define MBIM_PIN_TYPE_PUK1 11
|
||||
#define MBIM_PIN_TYPE_PUK2 12
|
||||
#define MBIM_PIN_TYPE_DEV_FIRST_SIM_PUK 13
|
||||
#define MBIM_PIN_TYPE_NETWORK_PUK 14
|
||||
#define MBIM_PIN_TYPE_NETWORK_SUBSET_PUK 15
|
||||
#define MBIM_PIN_TYPE_SERVICE_PROVIDER_PUK 16
|
||||
#define MBIM_PIN_TYPE_CORPORATE_PUK 17
|
||||
uint32_t type;
|
||||
|
||||
#define MBIM_PIN_OP_ENTER 0
|
||||
#define MBIM_PIN_OP_ENABLE 1
|
||||
#define MBIM_PIN_OP_DISABLE 2
|
||||
#define MBIM_PIN_OP_CHANGE 3
|
||||
uint32_t op;
|
||||
uint32_t pin_offs;
|
||||
uint32_t pin_size;
|
||||
uint32_t newpin_offs;
|
||||
uint32_t newpin_size;
|
||||
#define MBIM_PIN_MAXLEN 32
|
||||
uint8_t data[2 * MBIM_PIN_MAXLEN];
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_pin_info {
|
||||
uint32_t type;
|
||||
|
||||
#define MBIM_PIN_STATE_UNLOCKED 0
|
||||
#define MBIM_PIN_STATE_LOCKED 1
|
||||
uint32_t state;
|
||||
uint32_t remaining_attempts;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_pin_list_info {
|
||||
struct mbim_pin_desc {
|
||||
|
||||
#define MBIM_PINMODE_NOTSUPPORTED 0
|
||||
#define MBIM_PINMODE_ENABLED 1
|
||||
#define MBIM_PINMODE_DISABLED 2
|
||||
uint32_t mode;
|
||||
|
||||
#define MBIM_PINFORMAT_UNKNOWN 0
|
||||
#define MBIM_PINFORMAT_NUMERIC 1
|
||||
#define MBIM_PINFORMAT_ALPHANUMERIC 2
|
||||
uint32_t format;
|
||||
|
||||
uint32_t minlen;
|
||||
uint32_t maxlen;
|
||||
}
|
||||
pin1,
|
||||
pin2,
|
||||
dev_sim_pin,
|
||||
first_dev_sim_pin,
|
||||
net_pin,
|
||||
net_sub_pin,
|
||||
svp_pin,
|
||||
corp_pin,
|
||||
subsidy_lock,
|
||||
custom;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_device_caps {
|
||||
#define MBIM_DEVTYPE_UNKNOWN 0
|
||||
#define MBIM_DEVTYPE_EMBEDDED 1
|
||||
#define MBIM_DEVTYPE_REMOVABLE 2
|
||||
#define MBIM_DEVTYPE_REMOTE 3
|
||||
uint32_t devtype;
|
||||
|
||||
uint32_t cellclass; /* values: MBIM_CELLULAR_CLASS */
|
||||
uint32_t voiceclass;
|
||||
uint32_t simclass;
|
||||
uint32_t dataclass; /* values: MBIM_DATA_CLASS */
|
||||
uint32_t smscaps;
|
||||
uint32_t cntrlcaps;
|
||||
uint32_t max_sessions;
|
||||
|
||||
uint32_t custdataclass_offs;
|
||||
uint32_t custdataclass_size;
|
||||
|
||||
uint32_t devid_offs;
|
||||
uint32_t devid_size;
|
||||
|
||||
uint32_t fwinfo_offs;
|
||||
uint32_t fwinfo_size;
|
||||
|
||||
uint32_t hwinfo_offs;
|
||||
uint32_t hwinfo_size;
|
||||
|
||||
uint32_t data[];
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_registration_state {
|
||||
uint32_t provid_offs;
|
||||
uint32_t provid_size;
|
||||
|
||||
#define MBIM_REGACTION_AUTOMATIC 0
|
||||
#define MBIM_REGACTION_MANUAL 1
|
||||
uint32_t regaction;
|
||||
uint32_t data_class;
|
||||
|
||||
uint32_t data[];
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_registration_state_info {
|
||||
uint32_t nwerror;
|
||||
|
||||
uint32_t regstate; /* values: MBIM_REGISTER_STATE */
|
||||
|
||||
#define MBIM_REGMODE_UNKNOWN 0
|
||||
#define MBIM_REGMODE_AUTOMATIC 1
|
||||
#define MBIM_REGMODE_MANUAL 2
|
||||
uint32_t regmode;
|
||||
|
||||
uint32_t availclasses; /* values: MBIM_DATA_CLASS */
|
||||
uint32_t curcellclass; /* values: MBIM_CELLULAR_CLASS */
|
||||
|
||||
uint32_t provid_offs;
|
||||
uint32_t provid_size;
|
||||
|
||||
uint32_t provname_offs;
|
||||
uint32_t provname_size;
|
||||
|
||||
uint32_t roamingtxt_offs;
|
||||
uint32_t roamingtxt_size;
|
||||
|
||||
#define MBIM_REGFLAGS_NONE 0
|
||||
#define MBIM_REGFLAGS_MANUAL_NOT_AVAILABLE 1
|
||||
#define MBIM_REGFLAGS_PACKETSERVICE_AUTOATTACH 2
|
||||
uint32_t regflag;
|
||||
|
||||
uint32_t data[];
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_packet_service {
|
||||
#define MBIM_PKTSERVICE_ACTION_ATTACH 0
|
||||
#define MBIM_PKTSERVICE_ACTION_DETACH 1
|
||||
uint32_t action;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_packet_service_info {
|
||||
uint32_t nwerror;
|
||||
|
||||
#define MBIM_PKTSERVICE_STATE_UNKNOWN 0
|
||||
#define MBIM_PKTSERVICE_STATE_ATTACHING 1
|
||||
#define MBIM_PKTSERVICE_STATE_ATTACHED 2
|
||||
#define MBIM_PKTSERVICE_STATE_DETACHING 3
|
||||
#define MBIM_PKTSERVICE_STATE_DETACHED 4
|
||||
uint32_t state;
|
||||
|
||||
uint32_t highest_dataclass;
|
||||
uint64_t uplink_speed;
|
||||
uint64_t downlink_speed;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_signal_state {
|
||||
uint32_t rssi;
|
||||
uint32_t err_rate;
|
||||
uint32_t ss_intvl;
|
||||
uint32_t rssi_thr;
|
||||
uint32_t err_thr;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_connect {
|
||||
uint32_t sessionid;
|
||||
|
||||
#define MBIM_CONNECT_DEACTIVATE 0
|
||||
#define MBIM_CONNECT_ACTIVATE 1
|
||||
uint32_t command;
|
||||
|
||||
#define MBIM_ACCESS_MAXLEN 200
|
||||
uint32_t access_offs;
|
||||
uint32_t access_size;
|
||||
|
||||
#define MBIM_USER_MAXLEN 510
|
||||
uint32_t user_offs;
|
||||
uint32_t user_size;
|
||||
|
||||
#define MBIM_PASSWD_MAXLEN 510
|
||||
uint32_t passwd_offs;
|
||||
uint32_t passwd_size;
|
||||
|
||||
#define MBIM_COMPRESSION_NONE 0
|
||||
#define MBIM_COMPRESSION_ENABLE 1
|
||||
uint32_t compression;
|
||||
|
||||
#define MBIM_AUTHPROT_NONE 0
|
||||
#define MBIM_AUTHPROT_PAP 1
|
||||
#define MBIM_AUTHPROT_CHAP 2
|
||||
#define MBIM_AUTHPROT_MSCHAP 3
|
||||
uint32_t authprot;
|
||||
|
||||
#define MBIM_CONTEXT_IPTYPE_DEFAULT 0
|
||||
#define MBIM_CONTEXT_IPTYPE_IPV4 1
|
||||
#define MBIM_CONTEXT_IPTYPE_IPV6 2
|
||||
#define MBIM_CONTEXT_IPTYPE_IPV4V6 3
|
||||
#define MBIM_CONTEXT_IPTYPE_IPV4ANDV6 4
|
||||
uint32_t iptype;
|
||||
|
||||
uint8_t context[MBIM_UUID_LEN];
|
||||
|
||||
uint8_t data[MBIM_ACCESS_MAXLEN + MBIM_USER_MAXLEN +
|
||||
MBIM_PASSWD_MAXLEN];
|
||||
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_connect_info {
|
||||
uint32_t sessionid;
|
||||
|
||||
#define MBIM_ACTIVATION_STATE_UNKNOWN 0
|
||||
#define MBIM_ACTIVATION_STATE_ACTIVATED 1
|
||||
#define MBIM_ACTIVATION_STATE_ACTIVATING 2
|
||||
#define MBIM_ACTIVATION_STATE_DEACTIVATED 3
|
||||
#define MBIM_ACTIVATION_STATE_DEACTIVATING 4
|
||||
uint32_t activation;
|
||||
|
||||
uint32_t voice;
|
||||
uint32_t iptype;
|
||||
uint8_t context[MBIM_UUID_LEN];
|
||||
uint32_t nwerror;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_ipv4_element {
|
||||
uint32_t prefixlen;
|
||||
uint32_t addr;
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_ipv6_element {
|
||||
uint32_t prefixlen;
|
||||
uint8_t addr[16];
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_ip_configuration_info {
|
||||
uint32_t sessionid;
|
||||
|
||||
#define MBIM_IPCONF_HAS_ADDRINFO 0x0001
|
||||
#define MBIM_IPCONF_HAS_GWINFO 0x0002
|
||||
#define MBIM_IPCONF_HAS_DNSINFO 0x0004
|
||||
#define MBIM_IPCONF_HAS_MTUINFO 0x0008
|
||||
uint32_t ipv4_available;
|
||||
uint32_t ipv6_available;
|
||||
|
||||
uint32_t ipv4_naddr;
|
||||
uint32_t ipv4_addroffs;
|
||||
uint32_t ipv6_naddr;
|
||||
uint32_t ipv6_addroffs;
|
||||
|
||||
uint32_t ipv4_gwoffs;
|
||||
uint32_t ipv6_gwoffs;
|
||||
|
||||
uint32_t ipv4_ndnssrv;
|
||||
uint32_t ipv4_dnssrvoffs;
|
||||
uint32_t ipv6_ndnssrv;
|
||||
uint32_t ipv6_dnssrvoffs;
|
||||
|
||||
uint32_t ipv4_mtu;
|
||||
uint32_t ipv6_mtu;
|
||||
|
||||
uint32_t data[];
|
||||
} __packed;
|
||||
|
||||
struct mbim_cid_packet_statistics_info {
|
||||
uint32_t in_discards;
|
||||
uint32_t in_errors;
|
||||
uint64_t in_octets;
|
||||
uint64_t in_packets;
|
||||
uint64_t out_octets;
|
||||
uint64_t out_packets;
|
||||
uint32_t out_errors;
|
||||
uint32_t out_discards;
|
||||
} __packed;
|
||||
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
struct mbim_descriptor {
|
||||
uByte bLength;
|
||||
uByte bDescriptorType;
|
||||
uByte bDescriptorSubtype;
|
||||
#define MBIM_VER_MAJOR(v) (((v) >> 8) & 0x0f)
|
||||
#define MBIM_VER_MINOR(v) ((v) & 0x0f)
|
||||
uWord bcdMBIMVersion;
|
||||
uWord wMaxControlMessage;
|
||||
uByte bNumberFilters;
|
||||
uByte bMaxFilterSize;
|
||||
uWord wMaxSegmentSize;
|
||||
uByte bmNetworkCapabilities;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* NCM Parameters
|
||||
*/
|
||||
#define NCM_GET_NTB_PARAMETERS 0x80
|
||||
|
||||
struct ncm_ntb_parameters {
|
||||
uWord wLength;
|
||||
uWord bmNtbFormatsSupported;
|
||||
#define NCM_FORMAT_NTB16 0x0001
|
||||
#define NCM_FORMAT_NTB32 0x0002
|
||||
uDWord dwNtbInMaxSize;
|
||||
uWord wNtbInDivisor;
|
||||
uWord wNtbInPayloadRemainder;
|
||||
uWord wNtbInAlignment;
|
||||
uWord wReserved1;
|
||||
uDWord dwNtbOutMaxSize;
|
||||
uWord wNtbOutDivisor;
|
||||
uWord wNtbOutPayloadRemainder;
|
||||
uWord wNtbOutAlignment;
|
||||
uWord wNtbOutMaxDatagrams;
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* NCM Encoding
|
||||
*/
|
||||
#define MBIM_HDR16_LEN \
|
||||
(sizeof(struct ncm_header16) + sizeof(struct ncm_pointer16))
|
||||
#define MBIM_HDR32_LEN \
|
||||
(sizeof(struct ncm_header32) + sizeof(struct ncm_pointer32))
|
||||
|
||||
struct ncm_header16 {
|
||||
#define NCM_HDR16_SIG 0x484d434e
|
||||
uDWord dwSignature;
|
||||
uWord wHeaderLength;
|
||||
uWord wSequence;
|
||||
uWord wBlockLength;
|
||||
uWord wNdpIndex;
|
||||
} __packed;
|
||||
|
||||
struct ncm_header32 {
|
||||
#define NCM_HDR32_SIG 0x686d636e
|
||||
uDWord dwSignature;
|
||||
uWord wHeaderLength;
|
||||
uWord wSequence;
|
||||
uDWord dwBlockLength;
|
||||
uDWord dwNdpIndex;
|
||||
} __packed;
|
||||
|
||||
|
||||
#define MBIM_NCM_NTH_SIDSHIFT 24
|
||||
#define MBIM_NCM_NTH_GETSID(s) (((s) > MBIM_NCM_NTH_SIDSHIFT) & 0xff)
|
||||
|
||||
struct ncm_pointer16_dgram {
|
||||
uWord wDatagramIndex;
|
||||
uWord wDatagramLen;
|
||||
} __packed;
|
||||
|
||||
struct ncm_pointer16 {
|
||||
#define MBIM_NCM_NTH16_IPS 0x00535049
|
||||
#define MBIM_NCM_NTH16_ISISG(s) (((s) & 0x00ffffff) == MBIM_NCM_NTH16_IPS)
|
||||
#define MBIM_NCM_NTH16_SIG(s) \
|
||||
((((s) & 0xff) << MBIM_NCM_NTH_SIDSHIFT) | MBIM_NCM_NTH16_IPS)
|
||||
uDWord dwSignature;
|
||||
uWord wLength;
|
||||
uWord wNextNdpIndex;
|
||||
|
||||
/* Minimum is two datagrams, but can be more */
|
||||
struct ncm_pointer16_dgram dgram[2];
|
||||
} __packed;
|
||||
|
||||
struct ncm_pointer32_dgram {
|
||||
uDWord dwDatagramIndex;
|
||||
uDWord dwDatagramLen;
|
||||
} __packed;
|
||||
|
||||
struct ncm_pointer32 {
|
||||
#define MBIM_NCM_NTH32_IPS 0x00737069
|
||||
#define MBIM_NCM_NTH32_ISISG(s) \
|
||||
(((s) & 0x00ffffff) == MBIM_NCM_NTH32_IPS)
|
||||
#define MBIM_NCM_NTH32_SIG(s) \
|
||||
((((s) & 0xff) << MBIM_NCM_NTH_SIDSHIFT) | MBIM_NCM_NTH32_IPS)
|
||||
uDWord dwSignature;
|
||||
uWord wLength;
|
||||
uWord wReserved6;
|
||||
uDWord dwNextNdpIndex;
|
||||
uDWord dwReserved12;
|
||||
|
||||
/* Minimum is two datagrams, but can be more */
|
||||
struct ncm_pointer32_dgram dgram[2];
|
||||
} __packed;
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* _MBIM_H_ */
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb.h,v 1.115 2017/01/19 16:05:00 skrll Exp $ */
|
||||
/* $NetBSD: usb.h,v 1.116 2018/07/31 16:44:30 khorben Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -205,6 +205,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
uByte bLength;
|
||||
uByte bDescriptorType;
|
||||
uByte bDescriptorSubtype;
|
||||
} UPACKED usb_descriptor_t;
|
||||
|
||||
typedef struct {
|
||||
@ -659,16 +660,19 @@ typedef struct {
|
||||
#define UISUBCLASS_VIDEOCOLLECTION 3
|
||||
|
||||
#define UICLASS_CDC 0x02 /* communication */
|
||||
#define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1
|
||||
#define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1
|
||||
#define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2
|
||||
#define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3
|
||||
#define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4
|
||||
#define UISUBCLASS_CAPI_CONTROLMODEL 5
|
||||
#define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
|
||||
#define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
|
||||
#define UIPROTO_CDC_NOCLASS 0 /* no class specific
|
||||
#define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3
|
||||
#define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4
|
||||
#define UISUBCLASS_CAPI_CONTROLMODEL 5
|
||||
#define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
|
||||
#define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
|
||||
#define UISUBCLASS_MOBILE_DIRECT_LINE_MODEL 10
|
||||
#define UISUBCLASS_NETWORK_CONTROL_MODEL 13
|
||||
#define UISUBCLASS_MOBILE_BROADBAND_INTERFACE_MODEL 14
|
||||
#define UIPROTO_CDC_NOCLASS 0 /* no class specific
|
||||
protocol required */
|
||||
#define UIPROTO_CDC_AT 1
|
||||
#define UIPROTO_CDC_AT 1
|
||||
|
||||
#define UICLASS_HID 0x03
|
||||
#define UISUBCLASS_BOOT 1
|
||||
@ -706,6 +710,7 @@ typedef struct {
|
||||
|
||||
#define UICLASS_CDC_DATA 0x0a
|
||||
#define UISUBCLASS_DATA 0
|
||||
#define UIPROTO_DATA_MBIM 0x02 /* MBIM */
|
||||
#define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */
|
||||
#define UIPROTO_DATA_HDLC 0x31 /* HDLC */
|
||||
#define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usbdi.c,v 1.175 2017/10/28 00:37:12 pgoyette Exp $ */
|
||||
/* $NetBSD: usbdi.c,v 1.176 2018/07/31 16:44:30 khorben Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.175 2017/10/28 00:37:12 pgoyette Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.176 2018/07/31 16:44:30 khorben Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
@ -70,6 +70,7 @@ static void *usbd_alloc_buffer(struct usbd_xfer *, uint32_t);
|
||||
static void usbd_free_buffer(struct usbd_xfer *);
|
||||
static struct usbd_xfer *usbd_alloc_xfer(struct usbd_device *, unsigned int);
|
||||
static usbd_status usbd_free_xfer(struct usbd_xfer *);
|
||||
static void usbd_request_async_cb(struct usbd_xfer *, void *, usbd_status);
|
||||
|
||||
#if defined(USB_DEBUG)
|
||||
void
|
||||
@ -1120,6 +1121,36 @@ usbd_do_request_flags(struct usbd_device *dev, usb_device_request_t *req,
|
||||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
usbd_request_async_cb(struct usbd_xfer *xfer, void *priv, usbd_status status)
|
||||
{
|
||||
usbd_free_xfer(xfer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute a request without waiting for completion.
|
||||
* Can be used from interrupt context.
|
||||
*/
|
||||
usbd_status
|
||||
usbd_request_async(struct usbd_device *dev, struct usbd_xfer *xfer,
|
||||
usb_device_request_t *req, void *priv, usbd_callback callback)
|
||||
{
|
||||
usbd_status err;
|
||||
|
||||
if (callback == NULL)
|
||||
callback = usbd_request_async_cb;
|
||||
|
||||
usbd_setup_default_xfer(xfer, dev, priv,
|
||||
USBD_DEFAULT_TIMEOUT, req, NULL, UGETW(req->wLength), 0,
|
||||
callback);
|
||||
err = usbd_transfer(xfer);
|
||||
if (err != USBD_IN_PROGRESS) {
|
||||
usbd_free_xfer(xfer);
|
||||
return (err);
|
||||
}
|
||||
return (USBD_NORMAL_COMPLETION);
|
||||
}
|
||||
|
||||
const struct usbd_quirks *
|
||||
usbd_get_quirks(struct usbd_device *dev)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usbdi.h,v 1.93 2018/07/29 01:59:46 riastradh Exp $ */
|
||||
/* $NetBSD: usbdi.h,v 1.94 2018/07/31 16:44:30 khorben Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -139,6 +139,8 @@ usbd_status usbd_sync_transfer(struct usbd_xfer *);
|
||||
usbd_status usbd_sync_transfer_sig(struct usbd_xfer *);
|
||||
|
||||
usbd_status usbd_do_request(struct usbd_device *, usb_device_request_t *, void *);
|
||||
usbd_status usbd_request_async(struct usbd_device *, struct usbd_xfer *,
|
||||
usb_device_request_t *, void *, usbd_callback);
|
||||
usbd_status usbd_do_request_flags(struct usbd_device *, usb_device_request_t *,
|
||||
void *, uint16_t, int *, uint32_t);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if_types.h,v 1.28 2018/01/10 10:56:30 knakahara Exp $ */
|
||||
/* $NetBSD: if_types.h,v 1.29 2018/07/31 16:44:30 khorben Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
@ -266,5 +266,6 @@
|
||||
#define IFT_L2TP 0xf7 /* L2TPv3 I/F */
|
||||
#define IFT_CARP 0xf8 /* Common Address Redundancy Protocol */
|
||||
#define IFT_IPSEC 0xf9 /* IPsec I/F */
|
||||
#define IFT_MBIM 0xfa /* Mobile Broadband Interface Model */
|
||||
|
||||
#endif /* !_NET_IF_TYPES_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sockio.h,v 1.33 2015/05/02 14:41:32 roy Exp $ */
|
||||
/* $NetBSD: sockio.h,v 1.34 2018/07/31 16:44:30 khorben Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993, 1994
|
||||
@ -139,6 +139,10 @@
|
||||
#define SIOCGETHERCAP _IOWR('i', 139, struct eccapreq) /* get ethercap */
|
||||
#define SIOCGIFINDEX _IOWR('i', 140, struct ifreq) /* get ifnet index */
|
||||
|
||||
#define SIOCGUMBINFO _IOWR('i', 190, struct ifreq) /* get MBIM info */
|
||||
#define SIOCSUMBPARAM _IOW('i', 191, struct ifreq) /* set MBIM param */
|
||||
#define SIOCGUMBPARAM _IOWR('i', 192, struct ifreq) /* get MBIM param */
|
||||
|
||||
#define SIOCSETPFSYNC _IOW('i', 247, struct ifreq)
|
||||
#define SIOCGETPFSYNC _IOWR('i', 248, struct ifreq)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user