]> git.ozlabs.org Git - ppp.git/blob - pppd/eui64.h
Makefile.am: Add explicit openssl directory to pppd include path
[ppp.git] / pppd / eui64.h
1 /*
2  * eui64.h - EUI64 routines for IPv6CP.
3  *
4  * Copyright (c) 1999 Tommi Komulainen.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  *
18  * 3. The name(s) of the authors of this software must not be used to
19  *    endorse or promote products derived from this software without
20  *    prior written permission.
21  *
22  * 4. Redistributions of any form whatsoever must retain the following
23  *    acknowledgment:
24  *    "This product includes software developed by Tommi Komulainen
25  *     <Tommi.Komulainen@iki.fi>".
26  *
27  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
28  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
29  * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
30  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
31  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
32  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
33  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
34  *
35  */
36 #ifndef PPP_EUI64_H
37 #define PPP_EUI64_H
38
39 #include "pppdconf.h"
40
41 #if !defined(PPP_WITH_IPV6CP)
42 #error  "this file should only be included when PPP_WITH_IPV6CP is defined"
43 #endif /* not defined(PPP_WITH_IPV6CP) */
44
45 #define eui64_iszero(e)         (((e).e32[0] | (e).e32[1]) == 0)
46 #define eui64_equals(e, o)      (((e).e32[0] == (o).e32[0]) && \
47                                 ((e).e32[1] == (o).e32[1]))
48 #define eui64_zero(e)           (e).e32[0] = (e).e32[1] = 0;
49
50 #define eui64_copy(s, d)        memcpy(&(d), &(s), sizeof(eui64_t))
51
52 #define eui64_magic(e)          do {                    \
53                                 (e).e32[0] = magic();   \
54                                 (e).e32[1] = magic();   \
55                                 (e).e8[0] &= ~2;        \
56                                 } while (0)
57 #define eui64_magic_nz(x)       do {                            \
58                                 eui64_magic(x);                 \
59                                 } while (eui64_iszero(x))
60 #define eui64_magic_ne(x, y)    do {                            \
61                                 eui64_magic(x);                 \
62                                 } while (eui64_equals(x, y))
63
64 #define eui64_get(ll, cp)       do {                            \
65                                 eui64_copy((*cp), (ll));        \
66                                 (cp) += sizeof(eui64_t);        \
67                                 } while (0)
68
69 #define eui64_put(ll, cp)       do {                            \
70                                 eui64_copy((ll), (*cp));        \
71                                 (cp) += sizeof(eui64_t);        \
72                                 } while (0)
73
74 #define eui64_set32(e, l)       do {                    \
75                                 (e).e32[0] = 0;         \
76                                 (e).e32[1] = htonl(l);  \
77                                 } while (0)
78 #define eui64_setlo32(e, l)     eui64_set32(e, l)
79
80 char *eui64_ntoa(eui64_t);      /* Returns ascii representation of id */
81
82 #endif /* PPP_EUI64_H */