2 eui64.h - EUI64 routines for IPv6CP.
3 Copyright (C) 1999 Tommi Komulainen <Tommi.Komulainen@iki.fi>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 $Id: eui64.h,v 1.2 1999/08/25 04:15:51 paulus Exp $
26 * Maybe this should be done by processing struct in6_addr directly...
35 #define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0)
36 #define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \
37 ((e).e32[1] == (o).e32[1]))
38 #define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0;
40 #define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t))
42 #define eui64_magic(e) do { \
43 (e).e32[0] = magic(); \
44 (e).e32[1] = magic(); \
47 #define eui64_magic_nz(x) do { \
49 } while (eui64_iszero(x))
50 #define eui64_magic_ne(x, y) do { \
52 } while (eui64_equals(x, y))
54 #define eui64_get(ll, cp) do { \
55 eui64_copy((*cp), (ll)); \
56 (cp) += sizeof(eui64_t); \
59 #define eui64_put(ll, cp) do { \
60 eui64_copy((ll), (*cp)); \
61 (cp) += sizeof(eui64_t); \
64 #define eui64_set32(e, l) do { \
66 (e).e32[1] = htonl(l); \
68 #define eui64_setlo32(e, l) eui64_set32(e, l)
70 char *eui64_ntoa __P((eui64_t)); /* Returns ascii representation of id */