Commit | Line | Data |
---|---|---|
7517579a JK |
1 | /* |
2 | * Host Side support for RNDIS Networking Links | |
3 | * Copyright (C) 2005 by David Brownell | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | */ | |
19 | ||
dda43a0e RD |
20 | #ifndef __LINUX_USB_RNDIS_HOST_H |
21 | #define __LINUX_USB_RNDIS_HOST_H | |
7517579a | 22 | |
7591157e LW |
23 | #include <linux/rndis.h> |
24 | ||
7517579a JK |
25 | /* |
26 | * CONTROL uses CDC "encapsulated commands" with funky notifications. | |
27 | * - control-out: SEND_ENCAPSULATED | |
28 | * - interrupt-in: RESPONSE_AVAILABLE | |
29 | * - control-in: GET_ENCAPSULATED | |
30 | * | |
31 | * We'll try to ignore the RESPONSE_AVAILABLE notifications. | |
32 | * | |
33 | * REVISIT some RNDIS implementations seem to have curious issues still | |
34 | * to be resolved. | |
35 | */ | |
36 | struct rndis_msg_hdr { | |
37 | __le32 msg_type; /* RNDIS_MSG_* */ | |
38 | __le32 msg_len; | |
0858a3a5 | 39 | /* followed by data that varies between messages */ |
7517579a JK |
40 | __le32 request_id; |
41 | __le32 status; | |
0858a3a5 | 42 | /* ... and more */ |
7517579a JK |
43 | } __attribute__ ((packed)); |
44 | ||
45 | /* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */ | |
46 | #define CONTROL_BUFFER_SIZE 1025 | |
47 | ||
48 | /* RNDIS defines an (absurdly huge) 10 second control timeout, | |
49 | * but ActiveSync seems to use a more usual 5 second timeout | |
50 | * (which matches the USB 2.0 spec). | |
51 | */ | |
52 | #define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000) | |
53 | ||
7517579a JK |
54 | struct rndis_data_hdr { |
55 | __le32 msg_type; /* RNDIS_MSG_PACKET */ | |
0858a3a5 GKH |
56 | __le32 msg_len; /* rndis_data_hdr + data_len + pad */ |
57 | __le32 data_offset; /* 36 -- right after header */ | |
58 | __le32 data_len; /* ... real packet size */ | |
59 | ||
60 | __le32 oob_data_offset; /* zero */ | |
61 | __le32 oob_data_len; /* zero */ | |
62 | __le32 num_oob; /* zero */ | |
63 | __le32 packet_data_offset; /* zero */ | |
64 | ||
65 | __le32 packet_data_len; /* zero */ | |
66 | __le32 vc_handle; /* zero */ | |
67 | __le32 reserved; /* zero */ | |
7517579a JK |
68 | } __attribute__ ((packed)); |
69 | ||
70 | struct rndis_init { /* OUT */ | |
0858a3a5 | 71 | /* header and: */ |
7517579a | 72 | __le32 msg_type; /* RNDIS_MSG_INIT */ |
0858a3a5 | 73 | __le32 msg_len; /* 24 */ |
7517579a | 74 | __le32 request_id; |
0858a3a5 | 75 | __le32 major_version; /* of rndis (1.0) */ |
7517579a JK |
76 | __le32 minor_version; |
77 | __le32 max_transfer_size; | |
78 | } __attribute__ ((packed)); | |
79 | ||
80 | struct rndis_init_c { /* IN */ | |
0858a3a5 | 81 | /* header and: */ |
7517579a JK |
82 | __le32 msg_type; /* RNDIS_MSG_INIT_C */ |
83 | __le32 msg_len; | |
84 | __le32 request_id; | |
85 | __le32 status; | |
0858a3a5 | 86 | __le32 major_version; /* of rndis (1.0) */ |
7517579a JK |
87 | __le32 minor_version; |
88 | __le32 device_flags; | |
0858a3a5 | 89 | __le32 medium; /* zero == 802.3 */ |
7517579a JK |
90 | __le32 max_packets_per_message; |
91 | __le32 max_transfer_size; | |
0858a3a5 GKH |
92 | __le32 packet_alignment; /* max 7; (1<<n) bytes */ |
93 | __le32 af_list_offset; /* zero */ | |
94 | __le32 af_list_size; /* zero */ | |
7517579a JK |
95 | } __attribute__ ((packed)); |
96 | ||
97 | struct rndis_halt { /* OUT (no reply) */ | |
0858a3a5 | 98 | /* header and: */ |
7517579a JK |
99 | __le32 msg_type; /* RNDIS_MSG_HALT */ |
100 | __le32 msg_len; | |
101 | __le32 request_id; | |
102 | } __attribute__ ((packed)); | |
103 | ||
104 | struct rndis_query { /* OUT */ | |
0858a3a5 | 105 | /* header and: */ |
7517579a JK |
106 | __le32 msg_type; /* RNDIS_MSG_QUERY */ |
107 | __le32 msg_len; | |
108 | __le32 request_id; | |
109 | __le32 oid; | |
110 | __le32 len; | |
111 | __le32 offset; | |
0858a3a5 | 112 | /*?*/ __le32 handle; /* zero */ |
7517579a JK |
113 | } __attribute__ ((packed)); |
114 | ||
115 | struct rndis_query_c { /* IN */ | |
0858a3a5 | 116 | /* header and: */ |
7517579a JK |
117 | __le32 msg_type; /* RNDIS_MSG_QUERY_C */ |
118 | __le32 msg_len; | |
119 | __le32 request_id; | |
120 | __le32 status; | |
121 | __le32 len; | |
122 | __le32 offset; | |
123 | } __attribute__ ((packed)); | |
124 | ||
125 | struct rndis_set { /* OUT */ | |
0858a3a5 | 126 | /* header and: */ |
7517579a JK |
127 | __le32 msg_type; /* RNDIS_MSG_SET */ |
128 | __le32 msg_len; | |
129 | __le32 request_id; | |
130 | __le32 oid; | |
131 | __le32 len; | |
132 | __le32 offset; | |
0858a3a5 | 133 | /*?*/ __le32 handle; /* zero */ |
7517579a JK |
134 | } __attribute__ ((packed)); |
135 | ||
136 | struct rndis_set_c { /* IN */ | |
0858a3a5 | 137 | /* header and: */ |
7517579a JK |
138 | __le32 msg_type; /* RNDIS_MSG_SET_C */ |
139 | __le32 msg_len; | |
140 | __le32 request_id; | |
141 | __le32 status; | |
142 | } __attribute__ ((packed)); | |
143 | ||
144 | struct rndis_reset { /* IN */ | |
0858a3a5 | 145 | /* header and: */ |
7517579a JK |
146 | __le32 msg_type; /* RNDIS_MSG_RESET */ |
147 | __le32 msg_len; | |
148 | __le32 reserved; | |
149 | } __attribute__ ((packed)); | |
150 | ||
151 | struct rndis_reset_c { /* OUT */ | |
0858a3a5 | 152 | /* header and: */ |
7517579a JK |
153 | __le32 msg_type; /* RNDIS_MSG_RESET_C */ |
154 | __le32 msg_len; | |
155 | __le32 status; | |
156 | __le32 addressing_lost; | |
157 | } __attribute__ ((packed)); | |
158 | ||
159 | struct rndis_indicate { /* IN (unrequested) */ | |
0858a3a5 | 160 | /* header and: */ |
7517579a JK |
161 | __le32 msg_type; /* RNDIS_MSG_INDICATE */ |
162 | __le32 msg_len; | |
163 | __le32 status; | |
164 | __le32 length; | |
165 | __le32 offset; | |
166 | /**/ __le32 diag_status; | |
167 | __le32 error_offset; | |
168 | /**/ __le32 message; | |
169 | } __attribute__ ((packed)); | |
170 | ||
171 | struct rndis_keepalive { /* OUT (optionally IN) */ | |
0858a3a5 | 172 | /* header and: */ |
7517579a JK |
173 | __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */ |
174 | __le32 msg_len; | |
175 | __le32 request_id; | |
176 | } __attribute__ ((packed)); | |
177 | ||
178 | struct rndis_keepalive_c { /* IN (optionally OUT) */ | |
0858a3a5 | 179 | /* header and: */ |
7517579a JK |
180 | __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */ |
181 | __le32 msg_len; | |
182 | __le32 request_id; | |
183 | __le32 status; | |
184 | } __attribute__ ((packed)); | |
185 | ||
7517579a JK |
186 | /* default filter used with RNDIS devices */ |
187 | #define RNDIS_DEFAULT_FILTER ( \ | |
188 | RNDIS_PACKET_TYPE_DIRECTED | \ | |
189 | RNDIS_PACKET_TYPE_BROADCAST | \ | |
190 | RNDIS_PACKET_TYPE_ALL_MULTICAST | \ | |
191 | RNDIS_PACKET_TYPE_PROMISCUOUS) | |
192 | ||
039ee17d JK |
193 | /* Flags to require specific physical medium type for generic_rndis_bind() */ |
194 | #define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001 | |
195 | #define FLAG_RNDIS_PHYM_WIRELESS 0x0002 | |
196 | ||
4d42d417 BH |
197 | /* Flags for driver_info::data */ |
198 | #define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */ | |
5665998c JK |
199 | |
200 | extern void rndis_status(struct usbnet *dev, struct urb *urb); | |
818727ba JK |
201 | extern int |
202 | rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen); | |
039ee17d JK |
203 | extern int |
204 | generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); | |
5665998c JK |
205 | extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); |
206 | extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb); | |
207 | extern struct sk_buff * | |
208 | rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags); | |
209 | ||
dda43a0e | 210 | #endif /* __LINUX_USB_RNDIS_HOST_H */ |