[OpenWrt-Devel] [PATCH] umbim: add home provider query support
This adds support to query the home provider, mainly for debugging and information purposes. Signed-off-by: Ingo Feinerer --- cli.c | 36 +++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/cli.c b/cli.c index 19f36f4..ea7e0b0 100644 --- a/cli.c +++ b/cli.c @@ -95,6 +95,31 @@ mbim_pin_state_response(void *buffer, size_t len) return 0; } +static int +mbim_home_provider_response(void *buffer, size_t len) +{ + struct mbim_basic_connect_home_provider_r *state = (struct mbim_basic_connect_home_provider_r *) buffer; + char *provider_id, *provider_name; + + if (len < sizeof(struct mbim_basic_connect_home_provider_r)) { + fprintf(stderr, "message not long enough\n"); + return -1; + } + struct mbimprovider *provider = &state->provider; + + provider_id = mbim_get_string(&provider->providerid, buffer); + provider_name = mbim_get_string(&provider->providername, buffer); + + printf(" provider_id: %s\n", provider_id); + printf(" provider_name: %s\n", provider_name); + printf(" cellularclass: %04X - %s\n", le32toh(provider->cellularclass), + mbim_enum_string(mbim_cellular_class_values, le32toh(provider->cellularclass))); + printf(" rssi: %04X\n", le32toh(provider->rssi)); + printf(" errorrate: %04X\n", le32toh(provider->errorrate)); + + return 0; +} + static int mbim_registration_response(void *buffer, size_t len) { @@ -294,6 +319,14 @@ mbim_pin_state_request(void) return mbim_send_command_msg(); } +static int +mbim_home_provider_request(void) +{ + mbim_setup_command_msg(basic_connect, MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CID_BASIC_CONNECT_HOME_PROVIDER, 0); + + return mbim_send_command_msg(); +} + static int mbim_registration_request(void) { @@ -478,6 +511,7 @@ static struct mbim_handler handlers[] = { { "caps", 0, mbim_device_caps_request, mbim_device_caps_response }, { "pinstate", 0, mbim_pin_state_request, mbim_pin_state_response }, { "unlock", 1, mbim_pin_unlock_request, mbim_pin_state_response }, + { "home", 0, mbim_home_provider_request, mbim_home_provider_response }, { "registration", 0, mbim_registration_request, mbim_registration_response }, { "subscriber", 0, mbim_subscriber_request, mbim_subscriber_response }, { "attach", 0, mbim_attach_request, mbim_attach_response }, @@ -491,7 +525,7 @@ static struct mbim_handler handlers[] = { static int usage(void) { - fprintf(stderr, "Usage: umbim [options]\n" + fprintf(stderr, "Usage: umbim [options]\n" "Options:\n" #ifdef LIBQMI_MBIM_PROXY "-p use mbim-proxy\n" -- 2.22.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] umbim: add home provider query support
This adds support to query the home provider, mainly for debugging and information purposes. Signed-off-by: Ingo Feinerer --- cli.c | 37 - 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/cli.c b/cli.c index 19f36f4..3a845d4 100644 --- a/cli.c +++ b/cli.c @@ -95,6 +95,32 @@ mbim_pin_state_response(void *buffer, size_t len) return 0; } +static int +mbim_home_provider_response(void *buffer, size_t len) +{ + struct mbim_basic_connect_home_provider_r *state = (struct mbim_basic_connect_home_provider_r *) buffer; + struct mbimprovider *provider; + char *provider_id, *provider_name; + + if (len < sizeof(struct mbim_basic_connect_home_provider_r)) { + fprintf(stderr, "message not long enough\n"); + return -1; + } + + provider = &state->provider; + provider_id = mbim_get_string(&provider->providerid, buffer); + provider_name = mbim_get_string(&provider->providername, buffer); + + printf(" provider_id: %s\n", provider_id); + printf(" provider_name: %s\n", provider_name); + printf(" cellularclass: %04X - %s\n", le32toh(provider->cellularclass), + mbim_enum_string(mbim_cellular_class_values, le32toh(provider->cellularclass))); + printf(" rssi: %04X\n", le32toh(provider->rssi)); + printf(" errorrate: %04X\n", le32toh(provider->errorrate)); + + return 0; +} + static int mbim_registration_response(void *buffer, size_t len) { @@ -294,6 +320,14 @@ mbim_pin_state_request(void) return mbim_send_command_msg(); } +static int +mbim_home_provider_request(void) +{ + mbim_setup_command_msg(basic_connect, MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CID_BASIC_CONNECT_HOME_PROVIDER, 0); + + return mbim_send_command_msg(); +} + static int mbim_registration_request(void) { @@ -478,6 +512,7 @@ static struct mbim_handler handlers[] = { { "caps", 0, mbim_device_caps_request, mbim_device_caps_response }, { "pinstate", 0, mbim_pin_state_request, mbim_pin_state_response }, { "unlock", 1, mbim_pin_unlock_request, mbim_pin_state_response }, + { "home", 0, mbim_home_provider_request, mbim_home_provider_response }, { "registration", 0, mbim_registration_request, mbim_registration_response }, { "subscriber", 0, mbim_subscriber_request, mbim_subscriber_response }, { "attach", 0, mbim_attach_request, mbim_attach_response }, @@ -491,7 +526,7 @@ static struct mbim_handler handlers[] = { static int usage(void) { - fprintf(stderr, "Usage: umbim [options]\n" + fprintf(stderr, "Usage: umbim [options]\n" "Options:\n" #ifdef LIBQMI_MBIM_PROXY "-p use mbim-proxy\n" -- 2.22.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] umbim: add home provider query support
On Sun, Aug 04, 2019 at 10:25:01AM +0200, John Crispin wrote: > > +static int > > +mbim_home_provider_response(void *buffer, size_t len) > > +{ > > + struct mbim_basic_connect_home_provider_r *state = (struct > > mbim_basic_connect_home_provider_r *) buffer; > > + char *provider_id, *provider_name; > > + > > + if (len < sizeof(struct mbim_basic_connect_home_provider_r)) { > > + fprintf(stderr, "message not long enough\n"); > > + return -1; > > + } > > + struct mbimprovider *provider = &state->provider; > > please move this to the start of the function Thanks for the remark. I moved the declaration to the start of the function but kept the initialization below the length check (with the idea to better not touch the struct if something is known to be wrong with it). Best regards, Ingo ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] umbim: add registration set support
This implements the MBIM automatic registration mode to let the function select the best provider network. Signed-off-by: Ingo Feinerer --- cli.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cli.c b/cli.c index 1dd6330..e00b6d4 100644 --- a/cli.c +++ b/cli.c @@ -297,7 +297,16 @@ mbim_pin_state_request(void) static int mbim_registration_request(void) { - mbim_setup_command_msg(basic_connect, MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CMD_BASIC_CONNECT_REGISTER_STATE, 0); + if (_argc > 0) { + struct mbim_basic_connect_register_state_s *rs = + (struct mbim_basic_connect_register_state_s *) mbim_setup_command_msg(basic_connect, + MBIM_MESSAGE_COMMAND_TYPE_SET, MBIM_CMD_BASIC_CONNECT_REGISTER_STATE, + sizeof(struct mbim_basic_connect_register_state_s)); + + rs->registeraction = htole32(MBIM_REGISTER_ACTION_AUTOMATIC); + } else { + mbim_setup_command_msg(basic_connect, MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CMD_BASIC_CONNECT_REGISTER_STATE, 0); + } return mbim_send_command_msg(); } -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] umbim: registration set support
Hi, this mail gives a detailed background explanation and motivation for the patch "[PATCH] umbim: add registration set support" (the analysis is probably too lengthy to be included as a commit message). I am using a Medion S4222 (MediaTek OEM) USB stick and it failed to connect in OpenWrt: # umbim -n -d /dev/cdc-wdm0 connect "drei.at" sending (124): 03 00 00 00 7c 00 00 00 07 00 00 00 01 00 00 00 00 00 00 00 a2 89 cc 33 bc bb 8b 4f b6 b0 13 3e c2 aa e6 df 0c 00 00 00 01 00 00 00 4c 00 00 00 00 00 00 00 01 00 00 00 3c 00 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7e 5e 2a 7e 4e 6f 72 72 73 6b 65 6e 7e 5e 2a 7e 64 00 72 00 65 00 69 00 2e 00 61 00 74 00 00 00 header_type: 0003 header_length: 007C header_transaction: 0007 reading (48): 03 00 00 80 30 00 00 00 07 00 00 00 01 00 00 00 00 00 00 00 a2 89 cc 33 bc bb 8b 4f b6 b0 13 3e c2 aa e6 df 0c 00 00 00 07 00 00 00 00 00 00 00 header_type: 8003 header_length: 0030 header_transaction: 0007 command_id: 000C status_code: 0007 According to the MBIM specification the status code means: MBIM_STATUS_NOT_REGISTERED 7 The operation failed because the device is not registered with any network. Unfortunately, just calling the registration function in query mode before the connect attempt is not enough in my setup: # umbim -n -d /dev/cdc-wdm0 registration nwerror: - unknown registerstate: 0004 - roaming registermode: 0001 - automatic availabledataclasses: 0018 - (null) currentcellularclass: 0001 - gsm provider_id: 23205 provider_name: 23205 roamingtext: (null) With the new function the connect method succeeds and gives me a working IPv4 address. # umbim -n -d /dev/cdc-wdm0 registration automatic nwerror: - unknown registerstate: 0003 - home registermode: 0001 - automatic availabledataclasses: 0018 - (null) currentcellularclass: 0001 - gsm provider_id: 23210 provider_name: 23210 roamingtext: (null) As you see the registerstate is now "home" and there was a mobile network code change (23205 -> 23210). The MBIM specification mentions that both manual and automatic registration could be possible. I only implemented automatic; this seems to be in line with what mbimcli supports (--register-automatic); see https://manpages.debian.org/stretch/libmbim-utils/mbimcli.1.en.html. I assume that any argument (_argc > 0) triggers the setter so that the call could look like umbim ... registration automatic or umbim ... registration on and allows one to extended it later for manual setting with additional arguments for the manual registration process. As the existing call convention (i.e., no arguments) is not modified existing scripts (like /lib/netifd/proto/mbim.sh in OpenWrt) still work without adaption. Note that rs->registeraction = htole32(MBIM_REGISTER_ACTION_AUTOMATIC) is redundant as MBIM_REGISTER_ACTION_AUTOMATIC is defined as 0 (and the whole buffer is memset to zero before) but I thought it is clearer for the reader. Thanks a lot for consideration! Best regards, Ingo ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] umbim: registration set support
Hi, anyone willing to review/commit this diff? http://lists.infradead.org/pipermail/openwrt-devel/2019-January/015445.html http://lists.infradead.org/pipermail/openwrt-devel/2019-January/015444.html Thank you. Best regards, Ingo ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] umbim: update to latest git HEAD
184b707 umbim: add home provider query support Signed-off-by: Ingo Feinerer --- package/network/utils/umbim/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/utils/umbim/Makefile b/package/network/utils/umbim/Makefile index 66d25718cf..417363f4da 100644 --- a/package/network/utils/umbim/Makefile +++ b/package/network/utils/umbim/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/umbim.git -PKG_SOURCE_DATE:=2019-03-11 -PKG_SOURCE_VERSION:=24f9dc71a624cecd67c181cec77b4101038a39d9 -PKG_MIRROR_HASH:=452bd6f1019ce53fd02119b12a8d6b13e946b73de02642e20e9fd85c482c452d +PKG_SOURCE_DATE:=2019-09-11 +PKG_SOURCE_VERSION:=184b707ddaa0acee84d02e0ffe599cb8b67782bd +PKG_MIRROR_HASH:=482ff69144f81fafed99035840f5a24e772472f2df2f3ac0219d6de791ac5835 PKG_MAINTAINER:=John Crispin PKG_LICENSE:=GPL-2.0 -- 2.23.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel