3 * $Id: acl.h,v 1.2 1999/07/26 23:28:16 mdw Exp $
5 * Access control list handling
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the `fw' port forwarder.
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.
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.
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.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.2 1999/07/26 23:28:16 mdw
33 * Minor modifications for new design.
35 * Revision 1.1.1.1 1999/07/01 08:56:23 mdw
47 /*----- Header files ------------------------------------------------------*/
51 #include <sys/socket.h>
52 #include <netinet/in.h>
54 /*----- Data structures ---------------------------------------------------*/
56 /* --- An access control entry --- */
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 */
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 */
68 /*----- Functions provided ------------------------------------------------*/
70 /* --- @acl_check@ --- *
72 * Arguments: @acl_entry *a@ = pointer to ACL to check against
73 * @struct in_addr addr@ = address to check
75 * Returns: Nonzero if allowed.
77 * Use: Checks an address against an ACL.
80 extern int acl_check(acl_entry */
*a*/
, struct in_addr
/*addr*/);
82 /* --- @acl_dump@ --- *
84 * Arguments: @acl_entry *a@ = pointer to ACL to dump
85 * @FILE *fp@ = pointer to stream to dump on
89 * Use: Dumps an access control list to an output stream.
92 extern void acl_dump(acl_entry */
*a*/
, FILE */
*fp*/
);
94 /* --- @acl_free@ --- *
96 * Arguments: @acl_entry *a@ = pointer to a list of ACLs
100 * Use: Frees all of the memory used by an ACL.
103 extern void acl_free(acl_entry */
*a*/
);
105 /* --- @acl_add@ --- *
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
113 * Use: Adds an entry to the end of an access control list.
116 extern void acl_add(acl_entry
***/
*a*/
, unsigned /*act*/,
117 struct in_addr
/*addr*/, struct in_addr
/*mask*/);
119 /*----- That's all, folks -------------------------------------------------*/