diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-12-19 12:55:51 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-12-19 18:43:14 +0100 |
commit | 52d34ce0dbe375de646fd6ae25d2d8197d24dd32 (patch) | |
tree | cc3c108294044a2e3f3b6fbcf0c8527625e74b88 /src | |
parent | ab12d17bfb508e85c6b983b5d0ec8c915bd67a86 (diff) |
bearer-mbim: parse replies on failure
Based on a patch from: Bjørn Mork <bjorn@mork.no>
Some messages provide an additional NwError cause code from
the network in case of failure. This means that we need to
parse the reply even if the status indicates failure, to be
able to return the exact failure cause.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-bearer-mbim.c | 146 |
1 files changed, 91 insertions, 55 deletions
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index 2cfd1cfa..72cabebc 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -429,24 +429,36 @@ connect_set_ready (MbimDevice *device, response = mbim_device_command_finish (device, res, &error); if (response && - mbim_message_command_done_get_result (response, &error) && - mbim_message_connect_response_parse ( - response, - &session_id, - &activation_state, - NULL, /* voice_call_state */ - &ip_type, - NULL, /* context_type */ - &nw_error, - &error)) { - if (nw_error) - error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error); - else { - ctx->ip_type = ip_type; - mm_dbg ("Session ID '%u': %s (IP type: %s)", - session_id, - mbim_activation_state_get_string (activation_state), - mbim_context_ip_type_get_string (ip_type)); + (mbim_message_command_done_get_result (response, &error) || + error->code == MBIM_STATUS_ERROR_FAILURE)) { + GError *inner_error = NULL; + + if (mbim_message_connect_response_parse ( + response, + &session_id, + &activation_state, + NULL, /* voice_call_state */ + &ip_type, + NULL, /* context_type */ + &nw_error, + &inner_error)) { + if (nw_error) { + if (error) + g_error_free (error); + error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error); + } else { + ctx->ip_type = ip_type; + mm_dbg ("Session ID '%u': %s (IP type: %s)", + session_id, + mbim_activation_state_get_string (activation_state), + mbim_context_ip_type_get_string (ip_type)); + } + } else { + /* Prefer the error from the result to the parsing error */ + if (!error) + error = inner_error; + else + g_error_free (inner_error); } } @@ -523,27 +535,39 @@ packet_service_set_ready (MbimDevice *device, response = mbim_device_command_finish (device, res, &error); if (response && - mbim_message_command_done_get_result (response, &error) && - mbim_message_packet_service_response_parse ( - response, - &nw_error, - &packet_service_state, - &highest_available_data_class, - &uplink_speed, - &downlink_speed, - &error)) { - if (nw_error) - error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error); - else { - gchar *str; - - str = mbim_data_class_build_string_from_mask (highest_available_data_class); - mm_dbg ("Packet service update:"); - mm_dbg (" state: '%s'", mbim_packet_service_state_get_string (packet_service_state)); - mm_dbg (" data class: '%s'", str); - mm_dbg (" uplink: '%" G_GUINT64_FORMAT "' bps", uplink_speed); - mm_dbg (" downlink: '%" G_GUINT64_FORMAT "' bps", downlink_speed); - g_free (str); + (mbim_message_command_done_get_result (response, &error) || + error->code == MBIM_STATUS_ERROR_FAILURE)) { + GError *inner_error = NULL; + + if (mbim_message_packet_service_response_parse ( + response, + &nw_error, + &packet_service_state, + &highest_available_data_class, + &uplink_speed, + &downlink_speed, + &error)) { + if (nw_error) { + if (error) + g_error_free (error); + error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error); + } else { + gchar *str; + + str = mbim_data_class_build_string_from_mask (highest_available_data_class); + mm_dbg ("Packet service update:"); + mm_dbg (" state: '%s'", mbim_packet_service_state_get_string (packet_service_state)); + mm_dbg (" data class: '%s'", str); + mm_dbg (" uplink: '%" G_GUINT64_FORMAT "' bps", uplink_speed); + mm_dbg (" downlink: '%" G_GUINT64_FORMAT "' bps", downlink_speed); + g_free (str); + } + } else { + /* Prefer the error from the result to the parsing error */ + if (!error) + error = inner_error; + else + g_error_free (inner_error); } } @@ -902,22 +926,34 @@ disconnect_set_ready (MbimDevice *device, response = mbim_device_command_finish (device, res, &error); if (response && - mbim_message_command_done_get_result (response, &error) && - mbim_message_connect_response_parse ( - response, - &session_id, - &activation_state, - NULL, /* voice_call_state */ - NULL, /* ip_type */ - NULL, /* context_type */ - &nw_error, - &error)) { - if (nw_error) - error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error); - else - mm_dbg ("Session ID '%u': %s", - session_id, - mbim_activation_state_get_string (activation_state)); + (mbim_message_command_done_get_result (response, &error) || + error->code == MBIM_STATUS_ERROR_FAILURE)) { + GError *inner_error = NULL; + + if (mbim_message_connect_response_parse ( + response, + &session_id, + &activation_state, + NULL, /* voice_call_state */ + NULL, /* ip_type */ + NULL, /* context_type */ + &nw_error, + &error)) { + if (nw_error) { + if (error) + g_error_free (error); + error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error); + } else + mm_dbg ("Session ID '%u': %s", + session_id, + mbim_activation_state_get_string (activation_state)); + } else { + /* Prefer the error from the result to the parsing error */ + if (!error) + error = inner_error; + else + g_error_free (inner_error); + } } if (error) { |