From f17ebb6c8aa63e8d318b069140a4115af0793ff7 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Tue, 4 Feb 2020 14:51:02 +0100 Subject: umbim: allow sessionid != 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MBIM supports multiplexed IP sessions for connecting to more than one APN. The connect, config and disconnect operations are session specific. Add support for operatin on non-default sessions. Signed-off-by: Bjørn Mork --- cli.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cli.c b/cli.c index 3a845d4..d58ce64 100644 --- a/cli.c +++ b/cli.c @@ -40,6 +40,7 @@ struct mbim_handler *current_handler; static uint8_t uuid_context_type_internet[16] = { 0x7E, 0x5E, 0x2A, 0x7E, 0x4E, 0x6F, 0x72, 0x72, 0x73, 0x6B, 0x65, 0x6E, 0x7E, 0x5E, 0x2A, 0x7E }; static int _argc; static char **_argv; +static int sessionid; static int mbim_device_caps_response(void *buffer, size_t len) @@ -251,6 +252,7 @@ mbim_config_response(void *buffer, size_t len) return -1; } + printf(" sessionid: %d\n", le32toh(ip->sessionid)); if (le32toh(ip->ipv4configurationavailable) & MBIM_IP_CONFIGURATION_AVAILABLE_FLAG_ADDRESS) for (i = 0; i < le32toh(ip->ipv4addresscount); i++) { offset = le32toh(ip->ipv4address) + (i * 4); @@ -387,6 +389,7 @@ mbim_connect_request(void) MBIM_MESSAGE_COMMAND_TYPE_SET, MBIM_CMD_BASIC_CONNECT_CONNECT, sizeof(struct mbim_basic_connect_connect_s)); + c->sessionid = htole32(sessionid); c->activationcommand = htole32(MBIM_ACTIVATION_COMMAND_ACTIVATE); c->iptype = htole32(MBIM_CONTEXT_IP_TYPE_DEFAULT); memcpy(c->contexttype, uuid_context_type_internet, 16); @@ -430,6 +433,7 @@ mbim_disconnect_request(void) MBIM_MESSAGE_COMMAND_TYPE_SET, MBIM_CMD_BASIC_CONNECT_CONNECT, sizeof(struct mbim_basic_connect_connect_s)); + c->sessionid = htole32(sessionid); c->activationcommand = htole32(MBIM_ACTIVATION_COMMAND_DEACTIVATE); memcpy(c->contexttype, uuid_context_type_internet, 16); @@ -480,10 +484,12 @@ mbim_pin_unlock_request(void) static int mbim_config_request(void) { - mbim_setup_command_msg(basic_connect, - MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CMD_BASIC_CONNECT_IP_CONFIGURATION, - sizeof(struct mbim_basic_connect_ip_configuration_q)); + struct mbim_basic_connect_ip_configuration_q *q = + (struct mbim_basic_connect_ip_configuration_q *)mbim_setup_command_msg(basic_connect, + MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CMD_BASIC_CONNECT_IP_CONFIGURATION, + sizeof(struct mbim_basic_connect_ip_configuration_q)); + q->sessionid = htole32(sessionid); return mbim_send_command_msg(); } @@ -533,6 +539,7 @@ usage(void) #endif " -d the device (/dev/cdc-wdmX)\n" " -t the transaction id\n" + " -s sessionid for connect|disconnect|config\n" " -n no close\n\n" " -v verbose\n\n"); return 1; @@ -548,7 +555,7 @@ main(int argc, char **argv) int proxy = 0; #endif - while ((ch = getopt(argc, argv, "pnvd:t:")) != -1) { + while ((ch = getopt(argc, argv, "pnvd:t:s:")) != -1) { switch (ch) { case 'v': verbose = 1; @@ -563,6 +570,9 @@ main(int argc, char **argv) no_open = 1; transaction_id = atoi(optarg); break; + case 's': + sessionid = atoi(optarg); + break; #ifdef LIBQMI_MBIM_PROXY case 'p': proxy = 1; -- cgit v1.2.3