From 83930b4eff0277ca69a0800ccdd4f7552cdf1460 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 11 Oct 2013 21:02:07 +0200 Subject: Some basic initialization --- COPYRIGHT | 22 ++++++++++++++++ Makefile | 17 ++++++++++++ fastd.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 COPYRIGHT create mode 100644 Makefile create mode 100644 fastd.c diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..eebfc12 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,22 @@ +Copyright (c) 2013, Matthias Schiffer +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..82e3e7a --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +ifneq ($(KERNELRELEASE),) +obj-m := fastd.o + +else +KDIR := /lib/modules/$(shell uname -r)/build +PWD := $(shell pwd) + +all: + $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules + +endif + + +.PHONY: clean + +clean: + rm -rf *.o .depend .*.cmd *.ko *.mod.c *.markers *.symvers *.order diff --git a/fastd.c b/fastd.c new file mode 100644 index 0000000..9c3552f --- /dev/null +++ b/fastd.c @@ -0,0 +1,90 @@ +/* + Copyright (c) 2012-2013, Matthias Schiffer + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define DRV_NAME "fastd" +#define DRV_VERSION "1" +#define DRV_DESCRIPTION "fastd tunnel driver" +#define DRV_COPYRIGHT "(C) 2013 Matthias Schiffer " + + +#include +#include +#include +#include +#include +#include + + +static const struct file_operations fastd_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = do_sync_read, +// .aio_read = fastd_chr_aio_read, + .write = do_sync_write, +// .aio_write = fastd_chr_aio_write, +// .poll = fastd_chr_poll, +// .unlocked_ioctl = fastd_chr_ioctl, +//#ifdef CONFIG_COMPAT +// .compat_ioctl = fastd_chr_compat_ioctl, +//#endif +// .open = fastd_chr_open, +// .release = fastd_chr_close, +// .fasync = fastd_chr_fasync +}; + +static struct miscdevice fastd_miscdev = { + .minor = MISC_DYNAMIC_MINOR, + .name = "fastd", + .nodename = "net/fastd", + .fops = &fastd_fops, +}; + + +static int __init fastd_init(void) +{ + int ret; + + ret = misc_register(&fastd_miscdev); + if (ret) { + pr_err("Can't register misc device\n"); + return ret; + } + + return 0; +} + +static void fastd_cleanup(void) +{ + misc_deregister(&fastd_miscdev); +} + + +module_init(fastd_init); +module_exit(fastd_cleanup); +MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_AUTHOR(DRV_COPYRIGHT); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_ALIAS("devname:net/fastd"); -- cgit v1.2.3