Knight KE / Mbed OS Game_Master
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-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 #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 
00028 uint8_t mac_security_mic_length_get(uint8_t security_level);
00029 uint8_t mac_header_security_aux_header_length(uint8_t security_level, uint8_t keyIdmode);
00030 uint8_t mac_header_address_length(const struct mac_fcf_sequence_s *fcf);
00031 
00032 void mac_header_security_parameter_set(struct mac_aux_security_header_s *header, const struct mlme_security_s *frame_setup);
00033 
00034 /**
00035  * MAC layer FCF and data sequence parse from data
00036  */
00037 void mac_header_parse_fcf_dsn(struct mac_fcf_sequence_s *header, const uint8_t *ptr);
00038 
00039 void mac_header_security_components_read(struct mac_pre_parsed_frame_s *buffer, struct mlme_security_s *security_params);
00040 
00041 /**
00042  *  Next function should only call when address mode is not MAC_ADDR_MODE_NONE and parsed proper header!
00043  */
00044 uint16_t mac_header_get_src_panid(const struct mac_fcf_sequence_s *header, const uint8_t *ptr);
00045 uint16_t mac_header_get_dst_panid(const struct mac_fcf_sequence_s *header, const uint8_t *ptr);
00046 void mac_header_get_src_address(const struct mac_fcf_sequence_s *header, const uint8_t *ptr, uint8_t *address_ptr);
00047 void mac_header_get_dst_address(const struct mac_fcf_sequence_s *header, const uint8_t *ptr, uint8_t *address_ptr);
00048 
00049 uint16_t mcps_payload_length_from_received_frame(const struct mac_pre_parsed_frame_s *buffer);
00050 uint8_t mcps_mac_header_length_from_received_frame(const struct mac_pre_parsed_frame_s *buffer);
00051 uint32_t mcps_mac_security_frame_counter_read(const struct mac_pre_parsed_frame_s *buffer);
00052 uint8_t mcps_mac_command_frame_id_get(const struct mac_pre_parsed_frame_s *buffer);
00053 uint8_t *mcps_mac_payload_pointer_get(const struct mac_pre_parsed_frame_s *buffer);
00054 uint8_t *mcps_security_mic_pointer_get(const struct mac_pre_parsed_frame_s *buffer);
00055 uint8_t *mcps_mac_security_aux_header_start_pointer_get(const struct mac_pre_parsed_frame_s *buffer);
00056 
00057 uint8_t * mcps_generic_header_write(uint8_t *ptr, const struct mac_pre_build_frame *buffer);
00058 
00059 
00060 /** get pointer to Mac header start point*/
00061 #define mac_header_message_start_pointer(x)  (&(x)->buf[0])
00062 
00063 
00064 #endif /* MAC_HEADER_HELPER_FUNCTIONS_H_ */