umb(4) WIP diff and questions

2020-01-14 Thread leeb
Hello again tech@

I've included diffs of what I've got so far at the bottom 
of this mail, but first a couple of questions:

- Using the full 510-character limits for username and
passphrase specified in the MBIM spec, kernel compilation 
fails due to tripping the 2047-byte stack frame warning
when compiling the driver. That's the reason for the '100'
magic numbers that I put in there temporarily.

Any hints on the best way to handle this would be appreciated. 

- I included the username/passphrase fields in the ifconfig
output, as it seems to me that APN settings are generally
made public so end-users can configure their own devices
If needed I'll take it out, or perhaps change it to display 
'*set*' (or similar) if you think it should be hidden?

A couple of other points:

- Wireless providers where I am all seem to require a
username/password with the APN. So I'm unable to confirm
whether or not this breaks non-authenticated connections.

- I've been building my kernel using the documented 
procedure, and have no problems there. I ran through a
base system build and that (eventually) completed OK too.
When compiling ifconfig(8), I've been doing 'make includes'
in /usr/src (after installing and booting my new kernel), 
and using 'make ifconfig' and 'make install' in 
/usr/src/sbin/ifconfig. Is this OK? or should I be doing 
something else instead?

Thanks,

Lee.


Index: sbin/ifconfig/ifconfig.8
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.343
diff -u -p -u -p -r1.343 ifconfig.8
--- sbin/ifconfig/ifconfig.810 Nov 2019 09:10:44 -  1.343
+++ sbin/ifconfig/ifconfig.814 Jan 2020 11:56:06 -
@@ -1914,6 +1914,9 @@ Clear the virtual network identifier.
 .Op Cm pin Ar pin
 .Op Cm puk Ar puk Ar newpin
 .Op Oo Fl Oc Ns Cm roaming
+.Op Oo Fl Oc Ns Cm umbuser Ar user
+.Op Oo Fl Oc Ns Cm umbpasswd Ar password
+.Op Oo Fl Oc Ns Cm umbauth Ar authmethod
 .Ek
 .nr nS 0
 .Pp
@@ -1960,6 +1963,26 @@ to validate the request.
 Enable data roaming.
 .It Cm -roaming
 Disable data roaming.
+.It Cm umbuser Ar user
+Set the authentication username.
+.It Cm -umbuser
+Clear the current username.
+.It Cm umbpasswd Ar password
+Set the authentication password.
+.It Cm -umbpasswd
+Clear the current password.
+.It Cm umbauth Ar authmethod
+Set the authentication method. Valid methods are:
+.Ar none ,
+.Ar pap ,
+.Ar chap ,
+.Ar mschap .
+Specifying an invalid method will cause a value of
+.Ar none 
+to be used.
+.It Cm -umbauth
+Clear the authentication method. Equivalent to
+.Cm umbauth none .
 .It Cm up
 As soon as the interface is marked as "up", the
 .Xr umb 4
Index: sbin/ifconfig/ifconfig.c
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.417
diff -u -p -u -p -r1.417 ifconfig.c
--- sbin/ifconfig/ifconfig.c27 Dec 2019 14:34:46 -  1.417
+++ sbin/ifconfig/ifconfig.c14 Jan 2020 11:56:06 -
@@ -339,6 +339,9 @@ voidumb_chgpin(const char *, const char
 void   umb_puk(const char *, const char *);
 void   umb_pinop(int, int, const char *, const char *);
 void   umb_apn(const char *, int);
+void   umb_user(const char *, int);
+void   umb_passwd(const char *, int);
+void   umb_authentication(const char *, int);
 void   umb_setclass(const char *, int);
 void   umb_roaming(const char *, int);
 void   utf16_to_char(uint16_t *, int, char *, size_t);
@@ -587,6 +590,12 @@ const struct   cmd {
{ "puk",NEXTARG2,   0,  NULL, umb_puk },
{ "apn",NEXTARG,0,  umb_apn },
{ "-apn",   -1, 0,  umb_apn },
+   { "umbuser",NEXTARG,0,  umb_user },
+   { "-umbuser",   -1, 0,  umb_user },
+   { "umbpasswd",  NEXTARG,0,  umb_passwd },
+   { "-umbpasswd", -1, 0,  umb_passwd },
+   { "umbauth",NEXTARG,0,  umb_authentication },
+   { "-umbauth",   -1, 0,  umb_authentication },
{ "class",  NEXTARG0,   0,  umb_setclass },
{ "-class", -1, 0,  umb_setclass },
{ "roaming",1,  0,  umb_roaming },
@@ -5628,6 +5637,7 @@ setifpriority(const char *id, int param)
 
 const struct umb_valdescr umb_regstate[] = MBIM_REGSTATE_DESCRIPTIONS;
 const struct umb_valdescr umb_dataclass[] = MBIM_DATACLASS_DESCRIPTIONS;
+const struct umb_valdescr umb_authprot[] = MBIM_AUTHPROT_DESCRIPTIONS;
 const struct umb_valdescr umb_simstate[] = MBIM_SIMSTATE_DESCRIPTIONS;
 const struct umb_valdescr umb_istate[] = UMB_INTERNAL_STATE_DESCRIPTIONS;
 const struct umb_valdescr umb_pktstate[] = MBIM_PKTSRV_STATE_DESCRIPTIONS;
@@ -5665,6 +5675,9 @@ umb_status(void)
char iccid[UMB_ICCID_MAXLEN+1];
char

Re: umb(4) authentication

2020-01-13 Thread leeb
On Mon, Jan 13, 2020 at 04:42:22PM +0100, Martijn van Duren wrote:
> On 1/13/20 4:30 PM, Anders Andersson wrote:
> > On Mon, Jan 13, 2020 at 3:00 PM leeb  wrote:
> >>
> >> Hello,
> >>
 
> >>
> >> Thanks,
> >>
> >> Lee.
> > 
> > This email should be gold plated and moved to a permanent location in
> > the FAQ on how to help OpenBSD and how to request new features.
> > 
> Lee is obviously new to the community and doesn't know the workflow well
> enough. He tries to be polite and make sure he doesn't clutter the list.
> If you actually read his mail you would've seen that he has a diff and
> it works for him, so it's obviously not a dumb feature request.
> 
> Please refrain from ridiculing people with good intentions.
> 

I originally read Anders' mail as complimentary, but now I'm not so sure?

Lee.



umb(4) authentication

2020-01-13 Thread leeb
Hello,

I had an itch, so I scratched it.

The umb(4) driver has a FIXME in if_umb.c for user name
and passphrase support. My LTE provider happens to require
this so I thought I'd have a go. 

The provider seems happy with my umb changes, and I've 
added some bits in ifconfig(8) to allow setting of the
authentication information (user/pass/protocol):

umb0: flags=8851 mtu 1500
index 5 priority 6 llprio 3
roaming disabled registration home network
state up cell-class LTE rssi -67dBm speed 47.7Mps up 95.4Mps down
SIM initialized PIN valid (3 attempts left)
subscriber-id 999 ICC-id 999 provider 
xx
device MC7700 IMEI 999 firmware SWI9200X_03.05.19.00Aap
phone# 999 APN xx User  Pass x Auth CHAP
dns x.x.x.x x.x.x.x
groups: egress
status: active
inet x.x.x.x --> x.x.x.x netmask 0xfffc

(please excuse line wraps, and I've redacted possibly 
sensitive info)

Now, this is my first attempt at OpenBSD development, and
writing my changes raised a few questions. So, does someone
want to spare a few minutes off-list, or should I just 
clutter up tech@ ? 

(I've read the top of the Makefile, I've been through the
web pages on AnonCVS and release(8))

Thanks,

Lee.