VL2.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "Mutex.hpp"
  20. #include "FCV.hpp"
  21. namespace ZeroTier {
  22. class Path;
  23. class Peer;
  24. class RuntimeEnvironment;
  25. class VL1;
  26. class Network;
  27. class MAC;
  28. class VL2
  29. {
  30. friend class VL1;
  31. public:
  32. VL2(const RuntimeEnvironment *renv);
  33. ~VL2();
  34. /**
  35. * Called when a packet comes from a local Ethernet tap
  36. *
  37. * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
  38. * @param network Which network's TAP did this packet come from?
  39. * @param from Originating MAC address
  40. * @param to Destination MAC address
  41. * @param etherType Ethernet packet type
  42. * @param vlanId VLAN ID or 0 if none
  43. * @param data Ethernet payload
  44. * @param len Frame length
  45. */
  46. 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);
  47. protected:
  48. bool _FRAME(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  49. bool _EXT_FRAME(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  50. bool _MULTICAST_LIKE(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  51. bool _NETWORK_CREDENTIALS(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  52. bool _NETWORK_CONFIG_REQUEST(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  53. bool _NETWORK_CONFIG(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  54. bool _MULTICAST_GATHER(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  55. bool _MULTICAST_FRAME_deprecated(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  56. bool _MULTICAST(void *tPtr,const SharedPtr<Path> &path,SharedPtr<Peer> &peer,Buf &pkt,int packetSize);
  57. private:
  58. };
  59. } // namespace ZeroTier
  60. #endif