Electroneum
Toggle main menu visibility
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
44
struct
comm_reply
;
45
struct
comm_point
;
46
struct
comm_base
;
47
struct
tube
;
48
struct
tube_res_list
;
49
#ifdef USE_WINSOCK
50
#include "
util/locks.h
"
51
#endif
52
58
typedef
void
tube_callback_type
(
struct
tube
*,
uint8_t
*,
size_t
,
int
,
void
*);
59
63
struct
tube
{
64
#ifndef USE_WINSOCK
66
int
sr
;
68
int
sw
;
69
71
struct
comm_point
*
listen_com
;
73
tube_callback_type
*
listen_cb
;
75
void
*
listen_arg
;
77
size_t
cmd_read
;
79
uint32_t
cmd_len
;
81
uint8_t
*
cmd_msg
;
82
84
struct
comm_point
*
res_com
;
87
size_t
res_write
;
89
struct
tube_res_list
*
res_list
;
91
struct
tube_res_list
*
res_last
;
92
93
#else
/* USE_WINSOCK */
95
tube_callback_type
*
listen_cb
;
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
115
struct
tube_res_list
{
117
struct
tube_res_list
*
next
;
119
uint8_t
*
buf
;
121
uint32_t
len
;
122
};
123
128
struct
tube
*
tube_create
(
void
);
129
134
void
tube_delete
(
struct
tube
*
tube
);
135
153
int
tube_write_msg
(
struct
tube
*
tube
,
uint8_t
*
buf
,
uint32_t
len,
154
int
nonblock);
155
173
int
tube_read_msg
(
struct
tube
*
tube
,
uint8_t
**
buf
,
uint32_t
* len,
174
int
nonblock);
175
181
void
tube_close_read
(
struct
tube
*
tube
);
182
188
void
tube_close_write
(
struct
tube
*
tube
);
189
196
int
tube_poll
(
struct
tube
*
tube
);
197
205
int
tube_wait
(
struct
tube
*
tube
);
206
212
int
tube_read_fd
(
struct
tube
*
tube
);
213
224
int
tube_setup_bg_listen
(
struct
tube
*
tube
,
struct
comm_base
* base,
225
tube_callback_type
* cb,
void
* arg);
226
231
void
tube_remove_bg_listen
(
struct
tube
*
tube
);
232
240
int
tube_setup_bg_write
(
struct
tube
*
tube
,
struct
comm_base
* base);
241
246
void
tube_remove_bg_write
(
struct
tube
*
tube
);
247
248
259
int
tube_queue_item
(
struct
tube
*
tube
,
uint8_t
* msg,
size_t
len);
260
262
int
tube_handle_listen
(
struct
comm_point
* c,
void
* arg,
int
error,
263
struct
comm_reply
*
reply_info
);
264
266
int
tube_handle_write
(
struct
comm_point
* c,
void
* arg,
int
error,
267
struct
comm_reply
*
reply_info
);
268
270
void
tube_handle_signal
(
int
fd,
short
events,
void
* arg);
271
272
#endif
/* UTIL_TUBE_H */
locks.h
lock_basic_type
int lock_basic_type
Definition
locks.h:269
buf
const char * buf
Definition
slow_memmem.cpp:74
uint32_t
unsigned int uint32_t
Definition
stdint.h:126
uint8_t
unsigned char uint8_t
Definition
stdint.h:124
comm_base
Definition
netevent.h:96
comm_point
Definition
netevent.h:154
comm_reply
Definition
netevent.h:112
reply_info
Definition
msgreply.h:125
tube_res_list
Definition
tube.h:115
tube_res_list::next
struct tube_res_list * next
Definition
tube.h:117
tube_res_list::len
uint32_t len
Definition
tube.h:121
tube_res_list::buf
uint8_t * buf
Definition
tube.h:119
tube
Definition
tube.h:63
tube::cmd_len
uint32_t cmd_len
Definition
tube.h:79
tube::listen_com
struct comm_point * listen_com
Definition
tube.h:71
tube::res_write
size_t res_write
Definition
tube.h:87
tube::res_com
struct comm_point * res_com
Definition
tube.h:84
tube::cmd_msg
uint8_t * cmd_msg
Definition
tube.h:81
tube::cmd_read
size_t cmd_read
Definition
tube.h:77
tube::sr
int sr
Definition
tube.h:66
tube::sw
int sw
Definition
tube.h:68
tube::listen_cb
tube_callback_type * listen_cb
Definition
tube.h:73
tube::listen_arg
void * listen_arg
Definition
tube.h:75
tube::res_last
struct tube_res_list * res_last
Definition
tube.h:91
tube::res_list
struct tube_res_list * res_list
Definition
tube.h:89
ub_event
Definition
unbound-event.h:166
tube_write_msg
int tube_write_msg(struct tube *tube, uint8_t *buf, uint32_t len, int nonblock)
tube_close_write
void tube_close_write(struct tube *tube)
tube_poll
int tube_poll(struct tube *tube)
tube_wait
int tube_wait(struct tube *tube)
tube_delete
void tube_delete(struct tube *tube)
tube_setup_bg_write
int tube_setup_bg_write(struct tube *tube, struct comm_base *base)
tube_remove_bg_listen
void tube_remove_bg_listen(struct tube *tube)
tube_handle_write
int tube_handle_write(struct comm_point *c, void *arg, int error, struct comm_reply *reply_info)
tube_setup_bg_listen
int tube_setup_bg_listen(struct tube *tube, struct comm_base *base, tube_callback_type *cb, void *arg)
tube_callback_type
void tube_callback_type(struct tube *, uint8_t *, size_t, int, void *)
Definition
tube.h:58
tube_handle_signal
void tube_handle_signal(int fd, short events, void *arg)
tube_read_msg
int tube_read_msg(struct tube *tube, uint8_t **buf, uint32_t *len, int nonblock)
tube_handle_listen
int tube_handle_listen(struct comm_point *c, void *arg, int error, struct comm_reply *reply_info)
tube_queue_item
int tube_queue_item(struct tube *tube, uint8_t *msg, size_t len)
tube_remove_bg_write
void tube_remove_bg_write(struct tube *tube)
tube_create
struct tube * tube_create(void)
tube_close_read
void tube_close_read(struct tube *tube)
tube_read_fd
int tube_read_fd(struct tube *tube)
external
unbound
util
tube.h
Generated on
for Electroneum by
1.17.0