+ break;
+
+ case INT_ENABLE:
+ fprintf(stderr,"faking INT_ENABLE");
+ {
+ struct interrupt *it = (struct interrupt*)(wdheader->data);
+
+ fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
+
+ it->fEnableOk = 1;
+ //ret = (*ioctl_func) (fd, request, wdioctl);
+ }
+
+ break;
+
+ case INT_DISABLE:
+ fprintf(stderr,"INT_DISABLE\n");
+ {
+ struct interrupt *it = (struct interrupt*)(wdheader->data);
+
+ fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
+#ifndef NO_WINDRVR
+ ret = (*ioctl_func) (fd, request, wdioctl);
+#else
+ it->dwCounter = 0;
+ it->fStopped = 1;
+#endif
+ fprintf(stderr,"Handle: %lu, Options: %lx, ncmds: %lu, enableok: %lu, count: %lu, lost: %lu, stopped: %lu\n", it->hInterrupt, it->dwOptions, it->dwCmds, it->fEnableOk, it->dwCounter, it->dwLost, it->fStopped);
+ }
+ break;
+
+ case USB_SET_INTERFACE:
+ fprintf(stderr,"USB_SET_INTERFACE\n");
+ {
+ struct usb_set_interface *usi = (struct usb_set_interface*)(wdheader->data);
+
+ fprintf(stderr,"unique: %lu, interfacenum: %lu, alternatesetting: %lu, options: %lx\n", usi->dwUniqueID, usi->dwInterfaceNum, usi->dwAlternateSetting, usi->dwOptions);
+#ifndef NO_WINDRVR
+ ret = (*ioctl_func) (fd, request, wdioctl);
+#else
+ if (usbdevice) {
+ int iface;
+
+ if (!usb_devhandle)
+ usb_devhandle = usb_open(usbdevice);
+//MGMG
+ ret = usb_claim_interface(usb_devhandle, iface);
+ }
+#endif
+ fprintf(stderr,"unique: %lu, interfacenum: %lu, alternatesetting: %lu, options: %lx\n", usi->dwUniqueID, usi->dwInterfaceNum, usi->dwAlternateSetting, usi->dwOptions);
+ }
+ break;
+
+ case USB_GET_DEVICE_DATA:
+ fprintf(stderr,"USB_GET_DEVICE_DATA\n");
+ {
+ struct usb_get_device_data *ugdd = (struct usb_get_device_data*)(wdheader->data);
+ int pSize;
+
+ fprintf(stderr, "unique: %lu, bytes: %lu, options: %lx\n", ugdd->dwUniqueID, ugdd->dwBytes, ugdd->dwOptions);
+ pSize = ugdd->dwBytes;
+#ifndef NO_WINDRVR
+ ret = (*ioctl_func) (fd, request, wdioctl);
+#else
+ if (!ugdd->dwBytes) {
+ if (usbdevice) {
+ ugdd->dwBytes = usb_deviceinfo(NULL);
+ }
+ } else {
+ usb_deviceinfo((unsigned char*)ugdd->pBuf);
+ }
+#endif
+ if (pSize) {
+ struct usb_device_info *udi = (struct usb_device_info*)ugdd->pBuf;
+
+ fprintf(stderr, "Vendor: %x\n", udi->Descriptor.idVendor);
+
+ hexdump(ugdd->pBuf, pSize);
+ fprintf(stderr, "\n");
+ }
+ }
+ break;
+
+ case EVENT_REGISTER:
+ fprintf(stderr,"EVENT_REGISTER\n");
+ {
+ struct event *e = (struct event*)(wdheader->data);
+ struct usb_bus *bus;
+ int i;
+
+ fprintf(stderr,"handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n", e->handle, e->dwAction, e->dwStatus, e->dwEventId, e->dwCardType, e->hKernelPlugIn, e->dwOptions, e->u.Usb.deviceId.dwVendorId, e->u.Usb.deviceId.dwProductId, e->u.Usb.dwUniqueID, e->dwEventVer, e->dwNumMatchTables);
+ for (i = 0; i < e->dwNumMatchTables; i++) {
+ fprintf(stderr,"match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n", e->matchTables[i].VendorId, e->matchTables[i].ProductId, e->matchTables[i].bDeviceClass, e->matchTables[i].bDeviceSubClass, e->matchTables[i].bInterfaceClass, e->matchTables[i].bInterfaceSubClass, e->matchTables[i].bInterfaceProtocol);
+
+ for (bus = busses; bus; bus = bus->next) {
+ struct usb_device *dev;
+
+ for (dev = bus->devices; dev; dev = dev->next) {
+ struct usb_device_descriptor *desc = &(dev->descriptor);
+
+ if((desc->idVendor == e->matchTables[i].VendorId) &&
+ (desc->idProduct == e->matchTables[i].ProductId) &&
+ (desc->bDeviceClass == e->matchTables[i].bDeviceClass) &&
+ (desc->bDeviceSubClass == e->matchTables[i].bDeviceSubClass)) {
+ int ac;
+ for (ac = 0; ac < desc->bNumConfigurations; ac++) {
+ struct usb_interface *interface = dev->config[ac].interface;
+ int ai;
+
+ for (ai = 0; ai < interface->num_altsetting; ai++) {
+ fprintf(stderr, "intclass: %x, intsubclass: %x, intproto: %x\n", interface->altsetting[i].bInterfaceClass, interface->altsetting[i].bInterfaceSubClass, interface->altsetting[i].bInterfaceProtocol);
+ if ((interface->altsetting[ai].bInterfaceSubClass == e->matchTables[i].bInterfaceSubClass) &&
+ (interface->altsetting[ai].bInterfaceProtocol == e->matchTables[i].bInterfaceProtocol)){
+ /* TODO: check interfaceClass! */
+ fprintf(stderr,"!!!FOUND DEVICE WITH LIBUSB!!!\n");
+ usbdevice = dev;
+ card_type = e->dwCardType;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+#ifndef NO_WINDRVR
+ ret = (*ioctl_func) (fd, request, wdioctl);
+#else
+//handle: 0, action: 16371, status: 0, eventid: 0, cardtype: 4294967294, kplug: 0, options: 0, dev: 0:0, unique: 0, ver: 1, nummatch: 2
+//handle: 1, action: 16371, status: 0, eventid: 0, cardtype: 4294967294, kplug: 0, options: 0, dev: 0:0, unique: 0, ver: 1, nummatch: 2
+ e->handle++;
+#endif
+
+ fprintf(stderr,"handle: %lu, action: %lu, status: %lu, eventid: %lu, cardtype: %lu, kplug: %lu, options: %lu, dev: %lx:%lx, unique: %lu, ver: %lu, nummatch: %lu\n", e->handle, e->dwAction, e->dwStatus, e->dwEventId, e->dwCardType, e->hKernelPlugIn, e->dwOptions, e->u.Usb.deviceId.dwVendorId, e->u.Usb.deviceId.dwProductId, e->u.Usb.dwUniqueID, e->dwEventVer, e->dwNumMatchTables);
+ for (i = 0; i < e->dwNumMatchTables; i++)
+ fprintf(stderr,"match: dev: %04x:%04x, class: %x, subclass: %x, intclass: %x, intsubclass: %x, intproto: %x\n", e->matchTables[i].VendorId, e->matchTables[i].ProductId, e->matchTables[i].bDeviceClass, e->matchTables[i].bDeviceSubClass, e->matchTables[i].bInterfaceClass, e->matchTables[i].bInterfaceSubClass, e->matchTables[i].bInterfaceProtocol);
+ }
+ break;
+