|
1 /* $OpenBSD: ioev.h,v 1.1 2014/01/27 15:49:52 sunil Exp $ */ |
|
2 /* |
|
3 * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> |
|
4 * |
|
5 * Permission to use, copy, modify, and distribute this software for any |
|
6 * purpose with or without fee is hereby granted, provided that the above |
|
7 * copyright notice and this permission notice appear in all copies. |
|
8 * |
|
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
16 */ |
|
17 |
|
18 #include <event.h> |
|
19 |
|
20 enum { |
|
21 IO_CONNECTED = 0, /* connection successful */ |
|
22 IO_TLSREADY, /* TLS started succesfully */ |
|
23 IO_TLSVERIFIED, /* XXX - needs more work */ |
|
24 IO_DATAIN, /* new data in input buffer */ |
|
25 IO_LOWAT, /* output queue running low */ |
|
26 IO_DISCONNECTED, /* error? */ |
|
27 IO_TIMEOUT, /* error? */ |
|
28 IO_ERROR, /* details? */ |
|
29 }; |
|
30 |
|
31 #define IO_READ 0x01 |
|
32 #define IO_WRITE 0x02 |
|
33 #define IO_RW (IO_READ | IO_WRITE) |
|
34 #define IO_PAUSE_IN 0x04 |
|
35 #define IO_PAUSE_OUT 0x08 |
|
36 #define IO_RESET 0x10 /* internal */ |
|
37 #define IO_HELD 0x20 /* internal */ |
|
38 |
|
39 struct iobuf; |
|
40 struct io { |
|
41 int sock; |
|
42 void *arg; |
|
43 void (*cb)(struct io*, int); |
|
44 struct iobuf *iobuf; |
|
45 size_t lowat; |
|
46 int timeout; |
|
47 int flags; |
|
48 int state; |
|
49 struct event ev; |
|
50 void *ssl; |
|
51 const char *error; /* only valid immediatly on callback */ |
|
52 }; |
|
53 |
|
54 void io_set_blocking(int, int); |
|
55 void io_set_linger(int, int); |
|
56 |
|
57 void io_init(struct io*, int, void*, void(*)(struct io*, int), struct iobuf*); |
|
58 void io_clear(struct io*); |
|
59 void io_set_read(struct io *); |
|
60 void io_set_write(struct io *); |
|
61 void io_set_timeout(struct io *, int); |
|
62 void io_set_lowat(struct io *, size_t); |
|
63 void io_pause(struct io *, int); |
|
64 void io_resume(struct io *, int); |
|
65 void io_reload(struct io *); |
|
66 int io_connect(struct io *, const struct sockaddr *, const struct sockaddr *); |
|
67 int io_start_tls(struct io *, void *); |
|
68 const char* io_strio(struct io *); |
|
69 const char* io_strevent(int); |