EthernetTapFactory.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * ZeroTier One - Global Peer to Peer Ethernet
  3. * Copyright (C) 2011-2014 ZeroTier Networks LLC
  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. * ZeroTier may be used and distributed under the terms of the GPLv3, which
  21. * are available at: http://www.gnu.org/licenses/gpl-3.0.html
  22. *
  23. * If you would like to embed ZeroTier into a commercial application or
  24. * redistribute it in a modified binary form, please contact ZeroTier Networks
  25. * LLC. Start here: http://www.zerotier.com/
  26. */
  27. #ifndef ZT_ETHERNETTAPFACTORY_HPP
  28. #define ZT_ETHERNETTAPFACTORY_HPP
  29. #include <stdint.h>
  30. #include "MAC.hpp"
  31. namespace ZeroTier {
  32. class EthernetTap;
  33. /**
  34. * Ethernet tap factory
  35. *
  36. * This serves up tap implementations for a given platform. It should never be
  37. * deleted until the Node using it is shut down, since doing so may invalidate
  38. * any tap devices it manages.
  39. *
  40. * Using a factory pattern will faciliatate packaging ZeroTier as a library,
  41. * as well as moving toward a design that makes unit testing the entire app
  42. * quite a bit easier.
  43. */
  44. class EthernetTapFactory
  45. {
  46. public:
  47. EthernetTapFactory() {}
  48. virtual ~EthernetTapFactory() {}
  49. /**
  50. * Create / open an Ethernet tap device
  51. *
  52. * On some platforms (Windows) this can be a time-consuming operation.
  53. *
  54. * @param mac MAC address
  55. * @param mtu Device MTU
  56. * @param metric Interface metric (higher = lower priority, may not be supported on all OSes)
  57. * @param nwid ZeroTier network ID
  58. * @param desiredDevice Desired system device name or NULL for no preference
  59. * @param friendlyName Friendly name of this interface or NULL for none (not used on all platforms)
  60. * @return EthernetTap instance or NULL on failure
  61. */
  62. virtual EthernetTap *get(const MAC &mac,unsigned int mtu,unsigned int metric,uint64_t nwid,const char *desiredDevice,const char *friendlyName) = 0;
  63. };
  64. } // namespace ZeroTier
  65. #endif