示例#1
0
static void device_manager_destroy(struct object *obj)
{
	struct device_manager *manager = (struct device_manager *)obj;
	struct list_head *ptr;

	while ((ptr = list_head(&manager->devices))) {
		struct device *device = LIST_ENTRY(ptr, struct device, entry);
		delete_device(device);
	}
}
示例#2
0
int i825xx_unload_device_pci(i825xxdev_t *dev)
{
	if(!dev) return 0;
	struct pci_device *device = dev->device;
	printk(1, "[i825xx]: Unloading device (%x.%x.%x)\n", 
		device->bus, device->dev, device->func);
	device->flags &= ~PCI_ENGAGED;
	device->flags &= ~PCI_DRIVEN;
	iremove_force(dev->node);
	//interrupt_unregister_handler(dev->inter, (isr_t)&i825xx_int);
	delete_device(dev);
	return 0;
}
示例#3
0
static void pcihacker_exit(void)
{
#ifdef SYSFS_ATTR_CREATE
	kobject_put(pcihacker_kobj);
#endif

#ifdef CREATE_CHAR_DEV
	/* Unregister and delete the node */
	delete_device();
#endif
	printk("pcihacker###14%s: device exit...\n", __func__);

}
示例#4
0
/* see which wds devices we are getting beacons from.  (this routine doesn't
 * look at the ethernet connection or the wlan connection.  those devices
 * are added at startup, the latter only if we were told to do so from the
 * command line.  they don't come and go.  only the wds devices
 * come and go.)
 *
 * this routine manages the device_list array, which includes if_index,
 * file descriptor, etc. to support actual low-level communication.
 */
char check_devices(void)
{
    char result = 0;
    int retval;
    static struct ifreq get_index;
    struct sockaddr_ll bind_arg;
    char wds_devices[MAX_CLOUD][64];
    mac_address_t wds_macs[MAX_CLOUD];
    int wds_count = 0;
    int w, d;
    char buf[64];

    FILE *wds = fopen(wds_file, "r");
    if (wds == NULL) {
        ddprintf("check_devices; fopen failed:  %s\n", strerror(errno));
        ddprintf("    file:  '%s'\n", wds_file);
        goto finish;
    }

    /* read the mac addresses of the wds devices into
     * local array wds_devices
     */
    while (1) {
        if (wds_count >= MAX_CLOUD) {
            ddprintf("check_devices:  too many wds devices\n");
            break;
        }

        if (skip_comment_line(wds) != 0) {
            ddprintf("check_devices; problem reading file.\n");
            break;
        }


        #ifdef WRT54G
            retval = mac_read(wds, wds_macs[wds_count]);
        #else
            retval = fscanf(wds, "%s", wds_devices[wds_count]);
        #endif

        if (retval != 1) { break; }

        #ifdef WRT54G
            retval = fscanf(wds, "%s", wds_devices[wds_count]);
        #else
            retval = mac_read(wds, wds_macs[wds_count]);
        #endif

        if (retval != 1) {
            ddprintf("check_devices; could not read device name from wds\n");
            goto finish;
        }
        wds_count++;
    }

    top :
    /* see if every wds device in our list matches current truth */
    for (d = 0; d < device_list_count; d++) {
        int found = 0;

        if (device_list[d].device_type != device_type_wds
            && device_list[d].device_type != device_type_cloud_wds)
        { continue; }
        
        for (w = 0; w < wds_count; w++) {
            if (mac_equal(device_list[d].mac_address, wds_macs[w])) {
                found = 1;
                break;
            }
        }

        if (!found
            || strstr(device_list[d].device_name, wds_devices[w]) == NULL)
        {
            result = 1;
            delete_device(d);
            goto top;
        }

        if (!use_pipes) {
            /* check to see that the if_index is still the same.
             * (if "wds0.2" gets deleted and then re-created, it probably
             * has a different if_index.)
             */
            sprintf(get_index.ifr_name, device_list[d].device_name);
            retval = ioctl(device_list[d].fd, SIOCGIFINDEX, &get_index);
            if (retval == -1) {
                ddprintf("check_devices; could not get device index:  %s\n",
                        strerror(errno));
                goto finish;
            }
            if (device_list[d].if_index != get_index.ifr_ifindex) {
                device_list[d].if_index = get_index.ifr_ifindex;
                memset(&bind_arg, 0, sizeof(bind_arg));
                bind_arg.sll_family = AF_PACKET;
                bind_arg.sll_ifindex = get_index.ifr_ifindex;
                bind_arg.sll_protocol = htons(ETH_P_ALL);

                retval = bind(device_list[d].fd, (struct sockaddr *) &bind_arg,
                        sizeof(bind_arg));
                if (retval == -1) {
                    ddprintf("check_devices; bind failed:  %s\n",
                            strerror(errno));
                    goto finish;
                }
                result = 1;
                goto top;
            }
        }
    }

    /* see if every device out there is in our local table */
    for (w = 0; w < wds_count; w++) {
        int found = 0;

        for (d = 0; d < device_list_count; d++) {
            if (mac_equal(device_list[d].mac_address, wds_macs[w])) {
                found = 1;
                break;
            }
        }

        if (!found) {
            result = 1;
            add_device(
                    ad_hoc_mode ? "ad-hoc device" : wds_devices[w],
                    wds_macs[w],
                    ad_hoc_mode ? device_type_ad_hoc : device_type_wds);

            if (!ad_hoc_mode && db[47].d) {
                sprintf(buf, "%s:1", wds_devices[w]);
                add_device(buf, wds_macs[w], device_type_cloud_wds);
            }
        }
    }

    finish :

    if (wds != NULL) { fclose(wds); }

    return result;

} /* check_devices */