3 * $Id: endpt.h,v 1.1 1999/07/26 23:33:01 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.1 1999/07/26 23:33:01 mdw
33 * Infrastructure for the new design.
44 /*----- Header files ------------------------------------------------------*/
50 /*----- Data structures ---------------------------------------------------*/
52 /* --- Basic endpoint structure --- */
54 typedef struct endpt
{
55 struct endpt_ops
*ops
; /* Pointer to operations table */
56 struct endpt
*other
; /* Pointer to sibling endpoint */
57 unsigned f
; /* Various flags */
58 struct tango
*t
; /* Private data structure */
59 reffd
*in
, *out
; /* File descriptors */
62 /* --- Endpoint flags --- */
64 #define EPF_PENDING 1u /* Endpoint creation in progress */
65 #define EPF_FILE 2u /* Endpoint smells like a file */
67 /* --- Endpoint operations table --- */
69 typedef struct endpt_ops
{
73 * Arguments: @endpt *e@ = pointer to endpoint to be attached
74 * @reffd *in, *out@ = input and output file descriptors
78 * Use: Instructs a non-file endpoint to attach itself to a pair of
82 void (*attach
)(endpt */
*e*/
, reffd */
*in*/
, reffd */
*out*/
);
86 * Arguments: @endpt *e@ = endpoint to be partially closed
90 * Use: Announces that the endpoint will not be written to any more.
93 void (*wclose
)(endpt */
*e*/
);
97 * Arguments: @endpt *e@ = endpoint to be closed
101 * Use: Completely closes an endpoint. The endpoint's data may be
102 * freed, although some endpoints may wish to delay freeing for
106 void (*close
)(endpt */
*e*/
);
110 /*----- Functions provided ------------------------------------------------*/
112 /* --- @endpt_kill@ --- *
114 * Arguments: @endpt *a@ = an endpoint
118 * Use: Kills an endpoint. If the endpoint is joined to another, the
119 * other endpoint is also killed, as is the connection between
120 * them (and that's the tricky bit).
123 extern void endpt_kill(endpt */
*a*/
);
125 /* --- @endpt_killall@ --- *
131 * Use: Destroys all current endpoint connections. Used when
135 extern void endpt_killall(void);
137 /* --- @endpt_join@ --- *
139 * Arguments: @endpt *a@ = pointer to first endpoint
140 * @endpt *b@ = pointer to second endpoint
144 * Use: Joins two endpoints together.
147 extern void endpt_join(endpt */
*a*/
, endpt */
*b*/
);
149 /*----- That's all, folks -------------------------------------------------*/