1 /*
2  * Copyright (c) 2022, sakumisu
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef USBH_RNDIS_H
7 #define USBH_RNDIS_H
8 
9 #include "usb_cdc.h"
10 
11 struct usbh_rndis {
12     struct usbh_hubport *hport;
13     struct usb_endpoint_descriptor *bulkin;  /* Bulk IN endpoint */
14     struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */
15     struct usb_endpoint_descriptor *intin;   /* INTR endpoint */
16     struct usbh_urb bulkin_urb;              /* Bulk IN urb */
17     struct usbh_urb bulkout_urb;             /* Bulk OUT urb */
18     struct usbh_urb intin_urb;               /* INTR IN urb */
19 
20     uint8_t ctrl_intf; /* Control interface number */
21     uint8_t data_intf; /* Data interface number */
22     uint8_t minor;
23 
24     uint32_t request_id;
25     uint32_t tx_offset;
26     uint32_t max_transfer_pkts; /* max packets in one transfer */
27     uint32_t max_transfer_size; /* max size in one transfer */
28 
29     uint32_t link_speed;
30     bool connect_status;
31     uint8_t mac[6];
32 
33     void *user_data;
34 };
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 int usbh_rndis_get_connect_status(struct usbh_rndis *rndis_class);
41 int usbh_rndis_keepalive(struct usbh_rndis *rndis_class);
42 
43 void usbh_rndis_run(struct usbh_rndis *rndis_class);
44 void usbh_rndis_stop(struct usbh_rndis *rndis_class);
45 
46 uint8_t *usbh_rndis_get_eth_txbuf(void);
47 int usbh_rndis_eth_output(uint32_t buflen);
48 void usbh_rndis_eth_input(uint8_t *buf, uint32_t buflen);
49 void usbh_rndis_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV);
50 
51 #ifdef __cplusplus
52 }
53 #endif
54 
55 #endif /* USBH_RNDIS_H */
56