From 599a5b60ae6421481d1c471377405b41d63b3095 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Sun, 4 Jul 2021 19:22:33 +0000 Subject: 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 --- sbin/ifconfig/ifconfig.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'sbin/ifconfig/ifconfig.c') 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"); } -- cgit v1.2.3