ip.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * IP common code
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg 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 Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVFORMAT_IP_H
  21. #define AVFORMAT_IP_H
  22. #include "network.h"
  23. /**
  24. * Structure for storing IP (UDP) source filters or block lists.
  25. */
  26. typedef struct IPSourceFilters {
  27. int nb_include_addrs;
  28. int nb_exclude_addrs;
  29. struct sockaddr_storage *include_addrs;
  30. struct sockaddr_storage *exclude_addrs;
  31. } IPSourceFilters;
  32. /**
  33. * Checks the source address against a given IP source filter.
  34. * @return 0 if packet should be processed based on the filter, 1 if the packet
  35. * can be dropped.
  36. */
  37. int ff_ip_check_source_lists(struct sockaddr_storage *source_addr_ptr, IPSourceFilters *s);
  38. /**
  39. * Resolves hostname into an addrinfo structure.
  40. * @return addrinfo structure which should be freed by the user, NULL in case
  41. * of error.
  42. */
  43. struct addrinfo *ff_ip_resolve_host(void *log_ctx,
  44. const char *hostname, int port,
  45. int type, int family, int flags);
  46. /**
  47. * Parses the address[,address] source list in buf and adds it to the filters
  48. * in the IPSourceFilters structure.
  49. * @return 0 on success, < 0 AVERROR code on error.
  50. */
  51. int ff_ip_parse_sources(void *log_ctx, const char *buf, IPSourceFilters *filters);
  52. /**
  53. * Parses the address[,address] source block list in buf and adds it to the
  54. * filters in the IPSourceFilters structure.
  55. * @return 0 on success, < 0 AVERROR code on error.
  56. */
  57. int ff_ip_parse_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters);
  58. /**
  59. * Resets the IP filter list and frees the internal fields of an
  60. * IPSourceFilters structure.
  61. */
  62. void ff_ip_reset_filters(IPSourceFilters *filters);
  63. #endif /* AVFORMAT_IP_H */