tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / bsdsocket / kern / accesscontrol.c
blobe511889df5f2d817dec54415e2db9f88176823e8
1 /*
2 * Copyright (C) 1993,1994 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
4 * All rights reserved.
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,
19 * MA 02111-1307, USA.
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)
35 int i;
37 LOCK_R_NDB(NDB);
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) {
45 * match
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");
55 UNLOCK_NDB(NDB);
56 return allow;
57 #undef allow
58 #undef host
59 #undef AT
62 * No match. allow by default.
64 UNLOCK_NDB(NDB);
65 return ACF_ALLOW;