usbmuxd-proto.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * usbmuxd-proto.h - Protocol definition for the usbmux protocol.
  3. *
  4. * Copyright (C) 2009 Paul Sladen <libiphone@paul.sladen.org>
  5. * Copyright (C) 2009 Nikias Bassen <nikias@gmx.li>
  6. * Copyright (C) 2009 Hector Martin <hector@marcansoft.com>
  7. *
  8. * This library is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as
  10. * published by the Free Software Foundation, either version 2.1 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef USBMUXD_PROTO_H
  23. #define USBMUXD_PROTO_H
  24. #include <stdint.h>
  25. #define USBMUXD_PROTOCOL_VERSION 0
  26. #if defined(WIN32) || defined(__CYGWIN__)
  27. #define USBMUXD_SOCKET_PORT 27015
  28. #else
  29. #define USBMUXD_SOCKET_FILE "/var/run/usbmuxd"
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. enum usbmuxd_result {
  35. RESULT_OK = 0,
  36. RESULT_BADCOMMAND = 1,
  37. RESULT_BADDEV = 2,
  38. RESULT_CONNREFUSED = 3,
  39. // ???
  40. // ???
  41. RESULT_BADVERSION = 6,
  42. };
  43. enum usbmuxd_msgtype {
  44. MESSAGE_RESULT = 1,
  45. MESSAGE_CONNECT = 2,
  46. MESSAGE_LISTEN = 3,
  47. MESSAGE_DEVICE_ADD = 4,
  48. MESSAGE_DEVICE_REMOVE = 5,
  49. //???
  50. //???
  51. MESSAGE_PLIST = 8,
  52. };
  53. struct usbmuxd_header {
  54. uint32_t length; // length of message, including header
  55. uint32_t version; // protocol version
  56. uint32_t message; // message type
  57. uint32_t tag; // responses to this query will echo back this tag
  58. } __attribute__((__packed__));
  59. struct usbmuxd_result_msg {
  60. struct usbmuxd_header header;
  61. uint32_t result;
  62. } __attribute__((__packed__));
  63. struct usbmuxd_connect_request {
  64. struct usbmuxd_header header;
  65. uint32_t device_id;
  66. uint16_t port; // TCP port number
  67. uint16_t reserved; // set to zero
  68. } __attribute__((__packed__));
  69. struct usbmuxd_listen_request {
  70. struct usbmuxd_header header;
  71. } __attribute__((__packed__));
  72. struct usbmuxd_device_record {
  73. uint32_t device_id;
  74. uint16_t product_id;
  75. char serial_number[256];
  76. uint16_t padding;
  77. uint32_t location;
  78. } __attribute__((__packed__));
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /* USBMUXD_PROTO_H */