2 * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #error "Use this header only with sparse. It is not a correct implementation."
21 #ifndef __SYS_SOCKET_SPARSE
22 #define __SYS_SOCKET_SPARSE 1
24 #include "openvswitch/types.h"
28 typedef unsigned short int sa_family_t;
29 typedef __socklen_t socklen_t;
32 sa_family_t sa_family;
36 struct sockaddr_storage {
37 sa_family_t ss_family;
43 socklen_t msg_namelen;
44 struct iovec *msg_iov;
47 socklen_t msg_controllen;
55 unsigned char cmsg_data[];
58 #define __CMSG_ALIGNTO sizeof(size_t)
59 #define CMSG_ALIGN(LEN) \
60 (((LEN) + __CMSG_ALIGNTO - 1) / __CMSG_ALIGNTO * __CMSG_ALIGNTO)
61 #define CMSG_DATA(CMSG) ((CMSG)->cmsg_data)
62 #define CMSG_LEN(LEN) (sizeof(struct cmsghdr) + (LEN))
63 #define CMSG_SPACE(LEN) CMSG_ALIGN(CMSG_LEN(LEN))
64 #define CMSG_FIRSTHDR(MSG) \
65 ((MSG)->msg_controllen ? (struct cmsghdr *) (MSG)->msg_control : NULL)
66 #define CMSG_NXTHDR(MSG, CMSG) __cmsg_nxthdr(MSG, CMSG)
68 static inline struct cmsghdr *
69 __cmsg_nxthdr(struct msghdr *msg, struct cmsghdr *cmsg)
71 size_t ofs = (char *) cmsg - (char *) msg->msg_control;
72 size_t next_ofs = ofs + CMSG_ALIGN(cmsg->cmsg_len);
73 return (next_ofs < msg->msg_controllen
74 ? (void *) ((char *) msg->msg_control + next_ofs)
129 PF_UNSPEC = AF_UNSPEC,
137 PF_NETLINK = AF_NETLINK,
139 PF_PACKET = AF_PACKET
148 int accept(int, struct sockaddr *, socklen_t *);
149 int bind(int, const struct sockaddr *, socklen_t);
150 int connect(int, const struct sockaddr *, socklen_t);
151 int getpeername(int, struct sockaddr *, socklen_t *);
152 int getsockname(int, struct sockaddr *, socklen_t *);
153 int getsockopt(int, int, int, void *, socklen_t *);
154 int listen(int, int);
155 ssize_t recv(int, void *, size_t, int);
156 ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
157 ssize_t recvmsg(int, struct msghdr *, int);
158 ssize_t send(int, const void *, size_t, int);
159 ssize_t sendmsg(int, const struct msghdr *, int);
160 ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,
162 int setsockopt(int, int, int, const void *, socklen_t);
163 int shutdown(int, int);
165 int socket(int, int, int);
166 int socketpair(int, int, int, int[2]);
168 #endif /* <sys/socket.h> for sparse */