EthernetTap.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * ZeroTier One - Network Virtualization Everywhere
  3. * Copyright (C) 2011-2019 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. * --
  19. *
  20. * You can be released from the requirements of the license by purchasing
  21. * a commercial license. Buying such a license is mandatory as soon as you
  22. * develop commercial closed-source software that incorporates or links
  23. * directly against ZeroTier software without disclosing the source code
  24. * of your own application.
  25. */
  26. #ifndef ZT_ETHERNETTAP_HPP
  27. #define ZT_ETHERNETTAP_HPP
  28. #include "../node/Constants.hpp"
  29. #include "../node/MAC.hpp"
  30. #include "../node/InetAddress.hpp"
  31. #include "../node/MulticastGroup.hpp"
  32. #include <string>
  33. #include <memory>
  34. #include <vector>
  35. namespace ZeroTier {
  36. class EthernetTap
  37. {
  38. public:
  39. static std::shared_ptr<EthernetTap> newInstance(
  40. const char *tapDeviceType, // OS-specific, NULL for default
  41. const char *homePath,
  42. const MAC &mac,
  43. unsigned int mtu,
  44. unsigned int metric,
  45. uint64_t nwid,
  46. const char *friendlyName,
  47. void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int),
  48. void *arg);
  49. EthernetTap();
  50. virtual ~EthernetTap();
  51. virtual void setEnabled(bool en) = 0;
  52. virtual bool enabled() const = 0;
  53. virtual bool addIp(const InetAddress &ip) = 0;
  54. virtual bool removeIp(const InetAddress &ip) = 0;
  55. virtual std::vector<InetAddress> ips() const = 0;
  56. virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) = 0;
  57. virtual std::string deviceName() const = 0;
  58. virtual void setFriendlyName(const char *friendlyName) = 0;
  59. virtual void scanMulticastGroups(std::vector<MulticastGroup> &added,std::vector<MulticastGroup> &removed) = 0;
  60. virtual void setMtu(unsigned int mtu) = 0;
  61. };
  62. } // namespace ZeroTier
  63. #endif