aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/socketbits.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/socketbits.h')
-rw-r--r--sysdeps/unix/sysv/linux/socketbits.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/socketbits.h b/sysdeps/unix/sysv/linux/socketbits.h
index 1cf44b4347..91deb6c815 100644
--- a/sysdeps/unix/sysv/linux/socketbits.h
+++ b/sysdeps/unix/sysv/linux/socketbits.h
@@ -126,6 +126,47 @@ struct msghdr
int msg_flags; /* Flags on received message. */
};
+/* Structure used for storage of ancillary data object information. */
+struct cmsghdr
+ {
+ int cmsg_len; /* Length of data in cmsg_data plus length
+ of cmsghdr structure. */
+ /* XXX Should be type `size_t' according to POSIX.1g. */
+ int cmsg_level; /* Originating protocol. */
+ int cmsg_type; /* Protocol specific type. */
+ unsigned char __cmsg_data[0]; /* Ancillary data. */
+ };
+
+/* Ancillary data object manipulation macros. */
+#define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
+#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
+#define CMSG_FIRSTHDR(mhdr) (mhdr) \
+ ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
+ ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
+
+
+#ifndef _EXTERN_INLINE
+# define _EXTERN_INLINE extern __inline
+#endif
+extern struct cmsghdr *__cmsg_nxthdr __P ((struct msghdr *__mhdr,
+ struct cmsghdr *__cmsg));
+_EXTERN_INLINE struct cmsghdr *
+__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg)
+{
+ unsigned char *__p;
+
+ if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
+ /* The kernel header does this so there may be a reason. */
+ return NULL;
+
+ __p = (((unsigned char *) __cmsg)
+ + ((__cmsg->cmsg_len + sizeof (long int) - 1) & ~sizeof (long int)));
+ if (__p >= (unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)
+ /* No more entries. */
+ return NULL;
+ return (struct cmsghdr *) __p;
+}
+
/* Get socket manipulation related informations from kernel headers. */
#include <asm/socket.h>