Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
mac_mcps_sap.h
00001 /* 00002 * Copyright (c) 2016-2017, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 /* 00019 * mac_mcps_sap.h 00020 * 00021 * Created on: 19 Jan 2016 00022 * Author: juhhei01 00023 */ 00024 00025 #ifndef MAC_IEEE802_15_4_MAC_MCPS_SAP_H_ 00026 #define MAC_IEEE802_15_4_MAC_MCPS_SAP_H_ 00027 00028 #include "mlme.h" 00029 #include "mac_common_defines.h" 00030 00031 struct protocol_interface_rf_mac_setup; 00032 struct mcps_data_req_s; 00033 struct arm_phy_sap_msg_s; 00034 struct mcps_purge_s; 00035 00036 /** Address types */ 00037 typedef enum { 00038 MAC_FRAME_REQ, /*!< MAC upper layer data request message */ 00039 MAC_PHY_RAW_REQ, 00040 MAC_PARSED_FRAME_IND, /*!< PD-SAP parsed MAC Frame */ 00041 }mac_mcps_primitiv_type; 00042 00043 00044 #define MAC_PD_DATA_NORMAL_PRIORITY 0 //Normal MCPS DATA REQ 00045 #define MAC_PD_DATA_MEDIUM_PRIORITY 1 //Indirect Data which is polled 00046 #define MAC_PD_DATA_HIGH_PRIOTITY 2 //Beacon request Beacon response 00047 00048 #define MCPS_SAP_DATA_IND_EVENT 1 00049 #define MCPS_SAP_DATA_CNF_EVENT 2 00050 #define MAC_MLME_EVENT_HANDLER 3 00051 #define MAC_MCPS_INDIRECT_TIMER_CB 4 00052 #define MAC_MLME_SCAN_CONFIRM_HANDLER 5 00053 #define MAC_SAP_TRIG_TX 6 00054 00055 00056 /** 00057 * @brief struct mac_aux_security_header_t MAC auxiliarity security header structure 00058 * INTERNAL use only 00059 */ 00060 typedef struct mac_aux_security_header_s { 00061 unsigned securityLevel:3; 00062 unsigned KeyIdMode:2; 00063 uint32_t frameCounter; 00064 uint8_t Keysource[8]; 00065 uint8_t KeyIndex; 00066 } mac_aux_security_header_t; 00067 00068 typedef struct mac_fcf_sequence_s{ 00069 unsigned frametype:3; 00070 bool securityEnabled:1; 00071 bool framePending :1; 00072 bool ackRequested:1; 00073 bool intraPan:1; 00074 unsigned DstAddrMode:2; /*0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */ 00075 unsigned frameVersion:2; 00076 unsigned SrcAddrMode:2; /*0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */ 00077 uint8_t DSN; 00078 }mac_fcf_sequence_t; 00079 00080 typedef struct mac_pre_parsed_frame_s{ 00081 void *mac_class_ptr; 00082 mlme_device_descriptor_t *neigh_info; 00083 uint8_t LQI; 00084 int8_t dbm; 00085 mac_fcf_sequence_t fcf_dsn; 00086 uint16_t frameLength; //Encoded or open payload length 00087 uint8_t mac_header_length; 00088 uint8_t security_aux_header_length; 00089 uint16_t mac_payload_length; 00090 uint32_t timestamp; 00091 bool ack_pendinfg_status; 00092 uint8_t buf[]; /*!< Trailing buffer data */ 00093 } mac_pre_parsed_frame_t; 00094 00095 typedef struct mac_pre_build_frame{ 00096 mac_fcf_sequence_t fcf_dsn; 00097 uint16_t DstPANId; 00098 uint8_t DstAddr[8]; 00099 uint16_t SrcPANId; 00100 uint8_t SrcAddr[8]; 00101 mac_aux_security_header_t aux_header; 00102 uint8_t mac_command_id; //For MLME 00103 uint16_t mac_payload_length; 00104 uint8_t msduHandle; 00105 uint16_t buffer_ttl; 00106 uint8_t *mac_payload; 00107 uint8_t status; 00108 bool upper_layer_request; 00109 bool mac_allocated_payload_ptr:1; 00110 unsigned mac_header_length_with_security : 6; //Total max is 37 00111 unsigned security_mic_len:5; //Max possible lengths 0, 4, 8, 16 bytes 00112 unsigned priority:2; 00113 struct mac_pre_build_frame *next; //Pointer for queue purpose 00114 } mac_pre_build_frame_t; 00115 00116 00117 void mac_generic_event_trig(uint8_t event_type, void *mac_ptr, bool low_latency); 00118 00119 /** 00120 * Create MAC MCPS event handler tasklet 00121 */ 00122 int8_t mac_mcps_sap_tasklet_init(void); 00123 00124 /** 00125 * Free MAC MCPS SAP layer pre parsed buffer 00126 */ 00127 void mcps_sap_pre_parsed_frame_buffer_free(mac_pre_parsed_frame_t *buf); 00128 00129 00130 /** 00131 * Allocate MCPS SAP data request buffer frame 00132 * 00133 * \param payload_size set 0 when MCPS-DATA-REQUSEST other wise MAC internal packet send need to set dynamic payload size!! 00134 */ 00135 mac_pre_build_frame_t * mcps_sap_prebuild_frame_buffer_get(uint16_t payload_size); 00136 00137 /** 00138 * Free MCPS SAP data request buffer frame 00139 * 00140 * \param buffer pointer to allocated frame 00141 */ 00142 void mcps_sap_prebuild_frame_buffer_free(mac_pre_build_frame_t *buffer); 00143 00144 void mcps_sap_pd_req_queue_write(struct protocol_interface_rf_mac_setup *rf_mac_setup, mac_pre_build_frame_t *buffer); 00145 00146 00147 /** 00148 * Allocate MAC MCPS SAP layer buffer for received PHY layer Data Indication 00149 */ 00150 mac_pre_parsed_frame_t * mcps_sap_pre_parsed_frame_buffer_get(const uint8_t *data_ptr, uint16_t frame_length); 00151 00152 /** 00153 * Forward Buffer for MAC MCPS SAP layer event handler 00154 */ 00155 int8_t mcps_sap_pd_ind(mac_pre_parsed_frame_t *buffer); 00156 00157 /** 00158 * MAC MCPS SAP layer data confirmation event trig 00159 */ 00160 void mcps_sap_pd_confirm(void *mac_ptr); 00161 00162 int8_t mac_virtual_sap_data_cb(void *identifier, struct arm_phy_sap_msg_s *message); 00163 00164 void mcps_sap_data_req_handler(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req ); 00165 00166 void mac_mcps_trig_buffer_from_queue(struct protocol_interface_rf_mac_setup *rf_mac_setup); 00167 00168 void mac_mcps_buffer_queue_free(struct protocol_interface_rf_mac_setup *rf_mac_setup); 00169 00170 bool mac_is_ack_request_set(mac_pre_build_frame_t *buffer); 00171 00172 int mac_convert_frame_type_to_fhss(uint8_t frame_type); 00173 00174 void mcps_sap_trig_tx(void *mac_ptr); 00175 00176 void mcps_sap_purge_reg_handler(struct protocol_interface_rf_mac_setup *rf_mac_setup, const struct mcps_purge_s *purge_req); 00177 00178 #endif /* MAC_IEEE802_15_4_MAC_MCPS_SAP_H_ */
Generated on Fri Jul 22 2022 04:53:54 by
