blast: Upper-case metasyntactic variables in the usage message.
[fwd] / acl.h
CommitLineData
e82f7154 1/* -*-c-*-
2 *
7481fc9c 3 * $Id: acl.h,v 1.5 2004/04/08 01:36:25 mdw Exp $
e82f7154 4 *
5 * Access control list handling
6 *
e5398e09 7 * (c) 1999 Straylight/Edgeware
e82f7154 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
e82f7154 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
e0ce9d38 40#include <sys/types.h>
e82f7154 41#include <sys/socket.h>
42#include <netinet/in.h>
43
44/*----- Data structures ---------------------------------------------------*/
45
46/* --- An access control entry --- */
47
48typedef struct acl_entry {
49 struct acl_entry *next; /* Next entry in the list */
0ac54f22 50 const struct acl_ops *ops; /* Operations for the ACL entry */
e82f7154 51 unsigned act; /* What to do with matching hosts */
e82f7154 52} acl_entry;
53
0ac54f22 54#define ACL_DENY 0 /* Deny access to matching conns */
55#define ACL_ALLOW 1 /* Allow access to matching conns */
e82f7154 56#define ACL_PERM 1u /* Bit mask for permission bit */
57
0ac54f22 58/* --- Host-based access control --- */
59
60typedef 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
67typedef 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
e82f7154 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
0ac54f22 79 * @unsigned port@ = port number to check
80 * @int *act@ = verdict (should initially be @ACT_ALLOW@)
e82f7154 81 *
0ac54f22 82 * Returns: Zero if undecided, nonzero if a rule matched.
e82f7154 83 *
84 * Use: Checks an address against an ACL.
85 */
86
0ac54f22 87extern int acl_check(acl_entry */*a*/,
88 struct in_addr /*addr*/, unsigned /*port*/,
89 int */*act*/);
e82f7154 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
101extern void acl_dump(acl_entry */*a*/, FILE */*fp*/);
102
e5398e09 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
112extern void acl_free(acl_entry */*a*/);
113
0ac54f22 114/* --- @acl_addhost@ --- *
e82f7154 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 *
0ac54f22 122 * Use: Adds a host-authentication entry to the end of an access
123 * control list.
124 */
125
126extern 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.
e82f7154 138 */
139
0ac54f22 140extern void acl_addpriv(acl_entry ***/*a*/, unsigned /*act*/);
e82f7154 141
142/*----- That's all, folks -------------------------------------------------*/
143
144#ifdef __cplusplus
145 }
146#endif
147
148#endif