static enum qmi_cmd_result cmd_wds_set_autoconnect_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { qmi_set(&wds_sn_req, enable_autoconnect, true); qmi_set(&wds_stn_req, disable_autoconnect, true); return QMI_CMD_DONE; }
int qmi_parse_wms_send_from_memory_storage_response(struct qmi_msg *msg, struct qmi_wms_send_from_memory_storage_response *res) { void *tlv_buf = &msg->svc.tlv; int tlv_len = le16_to_cpu(msg->svc.tlv_len); struct tlv *tlv; int i; memset(res, 0, sizeof(*res)); __qmi_alloc_reset(); while ((tlv = tlv_get_next(&tlv_buf, &tlv_len)) != NULL) { unsigned int cur_tlv_len = le16_to_cpu(tlv->len); unsigned int ofs = 0; switch(tlv->type) { case 0x10: qmi_set(res, message_id, le16_to_cpu(*(uint16_t *) get_next(2))); break; case 0x11: qmi_set(res, cdma_cause_code, le16_to_cpu(*(uint16_t *) get_next(2))); break; case 0x12: qmi_set(res, cdma_error_class, *(uint8_t *) get_next(1)); break; case 0x13: res->set.gsm_wcdma_cause_info = 1; res->data.gsm_wcdma_cause_info.rp_cause = le16_to_cpu(*(uint16_t *) get_next(2)); res->data.gsm_wcdma_cause_info.tp_cause = *(uint8_t *) get_next(1); break; case 0x14: qmi_set(res, message_delivery_failure_type, *(uint8_t *) get_next(1)); break; default: break; } } return 0; error_len: fprintf(stderr, "%s: Invalid TLV length in message, tlv=0x%02x, len=%d\n", __func__, tlv->type, le16_to_cpu(tlv->len)); return QMI_ERROR_INVALID_DATA; }
static enum qmi_cmd_result cmd_wds_set_auth_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { static const struct { const char *name; QmiWdsAuthentication auth; } modes[] = { { "pap", QMI_WDS_AUTHENTICATION_PAP }, { "chap", QMI_WDS_AUTHENTICATION_CHAP }, { "both", QMI_WDS_AUTHENTICATION_PAP | QMI_WDS_AUTHENTICATION_CHAP }, { "none", QMI_WDS_AUTHENTICATION_NONE }, }; int i; for (i = 0; i < ARRAY_SIZE(modes); i++) { if (strcasecmp(modes[i].name, arg) != 0) continue; qmi_set(&wds_sn_req, authentication_preference, modes[i].auth); return QMI_CMD_DONE; } uqmi_add_error("Invalid auth mode (valid: pap, chap, both, none)"); return QMI_CMD_EXIT; }
static enum qmi_cmd_result cmd_wds_set_ip_family_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { struct qmi_wds_set_ip_family_request ipf_req; const struct ip_modes { const char *name; const QmiWdsIpFamily mode; } modes[] = { { "ipv4", QMI_WDS_IP_FAMILY_IPV4 }, { "ipv6", QMI_WDS_IP_FAMILY_IPV6 }, { "unspecified", QMI_WDS_IP_FAMILY_UNSPECIFIED }, }; int i; for (i = 0; i < ARRAY_SIZE(modes); i++) { if (strcasecmp(modes[i].name, arg) != 0) continue; qmi_set(&ipf_req, preference, modes[i].mode); qmi_set_wds_set_ip_family_request(msg, &ipf_req); return QMI_CMD_REQUEST; } uqmi_add_error("Invalid value (valid: ipv4, ipv6, unspecified)"); return QMI_CMD_EXIT; }
int qmi_parse_wms_get_message_protocol_response(struct qmi_msg *msg, struct qmi_wms_get_message_protocol_response *res) { void *tlv_buf = &msg->svc.tlv; int tlv_len = le16_to_cpu(msg->svc.tlv_len); struct tlv *tlv; int i; memset(res, 0, sizeof(*res)); __qmi_alloc_reset(); while ((tlv = tlv_get_next(&tlv_buf, &tlv_len)) != NULL) { unsigned int cur_tlv_len = le16_to_cpu(tlv->len); unsigned int ofs = 0; switch(tlv->type) { case 0x01: qmi_set(res, message_protocol, *(uint8_t *) get_next(1)); break; default: break; } } return 0; error_len: fprintf(stderr, "%s: Invalid TLV length in message, tlv=0x%02x, len=%d\n", __func__, tlv->type, le16_to_cpu(tlv->len)); return QMI_ERROR_INVALID_DATA; }
static enum qmi_cmd_result cmd_wds_stop_network_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { uint32_t pdh = strtoul(arg, NULL, 0); qmi_set(&wds_stn_req, packet_data_handle, pdh); qmi_set_wds_stop_network_request(msg, &wds_stn_req); return QMI_CMD_REQUEST; }
static enum qmi_cmd_result cmd_nas_set_network_preference_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { QmiNasGsmWcdmaAcquisitionOrderPreference pref = QMI_NAS_GSM_WCDMA_ACQUISITION_ORDER_PREFERENCE_AUTOMATIC; if (!strcmp(arg, "gsm")) pref = QMI_NAS_GSM_WCDMA_ACQUISITION_ORDER_PREFERENCE_GSM; else if (!strcmp(arg, "wcdma")) pref = QMI_NAS_GSM_WCDMA_ACQUISITION_ORDER_PREFERENCE_WCDMA; qmi_set(&sel_req, gsm_wcdma_acquisition_order_preference, pref); return do_sel_network(); }
static enum qmi_cmd_result cmd_wds_get_current_settings_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { struct qmi_wds_get_current_settings_request gcs_req; memset(&gcs_req, '\0', sizeof(struct qmi_wds_get_current_settings_request)); qmi_set(&gcs_req, requested_settings, QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_PDP_TYPE | QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_DNS_ADDRESS | QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_GRANTED_QOS | QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_IP_ADDRESS | QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_GATEWAY_INFO | QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_MTU | QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_DOMAIN_NAME_LIST | QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_IP_FAMILY); qmi_set_wds_get_current_settings_request(msg, &gcs_req); return QMI_CMD_REQUEST; }
int qmi_parse_wms_get_routes_response(struct qmi_msg *msg, struct qmi_wms_get_routes_response *res) { void *tlv_buf = &msg->svc.tlv; int tlv_len = le16_to_cpu(msg->svc.tlv_len); struct tlv *tlv; int i; memset(res, 0, sizeof(*res)); __qmi_alloc_reset(); while ((tlv = tlv_get_next(&tlv_buf, &tlv_len)) != NULL) { unsigned int cur_tlv_len = le16_to_cpu(tlv->len); unsigned int ofs = 0; switch(tlv->type) { case 0x01: i = le16_to_cpu(*(uint16_t *) get_next(2)); res->data.route_list = __qmi_alloc_static(i); while(i-- > 0) { res->data.route_list[res->data.route_list_n].message_type = *(uint8_t *) get_next(1); res->data.route_list[res->data.route_list_n].message_class = *(uint8_t *) get_next(1); res->data.route_list[res->data.route_list_n].storage = *(uint8_t *) get_next(1); res->data.route_list[res->data.route_list_n].receipt_action = *(uint8_t *) get_next(1); res->data.route_list_n++; } break; case 0x10: qmi_set(res, transfer_status_report, *(uint8_t *) get_next(1)); break; default: break; } } return 0; error_len: fprintf(stderr, "%s: Invalid TLV length in message, tlv=0x%02x, len=%d\n", __func__, tlv->type, le16_to_cpu(tlv->len)); return QMI_ERROR_INVALID_DATA; }
static enum qmi_cmd_result cmd_nas_set_roaming_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { QmiNasRoamingPreference pref; if (!strcmp(arg, "any")) pref = QMI_NAS_ROAMING_PREFERENCE_ANY; else if (!strcmp(arg, "only")) pref = QMI_NAS_ROAMING_PREFERENCE_NOT_OFF; else if (!strcmp(arg, "off")) pref = QMI_NAS_ROAMING_PREFERENCE_OFF; else { blobmsg_add_string(&status, "error", "Invalid argument"); return QMI_CMD_EXIT; } qmi_set(&sel_req, roaming_preference, pref); return do_sel_network(); }
static enum qmi_cmd_result cmd_nas_set_network_modes_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { static const struct { const char *name; QmiNasRatModePreference val; } modes[] = { { "cdma", QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1X | QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1XEVDO }, { "td-scdma", QMI_NAS_RAT_MODE_PREFERENCE_TD_SCDMA }, { "gsm", QMI_NAS_RAT_MODE_PREFERENCE_GSM }, { "umts", QMI_NAS_RAT_MODE_PREFERENCE_UMTS }, { "lte", QMI_NAS_RAT_MODE_PREFERENCE_LTE }, }; QmiNasRatModePreference val = 0; char *word; int i; for (word = strtok(arg, ","); word; word = strtok(NULL, ",")) { bool found = false; for (i = 0; i < ARRAY_SIZE(modes); i++) { if (strcmp(word, modes[i].name) != 0 && strcmp(word, "all") != 0) continue; val |= modes[i].val; found = true; } if (!found) { blobmsg_add_string(&status, "error", "Invalid network mode"); return QMI_CMD_EXIT; } } qmi_set(&sel_req, mode_preference, val); return do_sel_network(); }
static enum qmi_cmd_result cmd_wds_set_autoconnect_setting_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { struct qmi_wds_set_autoconnect_setting_request ac_req; const char *modes[] = { [QMI_WDS_AUTOCONNECT_DISABLED] = "disabled", [QMI_WDS_AUTOCONNECT_ENABLED] = "enabled", [QMI_WDS_AUTOCONNECT_PAUSED] = "paused", }; int i; for (i = 0; i < ARRAY_SIZE(modes); i++) { if (strcasecmp(modes[i], arg) != 0) continue; qmi_set(&ac_req, setting, i); qmi_set_wds_set_autoconnect_setting_request(msg, &ac_req); return QMI_CMD_DONE; } uqmi_add_error("Invalid value (valid: disabled, enabled, paused)"); return QMI_CMD_EXIT; }