Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

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-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 /** \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 #define MAC_FRAME_VERSION_2015         2        /**< FCF - IEEE 802.15.4-2015 (IE element support) */
00034 
00035 //See IEEE standard 802.15.4-2006 (table 96) for more details about identifiers
00036 #define MAC_KEY_ID_MODE_IMPLICIT    0           /**< Key identifier mode implicit */
00037 #define MAC_KEY_ID_MODE_IDX         1           /**< Key identifier mode for 1-octet key index */
00038 #define MAC_KEY_ID_MODE_SRC4_IDX    2           /**< Key identifier mode for combined 4-octet key source and 1-octet key index */
00039 #define MAC_KEY_ID_MODE_SRC8_IDX    3           /**< Key identifier mode for combined 8-octet key source and 1-octet key index */
00040 
00041 /* IEEE 802.15.4 constants */
00042 #define MAC_IEEE_802_15_4_MAX_MPDU_UNSECURED_OVERHEAD   25      /**< Maximum for MAC protocol data unit unsecured overhead */
00043 #define MAC_IEEE_802_15_4_MIN_MPDU_OVERHEAD             9       /**< Minimum overhead added by MAC to MPDU */
00044 #define MAC_IEEE_802_15_4_MAX_BEACON_OVERHEAD           75      /**< Maximum overhead which is added by the MAC for beacon */
00045 #define MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE           127     /**< Maximum number of octets PHY layer is able to receive */
00046 
00047 #define MAC_IEEE_802_15_4_MAX_BEACON_PAYLOAD_LENGTH \
00048     (MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE - MAC_IEEE_802_15_4_MAX_BEACON_OVERHEAD) /**< Maximum size of beacon payload */
00049 
00050 /** Maximum number of bytes which can be transmitted in the MAC payload of an unsecured MAC frame */
00051 #define MAC_IEEE_802_15_4_MAX_MAC_SAFE_PAYLOAD_SIZE \
00052     (MAC_IEEE_802_15_4_MAX_PHY_PACKET_SIZE - MAC_IEEE_802_15_4_MAX_MPDU_UNSECURED_OVERHEAD)
00053 
00054 #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 */
00055 
00056 /**
00057  * @brief struct mlme_security_t MLME/MCPS security structure
00058  * This structure encapsulates security related variables,
00059  * which are always used together if SecurityLevel > 0.
00060  *
00061  * See IEEE standard 802.15.4-2006 (e.g end of table 41) for more details
00062  */
00063 typedef struct mlme_security_s {
00064     unsigned SecurityLevel: 3;  /**< Security level */
00065     unsigned KeyIdMode: 2;      /**< 2-bit value which define key source and ID use case */
00066     uint8_t KeyIndex;           /**< Key index */
00067     uint8_t Keysource[8];       /**< Key source */
00068 } mlme_security_t;
00069 
00070 #define MAC_HEADER_VENDOR_SPESIFIC_IE_ID          0x00  /**< Vendor specific Header IE element */
00071 #define MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID    0x2a  /**< External organisation defined Header IE element */
00072 #define MAC_HEADER_TERMINATION1_IE_ID             0x7e  /**< Header IE element termination when Payload element is following Header IE */
00073 #define MAC_HEADER_TERMINATION2_IE_ID             0x7f  /**< Header IE element termination when no Payload element is following Header IE but normal payload is */
00074 
00075 
00076 /**
00077  * @brief struct mac_header_IE_t Mac Header information element structure for parsing or write operation
00078  * This structure encapsulates security related variables,
00079  */
00080 typedef struct mac_header_IE_s {
00081     uint8_t *content_ptr;   /**< Content data */
00082     unsigned length: 7;     /**< Element length 0- 127 */
00083     uint8_t id;             /**< Element ID */
00084 } mac_header_IE_t;
00085 
00086 #define MAC_PAYLOAD_IE_ESDU_GROUP_ID            0x00    /**< Encapsulated Service Data Unit (ESDU) Payload IE element's */
00087 #define MAC_PAYLOAD_MLME_IE_GROUP_ID            0x01    /**< MLME nested Payload IE element's */
00088 #define MAC_PAYLOAD_VENDOR_IE_GROUP_ID          0x02    /**< Vendor specific nested Payload IE element's */
00089 #define MAC_PAYLOAD_MPX_IE_GROUP_ID             0x03    /**< MPX Payload IE element, IEEE 802.15.9 defined */
00090 #define MAC_PAYLOAD_TERMINATION_IE_GROUP_ID     0x0f    /**< Payload IE element terminator. Mandatory when normal payload is coming after IE element part */
00091 
00092 /**
00093  * @brief struct mac_header_IE_t Mac Payload information element structure for parsing or write operation
00094  * This structure encapsulates security related variables,
00095  */
00096 typedef struct mac_payload_IE_s {
00097     uint8_t *content_ptr;   /**< Content data */
00098     unsigned length: 11;    /**< Element length 0- 2047 */
00099     unsigned id: 4;         /**< Group ID */
00100 } mac_payload_IE_t;
00101 
00102 #endif /* MAC_COMMON_DEFINES_H_ */