takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mac_header_helper_functions.h Source File

mac_header_helper_functions.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 #ifndef MAC_HEADER_HELPER_FUNCTIONS_H_
00020 #define MAC_HEADER_HELPER_FUNCTIONS_H_
00021 
00022 struct mac_fcf_sequence_s;
00023 struct mlme_security_s;
00024 struct mac_pre_parsed_frame_s;
00025 struct mac_pre_build_frame;
00026 struct mac_aux_security_header_s;
00027 struct ns_ie_iovec;
00028 struct protocol_interface_rf_mac_setup;
00029 
00030 uint8_t mac_security_mic_length_get(uint8_t security_level);
00031 uint8_t mac_header_security_aux_header_length(uint8_t security_level, uint8_t keyIdmode);
00032 bool mac_dst_panid_present(const struct mac_fcf_sequence_s *header);
00033 bool mac_src_panid_present(const struct mac_fcf_sequence_s *header);
00034 uint8_t mac_header_address_length(const struct mac_fcf_sequence_s *fcf);
00035 
00036 void mac_header_security_parameter_set(struct mac_aux_security_header_s *header, const struct mlme_security_s *frame_setup);
00037 
00038 /**
00039  * MAC layer FCF and data sequence parse from data
00040  */
00041 const uint8_t * mac_header_parse_fcf_dsn(struct mac_fcf_sequence_s *header, const uint8_t *ptr);
00042 
00043 uint16_t mac_header_off_set_to_aux_header(const struct mac_fcf_sequence_s *fcf);
00044 
00045 void mac_header_security_aux_header_parse(const uint8_t *ptr, struct mlme_security_s *security_params);
00046 
00047 void mac_header_security_components_read(struct mac_pre_parsed_frame_s *buffer, struct mlme_security_s *security_params);
00048 
00049 bool mac_header_information_elements_parse(struct mac_pre_parsed_frame_s *buffer);
00050 
00051 bool mac_payload_information_elements_parse(struct mac_pre_parsed_frame_s *buffer);
00052 
00053 uint16_t mac_header_information_elements_length(struct mac_pre_build_frame *buffer);
00054 
00055 void mac_header_information_elements_preparation(struct mac_pre_build_frame *buffer);
00056 
00057 uint16_t mac_buffer_total_payload_length(struct mac_pre_build_frame *buffer);
00058 
00059 /**
00060  *  Next function should only call when address mode is not MAC_ADDR_MODE_NONE and parsed proper header!
00061  */
00062 uint16_t mac_header_get_src_panid(const struct mac_fcf_sequence_s *header, const uint8_t *ptr);
00063 uint16_t mac_header_get_dst_panid(const struct mac_fcf_sequence_s *header, const uint8_t *ptr);
00064 void mac_header_get_src_address(const struct mac_fcf_sequence_s *header, const uint8_t *ptr, uint8_t *address_ptr);
00065 void mac_header_get_dst_address(const struct mac_fcf_sequence_s *header, const uint8_t *ptr, uint8_t *address_ptr);
00066 uint8_t mac_address_length(uint8_t address_mode);
00067 uint8_t mcps_mac_header_length_from_received_frame(const struct mac_pre_parsed_frame_s *buffer);
00068 uint32_t mcps_mac_security_frame_counter_read(const struct mac_pre_parsed_frame_s *buffer);
00069 uint8_t mcps_mac_command_frame_id_get(const struct mac_pre_parsed_frame_s *buffer);
00070 uint8_t *mcps_mac_payload_pointer_get(const struct mac_pre_parsed_frame_s *buffer);
00071 uint8_t *mcps_security_mic_pointer_get(const struct mac_pre_parsed_frame_s *buffer);
00072 /* Write Mac Header and payload */
00073 uint8_t * mac_generic_packet_write(struct protocol_interface_rf_mac_setup *rf_ptr, uint8_t *ptr, const struct mac_pre_build_frame *buffer);
00074 
00075 
00076 /** get pointer to Mac header start point*/
00077 #define mac_header_message_start_pointer(x)  (&(x)->buf[0])
00078 
00079 
00080 #endif /* MAC_HEADER_HELPER_FUNCTIONS_H_ */