summaryrefslogtreecommitdiff
path: root/defines.h
diff options
context:
space:
mode:
authordtucker <dtucker>2003-08-07 05:58:28 +0000
committerdtucker <dtucker>2003-08-07 05:58:28 +0000
commit07be84c75b92c247ca114d1b80318c525a18aea1 (patch)
tree29443891ab0f871d04ceb65370a2cb90c55301a0 /defines.h
parentdcfcc26cae481530ba980e613e769cbc105cfac5 (diff)
downloadopenssh-07be84c75b92c247ca114d1b80318c525a18aea1.tar.gz
- (dtucker) [defines.h] Bug #336: Add CMSG_DATA and CMSG_FIRSTHDR macros if
not already defined (eg Linux with some versions of libc5), based on those from OpenBSD.
Diffstat (limited to 'defines.h')
-rw-r--r--defines.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/defines.h b/defines.h
index ec610d0d..3679ea54 100644
--- a/defines.h
+++ b/defines.h
@@ -25,7 +25,7 @@
#ifndef _DEFINES_H
#define _DEFINES_H
-/* $Id: defines.h,v 1.99 2003/06/11 12:51:32 djm Exp $ */
+/* $Id: defines.h,v 1.100 2003/08/07 05:58:28 dtucker Exp $ */
/* Constants */
@@ -577,4 +577,22 @@ struct winsize {
/** end of login recorder definitions */
+#ifndef CMSG_DATA
+/* given pointer to struct cmsghdr, return pointer to data */
+#define CMSG_DATA(cmsg) \
+ ((u_char *)(cmsg) + (((u_int)(sizeof(struct cmsghdr)) \
+ (sizeof(int) - 1)) &~ (sizeof(int) - 1)))
+#endif /* CMSG_DATA */
+
+#ifndef CMSG_FIRSTHDR
+/*
+ * RFC 2292 requires to check msg_controllen, in case that the kernel returns
+ * an empty list for some reasons.
+ */
+# define CMSG_FIRSTHDR(mhdr) \
+ ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
+ (struct cmsghdr *)(mhdr)->msg_control : \
+ (struct cmsghdr *)NULL)
+#endif /* CMSG_FIRSTHDR */
+
#endif /* _DEFINES_H */