1 // SPDX-License-Identifier: GPL-2.0+
3 * Host Side support for RNDIS Networking Links
4 * Copyright (C) 2005 by David Brownell
7 #ifndef __LINUX_USB_RNDIS_HOST_H
8 #define __LINUX_USB_RNDIS_HOST_H
10 #include <linux/rndis.h>
13 * CONTROL uses CDC "encapsulated commands" with funky notifications.
14 * - control-out: SEND_ENCAPSULATED
15 * - interrupt-in: RESPONSE_AVAILABLE
16 * - control-in: GET_ENCAPSULATED
18 * We'll try to ignore the RESPONSE_AVAILABLE notifications.
20 * REVISIT some RNDIS implementations seem to have curious issues still
23 struct rndis_msg_hdr {
24 __le32 msg_type; /* RNDIS_MSG_* */
26 /* followed by data that varies between messages */
30 } __attribute__ ((packed));
32 /* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
33 #define CONTROL_BUFFER_SIZE 1025
35 /* RNDIS defines an (absurdly huge) 10 second control timeout,
36 * but ActiveSync seems to use a more usual 5 second timeout
37 * (which matches the USB 2.0 spec).
39 #define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000)
41 struct rndis_data_hdr {
42 __le32 msg_type; /* RNDIS_MSG_PACKET */
43 __le32 msg_len; /* rndis_data_hdr + data_len + pad */
44 __le32 data_offset; /* 36 -- right after header */
45 __le32 data_len; /* ... real packet size */
47 __le32 oob_data_offset; /* zero */
48 __le32 oob_data_len; /* zero */
49 __le32 num_oob; /* zero */
50 __le32 packet_data_offset; /* zero */
52 __le32 packet_data_len; /* zero */
53 __le32 vc_handle; /* zero */
54 __le32 reserved; /* zero */
55 } __attribute__ ((packed));
57 struct rndis_init { /* OUT */
59 __le32 msg_type; /* RNDIS_MSG_INIT */
60 __le32 msg_len; /* 24 */
62 __le32 major_version; /* of rndis (1.0) */
64 __le32 max_transfer_size;
65 } __attribute__ ((packed));
67 struct rndis_init_c { /* IN */
69 __le32 msg_type; /* RNDIS_MSG_INIT_C */
73 __le32 major_version; /* of rndis (1.0) */
76 __le32 medium; /* zero == 802.3 */
77 __le32 max_packets_per_message;
78 __le32 max_transfer_size;
79 __le32 packet_alignment; /* max 7; (1<<n) bytes */
80 __le32 af_list_offset; /* zero */
81 __le32 af_list_size; /* zero */
82 } __attribute__ ((packed));
84 struct rndis_halt { /* OUT (no reply) */
86 __le32 msg_type; /* RNDIS_MSG_HALT */
89 } __attribute__ ((packed));
91 struct rndis_query { /* OUT */
93 __le32 msg_type; /* RNDIS_MSG_QUERY */
99 /*?*/ __le32 handle; /* zero */
100 } __attribute__ ((packed));
102 struct rndis_query_c { /* IN */
104 __le32 msg_type; /* RNDIS_MSG_QUERY_C */
110 } __attribute__ ((packed));
112 struct rndis_set { /* OUT */
114 __le32 msg_type; /* RNDIS_MSG_SET */
120 /*?*/ __le32 handle; /* zero */
121 } __attribute__ ((packed));
123 struct rndis_set_c { /* IN */
125 __le32 msg_type; /* RNDIS_MSG_SET_C */
129 } __attribute__ ((packed));
131 struct rndis_reset { /* IN */
133 __le32 msg_type; /* RNDIS_MSG_RESET */
136 } __attribute__ ((packed));
138 struct rndis_reset_c { /* OUT */
140 __le32 msg_type; /* RNDIS_MSG_RESET_C */
143 __le32 addressing_lost;
144 } __attribute__ ((packed));
146 struct rndis_indicate { /* IN (unrequested) */
148 __le32 msg_type; /* RNDIS_MSG_INDICATE */
153 /**/ __le32 diag_status;
156 } __attribute__ ((packed));
158 struct rndis_keepalive { /* OUT (optionally IN) */
160 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
163 } __attribute__ ((packed));
165 struct rndis_keepalive_c { /* IN (optionally OUT) */
167 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
171 } __attribute__ ((packed));
173 /* default filter used with RNDIS devices */
174 #define RNDIS_DEFAULT_FILTER ( \
175 RNDIS_PACKET_TYPE_DIRECTED | \
176 RNDIS_PACKET_TYPE_BROADCAST | \
177 RNDIS_PACKET_TYPE_ALL_MULTICAST | \
178 RNDIS_PACKET_TYPE_PROMISCUOUS)
180 /* Flags to require specific physical medium type for generic_rndis_bind() */
181 #define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001
182 #define FLAG_RNDIS_PHYM_WIRELESS 0x0002
184 /* Flags for driver_info::data */
185 #define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */
186 #define RNDIS_DRIVER_DATA_DST_MAC_FIXUP 2 /* device ignores configured MAC address */
188 extern void rndis_status(struct usbnet *dev, struct urb *urb);
190 rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
192 generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
193 extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
194 extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
195 extern struct sk_buff *
196 rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
198 #endif /* __LINUX_USB_RNDIS_HOST_H */