mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
umb: Introduce the USB umb(4) network driver
This includes the port of a driver originally from OpenBSD, later ported to NetBSD by the author: * The umb(4) kernel driver * The umbctl(8) companion tool This driver supports USB network devices implementing the Mobile Broadband Interface Model (MBIM), often found in modern (internal) USB models for 4G/LTE mobile broadband access. It is currently limited to IPv4. umbctl has to be used to display or set MBIM cellular modem interface parameters (4G/LTE). Differential Revision: https://reviews.freebsd.org/D48167 Approved by: adrian, zlei Sponsored by: FreeBSD Foundation PR: kern/263783 Submitted by: Pierre Pronchery <khorben@defora.org>
This commit is contained in:
parent
e5f3620a3e
commit
0f1bf1c22a
12 changed files with 4982 additions and 1 deletions
|
|
@ -63,6 +63,7 @@ SUBDIR=adjkerntz \
|
|||
swapon \
|
||||
sysctl \
|
||||
tunefs \
|
||||
umbctl \
|
||||
umount
|
||||
|
||||
.if ${MK_INET} != "no" || ${MK_INET6} != "no"
|
||||
|
|
|
|||
8
sbin/umbctl/Makefile
Normal file
8
sbin/umbctl/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CFLAGS+= -I${SRCTOP}/sys/dev/usb/net
|
||||
|
||||
PROG= umbctl
|
||||
MAN= umbctl.8
|
||||
|
||||
BINDIR= /sbin
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
161
sbin/umbctl/umbctl.8
Normal file
161
sbin/umbctl/umbctl.8
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
.\"-
|
||||
.\" SPDX-License-Identifier: BSD-2-Clause
|
||||
.\"
|
||||
.\" Copyright (c) 2018 by Pierre Pronchery <khorben@defora.org>
|
||||
.\"
|
||||
.\" 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 $
|
||||
.\"
|
||||
.\" $NetBSD: umbctl.8,v 1.3 2020/03/22 07:45:02 khorben Exp $
|
||||
.\"
|
||||
.\" last edit-date: [Fri Dec 20 18:20:00 2024]
|
||||
.\"
|
||||
.Dd December 20, 2024
|
||||
.Dt UMBCTL 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm umbctl
|
||||
.Nd display or set MBIM cellular modem interface parameters (4G/LTE)
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl v
|
||||
.Ar ifname
|
||||
.Op Ar parameter Op Ar value
|
||||
.Ar ...
|
||||
.Nm
|
||||
.Op Fl v
|
||||
.Fl f Ar config-file
|
||||
.Ar ifname
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
supports the following options:
|
||||
.Bl -tag -width "-f config_file"
|
||||
.It Fl f Ar config-file
|
||||
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.
|
||||
.It Fl v
|
||||
Enables verbose mode.
|
||||
.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 to 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 "username=username"
|
||||
.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
|
||||
Display the settings for umb0:
|
||||
.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
|
||||
Configure the connection parameters for umb0 from the command line:
|
||||
.Bd -literal
|
||||
# umbctl umb0 apn operator.internet username mobile password mobile
|
||||
.Ed
|
||||
.Pp
|
||||
Configure the connection parameters for umb0 from a file:
|
||||
.Bd -literal
|
||||
# umbctl -f /dev/stdin umb0 << EOF
|
||||
pin=1234
|
||||
EOF
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr netstat 1 ,
|
||||
.Xr umb 4 ,
|
||||
.Xr ifconfig 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility first appeared in
|
||||
.Nx 9.0 ,
|
||||
and
|
||||
.Fx 15.0 .
|
||||
.Sh AUTHORS
|
||||
The program was written by
|
||||
.An Pierre Pronchery .
|
||||
557
sbin/umbctl/umbctl.c
Normal file
557
sbin/umbctl/umbctl.c
Normal file
|
|
@ -0,0 +1,557 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Original copyright (c) 2018 Pierre Pronchery <khorben@defora.org> (for the
|
||||
* NetBSD Project)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (c) 2022 ADISTA SAS (FreeBSD updates)
|
||||
*
|
||||
* Updates for FreeBSD by Pierre Pronchery <pierre@defora.net>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT HOLDER 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.
|
||||
*
|
||||
* $NetBSD: umbctl.c,v 1.4 2020/05/13 21:44:30 khorben Exp $
|
||||
*/
|
||||
|
||||
#include <sys/endian.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mbim.h"
|
||||
#include "if_umbreg.h"
|
||||
|
||||
/* constants */
|
||||
static const struct umb_valdescr _umb_actstate[] =
|
||||
MBIM_ACTIVATION_STATE_DESCRIPTIONS;
|
||||
|
||||
static const struct umb_valdescr _umb_simstate[] =
|
||||
MBIM_SIMSTATE_DESCRIPTIONS;
|
||||
|
||||
static const struct umb_valdescr _umb_regstate[] =
|
||||
MBIM_REGSTATE_DESCRIPTIONS;
|
||||
|
||||
static const struct umb_valdescr _umb_pktstate[] =
|
||||
MBIM_PKTSRV_STATE_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_pin_state[] =
|
||||
{
|
||||
{ UMB_PIN_REQUIRED, "PIN required"},
|
||||
{ UMB_PIN_UNLOCKED, "PIN unlocked"},
|
||||
{ UMB_PUK_REQUIRED, "PUK required"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
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);
|
||||
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 = (caddr_t)&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 = (caddr_t)&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 _file_parse(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * filename);
|
||||
|
||||
static int _umbctl_file(char const * ifname, char const * filename, int verbose)
|
||||
{
|
||||
int fd;
|
||||
struct ifreq ifr;
|
||||
struct umb_parameter umbp;
|
||||
struct umb_info umbi;
|
||||
|
||||
if((fd = _umbctl_socket()) < 0)
|
||||
return 2;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_data = (caddr_t)&umbp;
|
||||
memset(&umbp, 0, sizeof(umbp));
|
||||
if(_umbctl_ioctl(ifname, fd, SIOCGUMBPARAM, &ifr) != 0
|
||||
|| _file_parse(ifname, &umbp, filename) != 0
|
||||
|| _umbctl_ioctl(ifname, fd, SIOCSUMBPARAM, &ifr) != 0)
|
||||
{
|
||||
close(fd);
|
||||
return 2;
|
||||
}
|
||||
if(verbose > 0)
|
||||
{
|
||||
ifr.ifr_data = (caddr_t)&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;
|
||||
}
|
||||
|
||||
static int _file_parse(char const * ifname, struct umb_parameter * umbp,
|
||||
char const * filename)
|
||||
{
|
||||
int ret = 0;
|
||||
FILE * fp;
|
||||
char buf[512];
|
||||
size_t len;
|
||||
int i;
|
||||
int eof;
|
||||
char * tokens[3] = { buf, NULL, NULL };
|
||||
char * p;
|
||||
|
||||
if((fp = fopen(filename, "r")) == NULL)
|
||||
return _error(2, "%s: %s", filename, strerror(errno));
|
||||
while(fgets(buf, sizeof(buf), fp) != NULL)
|
||||
{
|
||||
if(buf[0] == '#')
|
||||
continue;
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
if((len = strlen(buf)) > 0)
|
||||
{
|
||||
if(buf[len - 1] != '\n')
|
||||
{
|
||||
ret = _error(2, "%s: %s", filename,
|
||||
"Line too long");
|
||||
while((i = fgetc(fp)) != EOF && i != '\n');
|
||||
continue;
|
||||
}
|
||||
buf[len - 1] = '\0';
|
||||
}
|
||||
if((p = strchr(buf, '=')) != NULL)
|
||||
{
|
||||
tokens[1] = p + 1;
|
||||
*p = '\0';
|
||||
} else
|
||||
tokens[1] = NULL;
|
||||
ret |= _umbctl_set(ifname, umbp, (p != NULL) ? 2 : 1, tokens)
|
||||
? 2 : 0;
|
||||
}
|
||||
eof = feof(fp);
|
||||
if(fclose(fp) != 0 || !eof)
|
||||
return _error(2, "%s: %s", filename, strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* 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:gv")) != -1)
|
||||
switch(o)
|
||||
{
|
||||
case 'f':
|
||||
filename = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
default:
|
||||
return _usage();
|
||||
}
|
||||
if(optind == argc)
|
||||
return _usage();
|
||||
if(filename != NULL)
|
||||
{
|
||||
if(optind + 1 != argc)
|
||||
return _usage();
|
||||
return _umbctl_file(argv[optind], filename, verbose);
|
||||
}
|
||||
return _umbctl(argv[optind], verbose, argc - optind - 1,
|
||||
&argv[optind + 1]);
|
||||
}
|
||||
|
|
@ -1041,6 +1041,7 @@ MAN+= \
|
|||
uled.4 \
|
||||
ulpt.4 \
|
||||
umass.4 \
|
||||
umb.4 \
|
||||
umcs.4 \
|
||||
umct.4 \
|
||||
umodem.4 \
|
||||
|
|
|
|||
119
share/man/man4/umb.4
Normal file
119
share/man/man4/umb.4
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
.\"-
|
||||
.\" SPDX-License-Identifier: 0BSD
|
||||
.\"
|
||||
.\" 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.4 2019/08/30 09:22:17 wiz Exp $
|
||||
.\"
|
||||
.Dd August 24, 2019
|
||||
.Dt UMB 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm umb
|
||||
.Nd USB Mobile Broadband Interface Model (MBIM)
|
||||
.Sh SYNOPSIS
|
||||
To compile this driver into the kernel,
|
||||
place the following lines in your
|
||||
kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "device usb"
|
||||
.Cd "device umb"
|
||||
.Ed
|
||||
.Pp
|
||||
Alternatively, to load the driver as a
|
||||
module at boot time, place the following line in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
umb_load="YES"
|
||||
.Ed
|
||||
.Pp
|
||||
If neither of the above is done, the driver will automatically be loaded
|
||||
by devd(8) when the device is connected.
|
||||
.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
|
||||
.Nm
|
||||
driver should support any USB device implementing MBIM, including
|
||||
the following cellular modems:
|
||||
.Pp
|
||||
.Bl -bullet -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 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 ,
|
||||
.Nx 9.0 ,
|
||||
and
|
||||
.Fx 15.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 .
|
||||
|
|
@ -3293,6 +3293,7 @@ dev/usb/net/if_muge.c optional muge
|
|||
dev/usb/net/if_rue.c optional rue
|
||||
dev/usb/net/if_smsc.c optional smsc
|
||||
dev/usb/net/if_udav.c optional udav
|
||||
dev/usb/net/if_umb.c optional umb
|
||||
dev/usb/net/if_ure.c optional ure
|
||||
dev/usb/net/if_usie.c optional usie
|
||||
dev/usb/net/if_urndis.c optional urndis
|
||||
|
|
|
|||
2930
sys/dev/usb/net/if_umb.c
Normal file
2930
sys/dev/usb/net/if_umb.c
Normal file
File diff suppressed because it is too large
Load diff
443
sys/dev/usb/net/if_umbreg.h
Normal file
443
sys/dev/usb/net/if_umbreg.h
Normal file
|
|
@ -0,0 +1,443 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Original copyright (c) 2016 genua mbH (OpenBSD version)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (c) 2022 ADISTA SAS (re-write for FreeBSD)
|
||||
*
|
||||
* Re-write for FreeBSD by Pierre Pronchery <pierre@defora.net>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT HOLDER 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.
|
||||
*
|
||||
* $OpenBSD: if_umb.h,v 1.4 2017/04/18 13:27:55 gerhard Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mobile Broadband Interface Model
|
||||
* http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
uint16_t 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
|
||||
struct in_addr ipv4dns[UMB_MAX_DNSSRV];
|
||||
};
|
||||
|
||||
#if !defined(ifr_mtu)
|
||||
#define ifr_mtu ifr_ifru.ifru_metric
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* UMB device
|
||||
*/
|
||||
enum {
|
||||
UMB_INTR_RX,
|
||||
UMB_BULK_RX,
|
||||
UMB_BULK_TX,
|
||||
UMB_N_TRANSFER,
|
||||
};
|
||||
|
||||
struct umb_task {
|
||||
struct usb_proc_msg hdr;
|
||||
struct umb_softc *sc;
|
||||
};
|
||||
|
||||
struct umb_softc {
|
||||
device_t sc_dev;
|
||||
struct ifnet *sc_if;
|
||||
#define GET_IFP(sc) ((sc)->sc_if)
|
||||
struct ifmedia sc_im;
|
||||
struct usb_device *sc_udev;
|
||||
struct usb_xfer *sc_xfer[UMB_N_TRANSFER];
|
||||
uint8_t sc_ifaces_index[2];
|
||||
|
||||
int sc_ver_maj;
|
||||
int sc_ver_min;
|
||||
int sc_ctrl_len;
|
||||
int sc_maxpktlen;
|
||||
int sc_maxsessions;
|
||||
|
||||
#define UMBFLG_FCC_AUTH_REQUIRED 0x0001
|
||||
#define UMBFLG_NO_INET6 0x0002
|
||||
uint32_t sc_flags;
|
||||
int sc_cid;
|
||||
|
||||
struct usb_process sc_taskqueue;
|
||||
struct umb_task sc_proc_attach_task[2];
|
||||
struct umb_task sc_proc_start_task[2];
|
||||
struct umb_task sc_proc_state_task[2];
|
||||
struct umb_task sc_proc_get_response_task[2];
|
||||
|
||||
int sc_nresp;
|
||||
struct mtx sc_mutex;
|
||||
struct usb_callout sc_statechg_timer;
|
||||
char sc_dying;
|
||||
char sc_attached;
|
||||
|
||||
uint8_t sc_ctrl_ifaceno;
|
||||
struct usb_interface *sc_data_iface;
|
||||
|
||||
void *sc_resp_buf;
|
||||
void *sc_ctrl_msg;
|
||||
|
||||
void *sc_rx_buf;
|
||||
uint32_t sc_rx_bufsz;
|
||||
unsigned sc_rx_nerr;
|
||||
struct ifqueue sc_rx_queue;
|
||||
|
||||
void *sc_tx_buf;
|
||||
struct mbuf *sc_tx_m;
|
||||
uint32_t sc_tx_bufsz;
|
||||
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 */
|
||||
727
sys/dev/usb/net/mbim.h
Normal file
727
sys/dev/usb/net/mbim.h
Normal file
|
|
@ -0,0 +1,727 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Original copyright (c) 2016 genua mbH (OpenBSD version)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (c) 2022 ADISTA SAS (re-write for FreeBSD)
|
||||
*
|
||||
* Re-write for FreeBSD by Pierre Pronchery <pierre@defora.net>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT HOLDER 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.
|
||||
*
|
||||
* $OpenBSD: mbim.h,v 1.4 2017/04/18 13:27:55 gerhard Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 wNdpInDivisor;
|
||||
uWord wNdpInPayloadRemainder;
|
||||
uWord wNdpInAlignment;
|
||||
uWord wReserved1;
|
||||
uDWord dwNtbOutMaxSize;
|
||||
uWord wNdpOutDivisor;
|
||||
uWord wNdpOutPayloadRemainder;
|
||||
uWord wNdpOutAlignment;
|
||||
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_ */
|
||||
|
|
@ -49,7 +49,7 @@ SUBDIR += ${_rum} ${_run} ${_runfw} ${_uath} upgt usie ural ${_zyd} ${_urtw}
|
|||
SUBDIR += atp cfumass uhid uhid_snes ukbd ums udbp uep wmt wsp ugold uled \
|
||||
usbhid
|
||||
SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom ufoma uftdi ugensa uipaq ulpt \
|
||||
umct umcs umodem umoscom uplcom uslcom uvisor uvscom
|
||||
umb umct umcs umodem umoscom uplcom uslcom uvisor uvscom
|
||||
SUBDIR += i2ctinyusb
|
||||
SUBDIR += cp2112
|
||||
SUBDIR += udl
|
||||
|
|
|
|||
33
sys/modules/usb/umb/Makefile
Normal file
33
sys/modules/usb/umb/Makefile
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright (c) 2008 Hans Petter Selasky. 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 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 THE AUTHOR 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.
|
||||
#
|
||||
|
||||
S= ${SRCTOP}/sys
|
||||
|
||||
.PATH: $S/dev/usb/net
|
||||
|
||||
KMOD= umb
|
||||
SRCS= opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h usbdevs.h \
|
||||
if_umb.c
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
Loading…
Add table
Reference in a new issue