Ejemplo n.º 1
0
int qmi_set_wms_send_from_memory_storage_request(struct qmi_msg *msg, struct qmi_wms_send_from_memory_storage_request *req)
{
    qmi_init_request_message(msg, QMI_SERVICE_WMS);
    msg->svc.message = cpu_to_le16(0x0042);

    if (req->set.information) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.information.storage_type, 1);
        put_tlv_var(uint32_t, cpu_to_le32(req->data.information.memory_index), 4);
        put_tlv_var(uint8_t, req->data.information.message_mode, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x01, ofs, buf);
    }

    if (req->set.sms_on_ims) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.sms_on_ims, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x10, ofs, buf);
    }

    return 0;
}
Ejemplo n.º 2
0
int qmi_set_wms_modify_tag_request(struct qmi_msg *msg, struct qmi_wms_modify_tag_request *req)
{
    qmi_init_request_message(msg, QMI_SERVICE_WMS);
    msg->svc.message = cpu_to_le16(0x0023);

    if (req->set.message_tag) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.message_tag.storage_type, 1);
        put_tlv_var(uint32_t, cpu_to_le32(req->data.message_tag.memory_index), 4);
        put_tlv_var(uint8_t, req->data.message_tag.message_tag, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x01, ofs, buf);
    }

    if (req->set.message_mode) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.message_mode, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x10, ofs, buf);
    }

    return 0;
}
Ejemplo n.º 3
0
Archivo: tlv.c Proyecto: dtaht/hnetd
struct tlv_attr *
tlv_put(struct tlv_buf *buf, int id, const void *ptr, int len)
{
	struct tlv_attr *attr;

	attr = tlv_new(buf, id, len);
	if (!attr)
		return NULL;

	if (ptr)
		memcpy(tlv_data(attr), ptr, len);
	return attr;
}
Ejemplo n.º 4
0
int qmi_set_wms_set_routes_request(struct qmi_msg *msg, struct qmi_wms_set_routes_request *req)
{
    qmi_init_request_message(msg, QMI_SERVICE_WMS);
    msg->svc.message = cpu_to_le16(0x0032);

    if (req->data.route_list) {
        void *buf;
        int ofs;
        int i;

        __qmi_alloc_reset();
        put_tlv_var(uint16_t, cpu_to_le16(req->data.route_list_n), 2);
        for (i = 0; i < req->data.route_list_n; i++) {
            put_tlv_var(uint8_t, req->data.route_list[i].message_type, 1);
            put_tlv_var(uint8_t, req->data.route_list[i].message_class, 1);
            put_tlv_var(uint8_t, req->data.route_list[i].storage, 1);
            put_tlv_var(uint8_t, req->data.route_list[i].receipt_action, 1);
        }

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x01, ofs, buf);
    }

    if (req->set.transfer_status_report) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.transfer_status_report, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x10, ofs, buf);
    }

    return 0;
}
Ejemplo n.º 5
0
int qmi_set_wms_set_event_report_request(struct qmi_msg *msg, struct qmi_wms_set_event_report_request *req)
{
    qmi_init_request_message(msg, QMI_SERVICE_WMS);
    msg->svc.message = cpu_to_le16(0x0001);

    if (req->set.new_mt_message_indicator) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.new_mt_message_indicator.report, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x10, ofs, buf);
    }

    return 0;
}
Ejemplo n.º 6
0
int qmi_set_pds_set_auto_tracking_state_request(struct qmi_msg *msg, struct qmi_pds_set_auto_tracking_state_request *req)
{
	qmi_init_request_message(msg, QMI_SERVICE_PDS);
	msg->svc.message = cpu_to_le16(0x0031);

	if (req->set.state) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.state.auto_tracking_state, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x01, ofs, buf);
	}

	return 0;
}
Ejemplo n.º 7
0
int qmi_set_wms_raw_write_request(struct qmi_msg *msg, struct qmi_wms_raw_write_request *req)
{
    qmi_init_request_message(msg, QMI_SERVICE_WMS);
    msg->svc.message = cpu_to_le16(0x0021);

    if (req->set.raw_message_data) {
        void *buf;
        int ofs;
        int i;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.raw_message_data.storage_type, 1);
        put_tlv_var(uint8_t, req->data.raw_message_data.format, 1);
        put_tlv_var(uint16_t, cpu_to_le16(req->data.raw_message_data.raw_data_n), 2);
        for (i = 0; i < req->data.raw_message_data.raw_data_n; i++) {
            put_tlv_var(uint8_t, req->data.raw_message_data.raw_data[i], 1);
        }

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x01, ofs, buf);
    }

    return 0;
}
Ejemplo n.º 8
0
static uint32
wpsap_createM7AP(WPSAPI_T *g_mc)
{
	char *cp_data;
	uint16 data16;
	uint8 *p_macAddr;
	CTlvNwKey *p_tlvKey;
	char *cp_psk;
	DevInfo *info = g_mc->dev_info;
	EsM7Ap *es;

	/*
	 * AP wants to be configured/managed
	 * Let the Enrollee SM know, so that it can be initialized
	 *
	 * Create an Encrypted Settings TLV to be passed to the SM,
	 * so that the SM can pass it to the Registrar in M7
	 * Also store this TLV locally, so we can delete it once the
	 * registration completes. The SM will not delete it.
	 */
	if (info->mp_tlvEsM7Ap) {
		TUTRACE((TUTRACE_ERR, "wpsap_createM7AP: info->mp_tlvEsM7Ap exist!"));
		reg_msg_es_del(info->mp_tlvEsM7Ap, 0);
	}

	info->mp_tlvEsM7Ap = (EsM7Ap *)reg_msg_es_new(ES_TYPE_M7AP);
	if (!info->mp_tlvEsM7Ap)
		return WPS_ERR_SYSTEM;

	es = info->mp_tlvEsM7Ap;

	/* SSID */
	cp_data = info->ssid;
	data16 = strlen(cp_data);
	tlv_set(&es->ssid, WPS_ID_SSID, cp_data, data16);

	/* MAC addr:  should really get this from the NIC driver */
	p_macAddr = info->macAddr;
	data16 = SIZE_MAC_ADDR;
	tlv_set(&es->macAddr, WPS_ID_MAC_ADDR, p_macAddr, data16);

	TUTRACE((TUTRACE_ERR, "MC_CreateTlvEsM7Ap: "
		"do REAL sec config here...\n"));
	if (info->auth)
		data16 = WPS_AUTHTYPE_SHARED;
	else if (devinfo_getKeyMgmtType(info) == WPS_WL_AKM_PSK)
		data16 = WPS_AUTHTYPE_WPAPSK;
	else if (devinfo_getKeyMgmtType(info) == WPS_WL_AKM_PSK2)
		data16 = WPS_AUTHTYPE_WPA2PSK;
	else if (devinfo_getKeyMgmtType(info) == WPS_WL_AKM_BOTH)
		data16 = WPS_AUTHTYPE_WPAPSK | WPS_AUTHTYPE_WPA2PSK;
	else
		data16 = WPS_AUTHTYPE_OPEN;

	tlv_set(&es->authType, WPS_ID_AUTH_TYPE, UINT2PTR(data16), 0);

	TUTRACE((TUTRACE_ERR, "MC_CreateTlvEsM7Ap: "
		"Auth type = %x...\n", data16));

	/* encrType */
	if (info->auth)
		data16 = WPS_ENCRTYPE_WEP;
	else if (data16 == WPS_AUTHTYPE_OPEN) {
		if (info->wep)
			data16 = WPS_ENCRTYPE_WEP;
		else
			data16 = WPS_ENCRTYPE_NONE;
	}
	else
		data16 = info->crypto;

	tlv_set(&es->encrType, WPS_ID_ENCR_TYPE, UINT2PTR(data16), 0);

	TUTRACE((TUTRACE_ERR, "MC_CreateTlvEsM7Ap: "
		"encr type = %x...\n", data16));

	if (data16 != WPS_ENCRTYPE_NONE) {
		char *dev_key = NULL;
		uint32	KeyLen;

		if (data16 == WPS_ENCRTYPE_WEP)
			tlv_set(&es->wepIdx, WPS_ID_WEP_TRANSMIT_KEY,
				UINT2PTR(info->wepKeyIdx), 0);

		dev_key = info->nwKey;
		KeyLen = strlen(dev_key);

		/* nwKey */
		p_tlvKey = (CTlvNwKey *)tlv_new(WPS_ID_NW_KEY);
		if (!p_tlvKey)
			return WPS_ERR_SYSTEM;

		if (tlv_allocate(p_tlvKey, WPS_ID_NW_KEY, KeyLen) == -1) {
			tlv_delete(p_tlvKey, 0);
			return WPS_ERR_SYSTEM;
		}

		cp_psk = p_tlvKey->m_data;
		memset(cp_psk, 0, KeyLen);

		memcpy(cp_psk, dev_key, KeyLen);
#ifdef BCMWPS_DEBUG_PRINT_KEY
		TUTRACE((TUTRACE_INFO,	"InitiateRegistration_NW_KEY get from AP is key "
			"%p %s\n",  p_tlvKey, cp_psk));
#endif
	}
	else {
		/* nwKey */
		p_tlvKey = (CTlvNwKey *)tlv_new(WPS_ID_NW_KEY);
		if (!p_tlvKey)
			return WPS_ERR_SYSTEM;

		if (tlv_allocate(p_tlvKey, WPS_ID_NW_KEY, 0) == -1) {
			tlv_delete(p_tlvKey, 0);
			return WPS_ERR_SYSTEM;
		}
	}
	if (!wps_sslist_add(&es->nwKey, p_tlvKey)) {
		tlv_delete(p_tlvKey, 0);
		return WPS_ERR_SYSTEM;
	}

	return WPS_SUCCESS;
}
Ejemplo n.º 9
0
int qmi_set_wms_raw_send_request(struct qmi_msg *msg, struct qmi_wms_raw_send_request *req)
{
    qmi_init_request_message(msg, QMI_SERVICE_WMS);
    msg->svc.message = cpu_to_le16(0x0020);

    if (req->set.raw_message_data) {
        void *buf;
        int ofs;
        int i;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.raw_message_data.format, 1);
        put_tlv_var(uint16_t, cpu_to_le16(req->data.raw_message_data.raw_data_n), 2);
        for (i = 0; i < req->data.raw_message_data.raw_data_n; i++) {
            put_tlv_var(uint8_t, req->data.raw_message_data.raw_data[i], 1);
        }

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x01, ofs, buf);
    }

    if (req->set.cdma_force_on_dc) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.cdma_force_on_dc.force, 1);
        put_tlv_var(uint8_t, req->data.cdma_force_on_dc.service_option, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x10, ofs, buf);
    }

    if (req->set.cdma_follow_on_dc) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.cdma_follow_on_dc.follow, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x11, ofs, buf);
    }

    if (req->set.gsm_wcdma_link_timer) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.gsm_wcdma_link_timer, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x12, ofs, buf);
    }

    if (req->set.sms_on_ims) {
        void *buf;
        int ofs;

        __qmi_alloc_reset();
        put_tlv_var(uint8_t, req->data.sms_on_ims, 1);

        buf = __qmi_get_buf(&ofs);
        tlv_new(msg, 0x13, ofs, buf);
    }

    return 0;
}
Ejemplo n.º 10
0
int qmi_set_pds_set_event_report_request(struct qmi_msg *msg, struct qmi_pds_set_event_report_request *req)
{
	qmi_init_request_message(msg, QMI_SERVICE_PDS);
	msg->svc.message = cpu_to_le16(0x0001);

	if (req->set.nmea_position_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.nmea_position_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x10, ofs, buf);
	}

	if (req->set.extended_nmea_position_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.extended_nmea_position_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x11, ofs, buf);
	}

	if (req->set.parsed_position_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.parsed_position_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x12, ofs, buf);
	}

	if (req->set.external_xtra_data_request_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.external_xtra_data_request_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x13, ofs, buf);
	}

	if (req->set.external_time_injection_request_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.external_time_injection_request_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x14, ofs, buf);
	}

	if (req->set.external_wifi_position_request_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.external_wifi_position_request_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x15, ofs, buf);
	}

	if (req->set.satellite_information_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.satellite_information_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x16, ofs, buf);
	}

	if (req->set.vx_network_initiated_request_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.vx_network_initiated_request_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x17, ofs, buf);
	}

	if (req->set.supl_network_initiated_prompt_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.supl_network_initiated_prompt_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x18, ofs, buf);
	}

	if (req->set.umts_cp_network_initiated_prompt_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.umts_cp_network_initiated_prompt_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x19, ofs, buf);
	}

	if (req->set.pds_comm_event_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.pds_comm_event_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x1A, ofs, buf);
	}

	if (req->set.accelerometer_data_streaming_ready_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.accelerometer_data_streaming_ready_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x1B, ofs, buf);
	}

	if (req->set.gyro_data_streaming_ready_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.gyro_data_streaming_ready_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x1C, ofs, buf);
	}

	if (req->set.time_sync_request_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.time_sync_request_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x1D, ofs, buf);
	}

	if (req->set.position_reliability_indicator_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.position_reliability_indicator_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x1E, ofs, buf);
	}

	if (req->set.sensor_data_usage_indicator_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.sensor_data_usage_indicator_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x1F, ofs, buf);
	}

	if (req->set.time_source_information_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.time_source_information_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x20, ofs, buf);
	}

	if (req->set.heading_uncertainty_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.heading_uncertainty_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x21, ofs, buf);
	}

	if (req->set.nmea_debug_strings_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.nmea_debug_strings_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x22, ofs, buf);
	}

	if (req->set.extended_external_xtra_data_request_reporting) {
		void *buf;
		unsigned int ofs;

		__qmi_alloc_reset();
		put_tlv_var(uint8_t, req->data.extended_external_xtra_data_request_reporting, 1);

		buf = __qmi_get_buf(&ofs);
		tlv_new(msg, 0x23, ofs, buf);
	}

	return 0;
}