summaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_urndis.c
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2016-09-16 11:13:38 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2016-09-16 11:13:38 +0000
commit75d1b14c55cfc49af18aa90f56d95932cd8e725e (patch)
tree7dc848fc896b88e2f78f01921bf54294e2fe6982 /sys/dev/usb/if_urndis.c
parentbe5753e45e9b22ccbeaf6298e4849cfb5993315d (diff)
Switch urndis(4) over to the generic RNDIS header
Diffstat (limited to 'sys/dev/usb/if_urndis.c')
-rw-r--r--sys/dev/usb/if_urndis.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/sys/dev/usb/if_urndis.c b/sys/dev/usb/if_urndis.c
index b836531963e..112556eceb0 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.61 2016/04/13 11:03:37 mpi Exp $ */
+/* $OpenBSD: if_urndis.c,v 1.62 2016/09/16 11:13:37 mikeb Exp $ */
/*
* Copyright (c) 2010 Jonathan Armani <armani@openbsd.org>
@@ -49,6 +49,8 @@
#include <dev/usb/usbdivar.h>
#include <dev/usb/usbdevs.h>
+#include <dev/rndis.h>
+
#include <dev/usb/if_urndisreg.h>
#ifdef URNDIS_DEBUG
@@ -78,16 +80,16 @@ void urndis_stop(struct urndis_softc *);
usbd_status urndis_ctrl_msg(struct urndis_softc *, uint8_t, uint8_t,
uint16_t, uint16_t, void *, size_t);
usbd_status urndis_ctrl_send(struct urndis_softc *, void *, size_t);
-struct urndis_comp_hdr *urndis_ctrl_recv(struct urndis_softc *);
+struct rndis_comp_hdr *urndis_ctrl_recv(struct urndis_softc *);
u_int32_t urndis_ctrl_handle(struct urndis_softc *,
- struct urndis_comp_hdr *, void **, size_t *);
+ struct rndis_comp_hdr *, void **, size_t *);
u_int32_t urndis_ctrl_handle_init(struct urndis_softc *,
- const struct urndis_comp_hdr *);
+ const struct rndis_comp_hdr *);
u_int32_t urndis_ctrl_handle_query(struct urndis_softc *,
- const struct urndis_comp_hdr *, void **, size_t *);
+ const struct rndis_comp_hdr *, void **, size_t *);
u_int32_t urndis_ctrl_handle_reset(struct urndis_softc *,
- const struct urndis_comp_hdr *);
+ const struct rndis_comp_hdr *);
u_int32_t urndis_ctrl_init(struct urndis_softc *);
u_int32_t urndis_ctrl_halt(struct urndis_softc *);
@@ -161,11 +163,11 @@ urndis_ctrl_send(struct urndis_softc *sc, void *buf, size_t len)
return err;
}
-struct urndis_comp_hdr *
+struct rndis_comp_hdr *
urndis_ctrl_recv(struct urndis_softc *sc)
{
#define RNDIS_RESPONSE_LEN 0x400
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
char *buf;
usbd_status err;
@@ -184,7 +186,7 @@ urndis_ctrl_recv(struct urndis_softc *sc)
return NULL;
}
- hdr = (struct urndis_comp_hdr *)buf;
+ hdr = (struct rndis_comp_hdr *)buf;
DPRINTF(("%s: urndis_ctrl_recv: type 0x%x len %u\n",
DEVNAME(sc),
letoh32(hdr->rm_type),
@@ -203,7 +205,7 @@ urndis_ctrl_recv(struct urndis_softc *sc)
}
u_int32_t
-urndis_ctrl_handle(struct urndis_softc *sc, struct urndis_comp_hdr *hdr,
+urndis_ctrl_handle(struct urndis_softc *sc, struct rndis_comp_hdr *hdr,
void **buf, size_t *bufsz)
{
u_int32_t rval;
@@ -246,11 +248,11 @@ urndis_ctrl_handle(struct urndis_softc *sc, struct urndis_comp_hdr *hdr,
u_int32_t
urndis_ctrl_handle_init(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr)
+ const struct rndis_comp_hdr *hdr)
{
- const struct urndis_init_comp *msg;
+ const struct rndis_init_comp *msg;
- msg = (struct urndis_init_comp *) hdr;
+ msg = (struct rndis_init_comp *) hdr;
DPRINTF(("%s: urndis_ctrl_handle_init: len %u rid %u status 0x%x "
"ver_major %u ver_minor %u devflags 0x%x medium 0x%x pktmaxcnt %u "
@@ -299,11 +301,11 @@ urndis_ctrl_handle_init(struct urndis_softc *sc,
u_int32_t
urndis_ctrl_handle_query(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr, void **buf, size_t *bufsz)
+ const struct rndis_comp_hdr *hdr, void **buf, size_t *bufsz)
{
- const struct urndis_query_comp *msg;
+ const struct rndis_query_comp *msg;
- msg = (struct urndis_query_comp *) hdr;
+ msg = (struct rndis_query_comp *) hdr;
DPRINTF(("%s: urndis_ctrl_handle_query: len %u rid %u status 0x%x "
"buflen %u bufoff %u\n",
@@ -334,7 +336,7 @@ urndis_ctrl_handle_query(struct urndis_softc *sc,
"go out of buffer limit %u\n",
DEVNAME(sc),
letoh32(msg->rm_infobuflen),
- letoh32(msg->rm_infobufoffset),
+ letoh32(msg->rm_infobufoffset),
letoh32(msg->rm_infobuflen) +
letoh32(msg->rm_infobufoffset) + RNDIS_HEADER_OFFSET,
letoh32(msg->rm_len));
@@ -362,12 +364,12 @@ urndis_ctrl_handle_query(struct urndis_softc *sc,
u_int32_t
urndis_ctrl_handle_reset(struct urndis_softc *sc,
- const struct urndis_comp_hdr *hdr)
+ const struct rndis_comp_hdr *hdr)
{
- const struct urndis_reset_comp *msg;
+ const struct rndis_reset_comp *msg;
u_int32_t rval;
- msg = (struct urndis_reset_comp *) hdr;
+ msg = (struct rndis_reset_comp *) hdr;
rval = letoh32(msg->rm_status);
@@ -402,9 +404,9 @@ urndis_ctrl_handle_reset(struct urndis_softc *sc,
u_int32_t
urndis_ctrl_init(struct urndis_softc *sc)
{
- struct urndis_init_req *msg;
+ struct rndis_init_req *msg;
u_int32_t rval;
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
msg = malloc(sizeof(*msg), M_TEMP, M_WAITOK);
if (msg == NULL) {
@@ -449,7 +451,7 @@ urndis_ctrl_init(struct urndis_softc *sc)
u_int32_t
urndis_ctrl_halt(struct urndis_softc *sc)
{
- struct urndis_halt_req *msg;
+ struct rndis_halt_req *msg;
u_int32_t rval;
msg = malloc(sizeof(*msg), M_TEMP, M_WAITOK);
@@ -482,9 +484,9 @@ urndis_ctrl_query(struct urndis_softc *sc, u_int32_t oid,
void *qbuf, size_t qlen,
void **rbuf, size_t *rbufsz)
{
- struct urndis_query_req *msg;
+ struct rndis_query_req *msg;
u_int32_t rval;
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
msg = malloc(sizeof(*msg) + qlen, M_TEMP, M_WAITOK);
if (msg == NULL) {
@@ -535,9 +537,9 @@ urndis_ctrl_query(struct urndis_softc *sc, u_int32_t oid,
u_int32_t
urndis_ctrl_set(struct urndis_softc *sc, u_int32_t oid, void *buf, size_t len)
{
- struct urndis_set_req *msg;
+ struct rndis_set_req *msg;
u_int32_t rval;
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
msg = malloc(sizeof(*msg) + len, M_TEMP, M_WAITOK);
if (msg == NULL) {
@@ -583,7 +585,7 @@ urndis_ctrl_set(struct urndis_softc *sc, u_int32_t oid, void *buf, size_t len)
rval = urndis_ctrl_handle(sc, hdr, NULL, NULL);
if (rval != RNDIS_STATUS_SUCCESS)
printf("%s: set failed 0x%x\n", DEVNAME(sc), rval);
-
+
return rval;
}
@@ -594,7 +596,7 @@ urndis_ctrl_set_param(struct urndis_softc *sc,
void *buf,
size_t len)
{
- struct urndis_set_parameter *param;
+ struct rndis_set_parameter *param;
u_int32_t rval;
size_t namelen, tlen;
@@ -645,9 +647,9 @@ urndis_ctrl_set_param(struct urndis_softc *sc,
u_int32_t
urndis_ctrl_reset(struct urndis_softc *sc)
{
- struct urndis_reset_req *reset;
+ struct rndis_reset_req *reset;
u_int32_t rval;
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
reset = malloc(sizeof(*reset), M_TEMP, M_WAITOK);
if (reset == NULL) {
@@ -685,9 +687,9 @@ urndis_ctrl_reset(struct urndis_softc *sc)
u_int32_t
urndis_ctrl_keepalive(struct urndis_softc *sc)
{
- struct urndis_keepalive_req *keep;
+ struct rndis_keepalive_req *keep;
u_int32_t rval;
- struct urndis_comp_hdr *hdr;
+ struct rndis_comp_hdr *hdr;
keep = malloc(sizeof(*keep), M_TEMP, M_WAITOK);
if (keep == NULL) {
@@ -732,11 +734,11 @@ urndis_encap(struct urndis_softc *sc, struct mbuf *m, int idx)
{
struct urndis_chain *c;
usbd_status err;
- struct urndis_packet_msg *msg;
+ struct rndis_packet_msg *msg;
c = &sc->sc_data.sc_tx_chain[idx];
- msg = (struct urndis_packet_msg *)c->sc_buf;
+ msg = (struct rndis_packet_msg *)c->sc_buf;
memset(msg, 0, sizeof(*msg));
msg->rm_type = htole32(REMOTE_NDIS_PACKET_MSG);
@@ -778,16 +780,16 @@ urndis_decap(struct urndis_softc *sc, struct urndis_chain *c, u_int32_t len)
{
struct mbuf *m;
struct mbuf_list ml = MBUF_LIST_INITIALIZER();
- struct urndis_packet_msg *msg;
+ struct rndis_packet_msg *msg;
struct ifnet *ifp;
int s;
int offset;
ifp = GET_IFP(sc);
offset = 0;
-
+
while (len > 0) {
- msg = (struct urndis_packet_msg *)((char*)c->sc_buf + offset);
+ msg = (struct rndis_packet_msg *)((char*)c->sc_buf + offset);
m = c->sc_mbuf;
DPRINTF(("%s: urndis_decap buffer size left %u\n", DEVNAME(sc),
@@ -838,8 +840,8 @@ urndis_decap(struct urndis_softc *sc, struct urndis_chain *c, u_int32_t len)
}
if (letoh32(msg->rm_dataoffset) +
- letoh32(msg->rm_datalen) + RNDIS_HEADER_OFFSET
- > letoh32(msg->rm_len)) {
+ letoh32(msg->rm_datalen) + RNDIS_HEADER_OFFSET
+ > letoh32(msg->rm_len)) {
printf("%s: urndis_decap invalid data "
"len/offset/end_position(%u/%u/%zu) -> "
"go out of receive buffer limit %u\n",
@@ -1312,7 +1314,7 @@ urndis_match(struct device *parent, void *match, void *aux)
if (id == NULL)
return (UMATCH_NONE);
- return (urndis_lookup(id) ?
+ return (urndis_lookup(id) ?
UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO : UMATCH_NONE);
}
@@ -1440,8 +1442,8 @@ urndis_attach(struct device *parent, struct device *self, void *aux)
}
/* Initialize packet filter */
- sc->sc_filter = RNDIS_PACKET_TYPE_BROADCAST;
- sc->sc_filter |= RNDIS_PACKET_TYPE_ALL_MULTICAST;
+ sc->sc_filter = NDIS_PACKET_TYPE_BROADCAST;
+ sc->sc_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST;
filter = htole32(sc->sc_filter);
if (urndis_ctrl_set(sc, OID_GEN_CURRENT_PACKET_FILTER, &filter,
sizeof(filter)) != RNDIS_STATUS_SUCCESS) {
@@ -1470,7 +1472,7 @@ urndis_detach(struct device *self, int flags)
DPRINTF(("urndis_detach: %s flags %u\n", DEVNAME(sc),
flags));
-
+
if (!sc->sc_attached)
return 0;