1 /* 2 * RNDIS Definitions for Remote NDIS 3 * 4 * Authors: Benedikt Spranger, Pengutronix 5 * Robert Schwebel, Pengutronix 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * version 2, as published by the Free Software Foundation. 10 * 11 * This software was originally developed in conformance with 12 * Microsoft's Remote NDIS Specification License Agreement. 13 */ 14 15 #ifndef _LINUX_RNDIS_H 16 #define _LINUX_RNDIS_H 17 18 #include <linux/rndis.h> 19 #include "u_ether.h" 20 #include "ndis.h" 21 22 #define RNDIS_MAXIMUM_FRAME_SIZE 1518 23 #define RNDIS_MAX_TOTAL_SIZE 1558 24 25 typedef struct rndis_init_msg_type { 26 __le32 MessageType; 27 __le32 MessageLength; 28 __le32 RequestID; 29 __le32 MajorVersion; 30 __le32 MinorVersion; 31 __le32 MaxTransferSize; 32 } rndis_init_msg_type; 33 34 typedef struct rndis_init_cmplt_type { 35 __le32 MessageType; 36 __le32 MessageLength; 37 __le32 RequestID; 38 __le32 Status; 39 __le32 MajorVersion; 40 __le32 MinorVersion; 41 __le32 DeviceFlags; 42 __le32 Medium; 43 __le32 MaxPacketsPerTransfer; 44 __le32 MaxTransferSize; 45 __le32 PacketAlignmentFactor; 46 __le32 AFListOffset; 47 __le32 AFListSize; 48 } rndis_init_cmplt_type; 49 50 typedef struct rndis_halt_msg_type { 51 __le32 MessageType; 52 __le32 MessageLength; 53 __le32 RequestID; 54 } rndis_halt_msg_type; 55 56 typedef struct rndis_query_msg_type { 57 __le32 MessageType; 58 __le32 MessageLength; 59 __le32 RequestID; 60 __le32 OID; 61 __le32 InformationBufferLength; 62 __le32 InformationBufferOffset; 63 __le32 DeviceVcHandle; 64 } rndis_query_msg_type; 65 66 typedef struct rndis_query_cmplt_type { 67 __le32 MessageType; 68 __le32 MessageLength; 69 __le32 RequestID; 70 __le32 Status; 71 __le32 InformationBufferLength; 72 __le32 InformationBufferOffset; 73 } rndis_query_cmplt_type; 74 75 typedef struct rndis_set_msg_type { 76 __le32 MessageType; 77 __le32 MessageLength; 78 __le32 RequestID; 79 __le32 OID; 80 __le32 InformationBufferLength; 81 __le32 InformationBufferOffset; 82 __le32 DeviceVcHandle; 83 } rndis_set_msg_type; 84 85 typedef struct rndis_set_cmplt_type { 86 __le32 MessageType; 87 __le32 MessageLength; 88 __le32 RequestID; 89 __le32 Status; 90 } rndis_set_cmplt_type; 91 92 typedef struct rndis_reset_msg_type { 93 __le32 MessageType; 94 __le32 MessageLength; 95 __le32 Reserved; 96 } rndis_reset_msg_type; 97 98 typedef struct rndis_reset_cmplt_type { 99 __le32 MessageType; 100 __le32 MessageLength; 101 __le32 Status; 102 __le32 AddressingReset; 103 } rndis_reset_cmplt_type; 104 105 typedef struct rndis_indicate_status_msg_type { 106 __le32 MessageType; 107 __le32 MessageLength; 108 __le32 Status; 109 __le32 StatusBufferLength; 110 __le32 StatusBufferOffset; 111 } rndis_indicate_status_msg_type; 112 113 typedef struct rndis_keepalive_msg_type { 114 __le32 MessageType; 115 __le32 MessageLength; 116 __le32 RequestID; 117 } rndis_keepalive_msg_type; 118 119 typedef struct rndis_keepalive_cmplt_type { 120 __le32 MessageType; 121 __le32 MessageLength; 122 __le32 RequestID; 123 __le32 Status; 124 } rndis_keepalive_cmplt_type; 125 126 struct rndis_packet_msg_type { 127 __le32 MessageType; 128 __le32 MessageLength; 129 __le32 DataOffset; 130 __le32 DataLength; 131 __le32 OOBDataOffset; 132 __le32 OOBDataLength; 133 __le32 NumOOBDataElements; 134 __le32 PerPacketInfoOffset; 135 __le32 PerPacketInfoLength; 136 __le32 VcHandle; 137 __le32 Reserved; 138 } __attribute__ ((packed)); 139 140 struct rndis_config_parameter { 141 __le32 ParameterNameOffset; 142 __le32 ParameterNameLength; 143 __le32 ParameterType; 144 __le32 ParameterValueOffset; 145 __le32 ParameterValueLength; 146 }; 147 148 /* implementation specific */ 149 enum rndis_state { 150 RNDIS_UNINITIALIZED, 151 RNDIS_INITIALIZED, 152 RNDIS_DATA_INITIALIZED, 153 }; 154 155 typedef struct rndis_resp_t { 156 struct list_head list; 157 u8 *buf; 158 u32 length; 159 int send; 160 } rndis_resp_t; 161 162 typedef struct rndis_params { 163 int confignr; 164 u8 used; 165 u16 saved_filter; 166 enum rndis_state state; 167 u32 medium; 168 u32 speed; 169 u32 media_state; 170 171 const u8 *host_mac; 172 u16 *filter; 173 struct net_device *dev; 174 175 u32 vendorID; 176 const char *vendorDescr; 177 void (*resp_avail)(void *v); 178 void *v; 179 struct list_head resp_queue; 180 } rndis_params; 181 182 /* RNDIS Message parser and other useless functions */ 183 int rndis_msg_parser(struct rndis_params *params, u8 *buf); 184 struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v); 185 void rndis_deregister(struct rndis_params *params); 186 int rndis_set_param_dev(struct rndis_params *params, struct net_device *dev, 187 u16 *cdc_filter); 188 int rndis_set_param_vendor(struct rndis_params *params, u32 vendorID, 189 const char *vendorDescr); 190 int rndis_set_param_medium(struct rndis_params *params, u32 medium, 191 u32 speed); 192 void rndis_add_hdr(struct sk_buff *skb); 193 int rndis_rm_hdr(struct gether *port, struct sk_buff *skb, 194 struct sk_buff_head *list); 195 u8 *rndis_get_next_response(struct rndis_params *params, u32 *length); 196 void rndis_free_response(struct rndis_params *params, u8 *buf); 197 198 void rndis_uninit(struct rndis_params *params); 199 int rndis_signal_connect(struct rndis_params *params); 200 int rndis_signal_disconnect(struct rndis_params *params); 201 int rndis_state(struct rndis_params *params); 202 extern void rndis_set_host_mac(struct rndis_params *params, const u8 *addr); 203 204 #endif /* _LINUX_RNDIS_H */ 205