BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
eui64.h
Go to the documentation of this file.
1 /* Copyright 2013-2014, Peter A. Bigot
2  *
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the software nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
58 #ifndef BSP430_UTILITY_EUI64_H
59 #define BSP430_UTILITY_EUI64_H
60 
61 #include <bsp430/core.h>
62 
68 #ifndef configBSP430_EUI64
69 #define configBSP430_EUI64 0
70 #endif /* configBSP430_EUI64 */
71 
81 #if defined(BSP430_DOXYGEN) || defined(configBSP430_EUI64)
82 #ifndef BSP430_EUI64
83 #define BSP430_EUI64 (configBSP430_EUI64 - 0)
84 #endif /* BSP430_EUI64 */
85 #endif /* BSP430_DOXYGEN */
86 
104 #ifndef configBSP430_EUI64_USE_PLATFORM
105 #define configBSP430_EUI64_USE_PLATFORM 1
106 #endif /* configBSP430_EUI64_USE_PLATFORM */
107 
120 #ifndef configBSP430_EUI64_USE_GENERIC
121 #define configBSP430_EUI64_USE_GENERIC 1
122 #endif /* configBSP430_EUI64_USE_GENERIC */
123 
127 #define BSP430_EUI64_PERM 0
128 
133 #define BSP430_EUI64_RANDOM 1
134 
137 #define BSP430_EUI64_STOLEN 2
138 
142 #define BSP430_EUI64_MASK_GROUP 0x01
143 
147 #define BSP430_EUI64_MASK_LOCAL 0x02
148 
150 typedef union uBSP430eui64 {
154  uint8_t bytes[8];
155 
159  uint64_t u64;
160 
164  int16_t ints[4];
165 
168  struct as48 {
170  uint8_t oui[3];
171 
174  uint8_t label[2];
175 
177  uint8_t extension_id[3];
178  } as48;
179 } uBSP430eui64;
180 
183 
186 #define BSP430_EUI64_IS_NULL(h_) ((0 == (h_)->ints[0]) \
187  & (0 == (h_)->ints[1]) \
188  & (0 == (h_)->ints[2]) \
189  & (0 == (h_)->ints[3]))
190 
195 #define BSP430_EUI64_IS_INVALID(h_) ((-1 == (h_)->ints[0]) \
196  & (-1 == (h_)->ints[1]) \
197  & (-1 == (h_)->ints[2]) \
198  & (-1 == (h_)->ints[3]))
199 
204 #define BSP430_EUI64_INVALIDATE(h_) do { \
205  hBSP430eui64 const h = (h_); \
206  h->ints[0] = -1; \
207  h->ints[1] = -1; \
208  h->ints[2] = -1; \
209  h->ints[3] = -1; \
210  } while (0)
211 
241 #if defined(BSP430_DOXYGEN) || (BSP430_EUI64 - 0)
242 int iBSP430eui64 (hBSP430eui64 eui64);
243 #endif /* BSP430_EUI64 */
244 
266 int iBSP430eui64Parse (const char * cfp,
267  size_t len,
268  hBSP430eui64 eui64);
269 
273 #define BSP430_EUI64_AS_TEXT_LENGTH sizeof("01-02-03-04-05-06-07-08")
274 
282 char * xBSP430eui64AsText (hBSP430eui64 eui64,
283  char * buffer);
284 
285 #endif /* BSP430_UTILITY_EUI64_H */
uint64_t u64
Definition: eui64.h:159
union uBSP430eui64 uBSP430eui64
int iBSP430eui64Parse(const char *cfp, size_t len, hBSP430eui64 eui64)
uint8_t label[2]
Definition: eui64.h:174
Common header included by all BSP430 leaf headers.
uint8_t extension_id[3]
Definition: eui64.h:177
int16_t ints[4]
Definition: eui64.h:164
char * xBSP430eui64AsText(hBSP430eui64 eui64, char *buffer)
int iBSP430eui64(hBSP430eui64 eui64)
uBSP430eui64 * hBSP430eui64
Definition: eui64.h:182
uint8_t bytes[8]
Definition: eui64.h:154
Definition: eui64.h:150
Definition: eui64.h:168
uint8_t oui[3]
Definition: eui64.h:170