1 #ifndef SOCKET32_H
2 #define SOCKET32_H 1
3
4 /* XXX This really belongs in some header file... -DaveM */
5 #define MAX_SOCK_ADDR 128 /* 108 for Unix domain -
6 16 for IP, 16 for IPX,
7 24 for IPv6,
8 about 80 for AX.25 */
9
10 extern struct socket *sockfd_lookup(int fd, int *err);
11
12 /* XXX This as well... */
sockfd_put(struct socket * sock)13 extern __inline__ void sockfd_put(struct socket *sock)
14 {
15 fput(sock->file);
16 }
17
18 struct msghdr32 {
19 u32 msg_name;
20 int msg_namelen;
21 u32 msg_iov;
22 __kernel_size_t32 msg_iovlen;
23 u32 msg_control;
24 __kernel_size_t32 msg_controllen;
25 unsigned msg_flags;
26 };
27
28 struct cmsghdr32 {
29 __kernel_size_t32 cmsg_len;
30 int cmsg_level;
31 int cmsg_type;
32 };
33
34 /* Bleech... */
35 #define __CMSG32_NXTHDR(ctl, len, cmsg, cmsglen) __cmsg32_nxthdr((ctl),(len),(cmsg),(cmsglen))
36 #define CMSG32_NXTHDR(mhdr, cmsg, cmsglen) cmsg32_nxthdr((mhdr), (cmsg), (cmsglen))
37
38 #define CMSG32_ALIGN(len) ( ((len)+sizeof(int)-1) & ~(sizeof(int)-1) )
39
40 #define CMSG32_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG32_ALIGN(sizeof(struct cmsghdr32))))
41 #define CMSG32_SPACE(len) (CMSG32_ALIGN(sizeof(struct cmsghdr32)) + CMSG32_ALIGN(len))
42 #define CMSG32_LEN(len) (CMSG32_ALIGN(sizeof(struct cmsghdr32)) + (len))
43
44 #define __CMSG32_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr32) ? \
45 (struct cmsghdr32 *)(ctl) : \
46 (struct cmsghdr32 *)NULL)
47 #define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
48 #define CMSG32_OK(ucmlen, ucmsg, mhdr) \
49 ((ucmlen) >= sizeof(struct cmsghdr32) && \
50 (ucmlen) <= (unsigned long) \
51 ((mhdr)->msg_controllen - \
52 ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
53
__cmsg32_nxthdr(void * __ctl,__kernel_size_t __size,struct cmsghdr32 * __cmsg,int __cmsg_len)54 __inline__ struct cmsghdr32 *__cmsg32_nxthdr(void *__ctl, __kernel_size_t __size,
55 struct cmsghdr32 *__cmsg, int __cmsg_len)
56 {
57 struct cmsghdr32 * __ptr;
58
59 __ptr = (struct cmsghdr32 *)(((unsigned char *) __cmsg) +
60 CMSG32_ALIGN(__cmsg_len));
61 if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
62 return NULL;
63
64 return __ptr;
65 }
66
cmsg32_nxthdr(struct msghdr * __msg,struct cmsghdr32 * __cmsg,int __cmsg_len)67 __inline__ struct cmsghdr32 *cmsg32_nxthdr (struct msghdr *__msg,
68 struct cmsghdr32 *__cmsg,
69 int __cmsg_len)
70 {
71 return __cmsg32_nxthdr(__msg->msg_control, __msg->msg_controllen,
72 __cmsg, __cmsg_len);
73 }
74
75 #endif
76