summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2017-07-19 16:31:57 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2017-07-19 16:31:57 +0000
commit37f405f5c573acf0847a4533e21afd6b3f092d7c (patch)
tree075e903a3ccea1cfdbe75338a56e01a831be8313
parentd89d92d65661b9bd60a53b6e9d5858ca6f0f89fd (diff)
Add a handler for RNDIS status messages
RNDIS status messages may indicate various conditions reported by the hardware, including link status events. They're not supposed to be universally treated as errors. Issue reported by Artturi Alm, ok armani
-rw-r--r--sys/dev/usb/if_urndis.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/sys/dev/usb/if_urndis.c b/sys/dev/usb/if_urndis.c
index 4af6b55cf05..5d148da4ab5 100644
--- a/sys/dev/usb/if_urndis.c
+++ b/sys/dev/usb/if_urndis.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_urndis.c,v 1.66 2017/06/10 12:58:37 kevlo Exp $ */
+/* $OpenBSD: if_urndis.c,v 1.67 2017/07/19 16:31:56 mikeb Exp $ */
/*
* Copyright (c) 2010 Jonathan Armani <armani@openbsd.org>
@@ -90,6 +90,8 @@ u_int32_t urndis_ctrl_handle_query(struct urndis_softc *,
const struct rndis_comp_hdr *, void **, size_t *);
u_int32_t urndis_ctrl_handle_reset(struct urndis_softc *,
const struct rndis_comp_hdr *);
+u_int32_t urndis_ctrl_handle_status(struct urndis_softc *,
+ const struct rndis_comp_hdr *);
u_int32_t urndis_ctrl_init(struct urndis_softc *);
u_int32_t urndis_ctrl_halt(struct urndis_softc *);
@@ -235,6 +237,10 @@ urndis_ctrl_handle(struct urndis_softc *sc, struct rndis_comp_hdr *hdr,
rval = letoh32(hdr->rm_status);
break;
+ case REMOTE_NDIS_INDICATE_STATUS_MSG:
+ rval = urndis_ctrl_handle_status(sc, hdr);
+ break;
+
default:
printf("%s: ctrl message error: unknown event 0x%x\n",
DEVNAME(sc), letoh32(hdr->rm_type));
@@ -402,6 +408,38 @@ urndis_ctrl_handle_reset(struct urndis_softc *sc,
}
u_int32_t
+urndis_ctrl_handle_status(struct urndis_softc *sc,
+ const struct rndis_comp_hdr *hdr)
+{
+ const struct rndis_status_msg *msg;
+ u_int32_t rval;
+
+ msg = (struct rndis_status_msg *)hdr;
+
+ rval = letoh32(msg->rm_status);
+
+ DPRINTF(("%s: urndis_ctrl_handle_status: len %u status 0x%x "
+ "stbuflen %u\n",
+ DEVNAME(sc),
+ letoh32(msg->rm_len),
+ rval,
+ letoh32(msg->rm_stbuflen)));
+
+ switch (rval) {
+ case RNDIS_STATUS_MEDIA_CONNECT:
+ case RNDIS_STATUS_MEDIA_DISCONNECT:
+ case RNDIS_STATUS_OFFLOAD_CURRENT_CONFIG:
+ rval = RNDIS_STATUS_SUCCESS;
+ break;
+
+ default:
+ printf("%s: status 0x%x\n", DEVNAME(sc), rval);
+ }
+
+ return rval;
+}
+
+u_int32_t
urndis_ctrl_init(struct urndis_softc *sc)
{
struct rndis_init_req *msg;