示例#1
0
bool wpan_mlme_set_req(uint8_t PIBAttribute,
		void *PIBAttributeValue)
{
	uint8_t pib_len;
	if (macBeaconPayload == PIBAttribute) {
		pib_len = *((uint8_t *)PIBAttributeValue - 1);
	} else {
		pib_len = mac_get_pib_attribute_size(PIBAttribute);
	}

	length = 0;
	tx_buff_ptr = &tx_buffer[CMD_POS];

	*tx_buff_ptr++ = MLME_SET_REQUEST;
	*tx_buff_ptr++ = PIBAttribute;

	*tx_buff_ptr++ = pib_len;
	memcpy(tx_buff_ptr, (uint8_t *)PIBAttributeValue, pib_len);
	tx_buff_ptr += pib_len;

	*tx_buff_ptr++ = EOT;

	length = tx_buff_ptr - (uint8_t *)&tx_buffer[0];
	tx_buffer[LEN_POS] = length - 3;
	sio2ncp_tx(tx_buffer, length);
	return true;
}
示例#2
0
bool wpan_mlme_set_req(uint8_t PIBAttribute,
                       void *PIBAttributeValue)
#endif  /* (MAC_SECURITY_ZIP || MAC_SECURITY_2006) */
{
    buffer_t *buffer_header;
    mlme_set_req_t *mlme_set_req;
    uint8_t pib_attribute_octet_no;

    /*
     * Allocate a large buffer for set request as maximum beacon payload
     * should be accommodated
     */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

    /* Check for buffer availability */
    if (NULL == buffer_header) {
        return false;
    }

    /* Get size of PIB attribute to be set */
    pib_attribute_octet_no = mac_get_pib_attribute_size(PIBAttribute);

    /* Get the buffer body from buffer header */
    mlme_set_req = (mlme_set_req_t *)BMM_BUFFER_POINTER(buffer_header);

    /* Construct mlme_set_req_t message */
    mlme_set_req->cmdcode = MLME_SET_REQUEST;

    /* Attribute and attribute value length */
    mlme_set_req->PIBAttribute = PIBAttribute;
#if ((defined MAC_SECURITY_ZIP)  || (defined MAC_SECURITY_2006))
    mlme_set_req->PIBAttributeIndex = PIBAttributeIndex;
#endif  /* (MAC_SECURITY_ZIP || MAC_SECURITY_2006) */

    /* Attribute value */

#ifdef TEST_HARNESS_BIG_ENDIAN
    if ((macMaxFrameTotalWaitTime == PIBAttribute)      ||
            (macResponseWaitTime == PIBAttribute)           ||
            (macTransactionPersistenceTime == PIBAttribute) ||
            (macBeaconTxTime == PIBAttribute)
#if ((defined MAC_SECURITY_ZIP)  || (defined MAC_SECURITY_2006))
            ||
            (macFrameCounter == PIBAttribute) ||
            (macDeviceTableEntries == PIBAttribute)
#endif
       ) {
        memcpy_be((void *)&(mlme_set_req->PIBAttributeValue),
                  (void *)PIBAttributeValue,
                  (size_t)pib_attribute_octet_no);
    } else {
        memcpy((void *)&(mlme_set_req->PIBAttributeValue),
               (void *)PIBAttributeValue,
               (size_t)pib_attribute_octet_no);
    }

#else
    memcpy((void *)&(mlme_set_req->PIBAttributeValue),
           (void *)PIBAttributeValue,
           (size_t)pib_attribute_octet_no);
#endif

    /* Insert message into NHLE MAC queue */
#ifdef ENABLE_QUEUE_CAPACITY
    if (MAC_SUCCESS != qmm_queue_append(&nhle_mac_q, buffer_header)) {
        /*
         * MLME-SET.request is not appended into NHLE MAC
         * queue, hence free the buffer allocated and return false
         */
        bmm_buffer_free(buffer_header);
        return false;
    }

#else
    qmm_queue_append(&nhle_mac_q, buffer_header);
#endif  /* ENABLE_QUEUE_CAPACITY */

    return true;
}