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