2 * Copyright (C) 1993,1994 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
5 * Copyright (C) 2005 Neil Cafferkey
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 #include <exec/types.h>
25 #include <sys/systm.h>
26 #include <sys/malloc.h>
27 #include <kern/amiga_config.h>
28 #include <kern/amiga_netdb.h>
29 #include <kern/accesscontrol.h>
31 #include <sys/syslog.h>
33 int controlaccess(struct in_addr shost
, unsigned short dport
)
38 for (i
= 0; NDB
->ndb_AccessTable
[i
].ai_flags
; i
++)
39 #define AT NDB->ndb_AccessTable[i]
40 #define host (*(ULONG *)&shost) /* XXX */
41 if ((AT
.ai_port
== 0 && (!(AT
.ai_flags
& ACF_PRIVONLY
) || dport
< 1024)
42 || AT
.ai_port
== dport
) &&
43 ((host
^ AT
.ai_host
) & AT
.ai_mask
) == 0) {
47 int allow
= AT
.ai_flags
& ACF_ALLOW
;
49 if (AT
.ai_flags
& ACF_LOG
)
50 __log(allow
? LOG_INFO
: LOG_NOTICE
,
51 "Access from host %ld.%ld.%ld.%ld to port %ld %s\n",
52 host
>>24 & 0xff, host
>>16 & 0xff, host
>>8 & 0xff, host
& 0xff,
53 dport
, allow
? "allowed": "denied");
62 * No match. allow by default.