Update.
[platform/upstream/glibc.git] / sysdeps / unix / sysv / linux / bits / socket.h
index 2a8d6ed..c1f752e 100644 (file)
@@ -1,5 +1,5 @@
 /* System-specific socket constants and types.  Linux version.
-   Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
+   Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifndef _SYS_SOCKET_H
-#error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
-#endif
-
+#ifndef __BITS_SOCKET_H
+#define __BITS_SOCKET_H
 
-#include <features.h>
+#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
+# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
+#endif
 
 #define        __need_size_t
 #define __need_NULL
@@ -30,8 +30,6 @@
 
 #include <sys/types.h>
 
-__BEGIN_DECLS
-
 /* Type for length arguments in socket calls.  */
 typedef unsigned int socklen_t;
 
@@ -61,17 +59,29 @@ enum __socket_type
 #define        PF_UNSPEC       0       /* Unspecified.  */
 #define        PF_LOCAL        1       /* Local to host (pipes and file-domain).  */
 #define        PF_UNIX         PF_LOCAL /* Old BSD name for PF_LOCAL.  */
-#define        PF_FILE         PF_LOCAL /* POSIX name for PF_LOCAL.  */
+#define        PF_FILE         PF_LOCAL /* Another non-standard name for PF_LOCAL.  */
 #define        PF_INET         2       /* IP protocol family.  */
 #define        PF_AX25         3       /* Amateur Radio AX.25.  */
 #define        PF_IPX          4       /* Novell Internet Protocol.  */
-#define        PF_APPLETALK    5       /* Don't use this.  */
+#define        PF_APPLETALK    5       /* Appletalk DDP.  */
 #define        PF_NETROM       6       /* Amateur radio NetROM.  */
 #define        PF_BRIDGE       7       /* Multiprotocol bridge.  */
-#define        PF_AAL5         8       /* Reserved for Werner's ATM.  */
+#define        PF_ATMPVC       8       /* ATM PVCs.  */
 #define        PF_X25          9       /* Reserved for X.25 project.  */
 #define        PF_INET6        10      /* IP version 6.  */
-#define        PF_MAX          12      /* For now.. */
+#define        PF_ROSE         11      /* Amateur Radio X.25 PLP.  */
+#define        PF_DECnet       12      /* Reserved for DECnet project.  */
+#define        PF_NETBEUI      13      /* Reserved for 802.2LLC project.  */
+#define        PF_SECURITY     14      /* Security callback pseudo AF.  */
+#define        PF_KEY          15      /* PF_KEY key management API.  */
+#define        PF_NETLINK      16
+#define        PF_ROUTE        PF_NETLINK /* Alias to emulate 4.4BSD.  */
+#define        PF_PACKET       17      /* Packet family.  */
+#define        PF_ASH          18      /* Ash.  */
+#define        PF_ECONET       19      /* Acorn Econet.  */
+#define        PF_ATMSVC       20      /* ATM SVCs.  */
+#define        PF_SNA          22      /* Linux SNA Project */
+#define        PF_MAX          32      /* For now..  */
 
 /* Address families.  */
 #define        AF_UNSPEC       PF_UNSPEC
@@ -84,9 +94,21 @@ enum __socket_type
 #define        AF_APPLETALK    PF_APPLETALK
 #define        AF_NETROM       PF_NETROM
 #define        AF_BRIDGE       PF_BRIDGE
-#define        AF_AAL5         PF_AAL5
+#define        AF_ATMPVC       PF_ATMPVC
 #define        AF_X25          PF_X25
 #define        AF_INET6        PF_INET6
+#define        AF_ROSE         PF_ROSE
+#define        AF_DECnet       PF_DECnet
+#define        AF_NETBEUI      PF_NETBEUI
+#define        AF_SECURITY     PF_SECURITY
+#define        pseudo_AF_KEY   PF_KEY
+#define        AF_NETLINK      PF_NETLINK
+#define        AF_ROUTE        PF_ROUTE
+#define        AF_PACKET       PF_PACKET
+#define        AF_ASH          PF_ASH
+#define        AF_ECONET       PF_ECONET
+#define        AF_ATMSVC       PF_ATMSVC
+#define        AF_SNA          PF_SNA
 #define        AF_MAX          PF_MAX
 
 /* Socket level values.  Others are defined in the appropriate headers.
@@ -96,10 +118,6 @@ enum __socket_type
 #define SOL_IPV6        41
 #define SOL_ICMPV6      58
 #define SOL_RAW                255
-#define SOL_AX25        257
-#define SOL_ATALK       258
-#define SOL_NETROM      259
-#define SOL_ROSE        260
 #define SOL_DECNET      261
 #define SOL_X25         262
 
@@ -121,10 +139,15 @@ struct sockaddr
 enum
   {
     MSG_OOB            = 0x01, /* Process out-of-band data.  */
+#define MSG_OOB                MSG_OOB
     MSG_PEEK           = 0x02, /* Peek at incoming messages.  */
+#define MSG_PEEK       MSG_PEEK
     MSG_DONTROUTE      = 0x04, /* Don't use local routing.  */
+#define MSG_DONTROUTE  MSG_DONTROUTE
     MSG_CTRUNC         = 0x08, /* Control data lost before delivery.  */
+#define MSG_CTRUNC     MSG_CTRUNC
     MSG_PROXY          = 0x10  /* Supply or ask second address.  */
+#define MSG_PROXY      MSG_PROXY
   };
 
 
@@ -136,10 +159,10 @@ struct msghdr
     socklen_t msg_namelen;     /* Length of address data.  */
 
     struct iovec *msg_iov;     /* Vector of data to send/receive into.  */
-    int msg_iovlen;            /* Number of elements in the vector.  */
+    size_t msg_iovlen;         /* Number of elements in the vector.  */
 
     __ptr_t msg_control;       /* Ancillary data (eg BSD filedesc passing). */
-    socklen_t msg_controllen;  /* Ancillary data buffer length.  */
+    size_t msg_controllen;     /* Ancillary data buffer length.  */
 
     int msg_flags;             /* Flags on received message.  */
   };
@@ -147,7 +170,7 @@ struct msghdr
 /* Structure used for storage of ancillary data object information.  */
 struct cmsghdr
   {
-    socklen_t cmsg_len;                /* Length of data in cmsg_data plus length
+    size_t cmsg_len;           /* Length of data in cmsg_data plus length
                                   of cmsghdr structure.  */
     int cmsg_level;            /* Originating protocol.  */
     int cmsg_type;             /* Protocol specific type.  */
@@ -195,6 +218,36 @@ __cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg)
   return (struct cmsghdr *) __p;
 }
 
+/* Socket level message types.  This must match the definitions in
+   <linux/socket.h>.  */
+enum
+  {
+    SCM_RIGHTS = 0x01,         /* Transfer file descriptors.  */
+#define SCM_RIGHTS SCM_RIGHTS
+#ifdef __USE_BSD
+    SCM_CREDS = 0x02,          /* BSD-compatible credentials passing.  */
+# define SCM_CREDS SCM_CREDS
+#endif
+    __SCM_CONNECT = 0x03,      /* Data array is `struct scm_connect'.  */
+  };
+
+#ifdef __USE_BSD
+
+/* User visible structure for SCM_CREDS message
+   (chosen for BSD source compatibility) */
+
+# define CMGROUP_MAX 16  /* Linux does not provide this info, so it doesn't
+                           matter... use what bsd does. */
+struct cmsgcred
+{
+  pid_t cmcred_pid;                    /* PID of sending process.  */
+  uid_t cmcred_uid;                    /* Real UID of sending process.  */
+  uid_t cmcred_euid;                   /* Effective UID of sending process. */
+  gid_t cmcred_gid;                    /* Real GID of sending process.  */
+  short int cmcred_ngroups;            /* Number or groups.  */
+  gid_t cmcred_groups[CMGROUP_MAX];    /* Groups.  */
+};
+#endif
 
 /* Get socket manipulation related informations from kernel headers.  */
 #include <asm/socket.h>
@@ -207,4 +260,4 @@ struct linger
     int l_linger;              /* Time to linger.  */
   };
 
-__END_DECLS
+#endif /* bits/socket.h */