1
/***************************************************************************
2
* libancillary - black magic on Unix domain sockets
4
* ancillary.h - public header
5
***************************************************************************/
8
* Redistribution and use in source and binary forms, with or without
9
* modification, are permitted provided that the following conditions are met:
11
* 1. Redistributions of source code must retain the above copyright notice,
12
* this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
* 3. The name of the author may not be used to endorse or promote products
17
* derived from this software without specific prior written permission.
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
22
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
/***************************************************************************
35
* Start of the readable part.
36
***************************************************************************/
38
#define ANCIL_MAX_N_FDS 960
40
* Maximum number of fds that can be sent or received using the "esay"
41
* functions; this is so that all can fit in one page.
45
ancil_send_fds_with_buffer(int, const int *, unsigned, void *);
47
* ancil_send_fds_with_buffer(sock, n_fds, fds, buffer)
49
* Sends the file descriptors in the array pointed by fds, of length n_fds
51
* buffer is a writeable memory area large enough to hold the required data
53
* Returns: -1 and errno in case of error, 0 in case of success.
57
ancil_recv_fds_with_buffer(int, int *, unsigned, void *);
59
* ancil_recv_fds_with_buffer(sock, n_fds, fds, buffer)
61
* Receives *n_fds file descriptors into the array pointed by fds
62
* from the socket sock.
63
* buffer is a writeable memory area large enough to hold the required data
65
* Returns: -1 and errno in case of error, the actual number of received fd
69
#define ANCIL_FD_BUFFER(n) \
76
* A structure type suitable to be used as buffer for n file descriptors.
77
* Requires <sys/socket.h>.
79
* ANCIL_FD_BUFFER(42) buffer;
80
* ancil_recv_fds_with_buffer(sock, 42, my_fds, &buffer);
84
ancil_send_fds(int, const int *, unsigned);
86
* ancil_send_fds(sock, n_fds, fds)
88
* Sends the file descriptors in the array pointed by fds, of length n_fds
90
* n_fds must not be greater than ANCIL_MAX_N_FDS.
91
* Returns: -1 and errno in case of error, 0 in case of success.
95
ancil_recv_fds(int, int *, unsigned);
97
* ancil_recv_fds(sock, n_fds, fds)
99
* Receives *n_fds file descriptors into the array pointed by fds
100
* from the socket sock.
101
* *n_fds must not be greater than ANCIL_MAX_N_FDS.
102
* Returns: -1 and errno in case of error, the actual number of received fd
103
* in case of success.
108
ancil_send_fd(int, int);
109
/* ancil_recv_fd(sock, fd);
111
* Sends the file descriptor fd on the socket sock.
112
* Returns : -1 and errno in case of error, 0 in case of success.
116
ancil_recv_fd(int, int *);
117
/* ancil_send_fd(sock, &fd);
119
* Receives the file descriptor fd from the socket sock.
120
* Returns : -1 and errno in case of error, 0 in case of success.
123
#endif /* ANCILLARY_H__ */