acl.h 1.9 KB

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