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