Example #1
0
int
umodem_get_caps(usbd_device_handle dev, int *cm, int *acm,
		usb_interface_descriptor_t *id)
{
	const usb_cdc_cm_descriptor_t *cmd;
	const usb_cdc_acm_descriptor_t *cad;
	const usb_cdc_union_descriptor_t *cud;

	*cm = *acm = 0;

	cmd = (const usb_cdc_cm_descriptor_t *)usb_find_desc_if(dev,
							UDESC_CS_INTERFACE,
							UDESCSUB_CDC_CM, id);
	if (cmd == NULL)
		DPRINTF(("umodem_get_caps: no CM desc\n"));
	else
		*cm = cmd->bmCapabilities;

	cad = (const usb_cdc_acm_descriptor_t *)usb_find_desc_if(dev,
							UDESC_CS_INTERFACE,
							UDESCSUB_CDC_ACM, id);
	if (cad == NULL)
		DPRINTF(("umodem_get_caps: no ACM desc\n"));
	else
		*acm = cad->bmCapabilities;

	cud = (const usb_cdc_union_descriptor_t *)usb_find_desc_if(dev,
							UDESC_CS_INTERFACE,
							UDESCSUB_CDC_UNION, id);
	if (cud == NULL)
		DPRINTF(("umodem_get_caps: no UNION desc\n"));

	return cmd ? cmd->bDataInterface : cud ? cud->bSlaveInterface[0] : -1;
}
Example #2
0
/*
 * Get mac address
 */
static int
lgue_getmac(struct lgue_softc *sc, void *buf)
{
	const usb_cdc_ethernet_descriptor_t *ced;
	usb_interface_descriptor_t *id;
	char sbuf[ETHER_ADDR_LEN * 2 + 1];
	usbd_status err;
	int i;

	id = usbd_get_interface_descriptor(sc->lgue_ctl_iface);
	if (id == NULL) goto bad;
	ced = (const usb_cdc_ethernet_descriptor_t *)usb_find_desc_if(sc->lgue_udev,
	    UDESC_CS_INTERFACE, UDESCSUB_CDC_ETHERNET, id);
	if (ced == NULL) goto bad;

	err = usbd_get_string(sc->lgue_udev, ced->iMACAddress, sbuf);
	if(err) {
		kprintf("Read MAC address failed\n");
		goto bad;
	}

	for (i = 0; i < ETHER_ADDR_LEN; ++i) {
		((uByte *)buf)[i] = (hex(sbuf[i * 2]) << 4) + hex(sbuf[(i * 2) + 1]);
	}
	return(0);
bad:
	return(-1);
}
Example #3
0
/*
 * Find data interface.
 */
int
lgue_get_data_iface_no(usbd_device_handle dev, usb_interface_descriptor_t *id)
{
	const usb_cdc_union_descriptor_t *cud;

	cud = (const usb_cdc_union_descriptor_t *)usb_find_desc_if(dev,
	    UDESC_CS_INTERFACE, UDESCSUB_CDC_UNION, id);
	return(cud ? cud->bSlaveInterface[0] : -1);
}
Example #4
0
/*
 * Get hard max mtu
 */
static int
lgue_getmtu(struct lgue_softc *sc)
{
	const usb_cdc_ethernet_descriptor_t *ced;
	usb_interface_descriptor_t *id;

	id = usbd_get_interface_descriptor(sc->lgue_ctl_iface);
	if (id == NULL) {
		kprintf("usbd_get_interface_descriptor() returned NULL\n");
		return(ETHERMTU);
	}

	ced = (const usb_cdc_ethernet_descriptor_t *)usb_find_desc_if(sc->lgue_udev,
	    UDESC_CS_INTERFACE, UDESCSUB_CDC_ETHERNET, id);
	if (ced == NULL) {
		kprintf("usb_find_desc_if() returned NULL\n");
		return(ETHERMTU);
	}
	return(UGETW(ced->wMaxSegmentSize));
}