Microchip® Advanced Software Framework

mac_data_ind.c File Reference

Implements incoming frame handling in the MAC.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include <compiler.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "return_val.h"
#include "pal.h"
#include "bmm.h"
#include "qmm.h"
#include "tal.h"
#include "ieee_const.h"
#include "mac_msg_const.h"
#include "mac_api.h"
#include "mac_msg_types.h"
#include "mac_data_structures.h"
#include "stack_config.h"
#include "mac_internal.h"
#include "mac.h"
#include "mac_config.h"
#include "mac_build_config.h"

Macros

#define GET_PAN_COORDINATOR(spec)   (((spec) & 0x4000) >> 14)
 
#define GTS_DESCRIPTOR_COUNTER_MASK   (0x07)
 
#define PAN_ID_CONFLICT_PAYLOAD_LEN   (1)
 

Functions

static void check_for_pan_id_conflict_non_pc (bool in_scan)
 PAN-Id conflict detection NOT as PAN-Coordinator. More...
 
void mac_process_tal_data_ind (uint8_t *msg)
 Depending on received frame the appropriate function is called. More...
 
static bool parse_mpdu (frame_info_t *frameptr)
 
static bool process_data_ind_not_transient (buffer_t *b_ptr, frame_info_t *f_ptr)
 Continues processing a data indication from the TAL for non-polling and non-scanning states of the MAC (mac_poll_state == MAC_POLL_IDLE, mac_scan_state == MAC_SCAN_IDLE). More...
 
static bool process_data_ind_scanning (buffer_t *b_ptr)
 Continues processing a data indication from the TAL for scanning states of the MAC (mac_scan_state == MAC_SCAN_IDLE). More...
 
void tal_rx_frame_cb (frame_info_t *frame)
 Callback function called by TAL on reception of any frame. More...
 
static bool tx_pan_id_conf_notif (void)
 Sends a PAN-Id conflict detection command frame. More...
 

#define GET_PAN_COORDINATOR (   spec)    (((spec) & 0x4000) >> 14)
#define GTS_DESCRIPTOR_COUNTER_MASK   (0x07)

Referenced by parse_mpdu().

#define PAN_ID_CONFLICT_PAYLOAD_LEN   (1)

Referenced by tx_pan_id_conf_notif().

static void check_for_pan_id_conflict_non_pc ( bool  in_scan)
static

PAN-Id conflict detection NOT as PAN-Coordinator.

This function handles the detection of PAN-Id Conflict detection in case the node is NOT a PAN Coordinator.

Parameters
in_scanIndicates whether node is currently scanning

References frame_payload_t::beacon_data, GET_PAN_COORDINATOR, address_field_t::long_address, mac_pib_tag::mac_CoordExtendedAddress, mac_pib_tag::mac_CoordShortAddress, mac_parse_data, parse_tag::mac_payload_data, mac_pib, MAC_SCAN_ACTIVE_REQUEST_CONFIRM, mac_scan_orig_panid, MAC_SCAN_PASSIVE_REQUEST_CONFIRM, address_field_t::short_address, parse_tag::src_addr, parse_tag::src_panid, tal_pib, and tx_pan_id_conf_notif().

Referenced by process_data_ind_not_transient(), and process_data_ind_scanning().

static bool parse_mpdu ( frame_info_t frameptr)
static

References aMaxMACPayloadSize, Assert, frame_payload_t::assoc_req_data, frame_payload_t::assoc_response_data, ASSOCIATIONREQUEST, ASSOCIATIONRESPONSE, frame_payload_t::beacon_data, BEACONREQUEST, bmm_buffer_alloc(), BMM_BUFFER_POINTER, CLE16_TO_CPU_ENDIAN, mlme_comm_status_ind_tag::cmdcode, convert_byte_array_to_16_bit(), frame_payload_t::coord_realign_data, mac_coord_realign_tag::coord_short_addr, COORDINATORREALIGNMENT, frame_payload_t::data, DATAREQUEST, parse_tag::dest_addr, parse_tag::dest_addr_mode, frame_payload_t::disassoc_req_data, DISASSOCIATIONNOTIFICATION, mlme_comm_status_ind_tag::DstAddr, mlme_comm_status_ind_tag::DstAddrMode, parse_tag::fcf, FCF_FRAME_VERSION_2006, FCF_FRAMETYPE_BEACON, FCF_FRAMETYPE_DATA, FCF_FRAMETYPE_MAC_CMD, FCF_GET_FRAMETYPE, FCF_SECURITY_ENABLED, parse_tag::frame_type, GTS_DESCRIPTOR_COUNTER_MASK, mac_beacon_payload_tag::gts_spec, GTSREQUEST, LARGE_BUFFER_SIZE, address_field_t::long_address, parse_tag::mac_command, mac_extract_mhr_addr_info(), mac_nhle_q, mac_parse_data, parse_tag::mac_payload_data, parse_tag::mac_payload_length, MAC_SUCCESS, MLME_COMM_STATUS_INDICATION, frame_info_tag::mpdu, NUM_LONG_PEND_ADDR, NUM_SHORT_PEND_ADDR, ORPHANNOTIFICATION, mac_coord_realign_tag::pan_id, mlme_comm_status_ind_tag::PANId, PANIDCONFLICTNOTIFICAION, mac_data_payload_tag::payload, mac_beacon_payload_tag::pending_addr_spec, qmm_queue_append(), parse_tag::sequence_number, mac_assoc_response_tag::short_addr, mac_coord_realign_tag::short_addr, parse_tag::src_addr, parse_tag::src_addr_mode, mlme_comm_status_ind_tag::SrcAddr, mlme_comm_status_ind_tag::SrcAddrMode, mlme_comm_status_ind_tag::status, mac_beacon_payload_tag::superframe_spec, tal_pib, parse_tag::time_stamp, and frame_info_tag::time_stamp.

Referenced by mac_process_tal_data_ind().

static bool process_data_ind_not_transient ( buffer_t b_ptr,
frame_info_t f_ptr 
)
static

Continues processing a data indication from the TAL for non-polling and non-scanning states of the MAC (mac_poll_state == MAC_POLL_IDLE, mac_scan_state == MAC_SCAN_IDLE).

Parameters
b_ptrPointer to the buffer header.
f_ptrPointer to the frame_info_t structure.
Returns
bool True if frame has been processed, or false otherwise.

References Assert, ASSOCIATIONREQUEST, BEACONREQUEST, bmm_buffer_free(), BO_USED_FOR_MAC_PERS_TIME, check_for_pan_id_conflict_non_pc(), COORDINATORREALIGNMENT, DATAREQUEST, DISASSOCIATIONNOTIFICATION, FAILURE, FCF_FRAMETYPE_BEACON, FCF_FRAMETYPE_DATA, FCF_FRAMETYPE_MAC_CMD, FCF_LONG_ADDR, FCF_SHORT_ADDR, FINAL_CAP_SLOT_DEFAULT, parse_tag::frame_type, FUNC_PTR, GTSREQUEST, MAC_ACTIVE_CAP, MAC_ASSOCIATED, mac_pib_tag::mac_AssociatedPANCoord, parse_tag::mac_command, mac_pib_tag::mac_CoordExtendedAddress, MAC_COORDINATOR, mac_pib_tag::mac_CoordShortAddress, MAC_IDLE, mac_idle_trans(), MAC_PAN_COORD_STARTED, MAC_PAN_ID_CONFLICT, mac_parse_data, mac_pib, MAC_POLL_IDLE, mac_poll_state, mac_process_beacon_frame(), mac_process_coord_realign(), mac_process_data_frame(), mac_process_disassociate_notification(), MAC_SCAN_IDLE, mac_scan_state, mac_sleep_trans(), mac_state, MAC_SUCCESS, MAC_SYNC_BEFORE_ASSOC, mac_sync_loss(), MAC_SYNC_NEVER, MAC_SYNC_ONCE, mac_sync_state, MAC_SYNC_TRACKING_BEACON, mac_trx_wakeup(), macBeaconTxTime, NON_BEACON_NWK, ORPHANNOTIFICATION, pal_is_timer_running(), pal_timer_start(), pal_timer_stop(), PANIDCONFLICTNOTIFICAION, PHY_RX_ON, port_pin_set_output_level(), port_pin_toggle_output_level(), set_tal_pib_internal(), parse_tag::src_addr, parse_tag::src_addr_mode, parse_tag::src_panid, tal_add_time_symbols(), TAL_CONVERT_SYMBOLS_TO_US, TAL_CONVERT_US_TO_SYMBOLS, TAL_GET_BEACON_INTERVAL_TIME, TAL_GET_SUPERFRAME_DURATION_TIME, tal_pib, TAL_RADIO_WAKEUP_TIME_SYM, tal_rx_enable(), tal_sub_time_symbols(), frame_info_tag::time_stamp, TIMEOUT_ABSOLUTE, and TIMEOUT_RELATIVE.

Referenced by mac_process_tal_data_ind().

static bool process_data_ind_scanning ( buffer_t b_ptr)
static

Continues processing a data indication from the TAL for scanning states of the MAC (mac_scan_state == MAC_SCAN_IDLE).

Parameters
b_ptrPointer to the buffer header.
Returns
bool True if frame has been processed, or false otherwise.

References Assert, check_for_pan_id_conflict_non_pc(), COORDINATORREALIGNMENT, FCF_FRAMETYPE_BEACON, FCF_FRAMETYPE_MAC_CMD, parse_tag::frame_type, MAC_ASSOCIATED, mac_pib_tag::mac_AssociatedPANCoord, parse_tag::mac_command, MAC_COORDINATOR, MAC_PAN_COORD_STARTED, mac_parse_data, mac_pib, mac_process_beacon_frame(), mac_process_orphan_realign(), MAC_SCAN_ACTIVE, MAC_SCAN_ED, MAC_SCAN_ORPHAN, MAC_SCAN_PASSIVE, mac_scan_state, mac_state, pal_timer_stop(), and T_Scan_Duration.

Referenced by mac_process_tal_data_ind().

void tal_rx_frame_cb ( frame_info_t frame)

Callback function called by TAL on reception of any frame.

User call back function for frame reception.

This function pushes an event into the TAL-MAC queue, indicating a frame reception.

Parameters
framePointer to recived frame

References Assert, frame_info_tag::buffer_header, frame_info_tag::msg_type, qmm_queue_append(), TAL_DATA_INDICATION, and tal_mac_q.

Referenced by process_incoming_frame().