Ejemplo n.º 1
0
/*
 * Called when removing the module from memory... 
 */
static void __exit kaodv_exit(void)
{
	unsigned int i;

	for (i = 0; i < sizeof(kaodv_ops) / sizeof(struct nf_hook_ops); i++)
		nf_unregister_hook(&kaodv_ops[i]);

	proc_net_remove("kaodv");

	kaodv_queue_fini();
	kaodv_expl_fini();
	kaodv_netlink_fini();
}
Ejemplo n.º 2
0
/*
 * Called when removing the module from memory... 
 */
static void __exit kaodv_exit(void)
{
	unsigned int i;
	
	if_info_purge();

	for (i = 0; i < sizeof(kaodv_ops) / sizeof(struct nf_hook_ops); i++)
		nf_unregister_hook(&kaodv_ops[i]);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
	proc_net_remove("kaodv");
#else
	remove_proc_entry("kaodv",NULL);
#endif
	kaodv_queue_fini();
	kaodv_expl_fini();
	kaodv_netlink_fini();
}
Ejemplo n.º 3
0
static int __init kaodv_init(void)
{
	struct net_device *dev = NULL;
	int i, ret = -ENOMEM;
	const struct kaodv_proc_file *f;

	kaodv_expl_init();

	ret = kaodv_queue_init();

	if (ret < 0)
		return ret;

	ret = kaodv_netlink_init();

	if (ret < 0)
		goto cleanup_queue;

	ret = nf_register_hook(&kaodv_ops[0]);

	if (ret < 0)
		goto cleanup_netlink;

	ret = nf_register_hook(&kaodv_ops[1]);

	if (ret < 0)
		goto cleanup_hook0;

	ret = nf_register_hook(&kaodv_ops[2]);

	if (ret < 0)
		goto cleanup_hook1;

	/* Prefetch network device info (ip, broadcast address, ifindex). */
	for (i = 0; i < MAX_INTERFACES; i++) {
		if (!ifname[i])
			break;

		dev = dev_get_by_name(&init_net, ifname[i]);

		if (!dev) {
			printk("No device %s available, ignoring!\n",
			       ifname[i]);
			continue;
		}
		if_info_add(dev);

		dev_put(dev);
	}
	
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
	proc_net_create("kaodv", 0, kaodv_proc_info);
#else
//    if (!create_proc_read_entry("kaodv", 0, init_net.proc_net, kaodv_read_proc,
//                            NULL))
//	if (!proc_create("kaodv", 0, init_net.proc_net, &kaodv_fops))
//        KAODV_DEBUG("Could not create kaodv proc entry");
	for (f = kaodv_proc_files; f->name[0]; f++) {
		if (!proc_create_data(f->name, 0, init_net.proc_net,
				&kaodv_proc_fops, f->show)) {
			KAODV_DEBUG("Could not create kaodv proc entry");
		}
	}
#endif
	KAODV_DEBUG("Module init OK");

	return ret;

cleanup_hook1:
	nf_unregister_hook(&kaodv_ops[1]);
cleanup_hook0:
	nf_unregister_hook(&kaodv_ops[0]);
cleanup_netlink:
	kaodv_netlink_fini();
cleanup_queue:
	kaodv_queue_fini();

	return ret;
}
Ejemplo n.º 4
0
static int __init kaodv_init(void)
{
	struct net_device *dev = NULL;
	struct in_device *indev;
	struct in_ifaddr **ifap = NULL;
	struct in_ifaddr *ifa = NULL;

	int i, ret = -ENOMEM;

#ifndef KERNEL26
	EXPORT_NO_SYMBOLS;
#endif

	kaodv_expl_init();

	ret = kaodv_queue_init();

	if (ret < 0)
		return ret;

	ret = kaodv_netlink_init();

	if (ret < 0)
		goto cleanup_queue;

	ret = nf_register_hook(&kaodv_ops[0]);

	if (ret < 0)
		goto cleanup_netlink;

	ret = nf_register_hook(&kaodv_ops[1]);

	if (ret < 0)
		goto cleanup_hook0;

	ret = nf_register_hook(&kaodv_ops[2]);

	if (ret < 0)
		goto cleanup_hook1;

	/* Prefetch network device info (ip, broadcast address, ifindex). */
	for (i = 0; i < MAX_INTERFACES; i++) {
		if (!ifname[i])
			break;
		dev = dev_get_by_name(ifname[i]);
		if (!dev) {
			printk("No device %s available, ignoring!\n",
			       ifname[i]);
			continue;
		}
		netdevs[nif].ifindex = dev->ifindex;

//      indev = inetdev_by_index(dev->ifindex);
		indev = in_dev_get(dev);

		if (indev) {
			for (ifap = &indev->ifa_list; (ifa = *ifap) != NULL;
			     ifap = &ifa->ifa_next)
				if (!strcmp(dev->name, ifa->ifa_label))
					break;

			if (ifa) {
				netdevs[nif].ip_addr = ifa->ifa_address;
				netdevs[nif].bc_addr = ifa->ifa_broadcast;

				//printk("dev ip=%s bc=%s\n", print_ip(netdevs[nif].ip_addr), print_ip(netdevs[nif].bc_addr));

			}
			in_dev_put(indev);
		}
		nif++;
		dev_put(dev);
	}

	proc_net_create("kaodv", 0, kaodv_proc_info);

	return ret;

      cleanup_hook1:
	nf_unregister_hook(&kaodv_ops[1]);
      cleanup_hook0:
	nf_unregister_hook(&kaodv_ops[0]);
      cleanup_netlink:
	kaodv_netlink_fini();
      cleanup_queue:
	kaodv_queue_fini();
	return ret;
}
Ejemplo n.º 5
0
static int __init kaodv_init(void)
{
	struct net_device *dev = NULL;
	int i, ret = -ENOMEM;

//#ifndef KERNEL26
	//EXPORT_NO_SYMBOLS;
//#endif
	

	printk("\n\nMODULE INIT\n\n");

	kaodv_expl_init();

	ret = kaodv_queue_init();

	if (ret < 0)
		return ret;

	ret = kaodv_netlink_init();

	if (ret < 0)
		goto cleanup_queue;

	ret = nf_register_hook(&kaodv_ops[0]);

	if (ret < 0)
		goto cleanup_netlink;

	ret = nf_register_hook(&kaodv_ops[1]);

	if (ret < 0)
		goto cleanup_hook0;

	ret = nf_register_hook(&kaodv_ops[2]);

	if (ret < 0)
		goto cleanup_hook1;

	/* Prefetch network device info (ip, broadcast address, ifindex). */
	for (i = 0; i < MAX_INTERFACES; i++) {
		if (!ifname[i])
			break;

		dev = dev_get_by_name(&init_net, ifname[i]);

		if (!dev) {
			printk("No device %s available, ignoring!\n",
			       ifname[i]);
			continue;
		}
		if_info_add(dev);

		dev_put(dev);
	}


	 if (!proc_create("kaodv", 0, NULL, &proc_fops))
        KAODV_DEBUG("Could not create kaodv proc entry");

	KAODV_DEBUG("Module init OK");

	return ret;

cleanup_hook1:
	nf_unregister_hook(&kaodv_ops[1]);
cleanup_hook0:
	nf_unregister_hook(&kaodv_ops[0]);
cleanup_netlink:
	kaodv_netlink_fini();
cleanup_queue:
	kaodv_queue_fini();

	return ret;
}
Ejemplo n.º 6
0
static int __init kaodv_init(void)
{
	struct net_device *dev = NULL;
	int i, ret = -ENOMEM;

//#ifndef KERNEL26
//	EXPORT_NO_SYMBOLS;
//#endif

	kaodv_expl_init();

	ret = kaodv_queue_init();

	if (ret < 0)
		return ret;

	ret = kaodv_netlink_init();

	if (ret < 0)
		goto cleanup_queue;

	ret = nf_register_hook(&kaodv_ops[0]);

	if (ret < 0)
		goto cleanup_netlink;

	ret = nf_register_hook(&kaodv_ops[1]);

	if (ret < 0)
		goto cleanup_hook0;

	ret = nf_register_hook(&kaodv_ops[2]);

	if (ret < 0)
		goto cleanup_hook1;

	ret = nf_register_hook(&kaodv_ops[3]);

	if (ret < 0)
		goto cleanup_hook2;

	/* Prefetch network device info (ip, broadcast address, ifindex). */
	for (i = 0; i < MAX_INTERFACES; i++) {
		if (!ifname[i])
		{
			printk(KERN_DEBUG "kaodv: No name available for %d!\n", i);
			break;
		}
		dev = dev_get_by_name(&init_net, ifname[i]);

		if (!dev) {
			printk(KERN_DEBUG "kaodv: No device %s available, ignoring!\n",
			       ifname[i]);
			continue;
		}
		if_info_add(dev);

		dev_put(dev);
		
		printk(KERN_DEBUG "kaodv: add dev %d.\n", i);
	}
	
	
//#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
//	proc_net_create("kaodv", 0, kaodv_proc_info);
//#else
    if (!create_proc_read_entry("kaodv", 0, init_net.proc_net, kaodv_read_proc,
                            NULL))
        KAODV_DEBUG("Could not create kaodv proc entry");
//#endif
	KAODV_DEBUG("Module init OK");

	return ret;

cleanup_hook2:
	nf_unregister_hook(&kaodv_ops[2]);
cleanup_hook1:
	nf_unregister_hook(&kaodv_ops[1]);
cleanup_hook0:
	nf_unregister_hook(&kaodv_ops[0]);
cleanup_netlink:
	kaodv_netlink_fini();
cleanup_queue:
	kaodv_queue_fini();

	return ret;
}