1 // Copyright Leandro Lucarella 2008 - 2010.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file COPYING or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef POSIXX_SOCKET_OPT_HPP_
8 #define POSIXX_SOCKET_OPT_HPP_
10 #include <sys/socket.h>
11 #include <linux/if.h> // TODO: split POSIX and Linux options
15 namespace posixx { namespace socket {
18 * Type-safe socket options
20 * @see posixx::socket::setsockopt(), posixx::socket::getsockopt()
24 #define MKSOLOPT(O, T, R, W) \
32 #define MKSOLOPT_R(O, T) MKSOLOPT(O, T type, true, false)
33 #define MKSOLOPT_RW(O, T) MKSOLOPT(O, T type, true, true)
34 #define MKSOLOPT_ARRAY(O, T, S) MKSOLOPT(O, T type[S], true, true)
36 MKSOLOPT_R(ACCEPTCONN, int);
37 MKSOLOPT_ARRAY(BINDTODEVICE, char, IFNAMSIZ);
38 MKSOLOPT_RW(BROADCAST, int);
39 MKSOLOPT_RW(BSDCOMPAT, int);
40 //XXX DEBUG is replaced by the preprocessor in debug builds MKSOLOPT_RW(DEBUG, int);
41 MKSOLOPT_R(ERROR, int);
42 MKSOLOPT_RW(DONTROUTE, int);
43 MKSOLOPT_RW(KEEPALIVE, int);
44 MKSOLOPT_RW(LINGER, linger);
45 MKSOLOPT_RW(OOBINLINE, int);
46 MKSOLOPT_RW(PASSCRED, int);
47 MKSOLOPT_R(PEERCRED, ucred);
48 MKSOLOPT_RW(PRIORITY, int);
49 MKSOLOPT_RW(RCVBUF, size_t);
50 MKSOLOPT_RW(RCVBUFFORCE, size_t);
51 MKSOLOPT_RW(RCVLOWAT, size_t);
52 MKSOLOPT_R(SNDLOWAT, size_t);
53 MKSOLOPT_RW(RCVTIMEO, timeval);
54 MKSOLOPT_RW(SNDTIMEO, timeval);
55 MKSOLOPT_RW(REUSEADDR, int);
56 MKSOLOPT_RW(SNDBUF, size_t);
57 MKSOLOPT_RW(SNDBUFFORCE, size_t);
58 MKSOLOPT_RW(TIMESTAMP, int);
59 MKSOLOPT_R(TYPE, int);
66 } } } // namespace posixx::socket::opt
68 #endif // POSIXX_SOCKET_OPT_HPP_