Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mac_common_defines.h Source File

mac_common_defines.h

Go to the documentation of this file.
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 /** \file mac_common_defines.h
00019  * \brief Common definitions for MAC layer.
00020  */
00021 
00022 #ifndef MAC_COMMON_DEFINES_H_
00023 #define MAC_COMMON_DEFINES_H_
00024 
00025 #include "ns_types.h"
00026 
00027 #define MAC_ADDR_MODE_NONE 0                    /**< Address mode for no address defined */
00028 #define MAC_ADDR_MODE_16_BIT 2                  /**< Address mode for 16-bit addresses */
00029 #define MAC_ADDR_MODE_64_BIT 3                  /**< Address mode for 64-bit addresses */
00030 
00031 #define MAC_FRAME_VERSION_2003         0        /**< FCF - IEEE 802.15.4-2003 compatible */
00032 #define MAC_FRAME_VERSION_2006         1        /**< FCF - IEEE 802.15.4-2006 (big payload or new security) */
00033 
00034 //See IEEE standard 802.15.4-2006 (table 96) for more details about identifiers
00035 #define MAC_KEY_ID_MODE_IMPLICIT    0           /**< Key identifier mode implicit */
00036 #define MAC_KEY_ID_MODE_IDX         1           /**< Key identifier mode for 1-octet key index */
00037 #define MAC_KEY_ID_MODE_SRC4_IDX    2           /**< Key identifier mode for combined 4-octet key source and 1-octet key index */
00038 #define MAC_KEY_ID_MODE_SRC8_IDX    3           /**< Key identifier mode for combined 8-octet key source and 1-octet key index */
00039 
00040 /* IEEE 802.15.4 constants */
00041 #define MAC_IEEE_802_15_4_MAX_MPDU_UNSECURED_OVERHEAD   25      /**< Maximum for MAC protocol data unit unsecured overhead */
00042 #define MAC_IEEE_802_15_4_MIN_MPDU_OVERHEAD             9       /**< Minimum overhead added by MAC to MPDU */
00043 #define MAC_IEEE_802_15_4_MAX_BEACON_OVERHEAD           75      /**< Maximum overhead which is added by the MAC for beacon */
00044 #define MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE           127     /**< Maximum number of octets PHY layer is able to receive */
00045 
00046 #define MAC_IEEE_802_15_4_MAX_BEACON_PAYLOAD_LENGTH \
00047     (MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE - MAC_IEEE_802_15_4_MAX_BEACON_OVERHEAD) /**< Maximum size of beacon payload */
00048 
00049 /** Maximum number of bytes which can be transmitted in the MAC payload of an unsecured MAC frame */
00050 #define MAC_IEEE_802_15_4_MAX_MAC_SAFE_PAYLOAD_SIZE \
00051     (MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE - MAC_IEEE_802_15_4_MAX_MPDU_UNSECURED_OVERHEAD)
00052 
00053 #define mac_unsecured_2003_compatibility false /**< For IEEE 802.15.4-2003 MAC compatibility, force max size to never exceed MAC_IEEE_802_15_4_MAX_MAC_SAFE_PAYLOAD_SIZE */
00054 
00055 /**
00056  * @brief struct mlme_security_t MLME/MCPS security structure
00057  * This structure encapsulates security related variables,
00058  * which are always used together if SecurityLevel > 0.
00059  *
00060  * See IEEE standard 802.15.4-2006 (e.g end of table 41) for more details
00061  */
00062 typedef struct mlme_security_s {
00063     unsigned SecurityLevel:3;   /**< Security level */
00064     unsigned KeyIdMode:2;       /**< 2-bit value which define key source and ID use case */
00065     uint8_t KeyIndex;           /**< Key index */
00066     uint8_t Keysource[8];       /**< Key source */
00067 } mlme_security_t;
00068 
00069 #endif /* MAC_COMMON_DEFINES_H_ */