/usr/include/proftpd/netio.h is in proftpd-dev 1.3.5e-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | /*
* ProFTPD - FTP server daemon
* Copyright (c) 1997, 1998 Public Flood Software
* Copyright (c) 1999, 2000 MacGyver aka Habeeb J. Dihu <macgyver@tos.net>
* Copyright (c) 2001-2014 The ProFTPD Project
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*
* As a special exemption, Public Flood Software/MacGyver aka Habeeb J. Dihu
* and other respective copyright holders give permission to link this program
* with OpenSSL, and distribute the resulting executable, without including
* the source code for OpenSSL in the source distribution.
*/
/* Network IO stream layer
* $Id: netio.h,v 1.18 2014-01-06 06:57:16 castaglia Exp $
*/
#ifndef PR_NETIO_H
#define PR_NETIO_H
/* Network I/O stream types */
/* This indicates that the netio being registered should be used when
* performing network I/O for the control connection.
*/
#define PR_NETIO_STRM_CTRL 0x00010
/* This indicates that the netio being registered should be used when
* performing network I/O for the data connection.
*/
#define PR_NETIO_STRM_DATA 0x00020
/* This indicates that the netio being registered should be used when
* performing network I/O for other connections (e.g. RFC931 lookups).
* This is rarely used.
*/
#define PR_NETIO_STRM_OTHR 0x00040
/* Network I/O stream direction */
#define PR_NETIO_IO_RD 1
#define PR_NETIO_IO_WR 2
/* Network I/O stream session flags */
/* This indicates that netio functions are allowed to be interruped by
* EINTR, and to return -2.
*/
#define PR_NETIO_SESS_INTR (1 << 1)
/* This is a temporary internal flag used to indicate that I/O on a
* network stream has been aborted, and should return -2 at the next
* possible instant. In combination with NETIO_INTR and interruptible
* syscalls, this should be near instantly. This flag cannot be tested
* for as it is cleared immediately after being detected.
*/
#define PR_NETIO_SESS_ABORT (1 << 2)
/* Network I/O objects */
typedef struct {
/* Pointer to the buffer memory. */
char *buf;
/* Total length of the buffer. */
unsigned long buflen;
/* Pointer to the current byte in the buffer. */
char *current;
/* Number of bytes left in the buffer. */
size_t remaining;
} pr_buffer_t;
typedef struct {
/* Memory pool for this object. */
struct pool_rec *strm_pool;
/* Stream type */
int strm_type;
/* File descriptor for this I/O stream. */
int strm_fd;
/* I/O mode: PR_NETIO_IO_RD or PR_NETIO_IO_WR. Patterned after
* open(2).
*/
int strm_mode;
/* Poll interval for this stream. */
unsigned int strm_interval;
/* Internal use. */
volatile unsigned long strm_flags;
/* Buffer. */
pr_buffer_t *strm_buf;
/* Arbitrary data for outside use. */
void *strm_data;
/* errno, if applicable. */
int strm_errno;
/* Private data for passing/retaining among modules. */
pr_table_t *notes;
} pr_netio_stream_t;
#define PR_NETIO_ERRNO(s) ((s)->strm_errno)
#define PR_NETIO_FD(s) ((s)->strm_fd)
typedef struct {
/* Memory pool for this object. */
struct pool_rec *pool;
/* NetIO callbacks */
void (*abort)(pr_netio_stream_t *);
int (*close)(pr_netio_stream_t *);
pr_netio_stream_t *(*open)(pr_netio_stream_t *, int, int);
int (*poll)(pr_netio_stream_t *);
int (*postopen)(pr_netio_stream_t *);
int (*read)(pr_netio_stream_t *, char *, size_t);
pr_netio_stream_t *(*reopen)(pr_netio_stream_t *, int, int);
int (*shutdown)(pr_netio_stream_t *, int);
int (*write)(pr_netio_stream_t *, char *, size_t);
/* Registering/owning module */
module *owner;
const char *owner_name;
} pr_netio_t;
/* Network IO function prototypes */
pr_buffer_t *pr_netio_buffer_alloc(pr_netio_stream_t *nstrm);
void pr_netio_abort(pr_netio_stream_t *);
int pr_netio_lingering_abort(pr_netio_stream_t *, long);
int pr_netio_close(pr_netio_stream_t *);
int pr_netio_lingering_close(pr_netio_stream_t *, long);
#define NETIO_LINGERING_CLOSE_FL_NO_SHUTDOWN 0x00001
char *pr_netio_gets(char *, size_t, pr_netio_stream_t *);
pr_netio_stream_t *pr_netio_open(pool *, int, int, int);
int pr_netio_postopen(pr_netio_stream_t *);
int pr_netio_printf(pr_netio_stream_t *, const char *, ...);
int pr_netio_vprintf(pr_netio_stream_t *, const char *, va_list);
/* pr_netio_printf_async() is for use inside alarm handlers, where no
* pr_netio_poll() blocking is allowed. This is necessary because otherwise,
* pr_netio_poll() can potentially hang forever if the send queue is maxed and
* the socket has been closed.
*/
int pr_netio_printf_async(pr_netio_stream_t *, char *,...);
/* pr_netio_poll() is needed instead of simply blocking read/write because
* there is a race condition if the syscall _should_ be interrupted inside
* read(), or write(), but the signal is received before we actually hit the
* read or write call. select() alleviates this problem by timing out
* (configurable by pr_netio_set_poll_interval()), restarting the syscall if
* PR_NETIO_SESS_INTR is not set, or returning if it is set and we were
* interrupted by a signal. If after the timeout PR_NETIO_SESS_ABORT is set
* (presumably by a signal handler) or PR_NETIO_SESS_INTR & errno == EINTR,
* we return 1. Otherwise, return zero when data is available, or -1 on
* other errors.
*/
int pr_netio_poll(pr_netio_stream_t *);
/* Read, from the given stream, into the buffer the requested size_t number
* of bytes. The int is the minimum number of bytes to read before
* returning 1 (or greater).
*/
int pr_netio_read(pr_netio_stream_t *, char *, size_t, int);
pr_netio_stream_t *pr_netio_reopen(pr_netio_stream_t *, int, int);
int pr_netio_shutdown(pr_netio_stream_t *, int);
/* pr_netio_telnet_gets() is exactly like pr_netio_gets(), except a few special
* telnet characters are handled (which takes care of the [IAC]ABOR
* command, and odd clients
*/
char *pr_netio_telnet_gets(char *, size_t, pr_netio_stream_t *,
pr_netio_stream_t *);
int pr_netio_write(pr_netio_stream_t *, char *, size_t);
/* This is a bit odd, because io_ functions are opaque, we can't be sure
* we are dealing with a conn_t or that it is in O_NONBLOCK mode. Trying
* to do this without O_NONBLOCK would cause the kernel itself to block
* here, and thus invalidate the whole principal. Instead we save
* the flags and put the fd in O_NONBLOCK mode.
*/
int pr_netio_write_async(pr_netio_stream_t *, char *, size_t);
void pr_netio_reset_poll_interval(pr_netio_stream_t *);
void pr_netio_set_poll_interval(pr_netio_stream_t *, unsigned int);
/* Allocate a NetIO object, and set all of its NetIO callbacks to their
* default handlers.
*/
pr_netio_t *pr_alloc_netio(pool *);
pr_netio_t *pr_alloc_netio2(pool *, module *);
/* Register the given NetIO object and all its callbacks for the network
* I/O layer's use. If given a NULL argument, it will automatically
* instantiate and register the default NetIO object.
*/
int pr_register_netio(pr_netio_t *, int);
/* Unregister the NetIO objects indicated by strm_types.
*/
int pr_unregister_netio(int);
/* Peek at the NetIO registered for the given stream type. */
pr_netio_t *pr_get_netio(int);
/* Initialize the network I/O layer.
*/
void init_netio(void);
#endif /* PR_NETIO_H */
|