e82f7154 |
1 | /* -*-c-*- |
2 | * |
e5398e09 |
3 | * $Id: acl.h,v 1.2 1999/07/26 23:28:16 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 | |
29 | /*----- Revision history --------------------------------------------------* |
30 | * |
31 | * $Log: acl.h,v $ |
e5398e09 |
32 | * Revision 1.2 1999/07/26 23:28:16 mdw |
33 | * Minor modifications for new design. |
34 | * |
35 | * Revision 1.1.1.1 1999/07/01 08:56:23 mdw |
36 | * Initial revision. |
e82f7154 |
37 | * |
38 | */ |
39 | |
40 | #ifndef ACL_H |
41 | #define ACL_H |
42 | |
43 | #ifdef __cplusplus |
44 | extern "C" { |
45 | #endif |
46 | |
47 | /*----- Header files ------------------------------------------------------*/ |
48 | |
49 | #include <stdio.h> |
50 | |
51 | #include <sys/socket.h> |
52 | #include <netinet/in.h> |
53 | |
54 | /*----- Data structures ---------------------------------------------------*/ |
55 | |
56 | /* --- An access control entry --- */ |
57 | |
58 | typedef struct acl_entry { |
59 | struct acl_entry *next; /* Next entry in the list */ |
60 | unsigned act; /* What to do with matching hosts */ |
61 | struct in_addr addr, mask; /* Address and netmask */ |
62 | } acl_entry; |
63 | |
64 | #define ACL_DENY 0 /* Deny access to matching hosts */ |
65 | #define ACL_ALLOW 1 /* Allow access to matching hosts */ |
66 | #define ACL_PERM 1u /* Bit mask for permission bit */ |
67 | |
68 | /*----- Functions provided ------------------------------------------------*/ |
69 | |
70 | /* --- @acl_check@ --- * |
71 | * |
72 | * Arguments: @acl_entry *a@ = pointer to ACL to check against |
73 | * @struct in_addr addr@ = address to check |
74 | * |
75 | * Returns: Nonzero if allowed. |
76 | * |
77 | * Use: Checks an address against an ACL. |
78 | */ |
79 | |
80 | extern int acl_check(acl_entry */*a*/, struct in_addr /*addr*/); |
81 | |
82 | /* --- @acl_dump@ --- * |
83 | * |
84 | * Arguments: @acl_entry *a@ = pointer to ACL to dump |
85 | * @FILE *fp@ = pointer to stream to dump on |
86 | * |
87 | * Returns: --- |
88 | * |
89 | * Use: Dumps an access control list to an output stream. |
90 | */ |
91 | |
92 | extern void acl_dump(acl_entry */*a*/, FILE */*fp*/); |
93 | |
e5398e09 |
94 | /* --- @acl_free@ --- * |
95 | * |
96 | * Arguments: @acl_entry *a@ = pointer to a list of ACLs |
97 | * |
98 | * Returns: --- |
99 | * |
100 | * Use: Frees all of the memory used by an ACL. |
101 | */ |
102 | |
103 | extern void acl_free(acl_entry */*a*/); |
104 | |
e82f7154 |
105 | /* --- @acl_add@ --- * |
106 | * |
107 | * Arguments: @acl_entry ***a@ = address of pointer to list tail |
108 | * @unsigned act@ = what to do with matching addresses |
109 | * @struct in_addr addr, mask@ = address and mask to match |
110 | * |
111 | * Returns: --- |
112 | * |
113 | * Use: Adds an entry to the end of an access control list. |
114 | */ |
115 | |
116 | extern void acl_add(acl_entry ***/*a*/, unsigned /*act*/, |
117 | struct in_addr /*addr*/, struct in_addr /*mask*/); |
118 | |
119 | /*----- That's all, folks -------------------------------------------------*/ |
120 | |
121 | #ifdef __cplusplus |
122 | } |
123 | #endif |
124 | |
125 | #endif |