VL2.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c)2013-2020 ZeroTier, Inc.
  3. *
  4. * Use of this software is governed by the Business Source License included
  5. * in the LICENSE.TXT file in the project's root directory.
  6. *
  7. * Change Date: 2024-01-01
  8. *
  9. * On the date above, in accordance with the Business Source License, use
  10. * of this software will be governed by version 2.0 of the Apache License.
  11. */
  12. /****/
  13. #ifndef ZT_VL2_HPP
  14. #define ZT_VL2_HPP
  15. #include "Constants.hpp"
  16. #include "Buf.hpp"
  17. #include "Address.hpp"
  18. #include "Protocol.hpp"
  19. #include "Hashtable.hpp"
  20. #include "Mutex.hpp"
  21. #include "FCV.hpp"
  22. namespace ZeroTier {
  23. class Path;
  24. class Peer;
  25. class RuntimeEnvironment;
  26. class VL1;
  27. class Network;
  28. class MAC;
  29. class VL2
  30. {
  31. friend class VL1;
  32. public:
  33. VL2(const RuntimeEnvironment *renv);
  34. ~VL2();
  35. /**
  36. * Called when a packet comes from a local Ethernet tap
  37. *
  38. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  39. * @param network Which network's TAP did this packet come from?
  40. * @param from Originating MAC address
  41. * @param to Destination MAC address
  42. * @param etherType Ethernet packet type
  43. * @param vlanId VLAN ID or 0 if none
  44. * @param data Ethernet payload
  45. * @param len Frame length
  46. */
  47. void onLocalEthernet(void *tPtr,const SharedPtr<Network> &network,const MAC &from,const MAC &to,unsigned int etherType,unsigned int vlanId,SharedPtr<Buf> &data,unsigned int len);
  48. protected:
  49. bool _FRAME(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  50. bool _EXT_FRAME(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  51. bool _MULTICAST_LIKE(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  52. bool _NETWORK_CREDENTIALS(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  53. bool _NETWORK_CONFIG_REQUEST(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  54. bool _NETWORK_CONFIG(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  55. bool _MULTICAST_GATHER(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  56. bool _MULTICAST_FRAME_deprecated(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  57. bool _MULTICAST(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  58. private:
  59. };
  60. } // namespace ZeroTier
  61. #endif