Filter.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef ZT_FILTER_HPP
  19. #define ZT_FILTER_HPP
  20. #include <stdint.h>
  21. #include "Constants.hpp"
  22. #include "../include/ZeroTierOne.h"
  23. namespace ZeroTier {
  24. class Address;
  25. class RuntimeEnvironment;
  26. class MAC;
  27. /**
  28. * Network packet filter for rules engine
  29. */
  30. class Filter
  31. {
  32. public:
  33. /**
  34. * Apply a list of rules to a packet
  35. *
  36. * This returns whether or not the packet should be accepted and may also
  37. * take other actions for e.g. the TEE and REDIRECT targets.
  38. *
  39. * @param RR ZeroTier runtime environment (context)
  40. * @param nwid ZeroTier network ID
  41. * @param ztSource Source ZeroTier address
  42. * @param ztDest Destination ZeroTier address
  43. * @param macSource Ethernet layer source address
  44. * @param macDest Ethernet layer destination address
  45. * @param frameData Ethernet frame data
  46. * @param frameLen Ethernet frame payload length
  47. * @param etherType 16-bit ethernet type ID
  48. * @param vlanId 16-bit VLAN ID
  49. * @param rules Pointer to array of rules
  50. * @param ruleCount Number of rules
  51. */
  52. static bool run(
  53. const RuntimeEnvironment *RR,
  54. const uint64_t nwid,
  55. const Address &ztSource,
  56. const Address &ztDest,
  57. const MAC &macSource,
  58. const MAC &macDest,
  59. const uint8_t *frameData,
  60. const unsigned int frameLen,
  61. const unsigned int etherType,
  62. const unsigned int vlanId,
  63. const ZT_VirtualNetworkRule *rules,
  64. const unsigned int ruleCount);
  65. };
  66. } // namespace ZeroTier
  67. #endif