Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
eui64.h
00001 /* 00002 * eui64.h - EUI64 routines for IPv6CP. 00003 * 00004 * Copyright (c) 1999 Tommi Komulainen. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * 3. The name(s) of the authors of this software must not be used to 00019 * endorse or promote products derived from this software without 00020 * prior written permission. 00021 * 00022 * 4. Redistributions of any form whatsoever must retain the following 00023 * acknowledgment: 00024 * "This product includes software developed by Tommi Komulainen 00025 * <Tommi.Komulainen@iki.fi>". 00026 * 00027 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO 00028 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00029 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY 00030 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00031 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 00032 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 00033 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00034 * 00035 * $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $ 00036 */ 00037 00038 #include "ppp_opts.h" 00039 #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in ppp_opts.h */ 00040 00041 #ifndef EUI64_H 00042 #define EUI64_H 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif 00047 00048 /* 00049 * @todo: 00050 * 00051 * Maybe this should be done by processing struct in6_addr directly... 00052 */ 00053 typedef union 00054 { 00055 u8_t e8[8]; 00056 u16_t e16[4]; 00057 u32_t e32[2]; 00058 } eui64_t; 00059 00060 #define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0) 00061 #define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \ 00062 ((e).e32[1] == (o).e32[1])) 00063 #define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0; 00064 00065 #define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t)) 00066 00067 #define eui64_magic(e) do { \ 00068 (e).e32[0] = magic(); \ 00069 (e).e32[1] = magic(); \ 00070 (e).e8[0] &= ~2; \ 00071 } while (0) 00072 #define eui64_magic_nz(x) do { \ 00073 eui64_magic(x); \ 00074 } while (eui64_iszero(x)) 00075 #define eui64_magic_ne(x, y) do { \ 00076 eui64_magic(x); \ 00077 } while (eui64_equals(x, y)) 00078 00079 #define eui64_get(ll, cp) do { \ 00080 eui64_copy((*cp), (ll)); \ 00081 (cp) += sizeof(eui64_t); \ 00082 } while (0) 00083 00084 #define eui64_put(ll, cp) do { \ 00085 eui64_copy((ll), (*cp)); \ 00086 (cp) += sizeof(eui64_t); \ 00087 } while (0) 00088 00089 #define eui64_set32(e, l) do { \ 00090 (e).e32[0] = 0; \ 00091 (e).e32[1] = ppp_htonl(l); \ 00092 } while (0) 00093 #define eui64_setlo32(e, l) eui64_set32(e, l) 00094 00095 char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ 00096 00097 #ifdef __cplusplus 00098 } 00099 #endif 00100 00101 #endif /* EUI64_H */ 00102 #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */
Generated on Tue Jul 12 2022 13:54:19 by
