summaryrefslogtreecommitdiff
path: root/nhrp/nhrp_defines.h
blob: 2812a13df644a898689f60d30a86bdf940f5f024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* nhrp_defines.h - NHRP definitions
 *
 * Copyright (C) 2007 Timo Teräs <timo.teras@iki.fi>
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 or later as
 * published by the Free Software Foundation.
 *
 * See http://www.gnu.org/ for details.
 */

#ifndef NHRP_DEFINES_H
#define NHRP_DEFINES_H

#include <stdint.h>
#include <byteswap.h>
#include <sys/param.h>
#include <linux/version.h>

#ifndef NULL
#define NULL 0L
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifndef __bswap_constant_16
#define __bswap_constant_16(x) \
	((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
#endif
#ifndef __bswap_constant_32
#define __bswap_constant_32(x) \
	((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
	 (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
#endif

#if __BYTE_ORDER == __BIG_ENDIAN
#define constant_ntohl(x) (x)
#define constant_ntohs(x) (x)
#define constant_htonl(x) (x)
#define constant_htons(x) (x)
#else
#define constant_ntohl(x) __bswap_constant_32(x)
#define constant_ntohs(x) __bswap_constant_16(x)
#define constant_htonl(x) __bswap_constant_32(x)
#define constant_htons(x) __bswap_constant_16(x)
#endif

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
#endif

#ifndef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
#endif

#define BIT(x) (1 << (x))

#ifndef container_of
#define container_of(ptr, type, member) ({                      \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
#endif

#if __GNUC__ >= 3
#define NHRP_EMPTY_ARRAY
#else
#define NHRP_EMPTY_ARRAY		0
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
#define NHRP_NO_NBMA_GRE
#endif

#define NHRP_DEFAULT_HOLDING_TIME	(2 * 60 * 60)

#endif