From 19c9bba94152148523ba0f7ef7cffe3d45656b11 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 29 Apr 1997 21:13:14 +0000 Subject: Import of Linux/MIPS 2.1.36 --- include/linux/socket.h | 113 ++++++++++++++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 43 deletions(-) (limited to 'include/linux/socket.h') diff --git a/include/linux/socket.h b/include/linux/socket.h index 21d7169bb..756d4cca6 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -4,6 +4,7 @@ #include /* arch-dependent defines */ #include /* the SIOCxxx I/O controls */ #include /* iovec support */ +#include /* pid_t */ typedef unsigned short sa_family_t; @@ -33,10 +34,10 @@ struct msghdr void * msg_name; /* Socket name */ int msg_namelen; /* Length of name */ struct iovec * msg_iov; /* Data blocks */ - size_t msg_iovlen; /* Number of blocks */ + __kernel_size_t msg_iovlen; /* Number of blocks */ void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ - size_t msg_controllen; /* Length of rights list */ - int msg_flags; /* 4.4 BSD item we dont use */ + __kernel_size_t msg_controllen; /* Length of cmsg list */ + unsigned msg_flags; }; /* @@ -46,7 +47,7 @@ struct msghdr */ struct cmsghdr { - size_t cmsg_len; /* data byte count, including hdr */ + __kernel_size_t cmsg_len; /* data byte count, including hdr */ int cmsg_level; /* originating protocol */ int cmsg_type; /* protocol-specific type */ unsigned char cmsg_data[0]; @@ -57,11 +58,38 @@ struct cmsghdr { * Table 5-14 of POSIX 1003.1g */ -#define CMSG_DATA(cmsg) cmsg->cmsg_data +#define CMSG_DATA(cmsg) (cmsg)->cmsg_data #define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr(mhdr, cmsg) -#define CMSG_FIRST(mhdr) ((struct cmsghdr *) (mhdr)->msg_control) -extern __inline__ struct cmsghdr * cmsg_nxthdr(struct msghdr *mhdr, +#define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) + +/* Stevens's Adv. API specifies CMSG_SPACE & CMSG_LENGTH, + * I cannot understand, what the differenece? --ANK + */ + +#define CMSG_SPACE(len) CMSG_ALIGN((len)+sizeof(struct cmsghdr)) +#define CMSG_LENGTH(len) CMSG_ALIGN((len)+sizeof(struct cmsghdr)) + +#define CMSG_FIRSTHDR(msg) ((msg)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(msg)->msg_control : \ + (struct cmsghdr *)NULL) + +/* + * This mess will go away with glibc + */ + +#ifdef __KERNEL__ +#define KINLINE extern __inline__ +#else +#define KINLINE static +#endif + + +/* + * Get the next cmsg header + */ + +KINLINE struct cmsghdr * cmsg_nxthdr(struct msghdr *mhdr, struct cmsghdr *cmsg) { unsigned char * ptr; @@ -70,16 +98,25 @@ extern __inline__ struct cmsghdr * cmsg_nxthdr(struct msghdr *mhdr, { return NULL; } - ptr = ((unsigned char *) cmsg) + cmsg->cmsg_len; + ptr = ((unsigned char *) cmsg) + CMSG_ALIGN(cmsg->cmsg_len); if (ptr >= (unsigned char *) mhdr->msg_control + mhdr->msg_controllen) return NULL; return (struct cmsghdr *) ptr; } -/* Control Messages */ +/* "Socket"-level control message types: */ -#define SCM_RIGHTS 1 +#define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ +#define SCM_CREDENTIALS 0x02 /* rw: struct ucred */ +#define SCM_CONNECT 0x03 /* rw: struct scm_connect */ + +struct ucred +{ + __kernel_pid_t pid; + __kernel_uid_t uid; + __kernel_gid_t gid; +}; /* Supported address families. */ @@ -98,6 +135,7 @@ extern __inline__ struct cmsghdr * cmsg_nxthdr(struct msghdr *mhdr, #define AF_ROSE 11 /* Amateur Radio X.25 PLP */ #define AF_DECNET 12 /* Reserved for DECnet project */ #define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ #define AF_MAX 32 /* For now.. */ /* Protocol families, same as address families. */ @@ -113,9 +151,10 @@ extern __inline__ struct cmsghdr * cmsg_nxthdr(struct msghdr *mhdr, #define PF_AAL5 AF_AAL5 #define PF_X25 AF_X25 #define PF_INET6 AF_INET6 -#define PR_ROSE AF_ROSE +#define PF_ROSE AF_ROSE #define PF_DECNET AF_DECNET #define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY #define PF_MAX AF_MAX @@ -126,17 +165,25 @@ extern __inline__ struct cmsghdr * cmsg_nxthdr(struct msghdr *mhdr, Added those for 1003.1g not all are supported yet */ -enum -{ - MSG_OOB = 0x01, /* Process out-of-band data. */ - MSG_PEEK = 0x02, /* Peek at incoming messages. */ - MSG_DONTROUTE = 0x04, /* Don't use local routing. */ - MSG_CTRUNC = 0x08, /* We need to support this for BSD oddments */ - MSG_PROXY = 0x10, /* Supply or ask second address. */ - MSG_EOR = 0x20, /* End of record */ - MSG_TRUNC = 0x40, /* Data was discarded before delivery */ - MSG_WAITALL = 0x80, /* Wait for a full request */ -}; +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_CTRUNC 8 +#define MSG_PROXY 0x10 /* Supply or ask second address. */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_SYN 0x400 +#define MSG_URG 0x800 +#define MSG_RST 0x1000 + +#define MSG_CTLIGNORE 0x80000000 + +#define MSG_EOF MSG_FIN +#define MSG_CTLFLAGS (MSG_OOB|MSG_URG|MSG_FIN|MSG_SYN|MSG_RST) + /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ #define SOL_IP 0 @@ -153,27 +200,6 @@ enum #define SOL_TCP 6 #define SOL_UDP 17 -/* IP options */ -#define IP_TOS 1 -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#define IPTOS_MINCOST 0x02 -#define IP_TTL 2 -#define IP_HDRINCL 3 -#define IP_OPTIONS 4 - -#define IP_MULTICAST_IF 32 -#define IP_MULTICAST_TTL 33 -#define IP_MULTICAST_LOOP 34 -#define IP_ADD_MEMBERSHIP 35 -#define IP_DROP_MEMBERSHIP 36 - -/* These need to appear somewhere around here */ -#define IP_DEFAULT_MULTICAST_TTL 1 -#define IP_DEFAULT_MULTICAST_LOOP 1 -#define IP_MAX_MEMBERSHIPS 20 - /* IPX options */ #define IPX_TYPE 1 @@ -199,5 +225,6 @@ extern int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len); extern int move_addr_to_user(void *kaddr, int klen, void *uaddr, int *ulen); extern int move_addr_to_kernel(void *uaddr, int ulen, void *kaddr); +extern void put_cmsg(struct msghdr*, int level, int type, int len, void *data); #endif #endif /* _LINUX_SOCKET_H */ -- cgit v1.2.3