3 * $Id: source.h,v 1.2 2004/04/08 01:36:25 mdw Exp $
5 * Description of forwarding sources
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 ------------------------------------------------------*/
48 /*----- Data structures ---------------------------------------------------*/
50 /* --- A basic source object --- */
52 typedef struct source
{
53 struct source
*next
, *prev
;
54 struct source_ops
*ops
;
58 /* --- Forwarding source operations --- */
60 typedef struct source_ops
{
61 const char *name
; /* Name of this source */
65 * Arguments: @scanner *sc@ = scanner to read from
66 * @source *s@ = pointer to source object, or zero if global
68 * Returns: Nonzero to claim the option.
70 * Use: Handles an option string from the configuration file.
73 int (*option
)(source */
*s*/
, scanner */
*sc*/
);
77 * Arguments: @scanner *sc@ = pointer to scanner to read from
79 * Returns: Pointer to a source object to claim, null to reject.
81 * Use: Parses a source description from the configuration file.
82 * Only the socket source is allowed to omit the prefix on a
83 * source specification.
86 source
*(*read
)(scanner */
*sc*/
);
90 * Arguments: @source *s@ = pointer to source
91 * @scanner *sc@ = scanner (for error reporting)
92 * @target *t@ = pointer to target to attach
96 * Use: Attaches a target to a source.
99 void (*attach
)(source */
*s*/
, scanner */
*sc*/
, target */
*t*/
);
101 /* --- @destroy@ --- *
103 * Arguments: @source *s@ = pointer to source
107 * Use: Destroys a source. Used when closing the system down, for
108 * example as a result of a signal.
111 void (*destroy
)(source */
*s*/
);
115 /*----- Functions provided ------------------------------------------------*/
117 /* --- @source_add@ --- *
119 * Arguments: @source *s@ = pointer to a source
123 * Use: Adds a source to the master list. Only do this for passive
124 * sources (e.g., listening sockets), not active sources (e.g.,
125 * executable programs).
128 extern void source_add(source */
*s*/
);
130 /* --- @source_remove@ --- *
132 * Arguments: @source *s@ = pointer to a source
136 * Use: Removes a source from the master list.
139 extern void source_remove(source */
*s*/
);
141 /* --- @source_killall@ --- *
147 * Use: Frees all sources.
150 extern void source_killall(void);
152 /*----- That's all, folks -------------------------------------------------*/