3 * $Id: endpt.h,v 1.3 2004/04/08 01:36:25 mdw Exp $
5 * Generic endpoint abstraction
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the `fw' port forwarder.
14 * `fw' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * `fw' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with `fw'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 /*----- Header files ------------------------------------------------------*/
42 /*----- Data structures ---------------------------------------------------*/
44 /* --- Basic endpoint structure --- */
46 typedef struct endpt
{
47 struct endpt_ops
*ops
; /* Pointer to operations table */
48 struct endpt
*other
; /* Pointer to sibling endpoint */
49 unsigned f
; /* Various flags */
50 struct tango
*t
; /* Private data structure */
51 reffd
*in
, *out
; /* File descriptors */
54 /* --- Endpoint flags --- */
56 #define EPF_PENDING 1u /* Endpoint creation in progress */
57 #define EPF_FILE 2u /* Endpoint smells like a file */
59 /* --- Endpoint operations table --- */
61 typedef struct endpt_ops
{
65 * Arguments: @endpt *e@ = pointer to endpoint to be attached
66 * @reffd *in, *out@ = input and output file descriptors
70 * Use: Instructs a non-file endpoint to attach itself to a pair of
74 void (*attach
)(endpt */
*e*/
, reffd */
*in*/
, reffd */
*out*/
);
78 * Arguments: @endpt *e@ = pointer to endpoint in question
79 * @endpt *f@ = pointer to a file endpoint
83 * Use: Informs a non-file endpoint of a file endpoint which will
84 * want to be closed when it's finished with. At that time, the
85 * endpoint should arrange to have both itself and its partner
86 * closed. If no file is registered, the endpoint manager will
87 * close both endpoints itself.
90 void (*file
)(endpt */
*e*/
, endpt */
*f*/
);
94 * Arguments: @endpt *e@ = endpoint to be partially closed
98 * Use: Announces that the endpoint will not be written to any more.
101 void (*wclose
)(endpt */
*e*/
);
105 * Arguments: @endpt *e@ = endpoint to be closed
109 * Use: Completely closes an endpoint. The endpoint's data may be
110 * freed, although some endpoints may wish to delay freeing for
114 void (*close
)(endpt */
*e*/
);
118 /*----- Functions provided ------------------------------------------------*/
120 /* --- @endpt_kill@ --- *
122 * Arguments: @endpt *a@ = an endpoint
126 * Use: Kills an endpoint. If the endpoint is joined to another, the
127 * other endpoint is also killed, as is the connection between
128 * them (and that's the tricky bit).
131 extern void endpt_kill(endpt */
*a*/
);
133 /* --- @endpt_killall@ --- *
139 * Use: Destroys all current endpoint connections. Used when
143 extern void endpt_killall(void);
145 /* --- @endpt_join@ --- *
147 * Arguments: @endpt *a@ = pointer to first endpoint
148 * @endpt *b@ = pointer to second endpoint
152 * Use: Joins two endpoints together.
155 extern void endpt_join(endpt */
*a*/
, endpt */
*b*/
);
157 /*----- That's all, folks -------------------------------------------------*/