cidr.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* $Id$ */
  2. /*
  3. * Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
  4. * Copyright (c) 2013-2018 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  5. *
  6. * The Tcpreplay Suite of tools is free software: you can redistribute it
  7. * and/or modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or with the authors permission any later version.
  10. *
  11. * The Tcpreplay Suite is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Tcpreplay Suite. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "cache.h"
  20. #ifndef __CIDR_H__
  21. #define __CIDR_H__
  22. struct tcpr_cidr_s {
  23. int family; /* AF_INET or AF_INET6 */
  24. union {
  25. u_int32_t network;
  26. struct tcpr_in6_addr network6;
  27. } u;
  28. int masklen;
  29. struct tcpr_cidr_s *next;
  30. };
  31. typedef struct tcpr_cidr_s tcpr_cidr_t;
  32. struct tcpr_cidrmap_s {
  33. tcpr_cidr_t *from;
  34. tcpr_cidr_t *to;
  35. struct tcpr_cidrmap_s *next;
  36. };
  37. typedef struct tcpr_cidrmap_s tcpr_cidrmap_t;
  38. int ip_in_cidr(const tcpr_cidr_t *, const unsigned long);
  39. int check_ip_cidr(tcpr_cidr_t *, const unsigned long);
  40. int check_ip6_cidr(tcpr_cidr_t *, const struct tcpr_in6_addr *addr);
  41. int parse_cidr(tcpr_cidr_t **, char *, char *delim);
  42. int parse_cidr_map(tcpr_cidrmap_t **, const char *);
  43. int parse_endpoints(tcpr_cidrmap_t **, tcpr_cidrmap_t **, const char *);
  44. u_char *ip2cidr(const unsigned long, const int);
  45. void add_cidr(tcpr_cidr_t **, tcpr_cidr_t **);
  46. tcpr_cidr_t *new_cidr(void);
  47. tcpr_cidrmap_t *new_cidr_map(void);
  48. void destroy_cidr(tcpr_cidr_t *);
  49. void print_cidr(tcpr_cidr_t *);
  50. char *cidr2iplist(tcpr_cidr_t *, char);
  51. int ip6_in_cidr(const tcpr_cidr_t * mycidr, const struct tcpr_in6_addr *addr);
  52. int check_ip6_cidr(tcpr_cidr_t *, const struct tcpr_in6_addr *addr);
  53. #endif