]> git.proxmox.com Git - mirror_ovs.git/blame - include/sparse/sys/socket.h
test-conntrack: Restore packet batching to pcap test.
[mirror_ovs.git] / include / sparse / sys / socket.h
CommitLineData
6506f45c 1/*
32383c3b 2 * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
6506f45c
BP
3 *
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:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#ifndef __CHECKER__
18#error "Use this header only with sparse. It is not a correct implementation."
19#endif
20
21#ifndef __SYS_SOCKET_SPARSE
22#define __SYS_SOCKET_SPARSE 1
23
24#include "openvswitch/types.h"
25#include <sys/uio.h>
4d3daf04 26#include <stddef.h>
6506f45c
BP
27
28typedef unsigned short int sa_family_t;
29typedef __socklen_t socklen_t;
30
31struct sockaddr {
32 sa_family_t sa_family;
33 char sa_data[64];
34};
35
36struct sockaddr_storage {
37 sa_family_t ss_family;
38 char sa_data[64];
39};
40
41struct msghdr {
42 void *msg_name;
43 socklen_t msg_namelen;
44 struct iovec *msg_iov;
45 int msg_iovlen;
46 void *msg_control;
47 socklen_t msg_controllen;
48 int msg_flags;
49};
50
fd94a42c
BP
51struct cmsghdr {
52 size_t cmsg_len;
53 int cmsg_level;
54 int cmsg_type;
55 unsigned char cmsg_data[];
56};
57
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)
67
68static inline struct cmsghdr *
69__cmsg_nxthdr(struct msghdr *msg, struct cmsghdr *cmsg)
70{
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)
75 : NULL);
76}
77
78enum {
79 SCM_RIGHTS = 1
80};
81
6506f45c
BP
82enum {
83 SOCK_DGRAM,
84 SOCK_RAW,
85 SOCK_SEQPACKET,
86 SOCK_STREAM
87};
88
89enum {
b73c8518 90 SOL_PACKET,
6506f45c
BP
91 SOL_SOCKET
92};
93
94enum {
95 SO_ACCEPTCONN,
96 SO_BROADCAST,
97 SO_DEBUG,
98 SO_DONTROUTE,
99 SO_ERROR,
100 SO_KEEPALIVE,
101 SO_LINGER,
102 SO_OOBINLINE,
103 SO_RCVBUF,
104 SO_RCVLOWAT,
105 SO_RCVTIMEO,
106 SO_REUSEADDR,
107 SO_SNDBUF,
108 SO_SNDLOWAT,
109 SO_SNDTIMEO,
d2b9f5b0 110 SO_TYPE,
32383c3b
MM
111 SO_RCVBUFFORCE,
112 SO_ATTACH_FILTER
6506f45c
BP
113};
114
115enum {
116 MSG_CTRUNC,
117 MSG_DONTROUTE,
118 MSG_EOR,
119 MSG_OOB,
120 MSG_NOSIGNAL,
121 MSG_PEEK,
122 MSG_TRUNC,
123 MSG_WAITALL,
124 MSG_DONTWAIT
125};
126
127enum {
128 AF_UNSPEC,
129 PF_UNSPEC = AF_UNSPEC,
130 AF_INET,
131 PF_INET = AF_INET,
132 AF_INET6,
133 PF_INET6 = AF_INET6,
134 AF_UNIX,
135 PF_UNIX = AF_UNIX,
136 AF_NETLINK,
137 PF_NETLINK = AF_NETLINK,
138 AF_PACKET,
139 PF_PACKET = AF_PACKET
140};
141
142enum {
143 SHUT_RD,
144 SHUT_RDWR,
145 SHUT_WR
146};
147
148int accept(int, struct sockaddr *, socklen_t *);
149int bind(int, const struct sockaddr *, socklen_t);
150int connect(int, const struct sockaddr *, socklen_t);
151int getpeername(int, struct sockaddr *, socklen_t *);
152int getsockname(int, struct sockaddr *, socklen_t *);
153int getsockopt(int, int, int, void *, socklen_t *);
154int listen(int, int);
155ssize_t recv(int, void *, size_t, int);
156ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
157ssize_t recvmsg(int, struct msghdr *, int);
158ssize_t send(int, const void *, size_t, int);
159ssize_t sendmsg(int, const struct msghdr *, int);
160ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,
161 socklen_t);
162int setsockopt(int, int, int, const void *, socklen_t);
163int shutdown(int, int);
164int sockatmark(int);
165int socket(int, int, int);
166int socketpair(int, int, int, int[2]);
167
168#endif /* <sys/socket.h> for sparse */