acl.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /****************************************************************************
  2. *
  3. * acl.h - header file for acl.c
  4. *
  5. * License: GPLv2
  6. * Copyright (c) 2011 Kaspersky Lab ZAO
  7. *
  8. * License Notice:
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23. *
  24. ****************************************************************************/
  25. #ifndef ACL_H_INCLUDED
  26. #define ACL_H_INCLUDED 1
  27. #include <sys/types.h>
  28. #include <sys/socket.h>
  29. #include <netinet/in.h>
  30. #include <arpa/inet.h>
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include <ctype.h>
  35. #include <netdb.h>
  36. #include <syslog.h>
  37. #include <stdarg.h>
  38. #define CHAR_TO_NUMBER(c) ((c) - '0')
  39. struct ip_acl {
  40. int family;
  41. struct in_addr addr;
  42. struct in_addr mask;
  43. struct in6_addr addr6;
  44. struct in6_addr mask6;
  45. struct ip_acl *next;
  46. };
  47. struct dns_acl {
  48. char domain[255];
  49. struct dns_acl *next;
  50. };
  51. /* Functions */
  52. void parse_allowed_hosts(char *allowed_hosts);
  53. int add_ipv4_to_acl(char *ipv4);
  54. int add_ipv6_to_acl(char *ipv6);
  55. int add_domain_to_acl(char *domain);
  56. //int is_an_allowed_host(struct in_addr);
  57. int is_an_allowed_host(int, void *);
  58. unsigned int prefix_from_mask(int family, const void* mask);
  59. void show_acl_lists(void);
  60. #endif /* ACL_H_INCLUDED */