Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 476d9894dde2da2c2b326d70b5bce5eccc593c8b 272 lines 8.9 kB view raw
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/* 24 * CONTROL uses CDC "encapsulated commands" with funky notifications. 25 * - control-out: SEND_ENCAPSULATED 26 * - interrupt-in: RESPONSE_AVAILABLE 27 * - control-in: GET_ENCAPSULATED 28 * 29 * We'll try to ignore the RESPONSE_AVAILABLE notifications. 30 * 31 * REVISIT some RNDIS implementations seem to have curious issues still 32 * to be resolved. 33 */ 34struct rndis_msg_hdr { 35 __le32 msg_type; /* RNDIS_MSG_* */ 36 __le32 msg_len; 37 // followed by data that varies between messages 38 __le32 request_id; 39 __le32 status; 40 // ... and more 41} __attribute__ ((packed)); 42 43/* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */ 44#define CONTROL_BUFFER_SIZE 1025 45 46/* RNDIS defines an (absurdly huge) 10 second control timeout, 47 * but ActiveSync seems to use a more usual 5 second timeout 48 * (which matches the USB 2.0 spec). 49 */ 50#define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000) 51 52 53#define ccpu2 __constant_cpu_to_le32 54 55#define RNDIS_MSG_COMPLETION ccpu2(0x80000000) 56 57/* codes for "msg_type" field of rndis messages; 58 * only the data channel uses packet messages (maybe batched); 59 * everything else goes on the control channel. 60 */ 61#define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */ 62#define RNDIS_MSG_INIT ccpu2(0x00000002) 63#define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION) 64#define RNDIS_MSG_HALT ccpu2(0x00000003) 65#define RNDIS_MSG_QUERY ccpu2(0x00000004) 66#define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION) 67#define RNDIS_MSG_SET ccpu2(0x00000005) 68#define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION) 69#define RNDIS_MSG_RESET ccpu2(0x00000006) 70#define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION) 71#define RNDIS_MSG_INDICATE ccpu2(0x00000007) 72#define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008) 73#define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION) 74 75/* codes for "status" field of completion messages */ 76#define RNDIS_STATUS_SUCCESS ccpu2(0x00000000) 77#define RNDIS_STATUS_FAILURE ccpu2(0xc0000001) 78#define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015) 79#define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb) 80#define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b) 81#define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c) 82 83/* codes for OID_GEN_PHYSICAL_MEDIUM */ 84#define RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED ccpu2(0x00000000) 85#define RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN ccpu2(0x00000001) 86#define RNDIS_PHYSICAL_MEDIUM_CABLE_MODEM ccpu2(0x00000002) 87#define RNDIS_PHYSICAL_MEDIUM_PHONE_LINE ccpu2(0x00000003) 88#define RNDIS_PHYSICAL_MEDIUM_POWER_LINE ccpu2(0x00000004) 89#define RNDIS_PHYSICAL_MEDIUM_DSL ccpu2(0x00000005) 90#define RNDIS_PHYSICAL_MEDIUM_FIBRE_CHANNEL ccpu2(0x00000006) 91#define RNDIS_PHYSICAL_MEDIUM_1394 ccpu2(0x00000007) 92#define RNDIS_PHYSICAL_MEDIUM_WIRELESS_WAN ccpu2(0x00000008) 93#define RNDIS_PHYSICAL_MEDIUM_MAX ccpu2(0x00000009) 94 95struct rndis_data_hdr { 96 __le32 msg_type; /* RNDIS_MSG_PACKET */ 97 __le32 msg_len; // rndis_data_hdr + data_len + pad 98 __le32 data_offset; // 36 -- right after header 99 __le32 data_len; // ... real packet size 100 101 __le32 oob_data_offset; // zero 102 __le32 oob_data_len; // zero 103 __le32 num_oob; // zero 104 __le32 packet_data_offset; // zero 105 106 __le32 packet_data_len; // zero 107 __le32 vc_handle; // zero 108 __le32 reserved; // zero 109} __attribute__ ((packed)); 110 111struct rndis_init { /* OUT */ 112 // header and: 113 __le32 msg_type; /* RNDIS_MSG_INIT */ 114 __le32 msg_len; // 24 115 __le32 request_id; 116 __le32 major_version; // of rndis (1.0) 117 __le32 minor_version; 118 __le32 max_transfer_size; 119} __attribute__ ((packed)); 120 121struct rndis_init_c { /* IN */ 122 // header and: 123 __le32 msg_type; /* RNDIS_MSG_INIT_C */ 124 __le32 msg_len; 125 __le32 request_id; 126 __le32 status; 127 __le32 major_version; // of rndis (1.0) 128 __le32 minor_version; 129 __le32 device_flags; 130 __le32 medium; // zero == 802.3 131 __le32 max_packets_per_message; 132 __le32 max_transfer_size; 133 __le32 packet_alignment; // max 7; (1<<n) bytes 134 __le32 af_list_offset; // zero 135 __le32 af_list_size; // zero 136} __attribute__ ((packed)); 137 138struct rndis_halt { /* OUT (no reply) */ 139 // header and: 140 __le32 msg_type; /* RNDIS_MSG_HALT */ 141 __le32 msg_len; 142 __le32 request_id; 143} __attribute__ ((packed)); 144 145struct rndis_query { /* OUT */ 146 // header and: 147 __le32 msg_type; /* RNDIS_MSG_QUERY */ 148 __le32 msg_len; 149 __le32 request_id; 150 __le32 oid; 151 __le32 len; 152 __le32 offset; 153/*?*/ __le32 handle; // zero 154} __attribute__ ((packed)); 155 156struct rndis_query_c { /* IN */ 157 // header and: 158 __le32 msg_type; /* RNDIS_MSG_QUERY_C */ 159 __le32 msg_len; 160 __le32 request_id; 161 __le32 status; 162 __le32 len; 163 __le32 offset; 164} __attribute__ ((packed)); 165 166struct rndis_set { /* OUT */ 167 // header and: 168 __le32 msg_type; /* RNDIS_MSG_SET */ 169 __le32 msg_len; 170 __le32 request_id; 171 __le32 oid; 172 __le32 len; 173 __le32 offset; 174/*?*/ __le32 handle; // zero 175} __attribute__ ((packed)); 176 177struct rndis_set_c { /* IN */ 178 // header and: 179 __le32 msg_type; /* RNDIS_MSG_SET_C */ 180 __le32 msg_len; 181 __le32 request_id; 182 __le32 status; 183} __attribute__ ((packed)); 184 185struct rndis_reset { /* IN */ 186 // header and: 187 __le32 msg_type; /* RNDIS_MSG_RESET */ 188 __le32 msg_len; 189 __le32 reserved; 190} __attribute__ ((packed)); 191 192struct rndis_reset_c { /* OUT */ 193 // header and: 194 __le32 msg_type; /* RNDIS_MSG_RESET_C */ 195 __le32 msg_len; 196 __le32 status; 197 __le32 addressing_lost; 198} __attribute__ ((packed)); 199 200struct rndis_indicate { /* IN (unrequested) */ 201 // header and: 202 __le32 msg_type; /* RNDIS_MSG_INDICATE */ 203 __le32 msg_len; 204 __le32 status; 205 __le32 length; 206 __le32 offset; 207/**/ __le32 diag_status; 208 __le32 error_offset; 209/**/ __le32 message; 210} __attribute__ ((packed)); 211 212struct rndis_keepalive { /* OUT (optionally IN) */ 213 // header and: 214 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */ 215 __le32 msg_len; 216 __le32 request_id; 217} __attribute__ ((packed)); 218 219struct rndis_keepalive_c { /* IN (optionally OUT) */ 220 // header and: 221 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */ 222 __le32 msg_len; 223 __le32 request_id; 224 __le32 status; 225} __attribute__ ((packed)); 226 227/* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and 228 * there are gobs more that may optionally be supported. We'll avoid as much 229 * of that mess as possible. 230 */ 231#define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101) 232#define OID_GEN_MAXIMUM_FRAME_SIZE ccpu2(0x00010106) 233#define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e) 234#define OID_GEN_PHYSICAL_MEDIUM ccpu2(0x00010202) 235 236/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ 237#define RNDIS_PACKET_TYPE_DIRECTED ccpu2(0x00000001) 238#define RNDIS_PACKET_TYPE_MULTICAST ccpu2(0x00000002) 239#define RNDIS_PACKET_TYPE_ALL_MULTICAST ccpu2(0x00000004) 240#define RNDIS_PACKET_TYPE_BROADCAST ccpu2(0x00000008) 241#define RNDIS_PACKET_TYPE_SOURCE_ROUTING ccpu2(0x00000010) 242#define RNDIS_PACKET_TYPE_PROMISCUOUS ccpu2(0x00000020) 243#define RNDIS_PACKET_TYPE_SMT ccpu2(0x00000040) 244#define RNDIS_PACKET_TYPE_ALL_LOCAL ccpu2(0x00000080) 245#define RNDIS_PACKET_TYPE_GROUP ccpu2(0x00001000) 246#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL ccpu2(0x00002000) 247#define RNDIS_PACKET_TYPE_FUNCTIONAL ccpu2(0x00004000) 248#define RNDIS_PACKET_TYPE_MAC_FRAME ccpu2(0x00008000) 249 250/* default filter used with RNDIS devices */ 251#define RNDIS_DEFAULT_FILTER ( \ 252 RNDIS_PACKET_TYPE_DIRECTED | \ 253 RNDIS_PACKET_TYPE_BROADCAST | \ 254 RNDIS_PACKET_TYPE_ALL_MULTICAST | \ 255 RNDIS_PACKET_TYPE_PROMISCUOUS) 256 257/* Flags to require specific physical medium type for generic_rndis_bind() */ 258#define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001 259#define FLAG_RNDIS_PHYM_WIRELESS 0x0002 260 261 262extern void rndis_status(struct usbnet *dev, struct urb *urb); 263extern int 264rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen); 265extern int 266generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); 267extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); 268extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb); 269extern struct sk_buff * 270rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags); 271 272#endif /* __LINUX_USB_RNDIS_HOST_H */