Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Set and check NDIS version.
details: https://anonhg.NetBSD.org/src/rev/cc296396cb34
branches: trunk
changeset: 994474:cc296396cb34
user: maya <maya%NetBSD.org@localhost>
date: Fri Nov 09 21:57:09 2018 +0000
description:
Set and check NDIS version.
Throw away length 1 packets without a warning: we already throw away messages
with (len < sizeof(*msg)) a short while after, but print a warning.
Hardware is allowed to pad USB packets which % wMaxPacketSize length with
such packets for hardware implementation simplicity reasons.
This is described in
https://docs.microsoft.com/en-us/windows-hardware/drivers/network/usb-short-packets
>From Artturi Alm in tech-net, with amendment from pgoyette.
diffstat:
sys/dev/usb/if_urndis.c | 23 +++++++++++++++++------
sys/dev/usb/if_urndisreg.h | 9 +++++++--
2 files changed, 24 insertions(+), 8 deletions(-)
diffs (89 lines):
diff -r 690d3e8065c6 -r cc296396cb34 sys/dev/usb/if_urndis.c
--- a/sys/dev/usb/if_urndis.c Fri Nov 09 21:33:50 2018 +0000
+++ b/sys/dev/usb/if_urndis.c Fri Nov 09 21:57:09 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_urndis.c,v 1.18 2018/06/26 06:48:02 msaitoh Exp $ */
+/* $NetBSD: if_urndis.c,v 1.19 2018/11/09 21:57:09 maya Exp $ */
/* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
/*
@@ -21,7 +21,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.18 2018/06/26 06:48:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.19 2018/11/09 21:57:09 maya Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -289,7 +289,18 @@
return RNDIS_STATUS_FAILURE;
}
- sc->sc_lim_pktsz = le32toh(msg->rm_pktmaxsz);
+ if (le32toh(msg->rm_ver_major) != RNDIS_MAJOR_VERSION ||
+ le32toh(msg->rm_ver_minor) != RNDIS_MINOR_VERSION) {
+ printf("%s: version not %u.%u (current version: %u.%u)\n",
+ DEVNAME(sc), RNDIS_MAJOR_VERSION, RNDIS_MINOR_VERSION,
+ le32toh(msg->rm_ver_major), le32toh(msg->rm_ver_minor));
+
+ return RNDIS_STATUS_FAILURE;
+ }
+
+ sc->sc_maxppt = le32toh(msg->rm_pktmaxcnt);
+ sc->sc_maxtsz = le32toh(msg->rm_pktmaxsz);
+ sc->sc_palign = 1U << le32toh(msg->rm_align);
return le32toh(msg->rm_status);
}
@@ -402,8 +413,8 @@
msg->rm_type = htole32(REMOTE_NDIS_INITIALIZE_MSG);
msg->rm_len = htole32(sizeof(*msg));
msg->rm_rid = htole32(0);
- msg->rm_ver_major = htole32(1);
- msg->rm_ver_minor = htole32(1);
+ msg->rm_ver_major = htole32(RNDIS_MAJOR_VERSION);
+ msg->rm_ver_minor = htole32(RNDIS_MINOR_VERSION);
msg->rm_max_xfersz = htole32(RNDIS_BUFSZ);
DPRINTF(("%s: urndis_ctrl_init send: type %u len %u rid %u ver_major %u "
@@ -743,7 +754,7 @@
ifp = GET_IFP(sc);
offset = 0;
- while (len > 0) {
+ while (len > 1) {
msg = (struct urndis_packet_msg *)((char*)c->sc_buf + offset);
m = c->sc_mbuf;
diff -r 690d3e8065c6 -r cc296396cb34 sys/dev/usb/if_urndisreg.h
--- a/sys/dev/usb/if_urndisreg.h Fri Nov 09 21:33:50 2018 +0000
+++ b/sys/dev/usb/if_urndisreg.h Fri Nov 09 21:57:09 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_urndisreg.h,v 1.3 2016/12/04 10:12:35 skrll Exp $ */
+/* $NetBSD: if_urndisreg.h,v 1.4 2018/11/09 21:57:09 maya Exp $ */
/* $OpenBSD: if_urndisreg.h,v 1.14 2010/07/08 18:22:01 ckuethe Exp $ */
/*
@@ -47,8 +47,10 @@
struct ethercom sc_ec;
/* RNDIS device info */
- uint32_t sc_lim_pktsz;
uint32_t sc_filter;
+ uint32_t sc_maxppt;
+ uint32_t sc_maxtsz;
+ uint32_t sc_palign;
/* USB goo */
struct usbd_device * sc_udev;
@@ -122,6 +124,9 @@
#define RNDIS_MEDIUM_802_3 0x00000000
+#define RNDIS_MAJOR_VERSION 0x00000001U
+#define RNDIS_MINOR_VERSION 0x00000000U
+
/* Device flags */
#define RNDIS_DF_CONNECTIONLESS 0x00000001
#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
Home |
Main Index |
Thread Index |
Old Index