3 * $Id: endpt.h,v 1.2 1999/10/22 22:46:17 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.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.2 1999/10/22 22:46:17 mdw
33 * When a non-file endpoint is attached to a file, keep the file endpoint
34 * open until the nonfile is done. This stops socket sources from
35 * resetting their connection limits too early.
37 * Revision 1.1 1999/07/26 23:33:01 mdw
38 * Infrastructure for the new design.
49 /*----- Header files ------------------------------------------------------*/
55 /*----- Data structures ---------------------------------------------------*/
57 /* --- Basic endpoint structure --- */
59 typedef struct endpt
{
60 struct endpt_ops
*ops
; /* Pointer to operations table */
61 struct endpt
*other
; /* Pointer to sibling endpoint */
62 unsigned f
; /* Various flags */
63 struct tango
*t
; /* Private data structure */
64 reffd
*in
, *out
; /* File descriptors */
67 /* --- Endpoint flags --- */
69 #define EPF_PENDING 1u /* Endpoint creation in progress */
70 #define EPF_FILE 2u /* Endpoint smells like a file */
72 /* --- Endpoint operations table --- */
74 typedef struct endpt_ops
{
78 * Arguments: @endpt *e@ = pointer to endpoint to be attached
79 * @reffd *in, *out@ = input and output file descriptors
83 * Use: Instructs a non-file endpoint to attach itself to a pair of
87 void (*attach
)(endpt */
*e*/
, reffd */
*in*/
, reffd */
*out*/
);
91 * Arguments: @endpt *e@ = pointer to endpoint in question
92 * @endpt *f@ = pointer to a file endpoint
96 * Use: Informs a non-file endpoint of a file endpoint which will
97 * want to be closed when it's finished with. At that time, the
98 * endpoint should arrange to have both itself and its partner
99 * closed. If no file is registered, the endpoint manager will
100 * close both endpoints itself.
103 void (*file
)(endpt */
*e*/
, endpt */
*f*/
);
105 /* --- @wclose@ --- *
107 * Arguments: @endpt *e@ = endpoint to be partially closed
111 * Use: Announces that the endpoint will not be written to any more.
114 void (*wclose
)(endpt */
*e*/
);
118 * Arguments: @endpt *e@ = endpoint to be closed
122 * Use: Completely closes an endpoint. The endpoint's data may be
123 * freed, although some endpoints may wish to delay freeing for
127 void (*close
)(endpt */
*e*/
);
131 /*----- Functions provided ------------------------------------------------*/
133 /* --- @endpt_kill@ --- *
135 * Arguments: @endpt *a@ = an endpoint
139 * Use: Kills an endpoint. If the endpoint is joined to another, the
140 * other endpoint is also killed, as is the connection between
141 * them (and that's the tricky bit).
144 extern void endpt_kill(endpt */
*a*/
);
146 /* --- @endpt_killall@ --- *
152 * Use: Destroys all current endpoint connections. Used when
156 extern void endpt_killall(void);
158 /* --- @endpt_join@ --- *
160 * Arguments: @endpt *a@ = pointer to first endpoint
161 * @endpt *b@ = pointer to second endpoint
165 * Use: Joins two endpoints together.
168 extern void endpt_join(endpt */
*a*/
, endpt */
*b*/
);
170 /*----- That's all, folks -------------------------------------------------*/