Fix bug in identification timout handling.
[fwd] / acl.h
1 /* -*-c-*-
2 *
3 * $Id: acl.h,v 1.4 2003/11/25 14:08:23 mdw Exp $
4 *
5 * Access control list handling
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: acl.h,v $
32 * Revision 1.4 2003/11/25 14:08:23 mdw
33 * Debianization. Socket target options. Internet binding.
34 *
35 * Revision 1.3 1999/07/27 18:30:53 mdw
36 * Various minor portability fixes.
37 *
38 * Revision 1.2 1999/07/26 23:28:16 mdw
39 * Minor modifications for new design.
40 *
41 * Revision 1.1.1.1 1999/07/01 08:56:23 mdw
42 * Initial revision.
43 *
44 */
45
46 #ifndef ACL_H
47 #define ACL_H
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 /*----- Header files ------------------------------------------------------*/
54
55 #include <stdio.h>
56
57 #include <sys/types.h>
58 #include <sys/socket.h>
59 #include <netinet/in.h>
60
61 /*----- Data structures ---------------------------------------------------*/
62
63 /* --- An access control entry --- */
64
65 typedef struct acl_entry {
66 struct acl_entry *next; /* Next entry in the list */
67 const struct acl_ops *ops; /* Operations for the ACL entry */
68 unsigned act; /* What to do with matching hosts */
69 } acl_entry;
70
71 #define ACL_DENY 0 /* Deny access to matching conns */
72 #define ACL_ALLOW 1 /* Allow access to matching conns */
73 #define ACL_PERM 1u /* Bit mask for permission bit */
74
75 /* --- Host-based access control --- */
76
77 typedef struct acl_host {
78 acl_entry a; /* Base structure */
79 struct in_addr addr, mask; /* Address and netmask */
80 } acl_host;
81
82 /* --- ACL methods --- */
83
84 typedef struct acl_ops {
85 int (*check)(void */*a*/, struct in_addr /*addr*/, unsigned /*port*/);
86 void (*dump)(void */*a*/, FILE */*fp*/);
87 void (*free)(void */*a*/);
88 } acl_ops;
89
90 /*----- Functions provided ------------------------------------------------*/
91
92 /* --- @acl_check@ --- *
93 *
94 * Arguments: @acl_entry *a@ = pointer to ACL to check against
95 * @struct in_addr addr@ = address to check
96 * @unsigned port@ = port number to check
97 * @int *act@ = verdict (should initially be @ACT_ALLOW@)
98 *
99 * Returns: Zero if undecided, nonzero if a rule matched.
100 *
101 * Use: Checks an address against an ACL.
102 */
103
104 extern int acl_check(acl_entry */*a*/,
105 struct in_addr /*addr*/, unsigned /*port*/,
106 int */*act*/);
107
108 /* --- @acl_dump@ --- *
109 *
110 * Arguments: @acl_entry *a@ = pointer to ACL to dump
111 * @FILE *fp@ = pointer to stream to dump on
112 *
113 * Returns: ---
114 *
115 * Use: Dumps an access control list to an output stream.
116 */
117
118 extern void acl_dump(acl_entry */*a*/, FILE */*fp*/);
119
120 /* --- @acl_free@ --- *
121 *
122 * Arguments: @acl_entry *a@ = pointer to a list of ACLs
123 *
124 * Returns: ---
125 *
126 * Use: Frees all of the memory used by an ACL.
127 */
128
129 extern void acl_free(acl_entry */*a*/);
130
131 /* --- @acl_addhost@ --- *
132 *
133 * Arguments: @acl_entry ***a@ = address of pointer to list tail
134 * @unsigned act@ = what to do with matching addresses
135 * @struct in_addr addr, mask@ = address and mask to match
136 *
137 * Returns: ---
138 *
139 * Use: Adds a host-authentication entry to the end of an access
140 * control list.
141 */
142
143 extern void acl_addhost(acl_entry ***/*a*/, unsigned /*act*/,
144 struct in_addr /*addr*/, struct in_addr /*mask*/);
145
146 /* --- @acl_addpriv@ --- *
147 *
148 * Arguments: @acl_entry ***a@ = address of pointer to list tail
149 * @unsigned act@ = what to do with matching addresses
150 *
151 * Returns: ---
152 *
153 * Use: Adds a privileged-port check to the end of an access control
154 * list.
155 */
156
157 extern void acl_addpriv(acl_entry ***/*a*/, unsigned /*act*/);
158
159 /*----- That's all, folks -------------------------------------------------*/
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif