Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rndis_host.h
Go to the documentation of this file.
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 
20 #ifndef __LINUX_USB_RNDIS_HOST_H
21 #define __LINUX_USB_RNDIS_HOST_H
22 
23 #include <linux/rndis.h>
24 
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_* */
39  /* followed by data that varies between messages */
42  /* ... and more */
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 
55  __le32 msg_type; /* RNDIS_MSG_PACKET */
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 */
64 
65  __le32 packet_data_len; /* zero */
66  __le32 vc_handle; /* zero */
67  __le32 reserved; /* zero */
68 } __attribute__ ((packed));
69 
70 struct rndis_init { /* OUT */
71  /* header and: */
72  __le32 msg_type; /* RNDIS_MSG_INIT */
73  __le32 msg_len; /* 24 */
75  __le32 major_version; /* of rndis (1.0) */
78 } __attribute__ ((packed));
79 
80 struct rndis_init_c { /* IN */
81  /* header and: */
82  __le32 msg_type; /* RNDIS_MSG_INIT_C */
86  __le32 major_version; /* of rndis (1.0) */
89  __le32 medium; /* zero == 802.3 */
92  __le32 packet_alignment; /* max 7; (1<<n) bytes */
93  __le32 af_list_offset; /* zero */
94  __le32 af_list_size; /* zero */
95 } __attribute__ ((packed));
96 
97 struct rndis_halt { /* OUT (no reply) */
98  /* header and: */
99  __le32 msg_type; /* RNDIS_MSG_HALT */
102 } __attribute__ ((packed));
104 struct rndis_query { /* OUT */
105  /* header and: */
106  __le32 msg_type; /* RNDIS_MSG_QUERY */
112 /*?*/ __le32 handle; /* zero */
113 } __attribute__ ((packed));
114 
115 struct rndis_query_c { /* IN */
116  /* header and: */
117  __le32 msg_type; /* RNDIS_MSG_QUERY_C */
123 } __attribute__ ((packed));
124 
125 struct rndis_set { /* OUT */
126  /* header and: */
127  __le32 msg_type; /* RNDIS_MSG_SET */
133 /*?*/ __le32 handle; /* zero */
134 } __attribute__ ((packed));
135 
136 struct rndis_set_c { /* IN */
137  /* header and: */
138  __le32 msg_type; /* RNDIS_MSG_SET_C */
142 } __attribute__ ((packed));
143 
144 struct rndis_reset { /* IN */
145  /* header and: */
146  __le32 msg_type; /* RNDIS_MSG_RESET */
149 } __attribute__ ((packed));
150 
151 struct rndis_reset_c { /* OUT */
152  /* header and: */
153  __le32 msg_type; /* RNDIS_MSG_RESET_C */
157 } __attribute__ ((packed));
158 
159 struct rndis_indicate { /* IN (unrequested) */
160  /* header and: */
161  __le32 msg_type; /* RNDIS_MSG_INDICATE */
169 } __attribute__ ((packed));
170 
171 struct rndis_keepalive { /* OUT (optionally IN) */
172  /* header and: */
173  __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
176 } __attribute__ ((packed));
178 struct rndis_keepalive_c { /* IN (optionally OUT) */
179  /* header and: */
180  __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
184 } __attribute__ ((packed));
185 
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 
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 
197 /* Flags for driver_info::data */
198 #define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */
199 
200 extern void rndis_status(struct usbnet *dev, struct urb *urb);
201 extern int
202 rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
203 extern int
204 generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
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 
210 #endif /* __LINUX_USB_RNDIS_HOST_H */