Electroneum
Loading...
Searching...
No Matches
tube.h
Go to the documentation of this file.
1/*
2 * util/tube.h - pipe service
3 *
4 * Copyright (c) 2008, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
41
42#ifndef UTIL_TUBE_H
43#define UTIL_TUBE_H
44struct comm_reply;
45struct comm_point;
46struct comm_base;
47struct tube;
48struct tube_res_list;
49#ifdef USE_WINSOCK
50#include "util/locks.h"
51#endif
52
58typedef void tube_callback_type(struct tube*, uint8_t*, size_t, int, void*);
59
63struct tube {
64#ifndef USE_WINSOCK
66 int sr;
68 int sw;
69
77 size_t cmd_read;
82
87 size_t res_write;
92
93#else /* USE_WINSOCK */
97 void* listen_arg;
99 WSAEVENT event;
101 struct ub_event* ev_listen;
102
104 lock_basic_type res_lock;
106 struct tube_res_list* res_list;
108 struct tube_res_list* res_last;
109#endif /* USE_WINSOCK */
110};
111
123
128struct tube* tube_create(void);
129
134void tube_delete(struct tube* tube);
135
154 int nonblock);
155
174 int nonblock);
175
182
189
196int tube_poll(struct tube* tube);
197
205int tube_wait(struct tube* tube);
206
212int tube_read_fd(struct tube* tube);
213
224int tube_setup_bg_listen(struct tube* tube, struct comm_base* base,
225 tube_callback_type* cb, void* arg);
226
232
240int tube_setup_bg_write(struct tube* tube, struct comm_base* base);
241
247
248
259int tube_queue_item(struct tube* tube, uint8_t* msg, size_t len);
260
262int tube_handle_listen(struct comm_point* c, void* arg, int error,
263 struct comm_reply* reply_info);
264
266int tube_handle_write(struct comm_point* c, void* arg, int error,
267 struct comm_reply* reply_info);
268
270void tube_handle_signal(int fd, short events, void* arg);
271
272#endif /* UTIL_TUBE_H */
int lock_basic_type
Definition locks.h:269
const char * buf
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
struct tube_res_list * next
Definition tube.h:117
uint32_t len
Definition tube.h:121
uint8_t * buf
Definition tube.h:119
Definition tube.h:63
uint32_t cmd_len
Definition tube.h:79
struct comm_point * listen_com
Definition tube.h:71
size_t res_write
Definition tube.h:87
struct comm_point * res_com
Definition tube.h:84
uint8_t * cmd_msg
Definition tube.h:81
size_t cmd_read
Definition tube.h:77
int sr
Definition tube.h:66
int sw
Definition tube.h:68
tube_callback_type * listen_cb
Definition tube.h:73
void * listen_arg
Definition tube.h:75
struct tube_res_list * res_last
Definition tube.h:91
struct tube_res_list * res_list
Definition tube.h:89
int tube_write_msg(struct tube *tube, uint8_t *buf, uint32_t len, int nonblock)
void tube_close_write(struct tube *tube)
int tube_poll(struct tube *tube)
int tube_wait(struct tube *tube)
void tube_delete(struct tube *tube)
int tube_setup_bg_write(struct tube *tube, struct comm_base *base)
void tube_remove_bg_listen(struct tube *tube)
int tube_handle_write(struct comm_point *c, void *arg, int error, struct comm_reply *reply_info)
int tube_setup_bg_listen(struct tube *tube, struct comm_base *base, tube_callback_type *cb, void *arg)
void tube_callback_type(struct tube *, uint8_t *, size_t, int, void *)
Definition tube.h:58
void tube_handle_signal(int fd, short events, void *arg)
int tube_read_msg(struct tube *tube, uint8_t **buf, uint32_t *len, int nonblock)
int tube_handle_listen(struct comm_point *c, void *arg, int error, struct comm_reply *reply_info)
int tube_queue_item(struct tube *tube, uint8_t *msg, size_t len)
void tube_remove_bg_write(struct tube *tube)
struct tube * tube_create(void)
void tube_close_read(struct tube *tube)
int tube_read_fd(struct tube *tube)