b2a5e14c23218375f1ee068ef185cf0a45a42559
3 * Generic endpoint abstraction
5 * (c) 1999 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the `fw' port forwarder.
12 * `fw' is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * `fw' is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with `fw'; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 /*----- Header files ------------------------------------------------------*/
40 /*----- Data structures ---------------------------------------------------*/
42 /* --- Basic endpoint structure --- */
44 typedef struct endpt
{
45 struct endpt_ops
*ops
; /* Pointer to operations table */
46 struct endpt
*other
; /* Pointer to sibling endpoint */
47 unsigned f
; /* Various flags */
48 struct tango
*t
; /* Private data structure */
49 reffd
*in
, *out
; /* File descriptors */
52 /* --- Endpoint flags --- */
54 #define EPF_PENDING 1u /* Endpoint creation in progress */
55 #define EPF_FILE 2u /* Endpoint smells like a file */
57 /* --- Endpoint operations table --- */
59 typedef struct endpt_ops
{
63 * Arguments: @endpt *e@ = pointer to endpoint to be attached
64 * @reffd *in, *out@ = input and output file descriptors
68 * Use: Instructs a non-file endpoint to attach itself to a pair of
72 void (*attach
)(endpt */
*e*/
, reffd */
*in*/
, reffd */
*out*/
);
76 * Arguments: @endpt *e@ = pointer to endpoint in question
77 * @endpt *f@ = pointer to a file endpoint
81 * Use: Informs a non-file endpoint of a file endpoint which will
82 * want to be closed when it's finished with. At that time, the
83 * endpoint should arrange to have both itself and its partner
84 * closed. If no file is registered, the endpoint manager will
85 * close both endpoints itself.
88 void (*file
)(endpt */
*e*/
, endpt */
*f*/
);
92 * Arguments: @endpt *e@ = endpoint to be partially closed
96 * Use: Announces that the endpoint will not be written to any more.
99 void (*wclose
)(endpt */
*e*/
);
103 * Arguments: @endpt *e@ = endpoint to be closed
107 * Use: Completely closes an endpoint. The endpoint's data may be
108 * freed, although some endpoints may wish to delay freeing for
112 void (*close
)(endpt */
*e*/
);
116 /*----- Functions provided ------------------------------------------------*/
118 /* --- @endpt_kill@ --- *
120 * Arguments: @endpt *a@ = an endpoint
124 * Use: Kills an endpoint. If the endpoint is joined to another, the
125 * other endpoint is also killed, as is the connection between
126 * them (and that's the tricky bit).
129 extern void endpt_kill(endpt */
*a*/
);
131 /* --- @endpt_killall@ --- *
137 * Use: Destroys all current endpoint connections. Used when
141 extern void endpt_killall(void);
143 /* --- @endpt_join@ --- *
145 * Arguments: @endpt *a@ = pointer to first endpoint
146 * @endpt *b@ = pointer to second endpoint
150 * Use: Joins two endpoints together.
153 extern void endpt_join(endpt */
*a*/
, endpt */
*b*/
);
155 /*----- That's all, folks -------------------------------------------------*/