acl.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. /* Pointers to head ACL structs */
  52. static struct ip_acl *ip_acl_head, *ip_acl_prev;
  53. static struct dns_acl *dns_acl_head, *dns_acl_prev;
  54. /* Functions */
  55. void parse_allowed_hosts(char *allowed_hosts);
  56. int add_ipv4_to_acl(char *ipv4);
  57. int add_ipv6_to_acl(char *ipv6);
  58. int add_domain_to_acl(char *domain);
  59. //int is_an_allowed_host(struct in_addr);
  60. int is_an_allowed_host(int, void *);
  61. unsigned int prefix_from_mask(struct in_addr mask);
  62. void show_acl_lists(void);
  63. #endif /* ACL_H_INCLUDED */