On Sun, Jul 09, 2017 at 09:57 +0300, Artturi Alm wrote:
> Hi,
>
> anyone else having issues w/urndis(android)?
> victim of circumstances, i have to rely on it at times during the summer.
> When i plug phone into usb, and enable usb tethering or w/e it is called,
> i never get ip on first try, i have nothing but "dhcp"
> in /etc/hostname.urndis0, so i just ^C on the first i"ksh /etc/netstart"
> and get ip pretty much as expected in seconds on the successive run
> right after ^C, the first dhclient would end up sleeping if not ^C'ed..
>
> this is what i see in dmesg:
> urndis0 at uhub0 port 1 configuration 1 interface 0 "SAMSUNG SAMSUNG_Android"
> rev 2.00/ff.ff addr 2
> urndis0: using RNDIS, address 02:56:66:63:30:3c
> urndis0: ctrl message error: unknown event 0x7
>
> no dmesg, as i've ran into this issue on every installation of OpenBSD
> i have tried w/.
> unrelated issue is this spam i get which i haven't noticed to affect
> anything:
> urndis0: urndis_decap invalid buffer len 1 < minimum header 44
>
> for which i ended up w/diff below.
> -Artturi
>
What happens if you apply the diff below w/o your modifications?
diff --git sys/dev/usb/if_urndis.c sys/dev/usb/if_urndis.c
index 4af6b55cf05..bdca361713d 100644
--- sys/dev/usb/if_urndis.c
+++ sys/dev/usb/if_urndis.c
@@ -88,10 +88,12 @@ u_int32_t urndis_ctrl_handle_init(struct urndis_softc *,
const struct rndis_comp_hdr *);
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 *);
u_int32_t urndis_ctrl_query(struct urndis_softc *, u_int32_t, void *, size_t,
void **, size_t *);
@@ -233,10 +235,14 @@ urndis_ctrl_handle(struct urndis_softc *sc, struct
rndis_comp_hdr *hdr,
case REMOTE_NDIS_KEEPALIVE_CMPLT:
case REMOTE_NDIS_SET_CMPLT:
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));
rval = RNDIS_STATUS_FAILURE;
}
@@ -400,10 +406,48 @@ urndis_ctrl_handle_reset(struct urndis_softc *sc,
return rval;
}
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:
+ printf("%s: link up\n", DEVNAME(sc));
+ break;
+
+ case RNDIS_STATUS_MEDIA_DISCONNECT:
+ printf("%s: link down\n", DEVNAME(sc));
+ break;
+
+ /* Ignore these */
+ case RNDIS_STATUS_OFFLOAD_CURRENT_CONFIG:
+ break;
+
+ default:
+ printf("%s: unknown status 0x%x\n", DEVNAME(sc), rval);
+ }
+
+ return RNDIS_STATUS_SUCCESS;
+}
+
+u_int32_t
urndis_ctrl_init(struct urndis_softc *sc)
{
struct rndis_init_req *msg;
u_int32_t rval;
struct rndis_comp_hdr *hdr;