void rtb_process_data_ind(uint8_t *msg)
{
    buffer_t *buf_ptr = (buffer_t *)msg;
    frame_info_t *frameptr = (frame_info_t *)BMM_BUFFER_POINTER(buf_ptr);
    mac_parse_data.mpdu_length = frameptr->mpdu[0];

    /* First extract LQI. */
    mac_parse_data.ppdu_link_quality = frameptr->mpdu[mac_parse_data.mpdu_length + LQI_LEN];

#ifdef RTB_WITHOUT_MAC
    /* Handle the received frame in case the frame is an RTB frame. */
    handle_rx_rtb_frame_type(frameptr);

    /*
     * Release buffer in any case, since it is not forwarded
     * to any higher layer.
     */
    bmm_buffer_free(buf_ptr);
#else   /* #ifdef RTB_WITHOUT_MAC */
    /* Handle the received frame in case the frame is an RTB frame. */
    if (!handle_rx_rtb_frame_type(frameptr))
    {
        /* This is a not an RTB frame, so it is forwarded to the MAC. */
        frameptr->msg_type = (frame_msgtype_t)TAL_DATA_INDICATION;
        qmm_queue_append(&tal_mac_q, buf_ptr);
    }
    else
    {
        bmm_buffer_free(buf_ptr);
    }
#endif  /* #ifdef RTB_WITHOUT_MAC */
}
Example #2
0
void mac_process_gts_request(buffer_t *gts_req)
{
    /* Use the frame reception buffer for association indication. */
    mlme_gts_ind_t *mgi = (mlme_gts_ind_t *)BMM_BUFFER_POINTER(
                              gts_req);

    mgi->DeviceAddr = mac_parse_data.src_addr.short_address;

    mgi->GtsChar = mac_parse_data.mac_payload_data.gts_req_data;
    mgi->cmdcode = MLME_GTS_INDICATION;

    if (GTS_ALLOCATE == (mgi->GtsChar).GtsCharType) {
        if (mac_gts_allocate(mgi->GtsChar, mgi->DeviceAddr)) {
            /* Append the MLME GTS indication to the MAC-NHLE queue.
             **/
            qmm_queue_append(&mac_nhle_q, gts_req);
        } else {
            bmm_buffer_free(gts_req);
        }
    } else {
        if (mac_gts_deallocate(mgi->GtsChar, mgi->DeviceAddr, false)) {
            /* Append the MLME GTS indication to the MAC-NHLE queue.
             **/
            qmm_queue_append(&mac_nhle_q, gts_req);
        } else {
            bmm_buffer_free(gts_req);
        }
    }
}
Example #3
0
void bc_data_cb_vanet(frame_info_t *transmit_frame)
{
	uint8_t index;
	index  = nwkFindPassiveAck(transmit_frame->NwkFrameHeader->srcAddr, transmit_frame->NwkFrameHeader->sequenceNumber);
	if (index != 0xFF)
	{
#if 0
		if (gNwkPassiveAckTable.table[index].end == false)
		{

			NwkState = NWK_MODULE_NONE;
			pal_timer_start(gNwkPassiveAckTable.table[index].timerID,
							((uint32_t)	(NWK_BROADCAST_DELIVERY_TIME-(gNwkPassiveAckTable.table[index].reTryTimes+1)*NWK_PASSIVE_ACK_TIMEOUT)),
							TIMEOUT_RELATIVE,
							(FUNC_PTR)bc_data_cb_vanet,
							transmit_frame);
			gNwkPassiveAckTable.table[index].end = true;
			return;
		}
#endif
		gNwkPassiveAckTable.table[index].end = false;
		gNwkPassiveAckTable.table[index].reTryTimes = 0;
		nwkFreePassiveAck(transmit_frame->NwkFrameHeader->srcAddr, transmit_frame->NwkFrameHeader->sequenceNumber);
		if (transmit_frame != NULL)
			bmm_buffer_free(transmit_frame->buffer_header);
		//NwkState = NWK_MODULE_NONE;//if为1时原本是释掉的
		mac_sleep_trans();
	}
}
Example #4
0
/**
 * @brief Wrapper function for messages of type mlme_comm_status_ind_t
 *
 * This function is a callback for mlme comm status indication.
 *
 * @param m Pointer to message structure
 */
void mlme_comm_status_ind(uint8_t *m)
{
	mlme_comm_status_ind_t *pmsg;
	wpan_addr_spec_t src_addr;
	wpan_addr_spec_t dst_addr;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_comm_status_ind_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	/* Source address spec */
	src_addr.PANId = pmsg->PANId;
	src_addr.AddrMode = pmsg->SrcAddrMode;
	ADDR_COPY_DST_SRC_64(src_addr.Addr.long_address, pmsg->SrcAddr);

	/* Destintion address spec */
	dst_addr.PANId = pmsg->PANId;
	dst_addr.AddrMode = pmsg->DstAddrMode;
	ADDR_COPY_DST_SRC_64(dst_addr.Addr.long_address, pmsg->DstAddr);

	/* Callback function */
	usr_mlme_comm_status_ind(&src_addr,
			&dst_addr,
			pmsg->status);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #5
0
/**
 * @brief Cleanup TAL
 *
 * @param trx_id Transceiver identifier
 */
static void cleanup_tal(trx_id_t trx_id)
{
	/* Clear all running TAL timers. */
	ENTER_CRITICAL_REGION();
	stop_tal_timer(trx_id);
	LEAVE_CRITICAL_REGION();

	/* Clear TAL Incoming Frame queue and free used buffers. */
	while (tal_incoming_frame_queue[trx_id].size > 0) {
		buffer_t *frame
			= qmm_queue_remove(
				&tal_incoming_frame_queue[trx_id], NULL);
		if (NULL != frame) {
			bmm_buffer_free(frame);
		}
	}
	/* Get new TAL Rx buffer if necessary */
	if (tal_rx_buffer[trx_id] == NULL) {
		tal_rx_buffer[trx_id] = bmm_buffer_alloc(LARGE_BUFFER_SIZE);
	}

	/* Handle buffer shortage */
	if (tal_rx_buffer[trx_id] == NULL) {
		tal_buf_shortage[trx_id] = true;
	} else {
		tal_buf_shortage[trx_id] = false;
	}
}
Example #6
0
bool wpan_mlme_associate_req(uint8_t LogicalChannel,
                             uint8_t ChannelPage,
                             wpan_addr_spec_t *CoordAddrSpec,
                             uint8_t CapabilityInformation)
{
    buffer_t *buffer_header;
    mlme_associate_req_t *mlme_associate_req;

    /* Allocate a buffer for mlme associate request */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

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

    /* Get the buffer body from buffer header */
    mlme_associate_req = (mlme_associate_req_t *)BMM_BUFFER_POINTER(
                             buffer_header);

    /* Construct mlme_associate_req_t message */
    mlme_associate_req->cmdcode = MLME_ASSOCIATE_REQUEST;

    /* Operating channel */
    mlme_associate_req->LogicalChannel = LogicalChannel;

    /* Coordinator address spec */
    mlme_associate_req->CoordAddrMode = CoordAddrSpec->AddrMode;

#ifdef TEST_HARNESS_BIG_ENDIAN
    mlme_associate_req->CoordPANId
        = CPU_ENDIAN_TO_LE16(CoordAddrSpec->PANId);
#else
    mlme_associate_req->CoordPANId = CoordAddrSpec->PANId;
#endif

    ADDR_COPY_DST_SRC_64(mlme_associate_req->CoordAddress.long_address,
                         CoordAddrSpec->Addr.long_address);

    /* Other fields */
    mlme_associate_req->CapabilityInformation = CapabilityInformation;
    mlme_associate_req->ChannelPage = ChannelPage;

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

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

    return true;
}
/**
 * @brief Obtains the message type from the buffer and calls the respective handler
 *
 * This function decodes all events/messages and calls the appropriate handler.
 *
 * @param event Pointer to the buffer header whose body part holds the message
 * type and message elemnets
 */
void dispatch_event(uint8_t *event)
{
    /*
     * A pointer to the body of the buffer is obtained from the pointer to the
     * received header.
     */
    uint8_t *buffer_body = BMM_BUFFER_POINTER((buffer_t *)event);

    /* Check is done to see if the message type is valid */
    /* Please note:
     * The macro PGM_READ_WORD is only relevant for AVR-GCC builds and
     * reads a DWord from flash, which is the start address of the function.
     *
     * How does this work for builds that are larger than 128K?
     *
     * For IAR builds this statement is fine, since PGM_READ_WORD just
     * turns to "*". The size of the function pointer is automatically
     * 3 byte for MCUs which have more than 128K flash. The the address
     * of the callback is properly derived from this location.
     *
     * AVR-GCC currently does not support function pointers larger than
     * 16 bit. This implies that functions residing in the upper 128K
     * cannot be addressed properly. Therefore this code does not work
     * in these cases.
     * In regular cases, where code is not larger than 128K, the size
     * of a function pointer is 16 bit and properly read via PGM_READ_WORD.
     *
     * Update: In order for this to work, the option -mrelax must be given 
     * on the compiler command-line that is used to link the final ELF file. 
     * (Older compilers did not implement this option for the AVR, 
     * use -Wl,--relax instead.)     */
    /* Check for regular MAC requests. */
    if (buffer_body[CMD_ID_OCTET] <= LAST_MESSAGE)
    {
        /*
         * The following statement reads the address from the dispatch table
         * of the function to be called by utilizing function pointers.
         */
        handler_t handler = (handler_t)PGM_READ_WORD(&dispatch_table[buffer_body[CMD_ID_OCTET]]);

        if (handler != NULL)
        {
            handler(event);
        }
        else
        {
            bmm_buffer_free((buffer_t *)event);
#if (DEBUG > 0)
            ASSERT("Dispatch handler unavailable" == 0);
#endif
        }
    }
#ifdef ENABLE_RTB
    else
    {
        dispatch_rtb_event(event);
    }
#endif  /* ENABLE_RTB */
}
Example #8
0
/**
 * @brief Callback that is called if data has been received by trx.
 *
 * @param rx_frame    Pointer to received data structure
  */
void tal_rx_frame_cb(frame_info_t *rx_frame)
{
    buffer_write_free = true;
    /* Handle the received frame */
    sniffer_handle_received_frame((uint8_t*)rx_frame);
    /* Free the received pointer */
    bmm_buffer_free(rx_frame->buffer_header);
}
Example #9
0
/**
 * @brief Wrapper function for messages of type mlme_associate_conf_t
 *
 * This function is a callback for mlme associate confirm.
 *
 * @param m Pointer to message structure
 */
void mlme_associate_conf(uint8_t *m)
{
	mlme_associate_conf_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_associate_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	usr_mlme_associate_conf(pmsg->AssocShortAddress, pmsg->status);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #10
0
/**
 * @brief Wrapper function for messages of type mcps_purge_conf_t
 *
 * This function is a callback for mcps purge confirm.
 *
 * @param m Pointer to message structure
 */
void mcps_purge_conf(uint8_t *m)
{
	mcps_purge_conf_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mcps_purge_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	usr_mcps_purge_conf(pmsg->msduHandle, pmsg->status);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #11
0
/*
 * \brief Callback that is called if data has been received by trx.
 *
 * \param frame Pointer to received frame
 */
void tal_rx_frame_cb(frame_info_t *frame)
{
	void (*handler_func)(frame_info_t *frame);

	handler_func = state_table[node_info.main_state].func_rx_frame_cb;
	if (handler_func) {
		handler_func(frame);
	}

	/* free buffer that was used for frame reception */
	bmm_buffer_free((buffer_t *)(frame->buffer_header));
}
Example #12
0
void mlme_gts_conf(uint8_t *m)
{
	mlme_gts_conf_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_gts_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	usr_mlme_gts_conf(pmsg->GtsChar, pmsg->status);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #13
0
void mlme_gts_ind(uint8_t *m)
{
	mlme_gts_ind_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_gts_ind_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	usr_mlme_gts_ind(pmsg->DeviceAddr, pmsg->GtsChar);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #14
0
/**
 * @brief Wrapper function for messages of type mlme_disassociate_ind_t
 *
 * This function is a callback for mlme disassociate indication.
 *
 * @param m Pointer to message structure
 */
void mlme_disassociate_ind(uint8_t *m)
{
	mlme_disassociate_ind_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_disassociate_ind_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	usr_mlme_disassociate_ind(pmsg->DeviceAddress,
			pmsg->DisassociateReason);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #15
0
/**
 * @brief Wrapper function for messages of type mlme_orphan_ind_t
 *
 * This function is a callback for mlme orphan indication.
 *
 * @param m Pointer to message structure
 */
void mlme_orphan_ind(uint8_t *m)
{
	mlme_orphan_ind_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_orphan_ind_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	/* Callback function */
	usr_mlme_orphan_ind(pmsg->OrphanAddress);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #16
0
/**
 * @brief Wrapper function for messages of type mcps_data_ind_t
 *
 * This function is a callback for mcps data indication
 *
 * @param m Pointer to message structure
 */
void mcps_data_ind(uint8_t *m)
{
	mcps_data_ind_t *pmsg;
	wpan_addr_spec_t src_addr;
	wpan_addr_spec_t dst_addr;

	/* Get the buffer body from buffer header */
	pmsg = (mcps_data_ind_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	/* Source address spec */
	src_addr.AddrMode = pmsg->SrcAddrMode;
	src_addr.PANId = pmsg->SrcPANId;
	src_addr.Addr.long_address = pmsg->SrcAddr;
	ADDR_COPY_DST_SRC_64(src_addr.Addr.long_address, pmsg->SrcAddr);

	/* Destination address spec */
	dst_addr.AddrMode = pmsg->DstAddrMode;
	dst_addr.PANId = pmsg->DstPANId;
	ADDR_COPY_DST_SRC_64(dst_addr.Addr.long_address, pmsg->DstAddr);

	/* Callback function */
#if ((defined MAC_SECURITY_ZIP)  || (defined MAC_SECURITY_2006))
	usr_mcps_data_ind(&src_addr,
			&dst_addr,
			pmsg->msduLength,
			pmsg->msdu,
			pmsg->mpduLinkQuality,
			pmsg->DSN,
    #ifdef ENABLE_TSTAMP
			pmsg->Timestamp,
    #endif  /* ENABLE_TSTAMP */
			pmsg->SecurityLevel,
			pmsg->KeyIdMode,
			pmsg->KeyIndex);
#else   /* No MAC_SECURITY */
	usr_mcps_data_ind(&src_addr,
			&dst_addr,
			pmsg->msduLength,
			pmsg->msdu,
			pmsg->mpduLinkQuality,
    #ifdef ENABLE_TSTAMP
			pmsg->DSN,
			pmsg->Timestamp);
    #else
			pmsg->DSN);
    #endif  /* ENABLE_TSTAMP */
#endif  /* MAC_SECURITY */

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #17
0
bool wpan_mlme_associate_resp(uint64_t DeviceAddress,
                              uint16_t AssocShortAddress,
                              uint8_t status)
{
    buffer_t *buffer_header;
    mlme_associate_resp_t *mlme_associate_resp;

    /* Allocate a small buffer for association response */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

    if (NULL == buffer_header) {
        /* Buffer is not available */
        return false;
    }

    /* Get the buffer body from buffer header */
    mlme_associate_resp = (mlme_associate_resp_t *)BMM_BUFFER_POINTER(
                              buffer_header);

    /* Construct mlme_associate_resp_t message */
    mlme_associate_resp->cmdcode = MLME_ASSOCIATE_RESPONSE;

    /* Other fields */
#ifdef TEST_HARNESS_BIG_ENDIAN
    mlme_associate_resp->DeviceAddress  = CPU_ENDIAN_TO_LE64(DeviceAddress);
    mlme_associate_resp->AssocShortAddress = CPU_ENDIAN_TO_LE16(
                AssocShortAddress);
#else
    mlme_associate_resp->DeviceAddress  = DeviceAddress;
    mlme_associate_resp->AssocShortAddress = AssocShortAddress;
#endif
    mlme_associate_resp->status = status;

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

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

    return true;
}
Example #18
0
bool wpan_mlme_poll_req(wpan_addr_spec_t *CoordAddrSpec)
{
    buffer_t *buffer_header;
    mlme_poll_req_t *mlme_poll_req;

    /* Allocate a small buffer for poll request */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

    if (NULL == buffer_header) {
        /* Buffer is not available */
        return false;
    }

    /* Get the buffer body from buffer header */
    mlme_poll_req = (mlme_poll_req_t *)BMM_BUFFER_POINTER(buffer_header);

    /* construct mlme_poll_req_t message */
    mlme_poll_req->cmdcode = MLME_POLL_REQUEST;

    /* Other fileds. */
    mlme_poll_req->CoordAddrMode = CoordAddrSpec->AddrMode;
#ifdef TEST_HARNESS_BIG_ENDIAN
    mlme_poll_req->CoordPANId = CPU_ENDIAN_TO_LE16(CoordAddrSpec->PANId);
#else
    mlme_poll_req->CoordPANId = CoordAddrSpec->PANId;
#endif
    if (WPAN_ADDRMODE_SHORT == CoordAddrSpec->AddrMode) {
        ADDR_COPY_DST_SRC_16(mlme_poll_req->CoordAddress,
                             CoordAddrSpec->Addr.short_address);
    } else {
        ADDR_COPY_DST_SRC_64(mlme_poll_req->CoordAddress,
                             CoordAddrSpec->Addr.long_address);
    }

#ifdef ENABLE_QUEUE_CAPACITY
    if (MAC_SUCCESS != qmm_queue_append(&nhle_mac_q, buffer_header)) {
        /*
         * MLME-POLL.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;
}
Example #19
0
bool wpan_mlme_disassociate_req(wpan_addr_spec_t *DeviceAddrSpec,
                                uint8_t DisassociateReason,
                                bool TxIndirect)
{
    buffer_t *buffer_header;
    mlme_disassociate_req_t *mlme_disassociate_req;

    /* Allocate a small buffer for disassociation request */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

    if (NULL == buffer_header) {
        /* Buffer is not available */
        return false;
    }

    /* Get the buffer body from buffer header */
    mlme_disassociate_req = (mlme_disassociate_req_t *)BMM_BUFFER_POINTER(
                                buffer_header);

    /* Update the disassociate request structure */
    mlme_disassociate_req->cmdcode = MLME_DISASSOCIATE_REQUEST;
    mlme_disassociate_req->DisassociateReason = DisassociateReason;
    mlme_disassociate_req->DeviceAddrMode = DeviceAddrSpec->AddrMode;
#ifdef TEST_HARNESS_BIG_ENDIAN
    mlme_disassociate_req->DevicePANId = CPU_ENDIAN_TO_LE16(
            DeviceAddrSpec->PANId);
#else
    mlme_disassociate_req->DevicePANId = DeviceAddrSpec->PANId;
#endif
    ADDR_COPY_DST_SRC_64(mlme_disassociate_req->DeviceAddress,
                         DeviceAddrSpec->Addr.long_address);
    mlme_disassociate_req->TxIndirect = TxIndirect;

#ifdef ENABLE_QUEUE_CAPACITY
    if (MAC_SUCCESS != qmm_queue_append(&nhle_mac_q, buffer_header)) {
        /*
         * MLME-DISASSOCIATE.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;
}
Example #20
0
/**
 * @brief Wrapper function for messages of type mcps_data_conf_t
 *
 * This function is a callback for mcps data confirm.
 *
 * @param m Pointer to message structure
 */
void mcps_data_conf(uint8_t *m)
{
	mcps_data_conf_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mcps_data_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

#ifdef ENABLE_TSTAMP
	usr_mcps_data_conf(pmsg->msduHandle, pmsg->status, pmsg->Timestamp);
#else
	usr_mcps_data_conf(pmsg->msduHandle, pmsg->status);
#endif  /* ENABLE_TSTAMP */

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #21
0
bool wpan_mlme_orphan_resp(uint64_t OrphanAddress,
                           uint16_t ShortAddress,
                           bool AssociatedMember)
{
    buffer_t *buffer_header;
    mlme_orphan_resp_t *mlme_orphan_resp;

    /* Allocate a small buffer for orphan response */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

    if (NULL == buffer_header) {
        /* Buffer is not available */
        return false;
    }

    /* Get the buffer body from buffer header */
    mlme_orphan_resp = (mlme_orphan_resp_t *)BMM_BUFFER_POINTER(
                           buffer_header);

    /* Update the orphan response structure */
    mlme_orphan_resp->cmdcode = MLME_ORPHAN_RESPONSE;
#ifdef TEST_HARNESS_BIG_ENDIAN
    mlme_orphan_resp->OrphanAddress = CPU_ENDIAN_TO_LE64(OrphanAddress);
    mlme_orphan_resp->ShortAddress  = CPU_ENDIAN_TO_LE16(ShortAddress);
#else
    mlme_orphan_resp->OrphanAddress = OrphanAddress;
    mlme_orphan_resp->ShortAddress  = ShortAddress;
#endif
    mlme_orphan_resp->AssociatedMember = AssociatedMember;

#ifdef ENABLE_QUEUE_CAPACITY
    if (MAC_SUCCESS != qmm_queue_append(&nhle_mac_q, buffer_header)) {
        /*
         * MLME-ORPHAN.response 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;
}
Example #22
0
/**
 * @brief Wrapper function for messages of type mlme_set_conf_t
 *
 * This function is a callback for mlme set confirm.
 *
 * @param m Pointer to message structure
 */
void mlme_set_conf(uint8_t *m)
{
	mlme_set_conf_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_set_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

#if ((defined MAC_SECURITY_ZIP)  || (defined MAC_SECURITY_2006))
	usr_mlme_set_conf(pmsg->status, pmsg->PIBAttribute,
			pmsg->PIBAttributeIndex);
#else
	usr_mlme_set_conf(pmsg->status, pmsg->PIBAttribute);
#endif  /* (MAC_SECURITY_ZIP || MAC_SECURITY_2006) */

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #23
0
/**
 * @brief Wrapper function for messages of type mlme_scan_conf_t
 *
 * This function is a callback for mlme scan confirm.
 *
 * @param m Pointer to message structure
 */
void mlme_scan_conf(uint8_t *m)
{
	mlme_scan_conf_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_scan_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	/* Callback */
	usr_mlme_scan_conf(pmsg->status,
			pmsg->ScanType,
			pmsg->ChannelPage,
			pmsg->UnscannedChannels,
			pmsg->ResultListSize,
			&pmsg->scan_result_list);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #24
0
/**
 * @brief Wrapper function for messages of type mlme_get_conf_t
 *
 * This function is a callback for mlme get confirm.
 *
 * @param m Pointer to message structure
 */
void mlme_get_conf(uint8_t *m)
{
	mlme_get_conf_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_get_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	/* Callback function */
	usr_mlme_get_conf(pmsg->status,
			pmsg->PIBAttribute,
#if ((defined MAC_SECURITY_ZIP)  || (defined MAC_SECURITY_2006))
			pmsg->PIBAttributeIndex,
#endif  /* (MAC_SECURITY_ZIP || MAC_SECURITY_2006) */
			&pmsg->PIBAttributeValue);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #25
0
/**
 * @brief Wrapper function for messages of type mlme_beacon_notify_ind_t
 *
 * This function is a callback for mlme beacon notify indication.
 *
 * @param m Pointer to message structure
 */
void mlme_beacon_notify_ind(uint8_t *m)
{
	mlme_beacon_notify_ind_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_beacon_notify_ind_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	/* Callback function */
	usr_mlme_beacon_notify_ind(pmsg->BSN,           /* BSN */
			&(pmsg->PANDescriptor),         /* PANDescriptor */
			pmsg->PendAddrSpec,             /* PendAddrSpec */
			pmsg->AddrList,                 /* AddrList */
			pmsg->sduLength,                /* sduLength */
			pmsg->sdu);                     /* sdu */

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #26
0
/**
 * @brief Internal function for flushing a specific queue
 *
 * @param q Queue to be flushed
 */
void qmm_queue_flush(queue_t *q)
{
	buffer_t *buf_to_free;

	while (q->size > 0) {
		/* Remove the buffer from the queue and free it */
		buf_to_free = qmm_queue_remove(q, NULL);

		if (NULL == buf_to_free) {
#if (_DEBUG_ > 0)
			ABORT("Corrupted queue");
#endif
			q->size = 0;
			return;
		}

		bmm_buffer_free(buf_to_free);
	}
}
Example #27
0
bool wpan_mlme_scan_req(uint8_t ScanType,
                        uint32_t ScanChannels,
                        uint8_t ScanDuration,
                        uint8_t ChannelPage)
{
    buffer_t *buffer_header;
    mlme_scan_req_t *mlme_scan_req;

    /* Allocate a small buffer for scan request */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

    if (NULL == buffer_header) {
        /* Buffer is not available */
        return false;
    }

    /* Get the buffer body from buffer header */
    mlme_scan_req = (mlme_scan_req_t *)BMM_BUFFER_POINTER(buffer_header);

    /* Update the scan request structure */
    mlme_scan_req->cmdcode = MLME_SCAN_REQUEST;
    mlme_scan_req->ScanType = ScanType;
    mlme_scan_req->ScanChannels = ScanChannels;
    mlme_scan_req->ScanDuration = ScanDuration;
    mlme_scan_req->ChannelPage = ChannelPage;

#ifdef ENABLE_QUEUE_CAPACITY
    if (MAC_SUCCESS != qmm_queue_append(&nhle_mac_q, buffer_header)) {
        /*
         * MLME-SCAN.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;
}
Example #28
0
/**
 * @brief Wrapper function for messages of type mlme_associate_ind_t
 *
 * This function is a callback for mlme associate indication.
 *
 * @param m Pointer to message structure
 */
void mlme_associate_ind(uint8_t *m)
{
	mlme_associate_ind_t *pmsg;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_associate_ind_t *)BMM_BUFFER_POINTER((buffer_t *)m);

#if  SAMD || SAMR21 || SAM4L || SAM4S || SAM4E
	uint64_t device_addr_temp = 0;
	memcpy((uint8_t *)&device_addr_temp, (uint8_t *)&pmsg->DeviceAddress,
			sizeof(device_addr_temp));
	usr_mlme_associate_ind(device_addr_temp, pmsg->CapabilityInformation);
#else
	usr_mlme_associate_ind(pmsg->DeviceAddress,
			pmsg->CapabilityInformation);
#endif

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #29
0
/**
 * @brief Wrapper function for messages of type mlme_disassociate_conf_t
 *
 * This function is a callback for mlme disassociate confirm.
 *
 * @param m Pointer to message structure
 */
void mlme_disassociate_conf(uint8_t *m)
{
	mlme_disassociate_conf_t *pmsg;
	wpan_addr_spec_t device_addr;

	/* Get the buffer body from buffer header */
	pmsg = (mlme_disassociate_conf_t *)BMM_BUFFER_POINTER(((buffer_t *)m));

	/* Device address spec */
	device_addr.AddrMode = pmsg->DeviceAddrMode;
	device_addr.PANId = pmsg->DevicePANId;
	ADDR_COPY_DST_SRC_64(device_addr.Addr.long_address,
			pmsg->DeviceAddress);

	usr_mlme_disassociate_conf(pmsg->status,
			&device_addr);

	/* Free the buffer */
	bmm_buffer_free((buffer_t *)m);
}
Example #30
0
bool wpan_mlme_rx_enable_req(bool DeferPermit,
                             uint32_t RxOnTime,
                             uint32_t RxOnDuration)
{
    buffer_t *buffer_header;
    mlme_rx_enable_req_t *mlme_rx_enable_req;

    /* Allocate a small buffer for rx enable request */
    buffer_header = bmm_buffer_alloc(LARGE_BUFFER_SIZE);

    if (NULL == buffer_header) {
        /* Buffer is not available */
        return false;
    }

    /* Get the buffer body from buffer header */
    mlme_rx_enable_req = (mlme_rx_enable_req_t *)BMM_BUFFER_POINTER(
                             buffer_header);

    /* Update the rx enable request structure */
    mlme_rx_enable_req->cmdcode = MLME_RX_ENABLE_REQUEST;
    mlme_rx_enable_req->DeferPermit = DeferPermit;
    mlme_rx_enable_req->RxOnTime = RxOnTime;
    mlme_rx_enable_req->RxOnDuration = RxOnDuration;

#ifdef ENABLE_QUEUE_CAPACITY
    if (MAC_SUCCESS != qmm_queue_append(&nhle_mac_q, buffer_header)) {
        /*
         * MLME-RX-ENABLE.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;
}