rndis.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /************************************************************************************
  2. * include/nuttx/usb/rndis.h
  3. *
  4. * Copyright (C) 2011-2018 Gregory Nutt. All rights reserved.
  5. * Authors: Sakari Kapanen <sakari.m.kapanen@gmail.com>,
  6. Petteri Aimonen <jpa@git.mail.kapsi.fi>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ************************************************************************************/
  36. #ifndef __INCLUDE_NUTTX_USB_RNDIS_H
  37. #define __INCLUDE_NUTTX_USB_RNDIS_H
  38. /************************************************************************************
  39. * Included Files
  40. ************************************************************************************/
  41. #include <nuttx/config.h>
  42. #include <nuttx/usb/usbdev.h>
  43. /****************************************************************************
  44. * Preprocessor definitions
  45. ****************************************************************************/
  46. /* Indexes for devinfo.epno[] array. Used for composite device configuration. */
  47. #define RNDIS_EP_INTIN_IDX (0)
  48. #define RNDIS_EP_BULKIN_IDX (1)
  49. #define RNDIS_EP_BULKOUT_IDX (2)
  50. /* Endpoint configuration ****************************************************/
  51. #define RNDIS_MKEPINTIN(desc) (USB_DIR_IN | (desc)->epno[RNDIS_EP_INTIN_IDX])
  52. #define RNDIS_EPINTIN_ATTR (USB_EP_ATTR_XFER_INT)
  53. #define RNDIS_MKEPBULKIN(desc) (USB_DIR_IN | (desc)->epno[RNDIS_EP_BULKIN_IDX])
  54. #define RNDIS_EPOUTBULK_ATTR (USB_EP_ATTR_XFER_BULK)
  55. #define RNDIS_MKEPBULKOUT(desc) ((desc)->epno[RNDIS_EP_BULKOUT_IDX])
  56. #define RNDIS_EPINBULK_ATTR (USB_EP_ATTR_XFER_BULK)
  57. #ifndef CONFIG_RNDIS_EPINTIN_FSSIZE
  58. # define CONFIG_RNDIS_EPINTIN_FSSIZE 16
  59. #endif
  60. #ifndef CONFIG_RNDIS_EPINTIN_HSSIZE
  61. # define CONFIG_RNDIS_EPINTIN_HSSIZE 16
  62. #endif
  63. #ifndef CONFIG_RNDIS_EPBULKIN_FSSIZE
  64. # define CONFIG_RNDIS_EPBULKIN_FSSIZE 64
  65. #endif
  66. #ifndef CONFIG_RNDIS_EPBULKIN_HSSIZE
  67. # define CONFIG_RNDIS_EPBULKIN_HSSIZE 512
  68. #endif
  69. #ifndef CONFIG_RNDIS_EPBULKOUT_FSSIZE
  70. # define CONFIG_RNDIS_EPBULKOUT_FSSIZE 64
  71. #endif
  72. #ifndef CONFIG_RNDIS_EPBULKOUT_HSSIZE
  73. # define CONFIG_RNDIS_EPBULKOUT_HSSIZE 512
  74. #endif
  75. /************************************************************************************
  76. * Public Data
  77. ************************************************************************************/
  78. #undef EXTERN
  79. #if defined(__cplusplus)
  80. # define EXTERN extern "C"
  81. extern "C"
  82. {
  83. #else
  84. # define EXTERN extern
  85. #endif
  86. /************************************************************************************
  87. * Public Functions
  88. ************************************************************************************/
  89. /************************************************************************************
  90. * Name: usbdev_rndis_initialize
  91. *
  92. * Description:
  93. * Register RNDIS USB device interface. Register the corresponding network driver
  94. * to NuttX and bring up the network.
  95. *
  96. * Input Parameters:
  97. * mac_address: an array of 6 bytes which make the MAC address of the host side
  98. * of the network.
  99. *
  100. * Returned Value:
  101. * 0 on success; -errno on failure
  102. *
  103. ************************************************************************************/
  104. #ifndef CONFIG_RNDIS_COMPOSITE
  105. int usbdev_rndis_initialize(FAR const uint8_t *mac_address);
  106. #endif
  107. /****************************************************************************
  108. * Name: usbdev_rndis_set_host_mac_addr
  109. *
  110. * Description:
  111. * Set host MAC address. Mainly for use with composite devices where
  112. * the MAC cannot be given directly to usbdev_rndis_initialize().
  113. *
  114. * Input Parameters:
  115. * netdev: pointer to the network interface. Can be obtained from
  116. * e.g. netdev_findbyname().
  117. *
  118. * mac_address: pointer to an array of six octets which is the MAC address
  119. * of the host side of the interface. May be NULL to use the
  120. * default MAC address.
  121. *
  122. * Returned Value:
  123. * 0 on success, -errno on failure
  124. *
  125. ****************************************************************************/
  126. int usbdev_rndis_set_host_mac_addr(FAR struct net_driver_s *netdev,
  127. FAR const uint8_t *mac_address);
  128. /****************************************************************************
  129. * Name: usbdev_rndis_get_composite_devdesc
  130. *
  131. * Description:
  132. * Helper function to fill in some constants into the composite
  133. * configuration struct.
  134. *
  135. * Input Parameters:
  136. * dev - Pointer to the configuration struct we should fill
  137. *
  138. * Returned Value:
  139. * None
  140. *
  141. ****************************************************************************/
  142. #ifdef CONFIG_RNDIS_COMPOSITE
  143. void usbdev_rndis_get_composite_devdesc(struct composite_devdesc_s *dev);
  144. #endif
  145. #undef EXTERN
  146. #if defined(__cplusplus)
  147. }
  148. #endif
  149. #endif /* __INCLUDE_NUTTX_USB_RNDIS_H */