zmac.h

Go to the documentation of this file.
00001 /*   Copyright (c) 2008, Swedish Institute of Computer Science
00002  *  All rights reserved.
00003  *
00004  *  Additional fixes for AVR contributed by:
00005  *
00006  *      Colin O'Flynn coflynn@newae.com
00007  *      Eric Gnoske egnoske@gmail.com
00008  *      Blake Leverett bleverett@gmail.com
00009  *      Mike Vidales mavida404@gmail.com
00010  *      Kevin Brown kbrown3@uccs.edu
00011  *      Nate Bohlmann nate@elfwerks.com
00012  *
00013  *   All rights reserved.
00014  *
00015  *   Redistribution and use in source and binary forms, with or without
00016  *   modification, are permitted provided that the following conditions are met:
00017  *
00018  *   * Redistributions of source code must retain the above copyright
00019  *     notice, this list of conditions and the following disclaimer.
00020  *   * Redistributions in binary form must reproduce the above copyright
00021  *     notice, this list of conditions and the following disclaimer in
00022  *     the documentation and/or other materials provided with the
00023  *     distribution.
00024  *   * Neither the name of the copyright holders nor the names of
00025  *     contributors may be used to endorse or promote products derived
00026  *     from this software without specific prior written permission.
00027  *
00028  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00029  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00032  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00033  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00034  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00035  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00036  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00037  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00038  *  POSSIBILITY OF SUCH DAMAGE.
00039  */
00040 /**
00041  *    \brief  The equivalent IEEE 802.15.4 (2003/2006) header file for
00042  *            the mac primitives.
00043  *
00044  */
00045 /**
00046  *   \addtogroup rf230mac
00047  *   @{
00048 */
00049 /**
00050  *    \file
00051  *    \brief  The IEEE 802.15.4 (2003/2006) MAC utility functions.
00052  */
00053 
00054 #ifndef MAC_H
00055 #define MAC_H
00056 
00057 /*  Includes */
00058 #include <stdint.h>
00059 #include <stdbool.h>
00060 #include "frame.h"
00061 #include "ieee-15-4-manager.h"
00062 
00063 #define EEPROMMACADDRESS                ((void*)0)
00064 #define EEPROMDSTADDRESS                ((void*)8)
00065 #define EEPROMCHANADDRESS               ((void*)16)
00066 #define EEPROMPANIDADDRESS              ((void*)17)
00067 #define EEPROMROLEADDRESS               ((void*)19)
00068 #define SUCCESS                         (0)
00069 #define CHANNEL_PAGE_0                  (0)
00070 
00071 
00072 
00073 
00074 /* MAC command frames codes */
00075 
00076 /* MAC enumerations */
00077 /** \brief Pre-defined data frame control field (FCF) values. 
00078  *  \name FCF Values
00079  *  @{
00080 */
00081 #define FCF_NO_ACK      (0x8841)
00082 #define FCF_ACK_REQ     (0x8861)
00083 /** @} */
00084 
00085 /** \brief Hardcoded various "network" addresses, for use when testing.
00086  *  \name Pre-defined network addresses
00087  *  @{
00088  */
00089 #define DEST_PAN_ID     (0xABCD)
00090 #define SOURCE_PAN_ID   (0xABCD)
00091 #define LONG_ADDR_1     (0xFFEEDDCCBBAA1100LL)
00092 #define LONG_ADDR_2     (0x1122334455667788LL)
00093 #define LONG_ADDR_3     (0xDDEEAADDBBEEEEFFLL)
00094 #define LONG_ADDR_4     (0x0123456789ABCDEFLL)
00095 #define SOURCE_ADDR     (0x1234)
00096 #define FCF_ACK         (0x0002)
00097 #define TX_OPTION_NOACK (0)
00098 #define TX_OPTION_ACK   (1)
00099 #define LONG_ADDR_LEN   (8)
00100 /** @} */
00101 
00102 #define MPDU_OVERHEAD   (11) /**< This overhead includes FCF, DSN, DEST_PAN_ID, DEST_ADDR, SOURCE_ADDR, & FCS */
00103 
00104 
00105 /** \brief These are some definitions of values used in the FCF.  See the 802.15.4 spec for details.
00106  *  \name FCF element values definitions
00107  *  @{
00108  */
00109 #define BEACONFRAME     (0x00)
00110 #define DATAFRAME       (0x01)
00111 #define ACKFRAME        (0x02)
00112 #define CMDFRAME        (0x03)
00113 
00114 #define BEACONREQ       (0x07)
00115 
00116 #define IEEERESERVED    (0x00)
00117 #define NOADDR          (0x00)      /**< Only valid for ACK or Beacon frames. */
00118 #define SHORTADDRMODE   (0x02)
00119 #define LONGADDRMODE    (0x03)
00120 
00121 #define NOBEACONS       (0x0F)
00122 
00123 #define BROADCASTADDR   (0xFFFF)
00124 #define BROADCASTPANDID (0xFFFF)
00125 
00126 #define IEEE802154_2003 (0x00)
00127 #define IEEE802154_2006 (0x01)
00128 
00129 #define SECURITY_LEVEL_NONE (0)
00130 #define SECURITY_LEVEL_128  (3)
00131 
00132 #define PSDULEN         (127)
00133 /** @} */
00134 
00135 
00136 /* typedef enum {TRUE, FALSE} bool; */
00137 
00138 typedef struct dataRequest  {
00139     uint8_t srcAddrMode;
00140     uint8_t dstAddrMode;
00141     uint16_t dstPANId;
00142     addr_t dstAddr;
00143     uint8_t msduLength;
00144     uint8_t *msdu;
00145     uint8_t msduHandle;
00146     uint8_t txOptions;
00147     uint8_t securityLevel;
00148     uint8_t keyIdMode;
00149     uint8_t *keySource;
00150     uint8_t keyIndex;
00151 } dataRequest_t;
00152 
00153 
00154 /*  Macros & Defines */
00155 extern ieee_15_4_manager_t ieee15_4ManagerAddress;
00156 extern dataRequest_t dataRequestStructAddress;
00157 #define ieee15_4Struct (&ieee15_4ManagerAddress)
00158 #define dataRequestStruct (&dataRequestStructAddress)
00159 
00160 
00161 /**
00162  *  \name Scan variables
00163  *  \brief Global variables and defines for scan.
00164  *  \{
00165 */
00166 extern uint8_t msduHandle;
00167 extern bool iAmCoord;
00168 extern bool autoModes;
00169 extern uint16_t macShortAddr;
00170 extern uint64_t macLongAddr;
00171 /** @} */
00172 
00173 /*  PHY PIB Attributes */
00174 
00175 /* uint8_t phyCurrentChannel              Integer 0-26
00176  * The RF channel to use for all following transmissions and receptions (see6.1.2).
00177  */
00178 extern uint8_t phyCurrentChannel;
00179 
00180 /* uint64_t macCoordExtendedAddress -- no default
00181  *
00182  *   The 64-bit address of the coordinator/router through which the network layer wishes to communicate
00183  */
00184 extern uint64_t macCoordExtendedAddress;
00185 
00186 /* uint16_t macCoordShortAddress  -- default 0xffff
00187  *
00188  *   The 16-bit short address assigned to the coordinator through which the network layer wishes
00189  *   to communicate.  A value of 0xfffe indicates th the coordinator is only using it's 64-bit
00190  *   extended address.  A value of 0xffff indicates that this value is unknown.
00191  */
00192 extern uint16_t macCoordShortAddress;
00193 
00194 /* uint64_t macDestAddress  -- default 0xffff
00195  *
00196  *   This address is the 64-bit address that will be used as the mechanism to
00197  *   provide a destination to the upper layers.
00198  */
00199 extern uint64_t macDestAddress;
00200 
00201 /* uint8_t macDSN                 -- default is random value within the range
00202  *
00203  *   The sequence number (0x00 - 0xff) added to the transmitted data or MAC command frame.
00204  */
00205 extern uint8_t macDSN;
00206 
00207 /* uint16_t macDstPANId              -- default 0xffff
00208  *
00209  *   The 16-bit identifier of the PAN on which the device is sending to.  If this value
00210  *   is 0xffff, the device is not associated.
00211  */
00212 extern uint16_t macDstPANId;
00213 
00214 /* uint16_t macSrcPANId              -- default 0xffff
00215  *
00216  *   The 16-bit identifier of the PAN on which the device is operating.  If this value
00217  *   is 0xffff, the device is not associated.
00218  */
00219 extern uint16_t macSrcPANId;
00220 
00221 /* uint16_t macShortAddress       -- default 0xffff
00222  *
00223  *   The 16-bit address that the device uses to communicate in the PAN.  If the device is the
00224  *   PAN coordinator, this value shall be chosen before a PAN is started.  Otherwise, the
00225  *   address is allocated by a coordinator during association.  A value of 0xfffe indicates
00226  *   that the device has associated but has not been allocated an address.  A value of 0xffff
00227  *   indicates that the device does not have a short address.
00228  */
00229 extern uint16_t macShortAddress;
00230 
00231 /*  Scan defines */
00232 
00233 
00234 /*  Protoypes */
00235 void mac_init(void);
00236 
00237 #endif
00238 
00239 /** @} */

Generated on Mon Apr 11 14:23:37 2011 for Contiki 2.5 by  doxygen 1.6.1