]> git.ipfire.org Git - thirdparty/squid.git/blame - helpers/external_acl/file_userip/ext_file_userip_acl.cc
Author: Various Translators
[thirdparty/squid.git] / helpers / external_acl / file_userip / ext_file_userip_acl.cc
CommitLineData
c152a447
AJ
1/* $Id$
2* Copyright (C) 2002 Rodrigo Campos
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program; if not, write to the Free Software
16* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*
18* Author: Rodrigo Campos (rodrigo@geekbunker.org)
19*
20*/
21#define SQUID_NO_ALLOC_PROTECT 1
22#include "config.h"
23#include "helpers/defines.h"
24#include "rfc1738.h"
25#include "util.h"
26
27#if HAVE_STDIO_H
28#include <stdio.h>
29#endif
30#if HAVE_STDLIB_H
31#include <stdlib.h>
32#endif
33#if HAVE_STRING_H
34#include <string.h>
35#endif
36#if HAVE_SYS_SOCKET_H
37#include <sys/socket.h>
38#endif
39#if HAVE_NETINET_IN_H
40#include <netinet/in.h>
41#endif
42#if HAVE_ARPA_INET_H
43#include <arpa/inet.h>
44#endif
45#if HAVE_GRP_H
46#include <grp.h>
47#endif
48
49
50struct ip_user_dict {
51 unsigned long address; // IP address (assumes IPv4)
52 unsigned long netmask; // IP netmask
53 char *username;
54 struct ip_user_dict *next_entry;
55};
56
57int match_user(char *, char *);
58int match_group(char *, char *);
59struct ip_user_dict *load_dict(FILE *);
60int dict_lookup(struct ip_user_dict *, char *, char *);
61
62/** Size of lines read from the dictionary file */
63#define DICT_BUFFER_SIZE 8196
64
65/** This function parses the dictionary file and loads it
66 * in memory. All IP addresses are processed with a bitwise AND
67 * with their netmasks before they are stored.
68