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.
mac_mcps_sap.h
00001 /* 00002 * Copyright (c) 2016-2018, 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 struct mcps_data_ie_list; 00036 struct mcps_data_req_ie_list; 00037 struct channel_list_s; 00038 00039 /** Address types */ 00040 typedef enum { 00041 MAC_FRAME_REQ, /*!< MAC upper layer data request message */ 00042 MAC_PHY_RAW_REQ, 00043 MAC_PARSED_FRAME_IND, /*!< PD-SAP parsed MAC Frame */ 00044 }mac_mcps_primitiv_type; 00045 00046 00047 #define MAC_PD_DATA_NORMAL_PRIORITY 0 //Normal MCPS DATA REQ 00048 #define MAC_PD_DATA_MEDIUM_PRIORITY 1 //Indirect Data which is polled 00049 #define MAC_PD_DATA_HIGH_PRIOTITY 2 //Beacon request Beacon response 00050 00051 #define MCPS_SAP_DATA_IND_EVENT 1 00052 #define MCPS_SAP_DATA_CNF_EVENT 2 00053 #define MAC_MLME_EVENT_HANDLER 3 00054 #define MAC_MCPS_INDIRECT_TIMER_CB 4 00055 #define MAC_MLME_SCAN_CONFIRM_HANDLER 5 00056 #define MAC_SAP_TRIG_TX 6 00057 #define MCPS_SAP_DATA_ACK_CNF_EVENT 7 00058 00059 00060 /** 00061 * @brief struct mac_aux_security_header_t MAC auxiliarity security header structure 00062 * INTERNAL use only 00063 */ 00064 typedef struct mac_aux_security_header_s { 00065 unsigned securityLevel:3; 00066 unsigned KeyIdMode:2; 00067 uint32_t frameCounter; 00068 uint8_t Keysource[8]; 00069 uint8_t KeyIndex; 00070 } mac_aux_security_header_t; 00071 00072 typedef struct mac_fcf_sequence_s{ 00073 unsigned frametype:3; 00074 bool securityEnabled:1; 00075 bool framePending :1; 00076 bool ackRequested:1; 00077 bool intraPan:1; 00078 bool sequenceNumberSuppress:1; 00079 bool informationElementsPresets:1; 00080 bool DstPanPresents:1; 00081 bool SrcPanPresents:1; 00082 unsigned DstAddrMode:2; /*0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */ 00083 unsigned frameVersion:2; 00084 unsigned SrcAddrMode:2; /*0x00 = no address 0x01 = reserved 0x02 = 16-bit short address 0x03 = 64-bit extended address */ 00085 uint8_t DSN; 00086 }mac_fcf_sequence_t; 00087 00088 typedef struct mac_pre_parsed_frame_s{ 00089 void *mac_class_ptr; 00090 uint8_t *payloadsIePtr; 00091 uint8_t *headerIePtr; 00092 uint8_t *macPayloadPtr; 00093 mlme_device_descriptor_t *neigh_info; 00094 uint8_t LQI; 00095 int8_t dbm; 00096 mac_fcf_sequence_t fcf_dsn; 00097 uint16_t frameLength; //Encoded or open payload length 00098 uint16_t payloadsIeLength; 00099 uint16_t headerIeLength; 00100 uint16_t mac_header_length; 00101 uint16_t header_ie_length; 00102 uint8_t security_aux_header_length; 00103 uint16_t mac_payload_length; 00104 uint32_t timestamp; 00105 bool ack_pendinfg_status; 00106 00107 uint8_t buf[]; /*!< Trailing buffer data */ 00108 } mac_pre_parsed_frame_t; 00109 00110 typedef struct mac_pre_build_frame{ 00111 mac_fcf_sequence_t fcf_dsn; 00112 uint16_t DstPANId; 00113 uint8_t DstAddr[8]; 00114 uint16_t SrcPANId; 00115 uint8_t SrcAddr[8]; 00116 mac_aux_security_header_t aux_header; 00117 uint8_t mac_command_id; //For MLME 00118 uint16_t payloadsIeLength; 00119 uint16_t headerIeLength; 00120 uint16_t mac_payload_length; 00121 uint16_t mac_header_length_with_security; 00122 uint8_t msduHandle; 00123 uint16_t buffer_ttl; 00124 struct mcps_data_req_ie_list ie_elements; 00125 struct channel_list_s asynch_channel_list; 00126 uint8_t *mac_payload; 00127 uint8_t status; 00128 uint8_t asynch_channel; 00129 uint32_t tx_time; 00130 bool upper_layer_request; 00131 bool mac_allocated_payload_ptr:1; 00132 bool asynch_request:1; 00133 bool message_builded:1; 00134 unsigned security_mic_len:5; //Max possible lengths 0, 4, 8, 16 bytes 00135 unsigned priority:2; 00136 struct mac_pre_build_frame *next; //Pointer for queue purpose 00137 } mac_pre_build_frame_t; 00138 00139 00140 void mac_generic_event_trig(uint8_t event_type, void *mac_ptr, bool low_latency); 00141 00142 /** 00143 * Create MAC MCPS event handler tasklet 00144 */ 00145 int8_t mac_mcps_sap_tasklet_init(void); 00146 00147 /** 00148 * Free MAC MCPS SAP layer pre parsed buffer 00149 */ 00150 void mcps_sap_pre_parsed_frame_buffer_free(mac_pre_parsed_frame_t *buf); 00151 00152 00153 /** 00154 * Allocate MCPS SAP data request buffer frame 00155 * 00156 * \param payload_size set 0 when MCPS-DATA-REQUSEST other wise MAC internal packet send need to set dynamic payload size!! 00157 */ 00158 mac_pre_build_frame_t * mcps_sap_prebuild_frame_buffer_get(uint16_t payload_size); 00159 00160 /** 00161 * Free MCPS SAP data request buffer frame 00162 * 00163 * \param buffer pointer to allocated frame 00164 */ 00165 void mcps_sap_prebuild_frame_buffer_free(mac_pre_build_frame_t *buffer); 00166 00167 void mcps_sap_pd_req_queue_write(struct protocol_interface_rf_mac_setup *rf_mac_setup, mac_pre_build_frame_t *buffer); 00168 00169 00170 /** 00171 * Allocate MAC MCPS SAP layer buffer for received PHY layer Data Indication 00172 */ 00173 mac_pre_parsed_frame_t * mcps_sap_pre_parsed_frame_buffer_get(const uint8_t *data_ptr, uint16_t frame_length); 00174 00175 /** 00176 * Forward Buffer for MAC MCPS SAP layer event handler 00177 */ 00178 int8_t mcps_sap_pd_ind(mac_pre_parsed_frame_t *buffer); 00179 00180 /** 00181 * MAC MCPS SAP layer data confirmation event trig 00182 */ 00183 void mcps_sap_pd_confirm(void *mac_ptr); 00184 00185 void mcps_sap_pd_ack(void *ack_ptr); 00186 00187 int8_t mac_virtual_sap_data_cb(void *identifier, struct arm_phy_sap_msg_s *message); 00188 00189 void mcps_sap_data_req_handler(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req ); 00190 00191 void mcps_sap_data_req_handler_ext(struct protocol_interface_rf_mac_setup *rf_mac_setup , const struct mcps_data_req_s *data_req , const struct mcps_data_req_ie_list *ie_list, const channel_list_s *asynch_channel_list); 00192 00193 void mac_mcps_trig_buffer_from_queue(struct protocol_interface_rf_mac_setup *rf_mac_setup); 00194 00195 void mac_mcps_buffer_queue_free(struct protocol_interface_rf_mac_setup *rf_mac_setup); 00196 00197 bool mac_is_ack_request_set(mac_pre_build_frame_t *buffer); 00198 00199 int mac_convert_frame_type_to_fhss(uint8_t frame_type); 00200 00201 void mcps_sap_trig_tx(void *mac_ptr); 00202 00203 void mcps_sap_purge_reg_handler(struct protocol_interface_rf_mac_setup *rf_mac_setup, const struct mcps_purge_s *purge_req); 00204 00205 int8_t mcps_pd_data_rebuild(struct protocol_interface_rf_mac_setup *rf_ptr, mac_pre_build_frame_t *buffer); 00206 00207 int8_t mcps_generic_ack_build(struct protocol_interface_rf_mac_setup *rf_ptr, const mac_fcf_sequence_t *fcf, const uint8_t *data_ptr, const mcps_ack_data_payload_t *ack_payload, uint32_t rx_time); 00208 00209 #endif /* MAC_IEEE802_15_4_MAC_MCPS_SAP_H_ */
Generated on Tue Aug 9 2022 00:37:12 by
1.7.2