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 */ 36struct rndis_msg_hdr { 37 __le32 msg_type; /* RNDIS_MSG_* */ 38 __le32 msg_len; 39 /* followed by data that varies between messages */ 40 __le32 request_id; 41 __le32 status; 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 54struct rndis_data_hdr { 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 */ 63 __le32 packet_data_offset; /* zero */ 64 65 __le32 packet_data_len; /* zero */ 66 __le32 vc_handle; /* zero */ 67 __le32 reserved; /* zero */ 68} __attribute__ ((packed)); 69 70struct rndis_init { /* OUT */ 71 /* header and: */ 72 __le32 msg_type; /* RNDIS_MSG_INIT */ 73 __le32 msg_len; /* 24 */ 74 __le32 request_id; 75 __le32 major_version; /* of rndis (1.0) */ 76 __le32 minor_version; 77 __le32 max_transfer_size; 78} __attribute__ ((packed)); 79 80struct rndis_init_c { /* IN */ 81 /* header and: */ 82 __le32 msg_type; /* RNDIS_MSG_INIT_C */ 83 __le32 msg_len; 84 __le32 request_id; 85 __le32 status; 86 __le32 major_version; /* of rndis (1.0) */ 87 __le32 minor_version; 88 __le32 device_flags; 89 __le32 medium; /* zero == 802.3 */ 90 __le32 max_packets_per_message; 91 __le32 max_transfer_size; 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 97struct rndis_halt { /* OUT (no reply) */ 98 /* header and: */ 99 __le32 msg_type; /* RNDIS_MSG_HALT */ 100 __le32 msg_len; 101 __le32 request_id; 102} __attribute__ ((packed)); 103 104struct rndis_query { /* OUT */ 105 /* header and: */ 106 __le32 msg_type; /* RNDIS_MSG_QUERY */ 107 __le32 msg_len; 108 __le32 request_id; 109 __le32 oid; 110 __le32 len; 111 __le32 offset; 112/*?*/ __le32 handle; /* zero */ 113} __attribute__ ((packed)); 114 115struct rndis_query_c { /* IN */ 116 /* header and: */ 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 125struct rndis_set { /* OUT */ 126 /* header and: */ 127 __le32 msg_type; /* RNDIS_MSG_SET */ 128 __le32 msg_len; 129 __le32 request_id; 130 __le32 oid; 131 __le32 len; 132 __le32 offset; 133/*?*/ __le32 handle; /* zero */ 134} __attribute__ ((packed)); 135 136struct rndis_set_c { /* IN */ 137 /* header and: */ 138 __le32 msg_type; /* RNDIS_MSG_SET_C */ 139 __le32 msg_len; 140 __le32 request_id; 141 __le32 status; 142} __attribute__ ((packed)); 143 144struct rndis_reset { /* IN */ 145 /* header and: */ 146 __le32 msg_type; /* RNDIS_MSG_RESET */ 147 __le32 msg_len; 148 __le32 reserved; 149} __attribute__ ((packed)); 150 151struct rndis_reset_c { /* OUT */ 152 /* header and: */ 153 __le32 msg_type; /* RNDIS_MSG_RESET_C */ 154 __le32 msg_len; 155 __le32 status; 156 __le32 addressing_lost; 157} __attribute__ ((packed)); 158 159struct rndis_indicate { /* IN (unrequested) */ 160 /* header and: */ 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 171struct rndis_keepalive { /* OUT (optionally IN) */ 172 /* header and: */ 173 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */ 174 __le32 msg_len; 175 __le32 request_id; 176} __attribute__ ((packed)); 177 178struct rndis_keepalive_c { /* IN (optionally OUT) */ 179 /* header and: */ 180 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */ 181 __le32 msg_len; 182 __le32 request_id; 183 __le32 status; 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 200extern void rndis_status(struct usbnet *dev, struct urb *urb); 201extern int 202rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen); 203extern int 204generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); 205extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); 206extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb); 207extern struct sk_buff * 208rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags); 209 210#endif /* __LINUX_USB_RNDIS_HOST_H */ 211