07d71f34 |
1 | /* -*-c-*- |
2 | * |
28d2517c |
3 | * $Id: endpt.h,v 1.2 1999/10/22 22:46:17 mdw Exp $ |
07d71f34 |
4 | * |
5 | * Generic endpoint abstraction |
6 | * |
7 | * (c) 1999 Straylight/Edgeware |
8 | */ |
9 | |
10 | /*----- Licensing notice --------------------------------------------------* |
11 | * |
12 | * This file is part of the `fw' port forwarder. |
13 | * |
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. |
18 | * |
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. |
23 | * |
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. |
27 | */ |
28 | |
29 | /*----- Revision history --------------------------------------------------* |
30 | * |
31 | * $Log: endpt.h,v $ |
28d2517c |
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. |
36 | * |
07d71f34 |
37 | * Revision 1.1 1999/07/26 23:33:01 mdw |
38 | * Infrastructure for the new design. |
39 | * |
40 | */ |
41 | |
42 | #ifndef ENDPT_H |
43 | #define ENDPT_H |
44 | |
45 | #ifdef __cplusplus |
46 | extern "C" { |
47 | #endif |
48 | |
49 | /*----- Header files ------------------------------------------------------*/ |
50 | |
51 | #ifndef REFFD_H |
52 | # include "reffd.h" |
53 | #endif |
54 | |
55 | /*----- Data structures ---------------------------------------------------*/ |
56 | |
57 | /* --- Basic endpoint structure --- */ |
58 | |
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 */ |
65 | } endpt; |
66 | |
67 | /* --- Endpoint flags --- */ |
68 | |
69 | #define EPF_PENDING 1u /* Endpoint creation in progress */ |
70 | #define EPF_FILE 2u /* Endpoint smells like a file */ |
71 | |
72 | /* --- Endpoint operations table --- */ |
73 | |
74 | typedef struct endpt_ops { |
75 | |
76 | /* --- @attach@ --- * |
77 | * |
78 | * Arguments: @endpt *e@ = pointer to endpoint to be attached |
79 | * @reffd *in, *out@ = input and output file descriptors |
80 | * |
81 | * Returns: --- |
82 | * |
83 | * Use: Instructs a non-file endpoint to attach itself to a pair of |
84 | * files. |
85 | */ |
86 | |
87 | void (*attach)(endpt */*e*/, reffd */*in*/, reffd */*out*/); |
88 | |
28d2517c |
89 | /* --- @file@ --- * |
90 | * |
91 | * Arguments: @endpt *e@ = pointer to endpoint in question |
92 | * @endpt *f@ = pointer to a file endpoint |
93 | * |
94 | * Returns: --- |
95 | * |
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. |
101 | */ |
102 | |
103 | void (*file)(endpt */*e*/, endpt */*f*/); |
104 | |
07d71f34 |
105 | /* --- @wclose@ --- * |
106 | * |
107 | * Arguments: @endpt *e@ = endpoint to be partially closed |
108 | * |
109 | * Returns: --- |
110 | * |
111 | * Use: Announces that the endpoint will not be written to any more. |
112 | */ |
113 | |
114 | void (*wclose)(endpt */*e*/); |
115 | |
116 | /* --- @close@ --- * |
117 | * |
118 | * Arguments: @endpt *e@ = endpoint to be closed |
119 | * |
120 | * Returns: --- |
121 | * |
122 | * Use: Completely closes an endpoint. The endpoint's data may be |
123 | * freed, although some endpoints may wish to delay freeing for |
124 | * some reason. |
125 | */ |
126 | |
127 | void (*close)(endpt */*e*/); |
128 | |
129 | } endpt_ops; |
130 | |
131 | /*----- Functions provided ------------------------------------------------*/ |
132 | |
133 | /* --- @endpt_kill@ --- * |
134 | * |
135 | * Arguments: @endpt *a@ = an endpoint |
136 | * |
137 | * Returns: --- |
138 | * |
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). |
142 | */ |
143 | |
144 | extern void endpt_kill(endpt */*a*/); |
145 | |
146 | /* --- @endpt_killall@ --- * |
147 | * |
148 | * Arguments: --- |
149 | * |
150 | * Returns: --- |
151 | * |
152 | * Use: Destroys all current endpoint connections. Used when |
153 | * shutting down. |
154 | */ |
155 | |
156 | extern void endpt_killall(void); |
157 | |
158 | /* --- @endpt_join@ --- * |
159 | * |
160 | * Arguments: @endpt *a@ = pointer to first endpoint |
161 | * @endpt *b@ = pointer to second endpoint |
162 | * |
163 | * Returns: --- |
164 | * |
165 | * Use: Joins two endpoints together. |
166 | */ |
167 | |
168 | extern void endpt_join(endpt */*a*/, endpt */*b*/); |
169 | |
170 | /*----- That's all, folks -------------------------------------------------*/ |
171 | |
172 | #ifdef __cplusplus |
173 | } |
174 | #endif |
175 | |
176 | #endif |