#define MAX_INPUT 255 /* size of the type-ahead buffer */
#define NAME_MAX DIRSIZ /* # chars in a file name */
#define PATH_MAX __MINIX_PATH_MAX /* # chars in a path name */
-#define PIPE_BUF 7168 /* # bytes in atomic write to a pipe */
+#define PIPE_BUF 32768 /* # bytes in atomic write to a pipe */
#define STREAM_MAX 20 /* must be the same as FOPEN_MAX in stdio.h */
#define TZNAME_MAX 3 /* maximum bytes in a time zone name is 3 */
#define SSIZE_MAX 32767 /* max defined byte count for read() */
/* Flag bits for i_mode in the inode. */
#define I_TYPE 0170000 /* this field gives inode type */
+#define I_UNIX_SOCKET 0140000 /* unix domain socket */
#define I_SYMBOLIC_LINK 0120000 /* file is a symbolic link */
#define I_REGULAR 0100000 /* regular file, not dir or special */
#define I_BLOCK_SPECIAL 0060000 /* block special file */
#define LOG_MAJOR 15 /* 15 = /dev/klog (log driver) */
#define RANDOM_MAJOR 16 /* 16 = /dev/random (random driver) */
#define HELLO_MAJOR 17 /* 17 = /dev/hello (hello driver) */
+#define UDS_MAJOR 18 /* 18 = /dev/uds (pfs) */
/* Minor device numbers for memory driver. */
#define NREQS 33
+#define IS_VFS_RQ(type) (((type) & ~0xff) == VFS_BASE)
+
#endif
#define _NET__IOCTL_H
#include <minix/ioctl.h>
+#include <sys/un.h>
/* Network ioctls. */
#define NWIOSETHOPT _IOW('n', 16, struct nwio_ethopt)
#define NWIOGUDPOPT _IOR('n', 65, struct nwio_udpopt)
#define NWIOUDPPEEK _IOR('n', 66, struct udp_io_hdr)
+#define NWIOGUDSFADDR _IOR('n', 67, struct sockaddr_un) /* recvfrom() */
+#define NWIOSUDSTADDR _IOW('n', 68, struct sockaddr_un) /* sendto() */
+#define NWIOSUDSADDR _IOW('n', 69, struct sockaddr_un) /* bind() */
+#define NWIOGUDSADDR _IOR('n', 70, struct sockaddr_un) /* getsockname() */
+#define NWIOGUDSPADDR _IOR('n', 71, struct sockaddr_un) /* getpeername() */
+#define NWIOSUDSTYPE _IOW('n', 72, int) /* socket() */
+#define NWIOSUDSBLOG _IOW('n', 73, int) /* listen() */
+#define NWIOSUDSCONN _IOW('n', 74, struct sockaddr_un) /* connect() */
+#define NWIOSUDSSHUT _IOW('n', 75, int) /* shutdown() */
+#define NWIOSUDSPAIR _IOW('n', 76, dev_t) /* socketpair() */
+#define NWIOSUDSACCEPT _IOW('n', 77, struct sockaddr_un) /* accept() */
+
#define NWIOSPSIPOPT _IOW('n', 80, struct nwio_psipopt)
#define NWIOGPSIPOPT _IOR('n', 81, struct nwio_psipopt)
+/* setsockopt/setsockopt for unix domain sockets */
+#define NWIOGUDSSOTYPE _IOR('n', 90, int) /* SO_TYPE */
+#define NWIOGUDSPEERCRED _IOR('n', 91, struct ucred) /* SO_PEERCRED */
+#define NWIOGUDSSNDBUF _IOR('n', 92, size_t) /* SO_SNDBUF */
+#define NWIOSUDSSNDBUF _IOW('n', 93, size_t) /* SO_SNDBUF */
+#define NWIOGUDSRCVBUF _IOR('n', 94, size_t) /* SO_RCVBUF */
+#define NWIOSUDSRCVBUF _IOW('n', 95, size_t) /* SO_RCVBUF */
+
#endif /* _NET__IOCTL_H */
/*
#define IP_DEVICE "/dev/ip"
#define TCP_DEVICE "/dev/tcp"
#define UDP_DEVICE "/dev/udp"
+#define UDS_DEVICE "/dev/uds"
#endif /* _NET__NETLIB_H_ */
mount.h mtio.h param.h ptrace.h queue.h resource.h \
select.h sem.h shm.h sigcontext.h signal.h socket.h \
soundcard.h statfs.h statvfs.h stat.h svrctl.h timeb.h \
- time.h times.h types.h ucontext.h uio.h un.h utsname.h video.h vm.h \
- wait.h cdefs.h null.h
+ time.h times.h types.h ucontext.h ucred.h uio.h un.h \
+ utsname.h video.h vm.h wait.h cdefs.h null.h
.include <bsd.kinc.mk>
*/
#include <stdint.h>
+#include <sys/ucred.h>
+
/* Open Group Base Specifications Issue 6 (not complete) */
#include <net/gen/socket.h>
#define SO_KEEPALIVE 0x0008
#define SO_TYPE 0x0010 /* get socket type, SOCK_STREAM or SOCK_DGRAM */
+#define SO_PASSCRED 0x0012
+#define SO_PEERCRED 0x0014
+
#define SO_SNDBUF 0x1001 /* send buffer size */
#define SO_RCVBUF 0x1002 /* receive buffer size */
#define SO_ERROR 0x1007 /* get and clear error status */
char sa_data[8]; /* Big enough for sockaddr_in */
};
+struct msghdr
+{
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ size_t msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+struct cmsghdr
+{
+ socklen_t cmsg_len;
+ int cmsg_level;
+ int cmsg_type;
+};
+
+#define CMSG_FIRSTHDR(mhdr) \
+ ( (mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
+ (struct cmsghdr *)(mhdr)->msg_control : \
+ (struct cmsghdr *)NULL )
+
+#define CMSG_ALIGN(len) \
+ ( (len % sizeof(long) == 0) ? \
+ len : \
+ len + sizeof(long) - (len % sizeof(long)) )
+
+#define CMSG_NXTHDR(mhdr, cmsg) \
+ ( ((cmsg) == NULL) ? CMSG_FIRSTHDR(mhdr) : \
+ (((unsigned char *)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len) \
+ + CMSG_ALIGN(sizeof(struct cmsghdr)) > \
+ (unsigned char *)((mhdr)->msg_control) + \
+ (mhdr)->msg_controllen) ? \
+ (struct cmsghdr *)NULL : \
+ (struct cmsghdr *)((unsigned char *)(cmsg) + \
+ CMSG_ALIGN((cmsg)->cmsg_len))) )
+
+#define CMSG_DATA(cmsg) \
+ ( (unsigned char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)) )
+
+#define SCM_RIGHTS 0x01
+#define SCM_CREDENTIALS 0x02
+#define SCM_SECURITY 0x04
+
_PROTOTYPE( int accept, (int _socket,
struct sockaddr *_RESTRICT _address,
socklen_t *_RESTRICT _address_len) );
_PROTOTYPE( int getpeername, (int _socket,
struct sockaddr *_RESTRICT _address,
socklen_t *_RESTRICT _address_len) );
+_PROTOTYPE( int getpeereid, (int _socket, uid_t *_euid, gid_t *_egid) );
_PROTOTYPE( int getsockname, (int _socket,
struct sockaddr *_RESTRICT _address,
socklen_t *_RESTRICT _address_len) );
_PROTOTYPE( ssize_t recvfrom, (int _socket, void *_RESTRICT _buffer,
size_t _length, int _flags, struct sockaddr *_RESTRICT _address,
socklen_t *_RESTRICT _address_len) );
+_PROTOTYPE( ssize_t recvmsg, (int _socket, struct msghdr *_msg,
+ int _flags) );
_PROTOTYPE( ssize_t send, (int _socket, const void *_buffer,
size_t _length, int _flags) );
+_PROTOTYPE( ssize_t sendmsg, (int _socket, const struct msghdr *_msg,
+ int _flags) );
_PROTOTYPE( ssize_t sendto, (int _socket, const void *_message,
size_t _length, int _flags, const struct sockaddr *_dest_addr,
socklen_t _dest_len) );
_PROTOTYPE( int shutdown, (int _socket, int _how) );
_PROTOTYPE( int socket, (int _domain, int _type, int _protocol) );
+_PROTOTYPE( int socketpair, (int _domain, int _type, int _protocol,
+ int _sv[2]) );
/* The following constants are often used in applications, but are not defined
* by POSIX.
#define PF_INET AF_INET
#define PF_INET6 AF_INET6
#define PF_UNIX AF_UNIX
+#define PF_LOCAL PF_UNIX
+#define PF_FILE PF_UNIX
#define PF_UNSPEC AF_UNSPEC
/* based on http://tools.ietf.org/html/rfc2553 */
--- /dev/null
+#ifndef __SYS_UCRED_H
+#define __SYS_UCRED_H
+
+struct ucred
+{
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
+};
+
+#endif
-/*
-sys/un.h
-*/
+#ifndef SYS_UN_H
+#define SYS_UN_H
-/* Open Group Base Specifications Issue 6 */
+#include <stdint.h>
#ifndef _SA_FAMILY_T
#define _SA_FAMILY_T
typedef uint8_t sa_family_t;
#endif /* _SA_FAMILY_T */
+#define UNIX_PATH_MAX 127
+
struct sockaddr_un
{
sa_family_t sun_family;
- char sun_path[127];
+ char sun_path[UNIX_PATH_MAX];
};
-/* Note: UNIX domain sockets are not implemented! */
+#include <string.h>
+
+/* Compute the actual length of a struct sockaddr_un pointed
+ * to by 'unp'. sun_path must be NULL terminated. Length does
+ * not include the NULL byte. This is not a POSIX standard
+ * definition, but BSD and Linux have it, so it is here for
+ * compatibility.
+ */
+#define SUN_LEN(unp) \
+((size_t)((sizeof(*(unp)) - sizeof((unp)->sun_path)) + strlen((unp)->sun_path)))
+
+#endif
#include <minix/types.h>
#endif
+#include <sys/ucred.h>
+
/* Values used by access(). POSIX Table 2-8. */
#define F_OK 0 /* test if file exists */
#define X_OK 1 /* test if file is executable */
_PROTOTYPE( pid_t getnpid, (endpoint_t proc_ep) );
_PROTOTYPE( uid_t getnuid, (endpoint_t proc_ep) );
_PROTOTYPE( gid_t getngid, (endpoint_t proc_ep) );
+_PROTOTYPE( int getnucred, (endpoint_t proc_ep, struct ucred *ucred) );
#endif