From: sthen Date: Sun, 4 Jul 2021 19:22:31 +0000 (+0000) Subject: store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5a5baf73d63c950ad2fd5afa5cfd410472f6f43e;p=openbsd store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt Previously only the provider's display name was used. The text used depends on how the SIM is configured and not just on the network in use (for example, an MVNO SIM on another network will often display the MVNO's name rather than that of the underlying network). I have a SIM that roams to any network in my country - whichever network it roams onto, the display name is the same, so you can't tell which network you're really using. By printing the provider ID (in GSM-land this is MCC+MNC) it's easy to lookup and check this. As the provider was printed on the ifconfig line also showing subscriber-id and ICCID it was already a bit long, and adding the provider-id there is a bit too much, so move it to the output line showing APN, now looking like : subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx : device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0 : APN key provider Tele2 IoT provider-id 23420 --- diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index c527dadadaf..20b68c1f95d 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.442 2021/03/20 17:11:49 florian Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.443 2021/07/04 19:22:32 sthen Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -6012,6 +6012,7 @@ umb_status(void) { struct umb_info mi; char provider[UMB_PROVIDERNAME_MAXLEN+1]; + char providerid[UMB_PROVIDERID_MAXLEN+1]; char roamingtxt[UMB_ROAMINGTEXT_MAXLEN+1]; char devid[UMB_DEVID_MAXLEN+1]; char fwinfo[UMB_FWINFO_MAXLEN+1]; @@ -6124,15 +6125,15 @@ umb_status(void) utf16_to_char(mi.iccid, UMB_ICCID_MAXLEN, iccid, sizeof (iccid)); utf16_to_char(mi.provider, UMB_PROVIDERNAME_MAXLEN, provider, sizeof (provider)); - if (sid[0] || iccid[0] || provider[0]) { + utf16_to_char(mi.providerid, UMB_PROVIDERID_MAXLEN, + providerid, sizeof (providerid)); + if (sid[0] || iccid[0]) { printf("\t"); n = 0; if (sid[0]) printf("%ssubscriber-id %s", n++ ? " " : "", sid); if (iccid[0]) printf("%sICC-id %s", n++ ? " " : "", iccid); - if (provider[0]) - printf("%sprovider %s", n ? " " : "", provider); printf("\n"); } @@ -6173,13 +6174,17 @@ umb_status(void) utf16_to_char(mi.pn, UMB_PHONENR_MAXLEN, pn, sizeof (pn)); utf16_to_char(mi.apn, UMB_APN_MAXLEN, apn, sizeof (apn)); - if (pn[0] || apn[0]) { + if (pn[0] || apn[0] || provider[0] || providerid[0]) { printf("\t"); n = 0; if (pn[0]) printf("%sphone# %s", n++ ? " " : "", pn); if (apn[0]) printf("%sAPN %s", n++ ? " " : "", apn); + if (provider[0]) + printf("%sprovider %s", n++ ? " " : "", provider); + if (providerid[0]) + printf("%sprovider-id %s", n ? " " : "", providerid); printf("\n"); } diff --git a/sys/dev/usb/if_umb.c b/sys/dev/usb/if_umb.c index 9c585cf61af..2dac7d3fd1d 100644 --- a/sys/dev/usb/if_umb.c +++ b/sys/dev/usb/if_umb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_umb.c,v 1.45 2021/05/18 14:23:03 kevlo Exp $ */ +/* $OpenBSD: if_umb.c,v 1.46 2021/07/04 19:22:31 sthen Exp $ */ /* * Copyright (c) 2016 genua mbH @@ -1490,9 +1490,10 @@ umb_decode_register_state(struct umb_softc *sc, void *data, int len) sc->sc_info.regmode = letoh32(rs->regmode); sc->sc_info.cellclass = letoh32(rs->curcellclass); - /* XXX should we remember the provider_id? */ umb_getinfobuf(data, len, rs->provname_offs, rs->provname_size, sc->sc_info.provider, sizeof (sc->sc_info.provider)); + umb_getinfobuf(data, len, rs->provid_offs, rs->provid_size, + sc->sc_info.providerid, sizeof (sc->sc_info.providerid)); umb_getinfobuf(data, len, rs->roamingtxt_offs, rs->roamingtxt_size, sc->sc_info.roamingtxt, sizeof (sc->sc_info.roamingtxt)); diff --git a/sys/dev/usb/if_umb.h b/sys/dev/usb/if_umb.h index 082c0f0acd9..0b602b54258 100644 --- a/sys/dev/usb/if_umb.h +++ b/sys/dev/usb/if_umb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_umb.h,v 1.9 2021/03/30 15:59:04 patrick Exp $ */ +/* $OpenBSD: if_umb.h,v 1.10 2021/07/04 19:22:32 sthen Exp $ */ /* * Copyright (c) 2016 genua mbH @@ -282,6 +282,8 @@ struct umb_info { uint32_t cellclass; #define UMB_PROVIDERNAME_MAXLEN 20 uint16_t provider[UMB_PROVIDERNAME_MAXLEN]; +#define UMB_PROVIDERID_MAXLEN 20 + uint16_t providerid[UMB_PROVIDERID_MAXLEN]; #define UMB_PHONENR_MAXLEN 22 uint16_t pn[UMB_PHONENR_MAXLEN]; #define UMB_SUBSCRIBERID_MAXLEN 15