]> git.ipfire.org Git - thirdparty/lldpd.git/blame - src/compat.h
Add "format" option.
[thirdparty/lldpd.git] / src / compat.h
CommitLineData
43c02e7b
VB
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. 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
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)queue.h 8.5 (Berkeley) 8/20/94
30 */
31
32#if !HAVE_DECL_TAILQ_FIRST
33#define TAILQ_FIRST(head) ((head)->tqh_first)
34#endif
35
36#if !HAVE_DECL_TAILQ_NEXT
37#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
38#endif
39
40#if !HAVE_DECL_TAILQ_FOREACH
41#define TAILQ_FOREACH(var, head, field) \
42 for ((var) = ((head)->tqh_first); \
43 (var); \
44 (var) = ((var)->field.tqe_next))
45#endif
46
47#if !HAVE_DECL_TAILQ_EMPTY
48#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
49#endif
50
9d09937f
VB
51#if !HAVE_DECL_SLIST_HEAD
52#define SLIST_HEAD(name, type) \
53struct name { \
54 struct type *slh_first; /* first element */ \
55}
56#endif
57
58#if !HAVE_DECL_SLIST_ENTRY
59#define SLIST_ENTRY(type) \
60struct { \
61 struct type *sle_next; /* next element */ \
62}
63#endif
64
65#if !HAVE_DECL_SLIST_INIT
66#define SLIST_INIT(head) do { \
67 (head)->slh_first = NULL; \
68} while (/*CONSTCOND*/0)
69#endif
70
71#if !HAVE_DECL_SLIST_INSERT_HEAD
72#define SLIST_INSERT_HEAD(head, elm, field) do { \
73 (elm)->field.sle_next = (head)->slh_first; \
74 (head)->slh_first = (elm); \
75} while (/*CONSTCOND*/0)
76#endif
77
78#if !HAVE_DECL_SLIST_REMOVE_HEAD
79#define SLIST_REMOVE_HEAD(head, field) do { \
80 (head)->slh_first = (head)->slh_first->field.sle_next; \
81} while (/*CONSTCOND*/0)
82#endif
83
84#if !HAVE_DECL_SLIST_EMPTY
85#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
86#endif
87
88#if !HAVE_DECL_SLIST_FIRST
89#define SLIST_FIRST(head) ((head)->slh_first)
90#endif
91
92#if !HAVE_DECL_SLIST_NEXT
93#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
94#endif
95
35097709
VB
96#if !HAVE_SIOCGIFVLAN
97#define SIOCGIFVLAN 0x8982
98#endif
99
100#if !HAVE_SIOCBONDINFOQUERY
101#define SIOCBONDINFOQUERY 0x8994
102#endif
103
104#if !HAVE_SIOCBONDSLAVEINFOQUERY
105#define SIOCBONDSLAVEINFOQUERY 0x8993
106#endif
107
f2af17b3
VB
108#if !HAVE_DECL_SPEED_10000
109#define SPEED_10000 10000
110#endif
111
112#if !HAVE_DECL_ADVERTISED_10000BASET_Full
113#define ADVERTISED_10000baseT_Full (1 << 12)
114#endif
115
9aee81ae
VB
116#if !HAVE_DECL_ADVERTISED_PAUSE
117#define ADVERTISED_Pause (1 << 13)
118#endif
119
120#if !HAVE_DECL_ADVERTISED_ASYM_PAUSE
121#define ADVERTISED_Asym_Pause (1 << 14)
122#endif
123
43c02e7b
VB
124#if !HAVE_DECL_ADVERTISED_2500BASEX_Full
125#define ADVERTISED_2500baseX_Full (1 << 15)
126#endif
127
128#if !HAVE_DECL_PACKET_ORIGDEV
129#define PACKET_ORIGDEV 9
130#endif
4de7bd54
VB
131
132#if !HAVE_DECL_ETHERTYPE_VLAN
133#define ETHERTYPE_VLAN 0x8100
134#endif
b7997528 135
d38eae28
VB
136#if !HAVE_DECL_GET_VLAN_REALDEV_NAME_CMD
137#include <linux/if_vlan.h>
138#define GET_VLAN_REALDEV_NAME_CMD (SET_VLAN_FLAG_CMD + 1)
139#endif
140
141#if !HAVE_DECL_GET_VLAN_VID_CMD
142#include <linux/if_vlan.h>
143#define GET_VLAN_VID_CMD (GET_VLAN_REALDEV_NAME_CMD + 1)
144#endif
145
b7997528
VB
146#if !HAVE_GETIFADDRS
147struct ifaddrs {
148 struct ifaddrs *ifa_next; /* Next item in list */
149 char *ifa_name; /* Name of interface */
150 unsigned int ifa_flags; /* Flags from SIOCGIFFLAGS */
151 struct sockaddr *ifa_addr; /* Address of interface */
152 struct sockaddr *ifa_netmask; /* Netmask of interface */
153 /* At most one of the following two is valid. If the IFF_BROADCAST
154 bit is set in `ifa_flags', then `ifa_broadaddr' is valid. If the
155 IFF_POINTOPOINT bit is set, then `ifa_dstaddr' is valid.
156 It is never the case that both these bits are set at once. */
157 union {
158 struct sockaddr *ifu_broadaddr;
159 /* Broadcast address of interface */
160 struct sockaddr *ifu_dstaddr;
161 /* Point-to-point destination address */
162 } ifa_ifu;
163# ifndef ifa_broadaddr
164# define ifa_broadaddr ifa_ifu.ifu_broadaddr
165# endif
166# ifndef ifa_dstaddr
167# define ifa_dstaddr ifa_ifu.ifu_dstaddr
168# endif
169 void *ifa_data; /* Address-specific data */
170};
171
172int getifaddrs(struct ifaddrs **ifap);
173void freeifaddrs(struct ifaddrs *ifa);
174#endif
175
176#if !HAVE_STRLCPY
177size_t strlcpy(char *, const char *, size_t);
178#endif
d38eae28
VB
179
180#if !HAVE_MALLOC
181void *malloc(size_t size);
182#endif
183
184#if !HAVE_REALLOC
185void *realloc(void *ptr, size_t size);
186#endif