acl.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. struct in_addr addr;
  38. struct in_addr mask;
  39. struct ip_acl *next;
  40. };
  41. struct dns_acl {
  42. char domain[255];
  43. struct dns_acl *next;
  44. };
  45. /* Poiters to head ACL structs */
  46. static struct ip_acl *ip_acl_head, *ip_acl_prev;
  47. static struct dns_acl *dns_acl_head, *dns_acl_prev;
  48. /* Functions */
  49. void parse_allowed_hosts(char *allowed_hosts);
  50. int add_ipv4_to_acl(char *ipv4);
  51. int add_domain_to_acl(char *domain);
  52. int is_an_allowed_host(struct in_addr);
  53. unsigned int prefix_from_mask(struct in_addr mask);
  54. void show_acl_lists(void);
  55. #endif /* ACL_H_INCLUDED */