Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Host Side support for RNDIS Networking Links
0004  * Copyright (C) 2005 by David Brownell
0005  */
0006 
0007 #ifndef __LINUX_USB_RNDIS_HOST_H
0008 #define __LINUX_USB_RNDIS_HOST_H
0009 
0010 #include <linux/rndis.h>
0011 
0012 /*
0013  * CONTROL uses CDC "encapsulated commands" with funky notifications.
0014  *  - control-out:  SEND_ENCAPSULATED
0015  *  - interrupt-in:  RESPONSE_AVAILABLE
0016  *  - control-in:  GET_ENCAPSULATED
0017  *
0018  * We'll try to ignore the RESPONSE_AVAILABLE notifications.
0019  *
0020  * REVISIT some RNDIS implementations seem to have curious issues still
0021  * to be resolved.
0022  */
0023 struct rndis_msg_hdr {
0024     __le32  msg_type;           /* RNDIS_MSG_* */
0025     __le32  msg_len;
0026     /* followed by data that varies between messages */
0027     __le32  request_id;
0028     __le32  status;
0029     /* ... and more */
0030 } __attribute__ ((packed));
0031 
0032 /* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
0033 #define CONTROL_BUFFER_SIZE     1025
0034 
0035 /* RNDIS defines an (absurdly huge) 10 second control timeout,
0036  * but ActiveSync seems to use a more usual 5 second timeout
0037  * (which matches the USB 2.0 spec).
0038  */
0039 #define RNDIS_CONTROL_TIMEOUT_MS    (5 * 1000)
0040 
0041 struct rndis_data_hdr {
0042     __le32  msg_type;       /* RNDIS_MSG_PACKET */
0043     __le32  msg_len;        /* rndis_data_hdr + data_len + pad */
0044     __le32  data_offset;        /* 36 -- right after header */
0045     __le32  data_len;       /* ... real packet size */
0046 
0047     __le32  oob_data_offset;    /* zero */
0048     __le32  oob_data_len;       /* zero */
0049     __le32  num_oob;        /* zero */
0050     __le32  packet_data_offset; /* zero */
0051 
0052     __le32  packet_data_len;    /* zero */
0053     __le32  vc_handle;      /* zero */
0054     __le32  reserved;       /* zero */
0055 } __attribute__ ((packed));
0056 
0057 struct rndis_init {     /* OUT */
0058     /* header and: */
0059     __le32  msg_type;           /* RNDIS_MSG_INIT */
0060     __le32  msg_len;            /* 24 */
0061     __le32  request_id;
0062     __le32  major_version;          /* of rndis (1.0) */
0063     __le32  minor_version;
0064     __le32  max_transfer_size;
0065 } __attribute__ ((packed));
0066 
0067 struct rndis_init_c {       /* IN */
0068     /* header and: */
0069     __le32  msg_type;           /* RNDIS_MSG_INIT_C */
0070     __le32  msg_len;
0071     __le32  request_id;
0072     __le32  status;
0073     __le32  major_version;          /* of rndis (1.0) */
0074     __le32  minor_version;
0075     __le32  device_flags;
0076     __le32  medium;             /* zero == 802.3 */
0077     __le32  max_packets_per_message;
0078     __le32  max_transfer_size;
0079     __le32  packet_alignment;       /* max 7; (1<<n) bytes */
0080     __le32  af_list_offset;         /* zero */
0081     __le32  af_list_size;           /* zero */
0082 } __attribute__ ((packed));
0083 
0084 struct rndis_halt {     /* OUT (no reply) */
0085     /* header and: */
0086     __le32  msg_type;           /* RNDIS_MSG_HALT */
0087     __le32  msg_len;
0088     __le32  request_id;
0089 } __attribute__ ((packed));
0090 
0091 struct rndis_query {        /* OUT */
0092     /* header and: */
0093     __le32  msg_type;           /* RNDIS_MSG_QUERY */
0094     __le32  msg_len;
0095     __le32  request_id;
0096     __le32  oid;
0097     __le32  len;
0098     __le32  offset;
0099 /*?*/   __le32  handle;             /* zero */
0100 } __attribute__ ((packed));
0101 
0102 struct rndis_query_c {      /* IN */
0103     /* header and: */
0104     __le32  msg_type;           /* RNDIS_MSG_QUERY_C */
0105     __le32  msg_len;
0106     __le32  request_id;
0107     __le32  status;
0108     __le32  len;
0109     __le32  offset;
0110 } __attribute__ ((packed));
0111 
0112 struct rndis_set {      /* OUT */
0113     /* header and: */
0114     __le32  msg_type;           /* RNDIS_MSG_SET */
0115     __le32  msg_len;
0116     __le32  request_id;
0117     __le32  oid;
0118     __le32  len;
0119     __le32  offset;
0120 /*?*/   __le32  handle;             /* zero */
0121 } __attribute__ ((packed));
0122 
0123 struct rndis_set_c {        /* IN */
0124     /* header and: */
0125     __le32  msg_type;           /* RNDIS_MSG_SET_C */
0126     __le32  msg_len;
0127     __le32  request_id;
0128     __le32  status;
0129 } __attribute__ ((packed));
0130 
0131 struct rndis_reset {        /* IN */
0132     /* header and: */
0133     __le32  msg_type;           /* RNDIS_MSG_RESET */
0134     __le32  msg_len;
0135     __le32  reserved;
0136 } __attribute__ ((packed));
0137 
0138 struct rndis_reset_c {      /* OUT */
0139     /* header and: */
0140     __le32  msg_type;           /* RNDIS_MSG_RESET_C */
0141     __le32  msg_len;
0142     __le32  status;
0143     __le32  addressing_lost;
0144 } __attribute__ ((packed));
0145 
0146 struct rndis_indicate {     /* IN (unrequested) */
0147     /* header and: */
0148     __le32  msg_type;           /* RNDIS_MSG_INDICATE */
0149     __le32  msg_len;
0150     __le32  status;
0151     __le32  length;
0152     __le32  offset;
0153 /**/    __le32  diag_status;
0154     __le32  error_offset;
0155 /**/    __le32  message;
0156 } __attribute__ ((packed));
0157 
0158 struct rndis_keepalive {    /* OUT (optionally IN) */
0159     /* header and: */
0160     __le32  msg_type;           /* RNDIS_MSG_KEEPALIVE */
0161     __le32  msg_len;
0162     __le32  request_id;
0163 } __attribute__ ((packed));
0164 
0165 struct rndis_keepalive_c {  /* IN (optionally OUT) */
0166     /* header and: */
0167     __le32  msg_type;           /* RNDIS_MSG_KEEPALIVE_C */
0168     __le32  msg_len;
0169     __le32  request_id;
0170     __le32  status;
0171 } __attribute__ ((packed));
0172 
0173 /* default filter used with RNDIS devices */
0174 #define RNDIS_DEFAULT_FILTER ( \
0175     RNDIS_PACKET_TYPE_DIRECTED | \
0176     RNDIS_PACKET_TYPE_BROADCAST | \
0177     RNDIS_PACKET_TYPE_ALL_MULTICAST | \
0178     RNDIS_PACKET_TYPE_PROMISCUOUS)
0179 
0180 /* Flags to require specific physical medium type for generic_rndis_bind() */
0181 #define FLAG_RNDIS_PHYM_NOT_WIRELESS    0x0001
0182 #define FLAG_RNDIS_PHYM_WIRELESS    0x0002
0183 
0184 /* Flags for driver_info::data */
0185 #define RNDIS_DRIVER_DATA_POLL_STATUS   1   /* poll status before control */
0186 #define RNDIS_DRIVER_DATA_DST_MAC_FIXUP 2   /* device ignores configured MAC address */
0187 
0188 extern void rndis_status(struct usbnet *dev, struct urb *urb);
0189 extern int
0190 rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
0191 extern int
0192 generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
0193 extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
0194 extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
0195 extern struct sk_buff *
0196 rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
0197 
0198 #endif  /* __LINUX_USB_RNDIS_HOST_H */