Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
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;
}
Пример #4
0
int qmi_parse_wms_raw_read_response(struct qmi_msg *msg, struct qmi_wms_raw_read_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:
            res->set.raw_message_data = 1;
            res->data.raw_message_data.message_tag = *(uint8_t *) get_next(1);
            res->data.raw_message_data.format = *(uint8_t *) get_next(1);
            i = le16_to_cpu(*(uint16_t *) get_next(2));
            res->data.raw_message_data.raw_data = __qmi_alloc_static(i);
            while(i-- > 0) {
                res->data.raw_message_data.raw_data[res->data.raw_message_data.raw_data_n] = *(uint8_t *) get_next(1);
                res->data.raw_message_data.raw_data_n++;
            }
            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;
}
Пример #5
0
int qmi_parse_pds_get_gps_service_state_response(struct qmi_msg *msg, struct qmi_pds_get_gps_service_state_response *res)
{
	void *tlv_buf = &msg->svc.tlv;
	unsigned int tlv_len = le16_to_cpu(msg->svc.tlv_len);
	struct tlv *tlv;
	int i;
	uint32_t found[1] = {};

	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:
			if (found[0] & (1 << 1))
				break;

			found[0] |= (1 << 1);
			res->set.state = 1;
			res->data.state.gps_service_state = *(uint8_t *) get_next(1);
			res->data.state.tracking_session_state = *(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;
}