summaryrefslogtreecommitdiffstats
path: root/lib/zebra.h
diff options
context:
space:
mode:
authorgdt <gdt>2004-11-15 18:51:15 +0000
committergdt <gdt>2004-11-15 18:51:15 +0000
commit07d450f34649aebb1885a04c02ff1d87f58fb0c3 (patch)
treedc8ec06f081b35ad7828d5fa468626cebb8777a1 /lib/zebra.h
parent199f21faf9724fe8b19416a4d268c2d158120799 (diff)
downloadquagga-07d450f34649aebb1885a04c02ff1d87f58fb0c3.tar.bz2
quagga-07d450f34649aebb1885a04c02ff1d87f58fb0c3.tar.xz
Rationalize CMSG_SPACE usage:
in lib/zebra.h, ensure that RFC3542-required CMSG_SPACE and CMSG_LEN are defined. Warn if alignment assumptions are made, since they are i386-centric. in lib/sockopt.h, declare that sockopt sizes are without CMSG_SPACE-required padding - just simple sizeof. in ospfd/ospf_packet.c, simply use CMSG_SPACE This should remove all instances of CMSG_ALIGN from the source code. This is a nonstandard, though rational, construct; quagga should use only those defines in RFC3542.
Diffstat (limited to 'lib/zebra.h')
-rw-r--r--lib/zebra.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/zebra.h b/lib/zebra.h
index 6980529e..f2c396d8 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -210,7 +210,13 @@ typedef int socklen_t;
#endif /* BSDI_NRL */
/*
- * RFC 2553-bis defines not available on some systems.
+ * RFC 3542 defines several macros for using struct cmsghdr.
+ * Here, we define those that are not present
+ */
+
+/*
+ * Internal defines, for use only in this file.
+ * These are likely wrong on other than ILP32 machines, so warn.
*/
#ifndef _CMSG_DATA_ALIGN
#define _CMSG_DATA_ALIGN(n) (((n) + 3) & ~3)
@@ -220,16 +226,24 @@ typedef int socklen_t;
#define _CMSG_HDR_ALIGN(n) (((n) + 3) & ~3)
#endif /* _CMSG_HDR_ALIGN */
+/*
+ * CMSG_SPACE and CMSG_LEN are required in RFC3542, but were new in that
+ * version.
+ */
#ifndef CMSG_SPACE
#define CMSG_SPACE(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + \
_CMSG_HDR_ALIGN(l))
+#warning "assuming 4-byte alignment for CMSG_SPACE"
#endif /* CMSG_SPACE */
#ifndef CMSG_LEN
#define CMSG_LEN(l) (_CMSG_DATA_ALIGN(sizeof(struct cmsghdr)) + (l))
+#warning "assuming 4-byte alignment for CMSG_LEN"
#endif /* CMSG_LEN */
+
+
#if !(defined(__GNUC__) || defined(VTYSH_EXTRACT_PL))
#define __attribute__(x)
#endif /* !__GNUC__ */