vmnet_int.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * vmnet_int.h
  3. *
  4. * Copyright(c) 2022 Vladislav Yaroshchuk <vladislav.yaroshchuk@jetbrains.com>
  5. *
  6. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  7. * See the COPYING file in the top-level directory.
  8. *
  9. */
  10. #ifndef VMNET_INT_H
  11. #define VMNET_INT_H
  12. #include "vmnet_int.h"
  13. #include "clients.h"
  14. #include <vmnet/vmnet.h>
  15. #include <dispatch/dispatch.h>
  16. /**
  17. * From vmnet.framework documentation
  18. *
  19. * Each read/write call allows up to 200 packets to be
  20. * read or written for a maximum of 256KB.
  21. *
  22. * Each packet written should be a complete
  23. * ethernet frame.
  24. *
  25. * https://developer.apple.com/documentation/vmnet
  26. */
  27. #define VMNET_PACKETS_LIMIT 200
  28. typedef struct VmnetState {
  29. NetClientState nc;
  30. interface_ref vmnet_if;
  31. uint64_t mtu;
  32. uint64_t max_packet_size;
  33. dispatch_queue_t if_queue;
  34. QEMUBH *send_bh;
  35. struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
  36. int packets_send_current_pos;
  37. int packets_send_end_pos;
  38. struct iovec iov_buf[VMNET_PACKETS_LIMIT];
  39. VMChangeStateEntry *change;
  40. } VmnetState;
  41. const char *vmnet_status_map_str(vmnet_return_t status);
  42. int vmnet_if_create(NetClientState *nc,
  43. xpc_object_t if_desc,
  44. Error **errp);
  45. ssize_t vmnet_receive_common(NetClientState *nc,
  46. const uint8_t *buf,
  47. size_t size);
  48. void vmnet_cleanup_common(NetClientState *nc);
  49. #endif /* VMNET_INT_H */